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

Unified Diff: chrome/browser/ui/startup/default_browser_prompt.cc

Issue 1182513007: Reset browser.check_default_browser to true when Chrome is the user's default browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: find Profile* by path Created 5 years, 6 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 | « no previous file | chrome/browser/ui/webui/options/browser_options_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/startup/default_browser_prompt.cc
diff --git a/chrome/browser/ui/startup/default_browser_prompt.cc b/chrome/browser/ui/startup/default_browser_prompt.cc
index 86a592ba84e1473536ef1258ccad48df782d2f89..b1a825e7bd8b90dedfc7350a215740ecbccc2f46 100644
--- a/chrome/browser/ui/startup/default_browser_prompt.cc
+++ b/chrome/browser/ui/startup/default_browser_prompt.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/shell_integration.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
@@ -194,8 +195,28 @@ void NotifyNotDefaultBrowserCallback(chrome::HostDesktopType desktop_type) {
ShellIntegration::SET_DEFAULT_INTERACTIVE));
}
-void CheckDefaultBrowserCallback(chrome::HostDesktopType desktop_type) {
- if (ShellIntegration::GetDefaultBrowser() == ShellIntegration::NOT_DEFAULT) {
+void ResetCheckDefaultBrowserPrefOnUIThread(
+ const base::FilePath& profile_path) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ Profile* profile =
+ g_browser_process->profile_manager()->GetProfileByPath(profile_path);
+ if (profile)
+ profile->GetPrefs()->SetBoolean(prefs::kCheckDefaultBrowser, true);
+}
+
+void CheckDefaultBrowserOnFileThread(const base::FilePath& profile_path,
+ bool show_prompt,
+ chrome::HostDesktopType desktop_type) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
+ ShellIntegration::DefaultWebClientState state =
+ ShellIntegration::GetDefaultBrowser();
+ if (state == ShellIntegration::IS_DEFAULT) {
+ // Notify the user in the future if Chrome ceases to be the user's chosen
+ // default browser.
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI, FROM_HERE,
+ base::Bind(&ResetCheckDefaultBrowserPrefOnUIThread, profile_path));
+ } else if (show_prompt && state == ShellIntegration::NOT_DEFAULT) {
ShellIntegration::DefaultWebClientSetPermission default_change_mode =
ShellIntegration::CanSetAsDefaultBrowser();
@@ -218,12 +239,13 @@ void RegisterDefaultBrowserPromptPrefs(PrefRegistrySimple* registry) {
void ShowDefaultBrowserPrompt(Profile* profile, HostDesktopType desktop_type) {
// We do not check if we are the default browser if:
- // - The user said "don't ask me again" on the infobar earlier.
// - There is a policy in control of this setting.
+ // We check if we are the default browser but do not prompt if:
+ // - The user said "don't ask me again" on the infobar earlier.
// - The "suppress_default_browser_prompt_for_version" master preference is
// set to the current version.
- if (!profile->GetPrefs()->GetBoolean(prefs::kCheckDefaultBrowser))
- return;
+ bool show_prompt =
+ profile->GetPrefs()->GetBoolean(prefs::kCheckDefaultBrowser);
if (g_browser_process->local_state()->IsManagedPreference(
prefs::kDefaultBrowserSettingEnabled)) {
@@ -240,20 +262,23 @@ void ShowDefaultBrowserPrompt(Profile* profile, HostDesktopType desktop_type) {
return;
}
- const std::string disable_version_string =
- g_browser_process->local_state()->GetString(
- prefs::kBrowserSuppressDefaultBrowserPrompt);
- const Version disable_version(disable_version_string);
- DCHECK(disable_version_string.empty() || disable_version.IsValid());
- if (disable_version.IsValid()) {
- const chrome::VersionInfo version_info;
- if (disable_version.Equals(Version(version_info.Version())))
- return;
+ if (show_prompt) {
+ const std::string disable_version_string =
+ g_browser_process->local_state()->GetString(
+ prefs::kBrowserSuppressDefaultBrowserPrompt);
+ const Version disable_version(disable_version_string);
+ DCHECK(disable_version_string.empty() || disable_version.IsValid());
+ if (disable_version.IsValid()) {
+ const chrome::VersionInfo version_info;
+ if (disable_version.Equals(Version(version_info.Version())))
+ show_prompt = false;
+ }
}
content::BrowserThread::PostTask(
content::BrowserThread::FILE, FROM_HERE,
- base::Bind(&CheckDefaultBrowserCallback, desktop_type));
+ base::Bind(&CheckDefaultBrowserOnFileThread, profile->GetPath(),
+ show_prompt, desktop_type));
}
#if !defined(OS_WIN)
« no previous file with comments | « no previous file | chrome/browser/ui/webui/options/browser_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698