diff options
author | mdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-20 20:50:45 +0000 |
---|---|---|
committer | mdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-20 20:50:45 +0000 |
commit | 6d33519bd4d811112cef3d64d9c346531d65ab9b (patch) | |
tree | 18609d77ad42c691104f823d302db9990dcd1a26 | |
parent | 631f0d40b34036928a3b4e3fc327de325904e8af (diff) | |
download | chromium_src-6d33519bd4d811112cef3d64d9c346531d65ab9b.zip chromium_src-6d33519bd4d811112cef3d64d9c346531d65ab9b.tar.gz chromium_src-6d33519bd4d811112cef3d64d9c346531d65ab9b.tar.bz2 |
Pretend we're the default browser when xdg-settings fails.
BUG=16981
TEST=use an unsupported desktop environment (like awesome) and start chrome; it should not ask about setting itself as the default
Review URL: http://codereview.chromium.org/159086
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21101 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/shell_integration_linux.cc | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc index 34b817b..b970208 100644 --- a/chrome/browser/shell_integration_linux.cc +++ b/chrome/browser/shell_integration_linux.cc @@ -38,32 +38,33 @@ bool ShellIntegration::SetAsDefaultBrowser() { return success_code == EXIT_SUCCESS; } -static std::string getDefaultBrowser() { +static bool GetDefaultBrowser(std::string* result) { std::vector<std::string> argv; argv.push_back("xdg-settings"); argv.push_back("get"); argv.push_back("default-web-browser"); - std::string output; - base::GetAppOutput(CommandLine(argv), &output); - // If GetAppOutput() fails, we'll return the empty string. - return output; + return base::GetAppOutput(CommandLine(argv), result); } bool ShellIntegration::IsDefaultBrowser() { - std::string browser = getDefaultBrowser(); + 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. + return true; + } // Allow for an optional newline at the end. if (browser.length() > 0 && browser[browser.length() - 1] == '\n') browser.resize(browser.length() - 1); - if (!browser.length()) { - // We don't know what the default browser is; chances are, we can't - // set it either. So, check to see if we were run in the wrapper - // and pretend that we are the default unless we were run from it, - // to avoid warning that we aren't the default when it's useless. - return !getenv("CHROME_WRAPPER"); - } return !browser.compare(DESKTOP_APP_NAME); } bool ShellIntegration::IsFirefoxDefaultBrowser() { - return getDefaultBrowser().find("irefox") != std::string::npos; + std::string browser; + // We don't care about the return value here. + GetDefaultBrowser(&browser); + return browser.find("irefox") != std::string::npos; } |