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

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

Issue 1748773002: Simplify the default browser infobar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: new approach without ditching the cancel button Created 4 years, 8 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
OLDNEW
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/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "base/metrics/user_metrics_action.h" 13 #include "base/metrics/user_metrics_action.h"
14 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/strings/string_number_conversions.h"
15 #include "base/thread_task_runner_handle.h" 16 #include "base/thread_task_runner_handle.h"
17 #include "base/time/time.h"
16 #include "base/version.h" 18 #include "base/version.h"
17 #include "build/build_config.h" 19 #include "build/build_config.h"
18 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/infobars/infobar_service.h" 21 #include "chrome/browser/infobars/infobar_service.h"
20 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/profiles/profile_manager.h" 23 #include "chrome/browser/profiles/profile_manager.h"
22 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
23 #include "chrome/browser/ui/browser_finder.h" 25 #include "chrome/browser/ui/browser_finder.h"
24 #include "chrome/browser/ui/tabs/tab_strip_model.h" 26 #include "chrome/browser/ui/tabs/tab_strip_model.h"
25 #include "chrome/common/pref_names.h" 27 #include "chrome/common/pref_names.h"
26 #include "chrome/grit/chromium_strings.h" 28 #include "chrome/grit/chromium_strings.h"
27 #include "chrome/grit/generated_resources.h" 29 #include "chrome/grit/generated_resources.h"
28 #include "components/infobars/core/confirm_infobar_delegate.h" 30 #include "components/infobars/core/confirm_infobar_delegate.h"
29 #include "components/infobars/core/infobar.h" 31 #include "components/infobars/core/infobar.h"
30 #include "components/prefs/pref_registry_simple.h" 32 #include "components/prefs/pref_registry_simple.h"
31 #include "components/prefs/pref_service.h" 33 #include "components/prefs/pref_service.h"
34 #include "components/variations/variations_associated_data.h"
32 #include "components/version_info/version_info.h" 35 #include "components/version_info/version_info.h"
33 #include "content/public/browser/navigation_details.h"
34 #include "content/public/browser/user_metrics.h" 36 #include "content/public/browser/user_metrics.h"
35 #include "content/public/browser/web_contents.h"
36 #include "grit/theme_resources.h" 37 #include "grit/theme_resources.h"
37 #include "ui/base/l10n/l10n_util.h" 38 #include "ui/base/l10n/l10n_util.h"
38 #include "ui/gfx/vector_icons_public.h" 39 #include "ui/gfx/vector_icons_public.h"
39 40
41 #if defined(OS_WIN)
42 #include "base/win/windows_version.h"
43 #endif
44
40 namespace { 45 namespace {
41 46
42 // The delegate for the infobar shown when Chrome is not the default browser. 47 // The delegate for the infobar shown when Chrome is not the default browser.
48 // Ownership of the delegate is given to the infobar itself, the lifetime of
49 // which is bound to the containing WebContents.
43 class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate { 50 class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate {
44 public: 51 public:
45 // Creates a default browser infobar and delegate and adds the infobar to 52 // Creates a default browser infobar and delegate and adds the infobar to
46 // |infobar_service|. 53 // |infobar_service|.
47 static void Create(InfoBarService* infobar_service, Profile* profile); 54 static void Create(InfoBarService* infobar_service, Profile* profile);
48 55
49 private: 56 private:
50 // Possible user interactions with the default browser info bar. 57 // Possible user interactions with the default browser info bar.
51 // Do not modify the ordering as it is important for UMA. 58 // Do not modify the ordering as it is important for UMA.
52 enum InfoBarUserInteraction { 59 enum InfoBarUserInteraction {
53 // The user clicked the "Set as default" button. 60 // The user clicked the "OK" (i.e., "Set as default") button.
54 START_SET_AS_DEFAULT, 61 ACCEPT_INFO_BAR = 0,
rkaplow 2016/04/11 22:16:29 since you're renaming here, I would suggest rename
grt (UTC plus 2) 2016/04/12 13:14:45 Do you mean the values for the DefaultBrowserInfoB
55 // The user doesn't want to be reminded again. 62 // The user clicked the "Cancel" (i.e., "Don't ask again") button.
56 DONT_ASK_AGAIN, 63 CANCEL_INFO_BAR = 1,
57 // The user did not interact with the info bar. 64 // The user did not interact with the info bar.
58 IGNORE_INFO_BAR, 65 IGNORE_INFO_BAR = 2,
59 NUM_INFO_BAR_USER_INTERACTION_TYPES 66 NUM_INFO_BAR_USER_INTERACTION_TYPES
60 }; 67 };
61 68
62 explicit DefaultBrowserInfoBarDelegate(Profile* profile); 69 explicit DefaultBrowserInfoBarDelegate(Profile* profile);
63 ~DefaultBrowserInfoBarDelegate() override; 70 ~DefaultBrowserInfoBarDelegate() override;
64 71
65 void AllowExpiry() { should_expire_ = true; } 72 void AllowExpiry() { should_expire_ = true; }
66 73
67 // ConfirmInfoBarDelegate: 74 // InfoBarDelegate:
68 Type GetInfoBarType() const override; 75 Type GetInfoBarType() const override;
69 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; 76 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override;
70 int GetIconId() const override; 77 int GetIconId() const override;
71 gfx::VectorIconId GetVectorIconId() const override; 78 gfx::VectorIconId GetVectorIconId() const override;
72 bool ShouldExpire(const NavigationDetails& details) const override; 79 bool ShouldExpire(const NavigationDetails& details) const override;
80 void InfoBarDismissed() override;
81
82 // ConfirmInfoBarDelegate:
73 base::string16 GetMessageText() const override; 83 base::string16 GetMessageText() const override;
74 base::string16 GetButtonLabel(InfoBarButton button) const override; 84 base::string16 GetButtonLabel(InfoBarButton button) const override;
75 bool OKButtonTriggersUACPrompt() const override; 85 bool OKButtonTriggersUACPrompt() const override;
76 bool Accept() override; 86 bool Accept() override;
77 bool Cancel() override; 87 bool Cancel() override;
78 88
79 // The WebContents's corresponding profile. 89 // The WebContents's corresponding profile.
80 Profile* profile_; 90 Profile* profile_;
81 91
82 // Whether the user clicked one of the buttons.
83 bool action_taken_;
84
85 // Whether the info-bar should be dismissed on the next navigation. 92 // Whether the info-bar should be dismissed on the next navigation.
86 bool should_expire_; 93 bool should_expire_ = false;
87 94
88 // Used to delay the expiration of the info-bar. 95 // Used to delay the expiration of the info-bar.
89 base::WeakPtrFactory<DefaultBrowserInfoBarDelegate> weak_factory_; 96 base::WeakPtrFactory<DefaultBrowserInfoBarDelegate> weak_factory_;
90 97
91 DISALLOW_COPY_AND_ASSIGN(DefaultBrowserInfoBarDelegate); 98 DISALLOW_COPY_AND_ASSIGN(DefaultBrowserInfoBarDelegate);
92 }; 99 };
93 100
94 // static 101 // static
95 void DefaultBrowserInfoBarDelegate::Create(InfoBarService* infobar_service, 102 void DefaultBrowserInfoBarDelegate::Create(InfoBarService* infobar_service,
96 Profile* profile) { 103 Profile* profile) {
97 infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( 104 infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar(
98 std::unique_ptr<ConfirmInfoBarDelegate>( 105 std::unique_ptr<ConfirmInfoBarDelegate>(
99 new DefaultBrowserInfoBarDelegate(profile)))); 106 new DefaultBrowserInfoBarDelegate(profile))));
100 } 107 }
101 108
102 DefaultBrowserInfoBarDelegate::DefaultBrowserInfoBarDelegate(Profile* profile) 109 DefaultBrowserInfoBarDelegate::DefaultBrowserInfoBarDelegate(Profile* profile)
103 : ConfirmInfoBarDelegate(), 110 : ConfirmInfoBarDelegate(), profile_(profile), weak_factory_(this) {
104 profile_(profile),
105 action_taken_(false),
106 should_expire_(false),
107 weak_factory_(this) {
108 // We want the info-bar to stick-around for few seconds and then be hidden 111 // We want the info-bar to stick-around for few seconds and then be hidden
109 // on the next navigation after that. 112 // on the next navigation after that.
110 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 113 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
111 FROM_HERE, base::Bind(&DefaultBrowserInfoBarDelegate::AllowExpiry, 114 FROM_HERE, base::Bind(&DefaultBrowserInfoBarDelegate::AllowExpiry,
112 weak_factory_.GetWeakPtr()), 115 weak_factory_.GetWeakPtr()),
113 base::TimeDelta::FromSeconds(8)); 116 base::TimeDelta::FromSeconds(8));
114 } 117 }
115 118
116 DefaultBrowserInfoBarDelegate::~DefaultBrowserInfoBarDelegate() { 119 DefaultBrowserInfoBarDelegate::~DefaultBrowserInfoBarDelegate() = default;
117 if (!action_taken_)
118 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction",
119 InfoBarUserInteraction::IGNORE_INFO_BAR,
120 NUM_INFO_BAR_USER_INTERACTION_TYPES);
121 }
122 120
123 infobars::InfoBarDelegate::Type DefaultBrowserInfoBarDelegate::GetInfoBarType() 121 infobars::InfoBarDelegate::Type DefaultBrowserInfoBarDelegate::GetInfoBarType()
124 const { 122 const {
125 #if defined(OS_WIN) 123 #if defined(OS_WIN)
126 return WARNING_TYPE; 124 return WARNING_TYPE;
127 #else 125 #else
128 return PAGE_ACTION_TYPE; 126 return PAGE_ACTION_TYPE;
129 #endif 127 #endif
130 } 128 }
131 129
(...skipping 12 matching lines...) Expand all
144 #else 142 #else
145 return gfx::VectorIconId::CHROME_PRODUCT; 143 return gfx::VectorIconId::CHROME_PRODUCT;
146 #endif 144 #endif
147 } 145 }
148 146
149 bool DefaultBrowserInfoBarDelegate::ShouldExpire( 147 bool DefaultBrowserInfoBarDelegate::ShouldExpire(
150 const NavigationDetails& details) const { 148 const NavigationDetails& details) const {
151 return should_expire_ && ConfirmInfoBarDelegate::ShouldExpire(details); 149 return should_expire_ && ConfirmInfoBarDelegate::ShouldExpire(details);
152 } 150 }
153 151
152 void DefaultBrowserInfoBarDelegate::InfoBarDismissed() {
msw 2016/04/11 21:54:27 We don't update kDefaultBrowserLastDeclined (on cl
grt (UTC plus 2) 2016/04/12 13:14:45 Yes, this is identical to the current behavior. 'x
153 content::RecordAction(
154 base::UserMetricsAction("DefaultBrowserInfoBar_Dismiss"));
155 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction",
156 IGNORE_INFO_BAR,
157 NUM_INFO_BAR_USER_INTERACTION_TYPES);
158 }
159
154 base::string16 DefaultBrowserInfoBarDelegate::GetMessageText() const { 160 base::string16 DefaultBrowserInfoBarDelegate::GetMessageText() const {
155 return l10n_util::GetStringUTF16(IDS_DEFAULT_BROWSER_INFOBAR_SHORT_TEXT); 161 return l10n_util::GetStringUTF16(IDS_DEFAULT_BROWSER_INFOBAR_SHORT_TEXT);
156 } 162 }
157 163
158 base::string16 DefaultBrowserInfoBarDelegate::GetButtonLabel( 164 base::string16 DefaultBrowserInfoBarDelegate::GetButtonLabel(
159 InfoBarButton button) const { 165 InfoBarButton button) const {
160 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? 166 #if defined(OS_WIN)
161 IDS_SET_AS_DEFAULT_INFOBAR_BUTTON_LABEL : 167 // On Windows 10, the "OK" button opens the Windows Settings application,
162 IDS_DONT_ASK_AGAIN_INFOBAR_BUTTON_LABEL); 168 // through which the user must make their default browser choice.
169 const int kSetAsDefaultButtonMessageId =
170 base::win::GetVersion() >= base::win::VERSION_WIN10
171 ? IDS_DEFAULT_BROWSER_INFOBAR_OK_BUTTON_LABEL_WIN_10
172 : IDS_DEFAULT_BROWSER_INFOBAR_OK_BUTTON_LABEL;
173 #else
174 const int kSetAsDefaultButtonMessageId =
175 IDS_DEFAULT_BROWSER_INFOBAR_OK_BUTTON_LABEL;
176 #endif
177 return l10n_util::GetStringUTF16(
178 button == BUTTON_OK ? kSetAsDefaultButtonMessageId
179 : IDS_DEFAULT_BROWSER_INFOBAR_CANCEL_BUTTON_LABEL);
163 } 180 }
164 181
165 // Setting an app as the default browser doesn't require elevation directly, but 182 // Setting an app as the default browser doesn't require elevation directly, but
166 // it does require registering it as the protocol handler for "http", so if 183 // it does require registering it as the protocol handler for "http", so if
167 // protocol registration in general requires elevation, this does as well. 184 // protocol registration in general requires elevation, this does as well.
168 bool DefaultBrowserInfoBarDelegate::OKButtonTriggersUACPrompt() const { 185 bool DefaultBrowserInfoBarDelegate::OKButtonTriggersUACPrompt() const {
169 return shell_integration::IsElevationNeededForSettingDefaultProtocolClient(); 186 return shell_integration::IsElevationNeededForSettingDefaultProtocolClient();
170 } 187 }
171 188
172 bool DefaultBrowserInfoBarDelegate::Accept() { 189 bool DefaultBrowserInfoBarDelegate::Accept() {
173 action_taken_ = true;
174 content::RecordAction( 190 content::RecordAction(
175 base::UserMetricsAction("DefaultBrowserInfoBar_Accept")); 191 base::UserMetricsAction("DefaultBrowserInfoBar_Accept"));
176 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction", 192 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction",
177 InfoBarUserInteraction::START_SET_AS_DEFAULT, 193 ACCEPT_INFO_BAR,
178 NUM_INFO_BAR_USER_INTERACTION_TYPES); 194 NUM_INFO_BAR_USER_INTERACTION_TYPES);
179 // The worker pointer is reference counted. While it is running, the 195 // The worker pointer is reference counted. While it is running, the
180 // message loops of the FILE and UI thread will hold references to it 196 // message loops of the FILE and UI thread will hold references to it
181 // and it will be automatically freed once all its tasks have finished. 197 // and it will be automatically freed once all its tasks have finished.
182 scoped_refptr<shell_integration::DefaultBrowserWorker>( 198 scoped_refptr<shell_integration::DefaultBrowserWorker>(
183 new shell_integration::DefaultBrowserWorker( 199 new shell_integration::DefaultBrowserWorker(
184 shell_integration::DefaultWebClientWorkerCallback())) 200 shell_integration::DefaultWebClientWorkerCallback()))
185 ->StartSetAsDefault(); 201 ->StartSetAsDefault();
186 return true; 202 return true;
187 } 203 }
188 204
189 bool DefaultBrowserInfoBarDelegate::Cancel() { 205 bool DefaultBrowserInfoBarDelegate::Cancel() {
190 action_taken_ = true; 206 chrome::DefaultBrowserPromptDeclined(profile_);
191 content::RecordAction( 207 content::RecordAction(
192 base::UserMetricsAction("DefaultBrowserInfoBar_DontAskAgain")); 208 base::UserMetricsAction("DefaultBrowserInfoBar_Cancel"));
193 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction", 209 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction",
194 InfoBarUserInteraction::DONT_ASK_AGAIN, 210 CANCEL_INFO_BAR,
195 NUM_INFO_BAR_USER_INTERACTION_TYPES); 211 NUM_INFO_BAR_USER_INTERACTION_TYPES);
196 // User clicked "Don't ask me again", remember that.
197 chrome::DefaultBrowserPromptDeclined(profile_);
198 return true; 212 return true;
199 } 213 }
200 214
201 void ResetCheckDefaultBrowserPref(const base::FilePath& profile_path) { 215 void ResetCheckDefaultBrowserPref(const base::FilePath& profile_path) {
202 Profile* profile = 216 Profile* profile =
203 g_browser_process->profile_manager()->GetProfileByPath(profile_path); 217 g_browser_process->profile_manager()->GetProfileByPath(profile_path);
204 if (profile) 218 if (profile)
205 chrome::ResetDefaultBrowserPrompt(profile); 219 chrome::ResetDefaultBrowserPrompt(profile);
206 } 220 }
207 221
208 void ShowPrompt() { 222 void ShowPrompt() {
209 Browser* browser = chrome::FindLastActive(); 223 Browser* browser = chrome::FindLastActive();
210 if (!browser) 224 if (!browser)
211 return; // Reached during ui tests. 225 return; // Reached during ui tests.
212 226
213 // In ChromeBot tests, there might be a race. This line appears to get 227 // In ChromeBot tests, there might be a race. This line appears to get
214 // called during shutdown and |tab| can be NULL. 228 // called during shutdown and |tab| can be NULL.
215 content::WebContents* web_contents = 229 content::WebContents* web_contents =
216 browser->tab_strip_model()->GetActiveWebContents(); 230 browser->tab_strip_model()->GetActiveWebContents();
217 if (!web_contents) 231 if (!web_contents)
218 return; 232 return;
219 233
220 DefaultBrowserInfoBarDelegate::Create( 234 DefaultBrowserInfoBarDelegate::Create(
221 InfoBarService::FromWebContents(web_contents), browser->profile()); 235 InfoBarService::FromWebContents(web_contents), browser->profile());
222 } 236 }
223 237
238 // Returns true if the default browser prompt should be shown if Chrome is not
239 // the user's default browser.
240 bool ShouldShowDefaultBrowserPrompt(Profile* profile) {
241 // Do not show the prompt if the "suppress_default_browser_prompt_for_version"
242 // master preference is set to the current version.
243 const std::string disable_version_string =
244 g_browser_process->local_state()->GetString(
245 prefs::kBrowserSuppressDefaultBrowserPrompt);
246 const Version disable_version(disable_version_string);
247 DCHECK(disable_version_string.empty() || disable_version.IsValid());
248 if (disable_version.IsValid() &&
249 disable_version == Version(version_info::GetVersionNumber())) {
250 return false;
251 }
252
253 // Do not show if the prompt period has yet to pass since the user previously
254 // dismissed the infobar.
255 int64_t last_dismissed_value =
256 profile->GetPrefs()->GetInt64(prefs::kDefaultBrowserLastDeclined);
257 if (last_dismissed_value) {
258 int period_days = 0;
259 base::StringToInt(variations::GetVariationParamValue(
260 "DefaultBrowserInfobar", "RefreshPeriodDays"),
261 &period_days);
262 if (period_days <= 0 || period_days == std::numeric_limits<int>::max())
263 return false; // Failed to parse a reasonable period.
264 base::Time show_on_or_after =
265 base::Time::FromInternalValue(last_dismissed_value) +
266 base::TimeDelta::FromDays(period_days);
267 if (base::Time::Now() < show_on_or_after)
268 return false;
269 }
270
271 return true;
272 }
273
224 void OnCheckIsDefaultBrowserFinished( 274 void OnCheckIsDefaultBrowserFinished(
225 const base::FilePath& profile_path, 275 const base::FilePath& profile_path,
226 bool show_prompt, 276 bool show_prompt,
227 shell_integration::DefaultWebClientState state) { 277 shell_integration::DefaultWebClientState state) {
228 if (state == shell_integration::IS_DEFAULT) { 278 if (state == shell_integration::IS_DEFAULT) {
229 // Notify the user in the future if Chrome ceases to be the user's chosen 279 // Notify the user in the future if Chrome ceases to be the user's chosen
230 // default browser. 280 // default browser.
231 ResetCheckDefaultBrowserPref(profile_path); 281 ResetCheckDefaultBrowserPref(profile_path);
232 } else if (show_prompt && state == shell_integration::NOT_DEFAULT && 282 } else if (show_prompt && state == shell_integration::NOT_DEFAULT &&
233 shell_integration::CanSetAsDefaultBrowser() != 283 shell_integration::CanSetAsDefaultBrowser() !=
(...skipping 21 matching lines...) Expand all
255 return; 305 return;
256 } 306 }
257 307
258 PrefService* prefs = profile->GetPrefs(); 308 PrefService* prefs = profile->GetPrefs();
259 // Reset preferences if kResetCheckDefaultBrowser is true. 309 // Reset preferences if kResetCheckDefaultBrowser is true.
260 if (prefs->GetBoolean(prefs::kResetCheckDefaultBrowser)) { 310 if (prefs->GetBoolean(prefs::kResetCheckDefaultBrowser)) {
261 prefs->SetBoolean(prefs::kResetCheckDefaultBrowser, false); 311 prefs->SetBoolean(prefs::kResetCheckDefaultBrowser, false);
262 ResetDefaultBrowserPrompt(profile); 312 ResetDefaultBrowserPrompt(profile);
263 } 313 }
264 314
265 // Check if Chrome is the default browser but do not prompt if:
266 // - The user said "don't ask me again" on the infobar earlier.
267 // - The "suppress_default_browser_prompt_for_version" master preference is
268 // set to the current version.
269 bool show_prompt = prefs->GetBoolean(prefs::kCheckDefaultBrowser);
270 if (show_prompt) {
271 const std::string disable_version_string =
272 g_browser_process->local_state()->GetString(
273 prefs::kBrowserSuppressDefaultBrowserPrompt);
274 const Version disable_version(disable_version_string);
275 DCHECK(disable_version_string.empty() || disable_version.IsValid());
276 if (disable_version.IsValid() &&
277 disable_version == Version(version_info::GetVersionNumber())) {
278 show_prompt = false;
279 }
280 }
281
282 scoped_refptr<shell_integration::DefaultBrowserWorker>( 315 scoped_refptr<shell_integration::DefaultBrowserWorker>(
283 new shell_integration::DefaultBrowserWorker(base::Bind( 316 new shell_integration::DefaultBrowserWorker(
284 &OnCheckIsDefaultBrowserFinished, profile->GetPath(), show_prompt))) 317 base::Bind(&OnCheckIsDefaultBrowserFinished, profile->GetPath(),
318 ShouldShowDefaultBrowserPrompt(profile))))
285 ->StartCheckIsDefault(); 319 ->StartCheckIsDefault();
286 } 320 }
287 321
288 void DefaultBrowserPromptDeclined(Profile* profile) { 322 void DefaultBrowserPromptDeclined(Profile* profile) {
289 profile->GetPrefs()->SetBoolean(prefs::kCheckDefaultBrowser, false); 323 profile->GetPrefs()->SetInt64(prefs::kDefaultBrowserLastDeclined,
324 base::Time::Now().ToInternalValue());
290 } 325 }
291 326
292 void ResetDefaultBrowserPrompt(Profile* profile) { 327 void ResetDefaultBrowserPrompt(Profile* profile) {
293 profile->GetPrefs()->ClearPref(prefs::kCheckDefaultBrowser); 328 profile->GetPrefs()->ClearPref(prefs::kDefaultBrowserLastDeclined);
294 } 329 }
295 330
296 #if !defined(OS_WIN) 331 #if !defined(OS_WIN)
297 bool ShowFirstRunDefaultBrowserPrompt(Profile* profile) { 332 bool ShowFirstRunDefaultBrowserPrompt(Profile* profile) {
298 return false; 333 return false;
299 } 334 }
300 #endif 335 #endif
301 336
302 } // namespace chrome 337 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698