OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/startup/default_browser_prompt.h" | 5 #include "chrome/browser/ui/startup/default_browser_prompt.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "components/infobars/core/confirm_infobar_delegate.h" | 30 #include "components/infobars/core/confirm_infobar_delegate.h" |
31 #include "components/infobars/core/infobar.h" | 31 #include "components/infobars/core/infobar.h" |
32 #include "components/version_info/version_info.h" | 32 #include "components/version_info/version_info.h" |
33 #include "content/public/browser/navigation_details.h" | 33 #include "content/public/browser/navigation_details.h" |
34 #include "content/public/browser/user_metrics.h" | 34 #include "content/public/browser/user_metrics.h" |
35 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
36 #include "grit/theme_resources.h" | 36 #include "grit/theme_resources.h" |
37 #include "ui/base/l10n/l10n_util.h" | 37 #include "ui/base/l10n/l10n_util.h" |
38 #include "ui/gfx/vector_icons_public.h" | 38 #include "ui/gfx/vector_icons_public.h" |
39 | 39 |
| 40 #if defined(OS_WIN) |
| 41 #include "base/win/windows_version.h" |
| 42 #endif |
| 43 |
40 namespace { | 44 namespace { |
41 | 45 |
42 // The delegate for the infobar shown when Chrome is not the default browser. | 46 // The delegate for the infobar shown when Chrome is not the default browser. |
43 class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate { | 47 class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate { |
44 public: | 48 public: |
45 // Creates a default browser infobar and delegate and adds the infobar to | 49 // Creates a default browser infobar and delegate and adds the infobar to |
46 // |infobar_service|. | 50 // |infobar_service|. |
47 static void Create(InfoBarService* infobar_service, PrefService* prefs); | 51 static void Create(InfoBarService* infobar_service, PrefService* prefs); |
48 | 52 |
49 private: | 53 private: |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 void ShowDefaultBrowserPrompt(Profile* profile, HostDesktopType desktop_type) { | 293 void ShowDefaultBrowserPrompt(Profile* profile, HostDesktopType desktop_type) { |
290 // Do not check if Chrome is the default browser if there is a policy in | 294 // Do not check if Chrome is the default browser if there is a policy in |
291 // control of this setting. | 295 // control of this setting. |
292 if (g_browser_process->local_state()->IsManagedPreference( | 296 if (g_browser_process->local_state()->IsManagedPreference( |
293 prefs::kDefaultBrowserSettingEnabled)) { | 297 prefs::kDefaultBrowserSettingEnabled)) { |
294 // Handling of the browser.default_browser_setting_enabled policy setting is | 298 // Handling of the browser.default_browser_setting_enabled policy setting is |
295 // taken care of in BrowserProcessImpl. | 299 // taken care of in BrowserProcessImpl. |
296 return; | 300 return; |
297 } | 301 } |
298 | 302 |
| 303 PrefService* prefs = profile->GetPrefs(); |
| 304 #if defined(OS_WIN) |
| 305 // Reset preferences if kResetCheckDefaultBrowser is true. |
| 306 if (base::win::GetVersion() >= base::win::VERSION_WIN10 && |
| 307 prefs->GetBoolean(prefs::kResetCheckDefaultBrowser)) { |
| 308 prefs->SetBoolean(prefs::kResetCheckDefaultBrowser, false); |
| 309 prefs->SetBoolean(prefs::kCheckDefaultBrowser, true); |
| 310 } |
| 311 #endif |
| 312 |
299 // Check if Chrome is the default browser but do not prompt if: | 313 // Check if Chrome is the default browser but do not prompt if: |
300 // - The user said "don't ask me again" on the infobar earlier. | 314 // - The user said "don't ask me again" on the infobar earlier. |
301 // - The "suppress_default_browser_prompt_for_version" master preference is | 315 // - The "suppress_default_browser_prompt_for_version" master preference is |
302 // set to the current version. | 316 // set to the current version. |
303 bool show_prompt = | 317 bool show_prompt = prefs->GetBoolean(prefs::kCheckDefaultBrowser); |
304 profile->GetPrefs()->GetBoolean(prefs::kCheckDefaultBrowser); | |
305 if (show_prompt) { | 318 if (show_prompt) { |
306 const std::string disable_version_string = | 319 const std::string disable_version_string = |
307 g_browser_process->local_state()->GetString( | 320 g_browser_process->local_state()->GetString( |
308 prefs::kBrowserSuppressDefaultBrowserPrompt); | 321 prefs::kBrowserSuppressDefaultBrowserPrompt); |
309 const Version disable_version(disable_version_string); | 322 const Version disable_version(disable_version_string); |
310 DCHECK(disable_version_string.empty() || disable_version.IsValid()); | 323 DCHECK(disable_version_string.empty() || disable_version.IsValid()); |
311 if (disable_version.IsValid()) { | 324 if (disable_version.IsValid()) { |
312 if (disable_version.Equals(Version(version_info::GetVersionNumber()))) | 325 if (disable_version.Equals(Version(version_info::GetVersionNumber()))) |
313 show_prompt = false; | 326 show_prompt = false; |
314 } | 327 } |
315 } | 328 } |
316 | 329 |
317 scoped_refptr<ShellIntegration::DefaultBrowserWorker>( | 330 scoped_refptr<ShellIntegration::DefaultBrowserWorker>( |
318 new ShellIntegration::DefaultBrowserWorker( | 331 new ShellIntegration::DefaultBrowserWorker( |
319 new CheckDefaultBrowserObserver(profile->GetPath(), show_prompt, | 332 new CheckDefaultBrowserObserver(profile->GetPath(), show_prompt, |
320 desktop_type))) | 333 desktop_type))) |
321 ->StartCheckIsDefault(); | 334 ->StartCheckIsDefault(); |
322 } | 335 } |
323 | 336 |
324 #if !defined(OS_WIN) | 337 #if !defined(OS_WIN) |
325 bool ShowFirstRunDefaultBrowserPrompt(Profile* profile) { | 338 bool ShowFirstRunDefaultBrowserPrompt(Profile* profile) { |
326 return false; | 339 return false; |
327 } | 340 } |
328 #endif | 341 #endif |
329 | 342 |
330 } // namespace chrome | 343 } // namespace chrome |
OLD | NEW |