summaryrefslogtreecommitdiffstats
path: root/chrome/browser/shell_integration_linux.cc
diff options
context:
space:
mode:
authormdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-22 02:24:35 +0000
committermdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-22 02:24:35 +0000
commit7061b12b4c63e24a7a3f3cf24c70a00f971cec31 (patch)
treefe27f4281bad33e4a8c39b22ba40da68242d7d6c /chrome/browser/shell_integration_linux.cc
parent603c389aba55c3a03729b15242c738b665d91b3e (diff)
downloadchromium_src-7061b12b4c63e24a7a3f3cf24c70a00f971cec31.zip
chromium_src-7061b12b4c63e24a7a3f3cf24c70a00f971cec31.tar.gz
chromium_src-7061b12b4c63e24a7a3f3cf24c70a00f971cec31.tar.bz2
Linux: use new xdg-settings "check" feature to determine whether we are the default browser.
BUG=17093 TEST=in GNOME, let Firefox set itself as the default after Chrome has set itself; Chrome should then detect that it is no longer the default Review URL: http://codereview.chromium.org/155889 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21260 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/shell_integration_linux.cc')
-rw-r--r--chrome/browser/shell_integration_linux.cc35
1 files changed, 18 insertions, 17 deletions
diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc
index 814ceff..fc5e053 100644
--- a/chrome/browser/shell_integration_linux.cc
+++ b/chrome/browser/shell_integration_linux.cc
@@ -67,33 +67,34 @@ bool ShellIntegration::SetAsDefaultBrowser() {
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".
+ 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;
}