Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(578)

Unified Diff: chrome/browser/shell_integration_linux.cc

Issue 155889: Linux: use new xdg-settings "check" feature to determine whether we are the default browser. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « DEPS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/shell_integration_linux.cc
===================================================================
--- chrome/browser/shell_integration_linux.cc (revision 21242)
+++ chrome/browser/shell_integration_linux.cc (working copy)
@@ -67,33 +67,34 @@
return success_code == EXIT_SUCCESS;
}
-static bool GetDefaultBrowser(std::string* result) {
+bool ShellIntegration::IsDefaultBrowser() {
std::vector<std::string> argv;
argv.push_back("xdg-settings");
- argv.push_back("get");
+ argv.push_back("check");
argv.push_back("default-web-browser");
- return base::GetAppOutput(CommandLine(argv), result);
-}
+ argv.push_back(GetDesktopName());
-bool ShellIntegration::IsDefaultBrowser() {
- std::string browser;
- if (!GetDefaultBrowser(&browser)) {
- // If GetDefaultBrowser() fails, we assume xdg-settings does not work for
- // some reason, and that we should pretend we're the default browser to
- // avoid giving repeated prompts to set ourselves as the default browser.
- // TODO: Really, being the default browser should be a ternary query: yes,
- // no, and "don't know" so that the UI can reflect this more accurately.
+ std::string reply;
+ if (!base::GetAppOutput(CommandLine(argv), &reply)) {
+ // If xdg-settings fails, we assume that we should pretend we're the default
+ // browser to avoid giving repeated prompts to set ourselves as the default.
+ // TODO(mdm): Really, being the default browser should be a ternary query:
+ // yes, no, and "don't know" so the UI can reflect this more accurately.
return true;
}
- // Allow for an optional newline at the end.
- if (browser.length() > 0 && browser[browser.length() - 1] == '\n')
- browser.resize(browser.length() - 1);
- return !browser.compare(GetDesktopName());
+
+ // Allow any reply that starts with "yes"
Evan Stade 2009/07/22 01:36:33 . at end of comment
+ return reply.find("yes") == 0;
}
bool ShellIntegration::IsFirefoxDefaultBrowser() {
+ std::vector<std::string> argv;
+ argv.push_back("xdg-settings");
+ argv.push_back("get");
+ argv.push_back("default-web-browser");
+
std::string browser;
// We don't care about the return value here.
- GetDefaultBrowser(&browser);
+ base::GetAppOutput(CommandLine(argv), &browser);
return browser.find("irefox") != std::string::npos;
}
« no previous file with comments | « DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698