| 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 <limits> | 7 #include <limits> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "base/version.h" | 16 #include "base/version.h" |
| 17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/first_run/first_run.h" |
| 19 #include "chrome/browser/infobars/infobar_service.h" | 20 #include "chrome/browser/infobars/infobar_service.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/profiles/profile_manager.h" | 22 #include "chrome/browser/profiles/profile_manager.h" |
| 22 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
| 23 #include "chrome/browser/ui/browser_finder.h" | 24 #include "chrome/browser/ui/browser_finder.h" |
| 24 #include "chrome/browser/ui/startup/default_browser_infobar_delegate.h" | 25 #include "chrome/browser/ui/startup/default_browser_infobar_delegate.h" |
| 25 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 26 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 26 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
| 27 #include "components/prefs/pref_registry_simple.h" | 28 #include "components/prefs/pref_registry_simple.h" |
| 28 #include "components/prefs/pref_service.h" | 29 #include "components/prefs/pref_service.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 45 if (!browser) | 46 if (!browser) |
| 46 return; // Reached during ui tests. | 47 return; // Reached during ui tests. |
| 47 | 48 |
| 48 // In ChromeBot tests, there might be a race. This line appears to get | 49 // In ChromeBot tests, there might be a race. This line appears to get |
| 49 // called during shutdown and |tab| can be NULL. | 50 // called during shutdown and |tab| can be NULL. |
| 50 content::WebContents* web_contents = | 51 content::WebContents* web_contents = |
| 51 browser->tab_strip_model()->GetActiveWebContents(); | 52 browser->tab_strip_model()->GetActiveWebContents(); |
| 52 if (!web_contents) | 53 if (!web_contents) |
| 53 return; | 54 return; |
| 54 | 55 |
| 56 // Never show the default browser prompt over the first run promos. |
| 57 // TODO(pmonette): The whole logic that determines when to show the default |
| 58 // browser prompt is due for a refactor. ShouldShowDefaultBrowserPrompt() |
| 59 // should be aware of the first run promos and return false instead of |
| 60 // counting on the early return here. See bug crbug.com/693292. |
| 61 if (first_run::IsOnWelcomePage(web_contents)) |
| 62 return; |
| 63 |
| 55 DefaultBrowserInfoBarDelegate::Create( | 64 DefaultBrowserInfoBarDelegate::Create( |
| 56 InfoBarService::FromWebContents(web_contents), browser->profile()); | 65 InfoBarService::FromWebContents(web_contents), browser->profile()); |
| 57 } | 66 } |
| 58 | 67 |
| 59 // Returns true if the default browser prompt should be shown if Chrome is not | 68 // Returns true if the default browser prompt should be shown if Chrome is not |
| 60 // the user's default browser. | 69 // the user's default browser. |
| 61 bool ShouldShowDefaultBrowserPrompt(Profile* profile) { | 70 bool ShouldShowDefaultBrowserPrompt(Profile* profile) { |
| 62 // Do not show the prompt if the "suppress_default_browser_prompt_for_version" | 71 // Do not show the prompt if the "suppress_default_browser_prompt_for_version" |
| 63 // master preference is set to the current version. | 72 // master preference is set to the current version. |
| 64 const std::string disable_version_string = | 73 const std::string disable_version_string = |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 profile->GetPrefs()->ClearPref(prefs::kDefaultBrowserLastDeclined); | 155 profile->GetPrefs()->ClearPref(prefs::kDefaultBrowserLastDeclined); |
| 147 } | 156 } |
| 148 | 157 |
| 149 #if !defined(OS_WIN) | 158 #if !defined(OS_WIN) |
| 150 bool ShowFirstRunDefaultBrowserPrompt(Profile* profile) { | 159 bool ShowFirstRunDefaultBrowserPrompt(Profile* profile) { |
| 151 return false; | 160 return false; |
| 152 } | 161 } |
| 153 #endif | 162 #endif |
| 154 | 163 |
| 155 } // namespace chrome | 164 } // namespace chrome |
| OLD | NEW |