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

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

Issue 2758353002: Deprecate the StickyDefaultBrowserPrompt experiment (Closed)
Patch Set: Remove unused include Created 3 years, 9 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 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 <memory> 7 #include <memory>
8 8
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
11 #include "chrome/app/vector_icons/vector_icons.h" 11 #include "chrome/app/vector_icons/vector_icons.h"
12 #include "chrome/browser/ui/startup/default_browser_prompt.h" 12 #include "chrome/browser/ui/startup/default_browser_prompt.h"
13 #include "chrome/grit/chromium_strings.h" 13 #include "chrome/grit/chromium_strings.h"
14 #include "chrome/grit/generated_resources.h" 14 #include "chrome/grit/generated_resources.h"
15 #include "components/infobars/core/infobar.h" 15 #include "components/infobars/core/infobar.h"
16 #include "content/public/browser/user_metrics.h" 16 #include "content/public/browser/user_metrics.h"
17 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
18 18
19 #if defined(OS_WIN)
20 #include "base/win/windows_version.h"
21 #endif
22
23 namespace chrome { 19 namespace chrome {
24 20
25 bool IsStickyDefaultBrowserPromptEnabled() {
26 #if defined(OS_WIN)
27 // The flow to set the default browser is only asynchronous on Windows 10+.
28 return base::win::GetVersion() >= base::win::VERSION_WIN10 &&
29 base::FeatureList::IsEnabled(kStickyDefaultBrowserPrompt);
30 #else
31 return false;
32 #endif
33 }
34
35 // static 21 // static
36 void DefaultBrowserInfoBarDelegate::Create(InfoBarService* infobar_service, 22 void DefaultBrowserInfoBarDelegate::Create(InfoBarService* infobar_service,
37 Profile* profile) { 23 Profile* profile) {
38 infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( 24 infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar(
39 std::unique_ptr<ConfirmInfoBarDelegate>( 25 std::unique_ptr<ConfirmInfoBarDelegate>(
40 new DefaultBrowserInfoBarDelegate(profile)))); 26 new DefaultBrowserInfoBarDelegate(profile))));
41 } 27 }
42 28
43 DefaultBrowserInfoBarDelegate::DefaultBrowserInfoBarDelegate(Profile* profile) 29 DefaultBrowserInfoBarDelegate::DefaultBrowserInfoBarDelegate(Profile* profile)
44 : ConfirmInfoBarDelegate(), 30 : ConfirmInfoBarDelegate(),
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 107 }
122 108
123 bool DefaultBrowserInfoBarDelegate::Accept() { 109 bool DefaultBrowserInfoBarDelegate::Accept() {
124 action_taken_ = true; 110 action_taken_ = true;
125 content::RecordAction( 111 content::RecordAction(
126 base::UserMetricsAction("DefaultBrowserInfoBar_Accept")); 112 base::UserMetricsAction("DefaultBrowserInfoBar_Accept"));
127 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction", 113 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction",
128 ACCEPT_INFO_BAR, 114 ACCEPT_INFO_BAR,
129 NUM_INFO_BAR_USER_INTERACTION_TYPES); 115 NUM_INFO_BAR_USER_INTERACTION_TYPES);
130 116
131 bool close_infobar = true;
132 shell_integration::DefaultWebClientWorkerCallback set_as_default_callback;
133
134 if (IsStickyDefaultBrowserPromptEnabled()) {
135 // When the experiment is enabled, the infobar is only closed when the
136 // DefaultBrowserWorker is finished.
137 set_as_default_callback =
138 base::Bind(&DefaultBrowserInfoBarDelegate::OnSetAsDefaultFinished,
139 weak_factory_.GetWeakPtr());
140 close_infobar = false;
141 }
142
143 // The worker pointer is reference counted. While it is running, the 117 // The worker pointer is reference counted. While it is running, the
144 // message loops of the FILE and UI thread will hold references to it 118 // message loops of the FILE and UI thread will hold references to it
145 // and it will be automatically freed once all its tasks have finished. 119 // and it will be automatically freed once all its tasks have finished.
146 CreateDefaultBrowserWorker(set_as_default_callback)->StartSetAsDefault(); 120 make_scoped_refptr(new shell_integration::DefaultBrowserWorker(
147 return close_infobar; 121 shell_integration::DefaultWebClientWorkerCallback()))
148 } 122 ->StartSetAsDefault();
149 123 return true;
150 scoped_refptr<shell_integration::DefaultBrowserWorker>
151 DefaultBrowserInfoBarDelegate::CreateDefaultBrowserWorker(
152 const shell_integration::DefaultWebClientWorkerCallback& callback) {
153 return new shell_integration::DefaultBrowserWorker(callback);
154 }
155
156 void DefaultBrowserInfoBarDelegate::OnSetAsDefaultFinished(
157 shell_integration::DefaultWebClientState state) {
158 infobar()->owner()->RemoveInfoBar(infobar());
159 } 124 }
160 125
161 } // namespace chrome 126 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698