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

Unified Diff: chrome/browser/ui/startup/default_browser_prompt.cc

Issue 1974153002: Add an experiment for the default browser infobar on Windows 10 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/startup/default_browser_prompt.cc
diff --git a/chrome/browser/ui/startup/default_browser_prompt.cc b/chrome/browser/ui/startup/default_browser_prompt.cc
index 8765d386d80a1a3dbbaa14a796fac3be68b70d32..b6dd2b002ca7c4092c5455159e8fb0490776490a 100644
--- a/chrome/browser/ui/startup/default_browser_prompt.cc
+++ b/chrome/browser/ui/startup/default_browser_prompt.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/startup/default_browser_prompt.h"
+#include <limits>
Patrick Monette 2016/05/12 23:43:25 This fixes a lint error.
#include <string>
#include "base/location.h"
@@ -39,11 +40,25 @@
#include "ui/gfx/vector_icons_public.h"
#if defined(OS_WIN)
+#include "base/feature_list.h"
#include "base/win/windows_version.h"
#endif
namespace {
+bool IsStickyDefaultBrowserInfobarEnabled() {
+#if defined(OS_WIN)
+ static const base::Feature kStickyDefaultBrowserInfobar{
Peter Kasting 2016/05/17 03:07:37 Nit: Can be constexpr
Patrick Monette 2016/05/31 15:19:41 I can't manage to make it constexpr now that I'm d
+ "StickyDefaultBrowserInfobar", base::FEATURE_DISABLED_BY_DEFAULT};
+
+ // The flow to set the default browser is only asynchronous on Windows 10+.
+ return base::win::GetVersion() >= base::win::VERSION_WIN10 &&
+ base::FeatureList::IsEnabled(kStickyDefaultBrowserInfobar);
+#else
+ return false;
+#endif
+}
+
// The delegate for the infobar shown when Chrome is not the default browser.
// Ownership of the delegate is given to the infobar itself, the lifetime of
// which is bound to the containing WebContents.
@@ -86,6 +101,12 @@ class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate {
bool Accept() override;
bool Cancel() override;
+ // Removes the infobar when the worker is finished setting the default
+ // browser. Only used if the StickyDefaultBrowserInfobar experiment is
+ // enabled.
+ void OnSetAsDefaultFinished(
+ shell_integration::DefaultWebClientState /* state */);
Peter Kasting 2016/05/17 03:07:37 Nit: No /* */; put the name uncommented here and b
Patrick Monette 2016/05/31 15:19:41 Done.
+
// The WebContents's corresponding profile.
Profile* profile_;
@@ -192,14 +213,26 @@ bool DefaultBrowserInfoBarDelegate::Accept() {
UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction",
ACCEPT_INFO_BAR,
NUM_INFO_BAR_USER_INTERACTION_TYPES);
+
+ bool close_infobar = true;
+ shell_integration::DefaultWebClientWorkerCallback set_as_default_callback;
+
+ if (IsStickyDefaultBrowserInfobarEnabled()) {
+ // When the experiment is enabled, the infobar is only closed when the
+ // DefaultBrowserWorker is finished.
+ set_as_default_callback =
+ base::Bind(&DefaultBrowserInfoBarDelegate::OnSetAsDefaultFinished,
+ weak_factory_.GetWeakPtr());
+ close_infobar = false;
+ }
+
// The worker pointer is reference counted. While it is running, the
// message loops of the FILE and UI thread will hold references to it
// and it will be automatically freed once all its tasks have finished.
scoped_refptr<shell_integration::DefaultBrowserWorker>(
- new shell_integration::DefaultBrowserWorker(
- shell_integration::DefaultWebClientWorkerCallback()))
+ new shell_integration::DefaultBrowserWorker(set_as_default_callback))
->StartSetAsDefault();
- return true;
+ return close_infobar;
}
bool DefaultBrowserInfoBarDelegate::Cancel() {
@@ -212,6 +245,11 @@ bool DefaultBrowserInfoBarDelegate::Cancel() {
return true;
}
+void DefaultBrowserInfoBarDelegate::OnSetAsDefaultFinished(
+ shell_integration::DefaultWebClientState /* state */) {
+ infobar()->owner()->RemoveInfoBar(infobar());
+}
+
void ResetCheckDefaultBrowserPref(const base::FilePath& profile_path) {
Profile* profile =
g_browser_process->profile_manager()->GetProfileByPath(profile_path);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698