| 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 "base/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 DefaultBrowserInfoBarDelegate(PrefService* prefs, | 69 DefaultBrowserInfoBarDelegate(PrefService* prefs, |
| 70 bool interactive_flow_required); | 70 bool interactive_flow_required); |
| 71 ~DefaultBrowserInfoBarDelegate() override; | 71 ~DefaultBrowserInfoBarDelegate() override; |
| 72 | 72 |
| 73 void AllowExpiry() { should_expire_ = true; } | 73 void AllowExpiry() { should_expire_ = true; } |
| 74 | 74 |
| 75 // ConfirmInfoBarDelegate: | 75 // ConfirmInfoBarDelegate: |
| 76 int GetIconID() const override; | 76 int GetIconID() const override; |
| 77 bool ShouldExpireInternal(const NavigationDetails& details) const override; |
| 77 base::string16 GetMessageText() const override; | 78 base::string16 GetMessageText() const override; |
| 78 base::string16 GetButtonLabel(InfoBarButton button) const override; | 79 base::string16 GetButtonLabel(InfoBarButton button) const override; |
| 79 bool OKButtonTriggersUACPrompt() const override; | 80 bool OKButtonTriggersUACPrompt() const override; |
| 80 bool Accept() override; | 81 bool Accept() override; |
| 81 bool Cancel() override; | 82 bool Cancel() override; |
| 82 bool ShouldExpireInternal(const NavigationDetails& details) const override; | |
| 83 | 83 |
| 84 // The prefs to use. | 84 // The prefs to use. |
| 85 PrefService* prefs_; | 85 PrefService* prefs_; |
| 86 | 86 |
| 87 // Whether the user clicked one of the buttons. | 87 // Whether the user clicked one of the buttons. |
| 88 bool action_taken_; | 88 bool action_taken_; |
| 89 | 89 |
| 90 // Whether the info-bar should be dismissed on the next navigation. | 90 // Whether the info-bar should be dismissed on the next navigation. |
| 91 bool should_expire_; | 91 bool should_expire_; |
| 92 | 92 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 129 |
| 130 DefaultBrowserInfoBarDelegate::~DefaultBrowserInfoBarDelegate() { | 130 DefaultBrowserInfoBarDelegate::~DefaultBrowserInfoBarDelegate() { |
| 131 if (!action_taken_) | 131 if (!action_taken_) |
| 132 UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.Ignored", 1); | 132 UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.Ignored", 1); |
| 133 } | 133 } |
| 134 | 134 |
| 135 int DefaultBrowserInfoBarDelegate::GetIconID() const { | 135 int DefaultBrowserInfoBarDelegate::GetIconID() const { |
| 136 return IDR_PRODUCT_LOGO_32; | 136 return IDR_PRODUCT_LOGO_32; |
| 137 } | 137 } |
| 138 | 138 |
| 139 bool DefaultBrowserInfoBarDelegate::ShouldExpireInternal( |
| 140 const NavigationDetails& details) const { |
| 141 return should_expire_; |
| 142 } |
| 143 |
| 139 base::string16 DefaultBrowserInfoBarDelegate::GetMessageText() const { | 144 base::string16 DefaultBrowserInfoBarDelegate::GetMessageText() const { |
| 140 return l10n_util::GetStringUTF16(IDS_DEFAULT_BROWSER_INFOBAR_SHORT_TEXT); | 145 return l10n_util::GetStringUTF16(IDS_DEFAULT_BROWSER_INFOBAR_SHORT_TEXT); |
| 141 } | 146 } |
| 142 | 147 |
| 143 base::string16 DefaultBrowserInfoBarDelegate::GetButtonLabel( | 148 base::string16 DefaultBrowserInfoBarDelegate::GetButtonLabel( |
| 144 InfoBarButton button) const { | 149 InfoBarButton button) const { |
| 145 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 150 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
| 146 IDS_SET_AS_DEFAULT_INFOBAR_BUTTON_LABEL : | 151 IDS_SET_AS_DEFAULT_INFOBAR_BUTTON_LABEL : |
| 147 IDS_DONT_ASK_AGAIN_INFOBAR_BUTTON_LABEL); | 152 IDS_DONT_ASK_AGAIN_INFOBAR_BUTTON_LABEL); |
| 148 } | 153 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 162 } | 167 } |
| 163 | 168 |
| 164 bool DefaultBrowserInfoBarDelegate::Cancel() { | 169 bool DefaultBrowserInfoBarDelegate::Cancel() { |
| 165 action_taken_ = true; | 170 action_taken_ = true; |
| 166 UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.DontSetAsDefault", 1); | 171 UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.DontSetAsDefault", 1); |
| 167 // User clicked "Don't ask me again", remember that. | 172 // User clicked "Don't ask me again", remember that. |
| 168 prefs_->SetBoolean(prefs::kCheckDefaultBrowser, false); | 173 prefs_->SetBoolean(prefs::kCheckDefaultBrowser, false); |
| 169 return true; | 174 return true; |
| 170 } | 175 } |
| 171 | 176 |
| 172 bool DefaultBrowserInfoBarDelegate::ShouldExpireInternal( | |
| 173 const NavigationDetails& details) const { | |
| 174 return should_expire_; | |
| 175 } | |
| 176 | |
| 177 void NotifyNotDefaultBrowserCallback(chrome::HostDesktopType desktop_type) { | 177 void NotifyNotDefaultBrowserCallback(chrome::HostDesktopType desktop_type) { |
| 178 Browser* browser = chrome::FindLastActiveWithHostDesktopType(desktop_type); | 178 Browser* browser = chrome::FindLastActiveWithHostDesktopType(desktop_type); |
| 179 if (!browser) | 179 if (!browser) |
| 180 return; // Reached during ui tests. | 180 return; // Reached during ui tests. |
| 181 | 181 |
| 182 // In ChromeBot tests, there might be a race. This line appears to get | 182 // In ChromeBot tests, there might be a race. This line appears to get |
| 183 // called during shutdown and |tab| can be NULL. | 183 // called during shutdown and |tab| can be NULL. |
| 184 content::WebContents* web_contents = | 184 content::WebContents* web_contents = |
| 185 browser->tab_strip_model()->GetActiveWebContents(); | 185 browser->tab_strip_model()->GetActiveWebContents(); |
| 186 if (!web_contents) | 186 if (!web_contents) |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 base::Bind(&CheckDefaultBrowserCallback, desktop_type)); | 256 base::Bind(&CheckDefaultBrowserCallback, desktop_type)); |
| 257 } | 257 } |
| 258 | 258 |
| 259 #if !defined(OS_WIN) | 259 #if !defined(OS_WIN) |
| 260 bool ShowFirstRunDefaultBrowserPrompt(Profile* profile) { | 260 bool ShowFirstRunDefaultBrowserPrompt(Profile* profile) { |
| 261 return false; | 261 return false; |
| 262 } | 262 } |
| 263 #endif | 263 #endif |
| 264 | 264 |
| 265 } // namespace chrome | 265 } // namespace chrome |
| OLD | NEW |