Commit 341426ee authored by Patrick Monette's avatar Patrick Monette Committed by Commit Bot

Adding an experiment to automatically open the default browser chooser

Bug: 798612
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: Ie9bb7d1af812a96f11058c928cb32fa6491d96db
Reviewed-on: https://chromium-review.googlesource.com/981079
Commit-Queue: Patrick Monette <pmonette@chromium.org>
Reviewed-by: default avatarDominic Battré <battre@chromium.org>
Reviewed-by: default avatarRobert Kaplow <rkaplow@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarGreg Thompson <grt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567797}
parent 1582e398
...@@ -339,6 +339,12 @@ const char kInstantUIZeroSuggestUrlPrefix[] = ...@@ -339,6 +339,12 @@ const char kInstantUIZeroSuggestUrlPrefix[] =
const char kTouchHudProjectionEnabled[] = "touch_hud.projection_enabled"; const char kTouchHudProjectionEnabled[] = "touch_hud.projection_enabled";
#endif #endif
#if defined(OS_WIN)
// Deprecated 6/2018.
const char kResetHasSeenWin10PromoPage[] =
"browser.reset_has_seen_win10_promo_page";
#endif
// Register prefs used only for migration (clearing or moving to a new key). // Register prefs used only for migration (clearing or moving to a new key).
void RegisterProfilePrefsForMigration( void RegisterProfilePrefsForMigration(
user_prefs::PrefRegistrySyncable* registry) { user_prefs::PrefRegistrySyncable* registry) {
...@@ -485,6 +491,8 @@ void RegisterLocalState(PrefRegistrySimple* registry) { ...@@ -485,6 +491,8 @@ void RegisterLocalState(PrefRegistrySimple* registry) {
ModuleDatabase::RegisterLocalStatePrefs(registry); ModuleDatabase::RegisterLocalStatePrefs(registry);
ThirdPartyConflictsManager::RegisterLocalStatePrefs(registry); ThirdPartyConflictsManager::RegisterLocalStatePrefs(registry);
#endif // defined(GOOGLE_CHROME_BUILD) #endif // defined(GOOGLE_CHROME_BUILD)
registry->RegisterBooleanPref(kResetHasSeenWin10PromoPage, false);
#endif #endif
#if defined(TOOLKIT_VIEWS) #if defined(TOOLKIT_VIEWS)
...@@ -747,6 +755,11 @@ void MigrateObsoleteBrowserPrefs(Profile* profile, PrefService* local_state) { ...@@ -747,6 +755,11 @@ void MigrateObsoleteBrowserPrefs(Profile* profile, PrefService* local_state) {
// Added 5/2018. // Added 5/2018.
local_state->ClearPref(prefs::kProblematicPrograms); local_state->ClearPref(prefs::kProblematicPrograms);
#endif #endif
#if defined(OS_WIN)
// Added 6/2018.
local_state->ClearPref(kResetHasSeenWin10PromoPage);
#endif
} }
// This method should be periodically pruned of year+ old migrations. // This method should be periodically pruned of year+ old migrations.
......
...@@ -8,9 +8,12 @@ ...@@ -8,9 +8,12 @@
<link rel="import" href="chrome://resources/cr_elements/icons.html"> <link rel="import" href="chrome://resources/cr_elements/icons.html">
<link rel="import" href="chrome://resources/html/cr.html"> <link rel="import" href="chrome://resources/html/cr.html">
<link rel="import" href="chrome://resources/html/load_time_data.html">
<link rel="import" href="chrome://resources/html/util.html">
<link rel="import" href="chrome://resources/html/action_link.html"> <link rel="import" href="chrome://resources/html/action_link.html">
<link rel="import" href="chrome://resources/html/action_link_css.html"> <link rel="import" href="chrome://resources/html/action_link_css.html">
<link rel="import" href="chrome://resources/html/util.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-styles/color.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-styles/color.html">
...@@ -18,11 +21,12 @@ ...@@ -18,11 +21,12 @@
<link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css"> <link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css">
<link rel="stylesheet" href="/welcome_win10.css"> <link rel="stylesheet" href="/welcome_win10.css">
<script src="strings.js"></script>
<dom-module id="welcome-win10"> <dom-module id="welcome-win10">
<template> <template>
<style include="action-link"> <style include="action-link">
:host { :host {
--expandable-section-height: 28.375em;
align-items: flex-start; align-items: flex-start;
display: inline-flex; display: inline-flex;
flex-direction: column; flex-direction: column;
...@@ -31,6 +35,14 @@ ...@@ -31,6 +35,14 @@
transition: opacity 300ms; transition: opacity 300ms;
} }
:host .section {
--expandable-section-height: 28.375em;
}
:host([is-accelerated]) .section {
--expandable-section-height: 26.375em;
}
a { a {
color: var(--google-blue-500); color: var(--google-blue-500);
text-decoration: none; text-decoration: none;
...@@ -52,8 +64,10 @@ ...@@ -52,8 +64,10 @@
margin: 0 -0.0625em; margin: 0 -0.0625em;
} }
.heading { h1 {
font-size: 2.125em; font-size: 2.125em;
font-weight: normal;
margin: 0;
padding-bottom: 2rem; padding-bottom: 2rem;
padding-top: 1rem; padding-top: 1rem;
} }
...@@ -274,7 +288,7 @@ ...@@ -274,7 +288,7 @@
} }
</style> </style>
<div class="header-logo" role="presentation"></div> <div class="header-logo" role="presentation"></div>
<div class="heading">$i18n{headerText}</div> <h1>$i18n{headerText}</h1>
<div class="sections"> <div class="sections">
<div class$="[[computeClasses(isCombined)]]"> <div class$="[[computeClasses(isCombined)]]">
<template is="dom-if" if="[[isCombined]]"> <template is="dom-if" if="[[isCombined]]">
......
...@@ -8,10 +8,19 @@ Polymer({ ...@@ -8,10 +8,19 @@ Polymer({
properties: { properties: {
// Determines if the combined variant should be displayed. The combined // Determines if the combined variant should be displayed. The combined
// variant includes instructions on how to pin Chrome to the taskbar. // variant includes instructions on how to pin Chrome to the taskbar.
isCombined: Boolean, isCombined: {
type: Boolean,
value: false,
},
// Indicates if the accelerated flow is enabled. // Indicates if the accelerated flow is enabled.
isAccelerated: Boolean, isAccelerated: {
type: Boolean,
value: function() {
return loadTimeData.getBoolean('acceleratedFlowEnabled');
},
reflectToAttribute: true,
},
}, },
receivePinnedState_: function(isPinnedToTaskbar) { receivePinnedState_: function(isPinnedToTaskbar) {
...@@ -30,21 +39,15 @@ Polymer({ ...@@ -30,21 +39,15 @@ Polymer({
}, },
ready: function() { ready: function() {
this.isCombined = false; // The accelerated flow can be overridden with a query parameter.
this.isAccelerated = false;
const FLOWTYPE_KEY = 'flowtype'; const FLOWTYPE_KEY = 'flowtype';
const FLOW_TYPE_MAP = {'regular': false, 'accelerated': true}; const FLOW_TYPE_MAP = {'regular': false, 'accelerated': true};
var params = new URLSearchParams(location.search); var params = new URLSearchParams(location.search);
if (params.has(FLOWTYPE_KEY)) { if (params.has(FLOWTYPE_KEY)) {
if (params.get(FLOWTYPE_KEY) in FLOW_TYPE_MAP) { if (params.get(FLOWTYPE_KEY) in FLOW_TYPE_MAP) {
this.isAccelerated = FLOW_TYPE_MAP[params.get(FLOWTYPE_KEY)]; this.isAccelerated = FLOW_TYPE_MAP[params.get(FLOWTYPE_KEY)];
// Adjust the height since the accelerated flow contains fewer steps.
this.customStyle['--expandable-section-height'] = '26.375em';
this.updateStyles();
} else { } else {
console.log( console.error(
'Found invalid value for the \'flowtype\' parameter: %s', 'Found invalid value for the \'flowtype\' parameter: %s',
params.get(FLOWTYPE_KEY)); params.get(FLOWTYPE_KEY));
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/welcome_win10_handler.h" #include "chrome/browser/ui/webui/welcome_win10_handler.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h" #include "chrome/grit/browser_resources.h"
...@@ -87,8 +88,15 @@ WelcomeWin10UI::WelcomeWin10UI(content::WebUI* web_ui, const GURL& url) ...@@ -87,8 +88,15 @@ WelcomeWin10UI::WelcomeWin10UI(content::WebUI* web_ui, const GURL& url)
content::WebUIDataSource* html_source = content::WebUIDataSource* html_source =
content::WebUIDataSource::Create(url.host()); content::WebUIDataSource::Create(url.host());
html_source->SetJsonPath("strings.js");
AddLocalizedStrings(html_source, is_first_run); AddLocalizedStrings(html_source, is_first_run);
// Controls the accelerated default browser flow experiment.
html_source->AddBoolean("acceleratedFlowEnabled",
base::FeatureList::IsEnabled(
features::kWin10AcceleratedDefaultBrowserFlow));
html_source->AddResourcePath("welcome_win10.css", IDR_WELCOME_WIN10_CSS); html_source->AddResourcePath("welcome_win10.css", IDR_WELCOME_WIN10_CSS);
html_source->AddResourcePath("welcome_win10.js", IDR_WELCOME_WIN10_JS); html_source->AddResourcePath("welcome_win10.js", IDR_WELCOME_WIN10_JS);
html_source->AddResourcePath("default.webp", IDR_WELCOME_WIN10_DEFAULT_WEBP); html_source->AddResourcePath("default.webp", IDR_WELCOME_WIN10_DEFAULT_WEBP);
......
...@@ -9,8 +9,10 @@ ...@@ -9,8 +9,10 @@
#include <utility> #include <utility>
#include "base/bind.h" #include "base/bind.h"
#include "base/feature_list.h"
#include "base/location.h" #include "base/location.h"
#include "base/memory/scoped_refptr.h" #include "base/memory/scoped_refptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/strings/pattern.h" #include "base/strings/pattern.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
...@@ -19,6 +21,7 @@ ...@@ -19,6 +21,7 @@
#include "base/win/scoped_variant.h" #include "base/win/scoped_variant.h"
#include "chrome/browser/win/automation_controller.h" #include "chrome/browser/win/automation_controller.h"
#include "chrome/browser/win/ui_automation_util.h" #include "chrome/browser/win/ui_automation_util.h"
#include "chrome/common/chrome_features.h"
namespace { namespace {
...@@ -43,6 +46,7 @@ void ConfigureCacheRequest(IUIAutomationCacheRequest* cache_request) { ...@@ -43,6 +46,7 @@ void ConfigureCacheRequest(IUIAutomationCacheRequest* cache_request) {
cache_request->AddProperty(UIA_AutomationIdPropertyId); cache_request->AddProperty(UIA_AutomationIdPropertyId);
cache_request->AddProperty(UIA_NamePropertyId); cache_request->AddProperty(UIA_NamePropertyId);
cache_request->AddProperty(UIA_ClassNamePropertyId); cache_request->AddProperty(UIA_ClassNamePropertyId);
cache_request->AddPattern(UIA_InvokePatternId);
} }
// Helper function to get the parent element with class name "Flyout". Used to // Helper function to get the parent element with class name "Flyout". Used to
...@@ -123,6 +127,10 @@ class SettingsAppMonitor::AutomationControllerDelegate ...@@ -123,6 +127,10 @@ class SettingsAppMonitor::AutomationControllerDelegate
IUIAutomationElement* sender) const override; IUIAutomationElement* sender) const override;
private: private:
// Invokes the |browser_button| if the Win10AcceleratedDefaultBrowserFlow
// feature is enabled.
void MaybeInvokeChooser(IUIAutomationElement* browser_button) const;
// The task runner on which the SettingsAppMonitor lives. // The task runner on which the SettingsAppMonitor lives.
const scoped_refptr<base::SequencedTaskRunner> monitor_runner_; const scoped_refptr<base::SequencedTaskRunner> monitor_runner_;
...@@ -135,6 +143,12 @@ class SettingsAppMonitor::AutomationControllerDelegate ...@@ -135,6 +143,12 @@ class SettingsAppMonitor::AutomationControllerDelegate
// State to suppress duplicate "focus changed" events. // State to suppress duplicate "focus changed" events.
mutable ElementType last_focused_element_; mutable ElementType last_focused_element_;
// Protect against concurrent accesses to |browser_chooser_invoked_|.
mutable base::Lock browser_chooser_invoked_lock_;
// The browser chooser must only be invoked once.
mutable bool browser_chooser_invoked_;
DISALLOW_COPY_AND_ASSIGN(AutomationControllerDelegate); DISALLOW_COPY_AND_ASSIGN(AutomationControllerDelegate);
}; };
...@@ -143,7 +157,8 @@ SettingsAppMonitor::AutomationControllerDelegate::AutomationControllerDelegate( ...@@ -143,7 +157,8 @@ SettingsAppMonitor::AutomationControllerDelegate::AutomationControllerDelegate(
base::WeakPtr<SettingsAppMonitor> monitor) base::WeakPtr<SettingsAppMonitor> monitor)
: monitor_runner_(monitor_runner), : monitor_runner_(monitor_runner),
monitor_(std::move(monitor)), monitor_(std::move(monitor)),
last_focused_element_(ElementType::UNKNOWN) {} last_focused_element_(ElementType::UNKNOWN),
browser_chooser_invoked_(false) {}
SettingsAppMonitor::AutomationControllerDelegate:: SettingsAppMonitor::AutomationControllerDelegate::
~AutomationControllerDelegate() = default; ~AutomationControllerDelegate() = default;
...@@ -208,6 +223,7 @@ void SettingsAppMonitor::AutomationControllerDelegate::OnFocusChangedEvent( ...@@ -208,6 +223,7 @@ void SettingsAppMonitor::AutomationControllerDelegate::OnFocusChangedEvent(
} }
if (element_type == ElementType::DEFAULT_BROWSER) { if (element_type == ElementType::DEFAULT_BROWSER) {
MaybeInvokeChooser(sender);
monitor_runner_->PostTask( monitor_runner_->PostTask(
FROM_HERE, base::BindOnce(&SettingsAppMonitor::OnAppFocused, monitor_)); FROM_HERE, base::BindOnce(&SettingsAppMonitor::OnAppFocused, monitor_));
} else if (element_type == ElementType::CHECK_IT_OUT) { } else if (element_type == ElementType::CHECK_IT_OUT) {
...@@ -217,6 +233,30 @@ void SettingsAppMonitor::AutomationControllerDelegate::OnFocusChangedEvent( ...@@ -217,6 +233,30 @@ void SettingsAppMonitor::AutomationControllerDelegate::OnFocusChangedEvent(
} }
} }
void SettingsAppMonitor::AutomationControllerDelegate::MaybeInvokeChooser(
IUIAutomationElement* browser_button) const {
if (!base::FeatureList::IsEnabled(
features::kWin10AcceleratedDefaultBrowserFlow)) {
return;
}
{
// Only invoke the browser chooser once.
base::AutoLock auto_lock(browser_chooser_invoked_lock_);
if (browser_chooser_invoked_)
return;
browser_chooser_invoked_ = true;
}
// Invoke the dialog and record whether it was successful.
Microsoft::WRL::ComPtr<IUIAutomationInvokePattern> invoke_pattern;
bool succeeded = SUCCEEDED(browser_button->GetCachedPatternAs(
UIA_InvokePatternId, IID_PPV_ARGS(&invoke_pattern))) &&
invoke_pattern && SUCCEEDED(invoke_pattern->Invoke());
UMA_HISTOGRAM_BOOLEAN("DefaultBrowser.Win10ChooserInvoked", succeeded);
}
SettingsAppMonitor::SettingsAppMonitor(Delegate* delegate) SettingsAppMonitor::SettingsAppMonitor(Delegate* delegate)
: delegate_(delegate), weak_ptr_factory_(this) { : delegate_(delegate), weak_ptr_factory_(this) {
// A fully initialized WeakPtrFactory is needed to create the // A fully initialized WeakPtrFactory is needed to create the
......
...@@ -625,4 +625,10 @@ const base::Feature kCrOSEnableUSMUserService{"CrOSEnableUSMUserService", ...@@ -625,4 +625,10 @@ const base::Feature kCrOSEnableUSMUserService{"CrOSEnableUSMUserService",
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
#if defined(OS_WIN)
// Enables the accelerated default browser flow for Windows 10.
const base::Feature kWin10AcceleratedDefaultBrowserFlow{
"Win10AcceleratedDefaultBrowserFlow", base::FEATURE_DISABLED_BY_DEFAULT};
#endif // defined(OS_WIN)
} // namespace features } // namespace features
...@@ -339,6 +339,10 @@ extern const base::Feature kTPMFirmwareUpdate; ...@@ -339,6 +339,10 @@ extern const base::Feature kTPMFirmwareUpdate;
extern const base::Feature kCrOSEnableUSMUserService; extern const base::Feature kCrOSEnableUSMUserService;
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
#if defined(OS_WIN)
extern const base::Feature kWin10AcceleratedDefaultBrowserFlow;
#endif // defined(OS_WIN)
bool PrefServiceEnabled(); bool PrefServiceEnabled();
// DON'T ADD RANDOM STUFF HERE. Put it in the main section above in // DON'T ADD RANDOM STUFF HERE. Put it in the main section above in
......
...@@ -4680,6 +4680,21 @@ ...@@ -4680,6 +4680,21 @@
] ]
} }
], ],
"Win10AcceleratedDefaultBrowserFlow": [
{
"platforms": [
"win"
],
"experiments": [
{
"name": "Enabled",
"enable_features": [
"Win10AcceleratedDefaultBrowserFlow"
]
}
]
}
],
"WorkStealingInScriptRunner": [ "WorkStealingInScriptRunner": [
{ {
"platforms": [ "platforms": [
......
...@@ -16672,6 +16672,16 @@ uploading your change for review. ...@@ -16672,6 +16672,16 @@ uploading your change for review.
<summary>Whether Chrome was the default browser when it started up.</summary> <summary>Whether Chrome was the default browser when it started up.</summary>
</histogram> </histogram>
<histogram name="DefaultBrowser.Win10ChooserInvoked" enum="BooleanSuccess">
<owner>pmonette@chromium.org</owner>
<summary>
When changing the default browser on Windows 10, records whether the browser
chooser is successfully invoked when opening the settings page. This
histogram is only recorded when the Win10AcceleratedDefaultBrowserFlow
experiment is enabled.
</summary>
</histogram>
<histogram name="DefaultBrowserWarning.DontSetAsDefault" enum="BooleanHit"> <histogram name="DefaultBrowserWarning.DontSetAsDefault" enum="BooleanHit">
<obsolete> <obsolete>
Deprecated 2015/11. The same information is available as the value Failure Deprecated 2015/11. The same information is available as the value Failure
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment