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/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 void ShowDefaultBrowserPrompt(Profile* profile, HostDesktopType desktop_type) { | 322 void ShowDefaultBrowserPrompt(Profile* profile, HostDesktopType desktop_type) { |
323 // Do not check if Chrome is the default browser if there is a policy in | 323 // Do not check if Chrome is the default browser if there is a policy in |
324 // control of this setting. | 324 // control of this setting. |
325 if (g_browser_process->local_state()->IsManagedPreference( | 325 if (g_browser_process->local_state()->IsManagedPreference( |
326 prefs::kDefaultBrowserSettingEnabled)) { | 326 prefs::kDefaultBrowserSettingEnabled)) { |
327 // Handling of the browser.default_browser_setting_enabled policy setting is | 327 // Handling of the browser.default_browser_setting_enabled policy setting is |
328 // taken care of in BrowserProcessImpl. | 328 // taken care of in BrowserProcessImpl. |
329 return; | 329 return; |
330 } | 330 } |
331 | 331 |
| 332 PrefService* prefs = profile->GetPrefs(); |
| 333 // Reset preferences if kResetCheckDefaultBrowser is true. |
| 334 if (prefs->GetBoolean(prefs::kResetCheckDefaultBrowser)) { |
| 335 prefs->SetBoolean(prefs::kResetCheckDefaultBrowser, false); |
| 336 prefs->SetBoolean(prefs::kCheckDefaultBrowser, true); |
| 337 } |
| 338 |
332 // Check if Chrome is the default browser but do not prompt if: | 339 // Check if Chrome is the default browser but do not prompt if: |
333 // - The user said "don't ask me again" on the infobar earlier. | 340 // - The user said "don't ask me again" on the infobar earlier. |
334 // - The "suppress_default_browser_prompt_for_version" master preference is | 341 // - The "suppress_default_browser_prompt_for_version" master preference is |
335 // set to the current version. | 342 // set to the current version. |
336 bool show_prompt = | 343 bool show_prompt = prefs->GetBoolean(prefs::kCheckDefaultBrowser); |
337 profile->GetPrefs()->GetBoolean(prefs::kCheckDefaultBrowser); | |
338 if (show_prompt) { | 344 if (show_prompt) { |
339 const std::string disable_version_string = | 345 const std::string disable_version_string = |
340 g_browser_process->local_state()->GetString( | 346 g_browser_process->local_state()->GetString( |
341 prefs::kBrowserSuppressDefaultBrowserPrompt); | 347 prefs::kBrowserSuppressDefaultBrowserPrompt); |
342 const Version disable_version(disable_version_string); | 348 const Version disable_version(disable_version_string); |
343 DCHECK(disable_version_string.empty() || disable_version.IsValid()); | 349 DCHECK(disable_version_string.empty() || disable_version.IsValid()); |
344 if (disable_version.IsValid()) { | 350 if (disable_version.IsValid()) { |
345 if (disable_version.Equals(Version(version_info::GetVersionNumber()))) | 351 if (disable_version.Equals(Version(version_info::GetVersionNumber()))) |
346 show_prompt = false; | 352 show_prompt = false; |
347 } | 353 } |
348 } | 354 } |
349 | 355 |
350 scoped_refptr<ShellIntegration::DefaultBrowserWorker>( | 356 scoped_refptr<ShellIntegration::DefaultBrowserWorker>( |
351 new ShellIntegration::DefaultBrowserWorker( | 357 new ShellIntegration::DefaultBrowserWorker( |
352 new CheckDefaultBrowserObserver(profile->GetPath(), show_prompt, | 358 new CheckDefaultBrowserObserver(profile->GetPath(), show_prompt, |
353 desktop_type))) | 359 desktop_type))) |
354 ->StartCheckIsDefault(); | 360 ->StartCheckIsDefault(); |
355 } | 361 } |
356 | 362 |
357 #if !defined(OS_WIN) | 363 #if !defined(OS_WIN) |
358 bool ShowFirstRunDefaultBrowserPrompt(Profile* profile) { | 364 bool ShowFirstRunDefaultBrowserPrompt(Profile* profile) { |
359 return false; | 365 return false; |
360 } | 366 } |
361 #endif | 367 #endif |
362 | 368 |
363 } // namespace chrome | 369 } // namespace chrome |
OLD | NEW |