Skip to content

add setAsDefaultProtocolClient for Linux - #10670

Merged
codebytere merged 8 commits into
masterfrom
add-linuxdefaultprotocol
Oct 7, 2017
Merged

codebytere merged 8 commits into
masterfrom
add-linuxdefaultprotocol

Conversation

@codebytere

@codebytere codebytere commented Oct 2, 2017 •

Copy link
Copy Markdown
Member

Tracking progress for implementation of #6440

Todo:

  • Replace GetChromeVersionOfScript in SetAsDefaultProtocolClient and IsDefaultProtocolClient appropriately

@codebytere
codebytere requested a review from a team October 2, 2017 14:23
@codebytere codebytere changed the title [WIP} add setAsDefaultProtocolClient for Linux [WIP] add setAsDefaultProtocolClient for Linux Oct 2, 2017
@codebytere codebytere changed the title [WIP] add setAsDefaultProtocolClient for Linux add setAsDefaultProtocolClient for Linux Oct 7, 2017
Comment thread atom/browser/browser_linux.cc Outdated
}

bool SetDefaultWebClient(const std::string& protocol) {
#if defined(OS_CHROMEOS)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably not care about the CHROMEOS check

Comment thread atom/browser/browser_linux.cc Outdated
bool Browser::IsDefaultProtocolClient(const std::string& protocol,
mate::Arguments* args) {
mate::Arguments* args) {
#if defined(OS_CHROMEOS)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Comment thread atom/browser/browser_linux.cc Outdated
base::Process process = base::LaunchProcess(argv, options);
close(devnull);

if (!process.IsValid())return false;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This spacing stood out for some reason, and now I can't unsee it 😆

std::vector<std::string> argv;
argv.push_back(kXdgSettings);
argv.push_back("set");
if (!protocol.empty()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the protocol is empty do we still want to continue? If they didn't provide a protocol should we just stop trying?

@codebytere codebytere Oct 7, 2017 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hrm yeah i suppose we can immediately return false if there's no protocol, otherwise continue

#endif
}

// Todo implement

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not currently sure if it's possible to remove using xdg-settings sadly...docs don't reference anything about it and chromium doesn't implement any form of protocol removal

Comment thread atom/browser/browser_linux.cc Outdated
namespace atom {

const char kXdgSettings[] = "xdg-settings";
const char kXdgSettingsDefaultBrowser[] = "default-web-browser";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't appear to be used

Comment thread atom/browser/browser_linux.cc Outdated

bool Browser::IsDefaultProtocolClient(const std::string& protocol,
mate::Arguments* args) {
base::ThreadRestrictions::AssertIOAllowed();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is dummy, since DCHECKS are disabled currently. But it is not good to do IO operations on the UI thread. I suggest moving these to the FILE thread instead. Currently we have not started using the new task scheduler api of chromium, which would make scenarios like this easier to deal with. You can look at how the previous version of {set/check}DefaultProtocolClient was implemented in chromium using FILE thread https://codereview.chromium.org/2888693003 .

@codebytere

Copy link
Copy Markdown
Member Author

Per @deepak1556's comment above, i'm planning to migrate implementations of SetDefaultProtocolClient and IsDefaultProtocolClient to the FILE thread, but i'll open a separate PR and migrate implementations at the same time on all three platforms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants