Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(536)

Side by Side Diff: chrome/browser/ui/startup/default_browser_infobar_delegate.cc

Issue 2148523002: Removed the "Don't ask again" button on the default browser prompt (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/startup/default_browser_infobar_delegate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // We want the info-bar to stick-around for few seconds and then be hidden 62 // We want the info-bar to stick-around for few seconds and then be hidden
63 // on the next navigation after that. 63 // on the next navigation after that.
64 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 64 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
65 FROM_HERE, base::Bind(&DefaultBrowserInfoBarDelegate::AllowExpiry, 65 FROM_HERE, base::Bind(&DefaultBrowserInfoBarDelegate::AllowExpiry,
66 weak_factory_.GetWeakPtr()), 66 weak_factory_.GetWeakPtr()),
67 base::TimeDelta::FromSeconds(8)); 67 base::TimeDelta::FromSeconds(8));
68 } 68 }
69 69
70 DefaultBrowserInfoBarDelegate::~DefaultBrowserInfoBarDelegate() { 70 DefaultBrowserInfoBarDelegate::~DefaultBrowserInfoBarDelegate() {
71 if (!action_taken_) { 71 if (!action_taken_) {
72 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction", 72 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction",
grt (UTC plus 2) 2016/07/14 18:54:16 nit: use content::RecordAction here as well
Patrick Monette 2016/07/14 19:40:58 Done.
73 IGNORE_INFO_BAR, 73 IGNORE_INFO_BAR,
74 NUM_INFO_BAR_USER_INTERACTION_TYPES); 74 NUM_INFO_BAR_USER_INTERACTION_TYPES);
75 } 75 }
76 } 76 }
77 77
78 void DefaultBrowserInfoBarDelegate::AllowExpiry() { 78 void DefaultBrowserInfoBarDelegate::AllowExpiry() {
79 should_expire_ = true; 79 should_expire_ = true;
80 } 80 }
81 81
82 infobars::InfoBarDelegate::Type DefaultBrowserInfoBarDelegate::GetInfoBarType() 82 infobars::InfoBarDelegate::Type DefaultBrowserInfoBarDelegate::GetInfoBarType()
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 128 }
129 #endif // defined(OS_WIN) 129 #endif // defined(OS_WIN)
130 130
131 bool DefaultBrowserInfoBarDelegate::ShouldExpire( 131 bool DefaultBrowserInfoBarDelegate::ShouldExpire(
132 const NavigationDetails& details) const { 132 const NavigationDetails& details) const {
133 return should_expire_ && ConfirmInfoBarDelegate::ShouldExpire(details); 133 return should_expire_ && ConfirmInfoBarDelegate::ShouldExpire(details);
134 } 134 }
135 135
136 void DefaultBrowserInfoBarDelegate::InfoBarDismissed() { 136 void DefaultBrowserInfoBarDelegate::InfoBarDismissed() {
137 action_taken_ = true; 137 action_taken_ = true;
138 // This can get reached in tests where profile_ is null.
139 if (profile_)
140 chrome::DefaultBrowserPromptDeclined(profile_);
138 content::RecordAction( 141 content::RecordAction(
139 base::UserMetricsAction("DefaultBrowserInfoBar_Dismiss")); 142 base::UserMetricsAction("DefaultBrowserInfoBar_Dismiss"));
140 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction", 143 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction",
141 DISMISS_INFO_BAR, 144 DISMISS_INFO_BAR,
142 NUM_INFO_BAR_USER_INTERACTION_TYPES); 145 NUM_INFO_BAR_USER_INTERACTION_TYPES);
143 } 146 }
144 147
145 base::string16 DefaultBrowserInfoBarDelegate::GetMessageText() const { 148 base::string16 DefaultBrowserInfoBarDelegate::GetMessageText() const {
146 return l10n_util::GetStringUTF16(IDS_DEFAULT_BROWSER_INFOBAR_SHORT_TEXT); 149 return l10n_util::GetStringUTF16(IDS_DEFAULT_BROWSER_INFOBAR_SHORT_TEXT);
147 } 150 }
148 151
152 int DefaultBrowserInfoBarDelegate::GetButtons() const {
153 return BUTTON_OK;
154 }
155
149 base::string16 DefaultBrowserInfoBarDelegate::GetButtonLabel( 156 base::string16 DefaultBrowserInfoBarDelegate::GetButtonLabel(
150 InfoBarButton button) const { 157 InfoBarButton button) const {
158 DCHECK_EQ(BUTTON_OK, button);
151 #if defined(OS_WIN) 159 #if defined(OS_WIN)
152 // On Windows 10, the "OK" button opens the Windows Settings application, 160 // On Windows 10, the "OK" button opens the Windows Settings application,
153 // through which the user must make their default browser choice. 161 // through which the user must make their default browser choice.
154 const int kSetAsDefaultButtonMessageId = 162 const int kSetAsDefaultButtonMessageId =
155 base::win::GetVersion() >= base::win::VERSION_WIN10 163 base::win::GetVersion() >= base::win::VERSION_WIN10
156 ? IDS_DEFAULT_BROWSER_INFOBAR_OK_BUTTON_LABEL_WIN_10 164 ? IDS_DEFAULT_BROWSER_INFOBAR_OK_BUTTON_LABEL_WIN_10
grt (UTC plus 2) 2016/07/14 18:54:16 i think we're clear to remove this in a separate C
Patrick Monette 2016/07/14 19:40:58 Sure!
157 : IDS_DEFAULT_BROWSER_INFOBAR_OK_BUTTON_LABEL; 165 : IDS_DEFAULT_BROWSER_INFOBAR_OK_BUTTON_LABEL;
158 #else 166 #else
159 const int kSetAsDefaultButtonMessageId = 167 const int kSetAsDefaultButtonMessageId =
160 IDS_DEFAULT_BROWSER_INFOBAR_OK_BUTTON_LABEL; 168 IDS_DEFAULT_BROWSER_INFOBAR_OK_BUTTON_LABEL;
161 #endif 169 #endif
162 return l10n_util::GetStringUTF16( 170 return l10n_util::GetStringUTF16(kSetAsDefaultButtonMessageId);
163 button == BUTTON_OK ? kSetAsDefaultButtonMessageId
164 : IDS_DEFAULT_BROWSER_INFOBAR_CANCEL_BUTTON_LABEL);
165 } 171 }
166 172
167 // Setting an app as the default browser doesn't require elevation directly, but 173 // Setting an app as the default browser doesn't require elevation directly, but
168 // it does require registering it as the protocol handler for "http", so if 174 // it does require registering it as the protocol handler for "http", so if
169 // protocol registration in general requires elevation, this does as well. 175 // protocol registration in general requires elevation, this does as well.
170 bool DefaultBrowserInfoBarDelegate::OKButtonTriggersUACPrompt() const { 176 bool DefaultBrowserInfoBarDelegate::OKButtonTriggersUACPrompt() const {
171 return shell_integration::IsElevationNeededForSettingDefaultProtocolClient(); 177 return shell_integration::IsElevationNeededForSettingDefaultProtocolClient();
172 } 178 }
173 179
174 bool DefaultBrowserInfoBarDelegate::Accept() { 180 bool DefaultBrowserInfoBarDelegate::Accept() {
(...skipping 16 matching lines...) Expand all
191 close_infobar = false; 197 close_infobar = false;
192 } 198 }
193 199
194 // The worker pointer is reference counted. While it is running, the 200 // The worker pointer is reference counted. While it is running, the
195 // message loops of the FILE and UI thread will hold references to it 201 // message loops of the FILE and UI thread will hold references to it
196 // and it will be automatically freed once all its tasks have finished. 202 // and it will be automatically freed once all its tasks have finished.
197 CreateDefaultBrowserWorker(set_as_default_callback)->StartSetAsDefault(); 203 CreateDefaultBrowserWorker(set_as_default_callback)->StartSetAsDefault();
198 return close_infobar; 204 return close_infobar;
199 } 205 }
200 206
201 bool DefaultBrowserInfoBarDelegate::Cancel() {
202 action_taken_ = true;
203 // This can get reached in tests where profile_ is null.
204 if (profile_)
205 chrome::DefaultBrowserPromptDeclined(profile_);
206 content::RecordAction(
207 base::UserMetricsAction("DefaultBrowserInfoBar_Cancel"));
208 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction",
209 CANCEL_INFO_BAR,
210 NUM_INFO_BAR_USER_INTERACTION_TYPES);
211 return true;
212 }
213
214 scoped_refptr<shell_integration::DefaultBrowserWorker> 207 scoped_refptr<shell_integration::DefaultBrowserWorker>
215 DefaultBrowserInfoBarDelegate::CreateDefaultBrowserWorker( 208 DefaultBrowserInfoBarDelegate::CreateDefaultBrowserWorker(
216 const shell_integration::DefaultWebClientWorkerCallback& callback) { 209 const shell_integration::DefaultWebClientWorkerCallback& callback) {
217 return new shell_integration::DefaultBrowserWorker(callback); 210 return new shell_integration::DefaultBrowserWorker(callback);
218 } 211 }
219 212
220 void DefaultBrowserInfoBarDelegate::OnSetAsDefaultFinished( 213 void DefaultBrowserInfoBarDelegate::OnSetAsDefaultFinished(
221 shell_integration::DefaultWebClientState state) { 214 shell_integration::DefaultWebClientState state) {
222 infobar()->owner()->RemoveInfoBar(infobar()); 215 infobar()->owner()->RemoveInfoBar(infobar());
223 } 216 }
224 217
225 } // namespace chrome 218 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/startup/default_browser_infobar_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698