OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_infobar_delegate.h" | 5 #include "chrome/browser/ui/startup/default_browser_infobar_delegate.h" |
6 | 6 |
7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
8 #include "base/threading/thread_task_runner_handle.h" | 8 #include "base/threading/thread_task_runner_handle.h" |
9 #include "chrome/browser/ui/startup/default_browser_prompt.h" | 9 #include "chrome/browser/ui/startup/default_browser_prompt.h" |
10 #include "chrome/grit/chromium_strings.h" | 10 #include "chrome/grit/chromium_strings.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 return ConfirmInfoBarDelegate::GetIcon(); | 120 return ConfirmInfoBarDelegate::GetIcon(); |
121 } | 121 } |
122 #endif // defined(OS_WIN) | 122 #endif // defined(OS_WIN) |
123 | 123 |
124 bool DefaultBrowserInfoBarDelegate::ShouldExpire( | 124 bool DefaultBrowserInfoBarDelegate::ShouldExpire( |
125 const NavigationDetails& details) const { | 125 const NavigationDetails& details) const { |
126 return should_expire_ && ConfirmInfoBarDelegate::ShouldExpire(details); | 126 return should_expire_ && ConfirmInfoBarDelegate::ShouldExpire(details); |
127 } | 127 } |
128 | 128 |
129 void DefaultBrowserInfoBarDelegate::InfoBarDismissed() { | 129 void DefaultBrowserInfoBarDelegate::InfoBarDismissed() { |
130 // This can get reached in tests where profile_ is null. | |
grt (UTC plus 2)
2016/07/14 06:31:16
does this treat 'x' and ignore equally? IIUC, 'x'
Patrick Monette
2016/07/14 17:42:57
InfoBarDismissed() is only called when the (X) but
| |
131 if (profile_) | |
132 chrome::DefaultBrowserPromptDeclined(profile_); | |
130 content::RecordAction( | 133 content::RecordAction( |
131 base::UserMetricsAction("DefaultBrowserInfoBar_Dismiss")); | 134 base::UserMetricsAction("DefaultBrowserInfoBar_Dismiss")); |
132 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction", | 135 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction", |
133 IGNORE_INFO_BAR, | 136 IGNORE_INFO_BAR, |
134 NUM_INFO_BAR_USER_INTERACTION_TYPES); | 137 NUM_INFO_BAR_USER_INTERACTION_TYPES); |
135 } | 138 } |
136 | 139 |
137 base::string16 DefaultBrowserInfoBarDelegate::GetMessageText() const { | 140 base::string16 DefaultBrowserInfoBarDelegate::GetMessageText() const { |
138 return l10n_util::GetStringUTF16(IDS_DEFAULT_BROWSER_INFOBAR_SHORT_TEXT); | 141 return l10n_util::GetStringUTF16(IDS_DEFAULT_BROWSER_INFOBAR_SHORT_TEXT); |
139 } | 142 } |
140 | 143 |
144 int DefaultBrowserInfoBarDelegate::GetButtons() const { | |
145 return BUTTON_OK; | |
146 } | |
147 | |
141 base::string16 DefaultBrowserInfoBarDelegate::GetButtonLabel( | 148 base::string16 DefaultBrowserInfoBarDelegate::GetButtonLabel( |
142 InfoBarButton button) const { | 149 InfoBarButton button) const { |
150 DCHECK_EQ(BUTTON_OK, button); | |
143 #if defined(OS_WIN) | 151 #if defined(OS_WIN) |
144 // On Windows 10, the "OK" button opens the Windows Settings application, | 152 // On Windows 10, the "OK" button opens the Windows Settings application, |
145 // through which the user must make their default browser choice. | 153 // through which the user must make their default browser choice. |
146 const int kSetAsDefaultButtonMessageId = | 154 const int kSetAsDefaultButtonMessageId = |
147 base::win::GetVersion() >= base::win::VERSION_WIN10 | 155 base::win::GetVersion() >= base::win::VERSION_WIN10 |
148 ? IDS_DEFAULT_BROWSER_INFOBAR_OK_BUTTON_LABEL_WIN_10 | 156 ? IDS_DEFAULT_BROWSER_INFOBAR_OK_BUTTON_LABEL_WIN_10 |
149 : IDS_DEFAULT_BROWSER_INFOBAR_OK_BUTTON_LABEL; | 157 : IDS_DEFAULT_BROWSER_INFOBAR_OK_BUTTON_LABEL; |
150 #else | 158 #else |
151 const int kSetAsDefaultButtonMessageId = | 159 const int kSetAsDefaultButtonMessageId = |
152 IDS_DEFAULT_BROWSER_INFOBAR_OK_BUTTON_LABEL; | 160 IDS_DEFAULT_BROWSER_INFOBAR_OK_BUTTON_LABEL; |
153 #endif | 161 #endif |
154 return l10n_util::GetStringUTF16( | 162 return l10n_util::GetStringUTF16(kSetAsDefaultButtonMessageId); |
155 button == BUTTON_OK ? kSetAsDefaultButtonMessageId | |
156 : IDS_DEFAULT_BROWSER_INFOBAR_CANCEL_BUTTON_LABEL); | |
157 } | 163 } |
158 | 164 |
159 // Setting an app as the default browser doesn't require elevation directly, but | 165 // Setting an app as the default browser doesn't require elevation directly, but |
160 // it does require registering it as the protocol handler for "http", so if | 166 // it does require registering it as the protocol handler for "http", so if |
161 // protocol registration in general requires elevation, this does as well. | 167 // protocol registration in general requires elevation, this does as well. |
162 bool DefaultBrowserInfoBarDelegate::OKButtonTriggersUACPrompt() const { | 168 bool DefaultBrowserInfoBarDelegate::OKButtonTriggersUACPrompt() const { |
163 return shell_integration::IsElevationNeededForSettingDefaultProtocolClient(); | 169 return shell_integration::IsElevationNeededForSettingDefaultProtocolClient(); |
164 } | 170 } |
165 | 171 |
166 bool DefaultBrowserInfoBarDelegate::Accept() { | 172 bool DefaultBrowserInfoBarDelegate::Accept() { |
(...skipping 15 matching lines...) Expand all Loading... | |
182 close_infobar = false; | 188 close_infobar = false; |
183 } | 189 } |
184 | 190 |
185 // The worker pointer is reference counted. While it is running, the | 191 // The worker pointer is reference counted. While it is running, the |
186 // message loops of the FILE and UI thread will hold references to it | 192 // message loops of the FILE and UI thread will hold references to it |
187 // and it will be automatically freed once all its tasks have finished. | 193 // and it will be automatically freed once all its tasks have finished. |
188 CreateDefaultBrowserWorker(set_as_default_callback)->StartSetAsDefault(); | 194 CreateDefaultBrowserWorker(set_as_default_callback)->StartSetAsDefault(); |
189 return close_infobar; | 195 return close_infobar; |
190 } | 196 } |
191 | 197 |
192 bool DefaultBrowserInfoBarDelegate::Cancel() { | |
193 // This can get reached in tests where profile_ is null. | |
194 if (profile_) | |
195 chrome::DefaultBrowserPromptDeclined(profile_); | |
196 content::RecordAction( | |
197 base::UserMetricsAction("DefaultBrowserInfoBar_Cancel")); | |
198 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction", | |
199 CANCEL_INFO_BAR, | |
200 NUM_INFO_BAR_USER_INTERACTION_TYPES); | |
201 return true; | |
202 } | |
203 | |
204 scoped_refptr<shell_integration::DefaultBrowserWorker> | 198 scoped_refptr<shell_integration::DefaultBrowserWorker> |
205 DefaultBrowserInfoBarDelegate::CreateDefaultBrowserWorker( | 199 DefaultBrowserInfoBarDelegate::CreateDefaultBrowserWorker( |
206 const shell_integration::DefaultWebClientWorkerCallback& callback) { | 200 const shell_integration::DefaultWebClientWorkerCallback& callback) { |
207 return new shell_integration::DefaultBrowserWorker(callback); | 201 return new shell_integration::DefaultBrowserWorker(callback); |
208 } | 202 } |
209 | 203 |
210 void DefaultBrowserInfoBarDelegate::OnSetAsDefaultFinished( | 204 void DefaultBrowserInfoBarDelegate::OnSetAsDefaultFinished( |
211 shell_integration::DefaultWebClientState state) { | 205 shell_integration::DefaultWebClientState state) { |
212 infobar()->owner()->RemoveInfoBar(infobar()); | 206 infobar()->owner()->RemoveInfoBar(infobar()); |
213 } | 207 } |
214 | 208 |
215 } // namespace chrome | 209 } // namespace chrome |
OLD | NEW |