Commit ae0aec3d authored by Thomas Tangl's avatar Thomas Tangl Committed by Commit Bot

[unified-consent] Remove consent bump UI on Desktop

The UI implementation of the consent bump on Desktop
is removed.

The backend code and the consent bump flag will be
removed in a follow-up CL.

Bug: 906026
Change-Id: Ib10b0aaa692f5417c1ba1b1f7219d6e6e89457fc
Reviewed-on: https://chromium-review.googlesource.com/c/1349691
Commit-Queue: Thomas Tangl <tangltom@chromium.org>
Reviewed-by: default avatarScott Chen <scottchen@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611617}
parent ce2c778f
...@@ -6650,36 +6650,6 @@ the Bookmarks menu."> ...@@ -6650,36 +6650,6 @@ the Bookmarks menu.">
<message name="IDS_SYNC_CONFIRMATION_UNITY_TITLE" desc="Title of the sync confirmation dialog in the tab modal signin flow when Unity is enabled"> <message name="IDS_SYNC_CONFIRMATION_UNITY_TITLE" desc="Title of the sync confirmation dialog in the tab modal signin flow when Unity is enabled">
Get Google smarts in Chrome Get Google smarts in Chrome
</message> </message>
<message name="IDS_SYNC_CONFIRMATION_UNITY_CONSENT_BUMP_TITLE" desc="Title of the sync consent bump in the tab modal signin flow when Unity is enabled">
Get more Google smarts
</message>
<message name="IDS_SYNC_CONFIRMATION_UNITY_MORE_OPTIONS_BUTTON_LABEL" desc="Label of the sync confirmation button to show more options">
More options
</message>
<message name="IDS_SYNC_CONFIRMATION_UNITY_MORE_OPTIONS_TITLE" desc="Title of the sync confirmation more options dialog">
Control sync, personalization, and more
</message>
<message name="IDS_SYNC_CONFIRMATION_UNITY_MORE_OPTIONS_SUBTITLE" desc="Subitle of the sync confirmation more options dialog">
The settings that control sync, personalization, and other Google services in Chrome have changed. This may affect your current settings.
</message>
<message name="IDS_SYNC_CONFIRMATION_UNITY_OPTIONS_REVIEW_SETTINGS_TITLE" desc="Title of the sync confirmation option to review settings">
Review your settings on the next screen
</message>
<message name="IDS_SYNC_CONFIRMATION_UNITY_OPTIONS_MAKE_NO_CHANGES_TITLE" desc="Title of the sync confirmation option to make no changes">
Make no changes
</message>
<message name="IDS_SYNC_CONFIRMATION_UNITY_OPTIONS_MAKE_NO_CHANGES_SUBTITLE" desc="Subtitle of the sync confirmation option to make no changes">
The data you sync to Google and the features you use will not change
</message>
<message name="IDS_SYNC_CONFIRMATION_UNITY_OPTIONS_USE_DEFAULT_TITLE" desc="Title of the sync confirmation option to use the default settings">
Turn on sync, personalization, and other Google services
</message>
<message name="IDS_SYNC_CONFIRMATION_UNITY_OPTIONS_USE_DEFAULT_SUBTITLE" desc="Subtitle of the sync confirmation option to use the default settings">
You can customize this anytime in Chrome Settings
</message>
<message name="IDS_SYNC_CONFIRMATION_UNITY_OPTIONS_BACK_BUTTON_LABEL" desc="Label of the sync confirmation options button to go to the previous screen">
Back
</message>
<!-- "Chrome sync" is the Google Cloud Based service used for sync. Thus this string resource is set to "Chrome sync" even for Chromium builds. --> <!-- "Chrome sync" is the Google Cloud Based service used for sync. Thus this string resource is set to "Chrome sync" even for Chromium builds. -->
<message name="IDS_SYNC_CONFIRMATION_CHROME_SYNC_TITLE" desc="Title of the chrome sync section of the sync confirmation dialog in the tab modal signin flow" formatter_data="android_java"> <message name="IDS_SYNC_CONFIRMATION_CHROME_SYNC_TITLE" desc="Title of the chrome sync section of the sync confirmation dialog in the tab modal signin flow" formatter_data="android_java">
......
<link rel="import" href="chrome://resources/html/polymer.html"> <link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/cr_radio_button/cr_radio_button.html">
<link rel="import" href="chrome://resources/cr_elements/cr_radio_group/cr_radio_group.html">
<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/cr_elements/paper_button_style_css.html"> <link rel="import" href="chrome://resources/cr_elements/paper_button_style_css.html">
<link rel="import" href="chrome://resources/html/cr.html"> <link rel="import" href="chrome://resources/html/cr.html">
...@@ -145,36 +143,6 @@ ...@@ -145,36 +143,6 @@
url(./images/ic_google_2x.png) 2x); url(./images/ic_google_2x.png) 2x);
} }
#options-container {
background: white;
bottom: 0;
left: 0;
margin-inline-start: 16px;
position: absolute;
right: 0;
top: 0;
}
#options-heading {
color: var(--paper-grey-800);
font-weight: normal;
margin-top: 0;
}
#options-description {
padding-bottom: 25px;
padding-inline-end: 24px;
}
cr-radio-button {
line-height: 1.25rem;
}
.subtitle-text {
color: var(--paper-grey-600);
line-height: 1.25rem;
}
#grey-banner { #grey-banner {
background: var(--paper-grey-50); background: var(--paper-grey-50);
height: 128px; height: 128px;
...@@ -206,13 +174,9 @@ ...@@ -206,13 +174,9 @@
<img src="[[accountImageSrc_]]"> <img src="[[accountImageSrc_]]">
</div> </div>
<div id="content-container"> <div id="content-container">
<h1 id="syncConfirmationHeading" class="heading" consent-description <h1 id="syncConfirmationHeading" class="heading" consent-description>
hidden="[[isConsentBump_]]">
$i18n{syncConfirmationTitle} $i18n{syncConfirmationTitle}
</h1> </h1>
<h1 class="heading" consent-description hidden="[[!isConsentBump_]]">
$i18n{syncConsentBumpTitle}
</h1>
<div class="message-container"> <div class="message-container">
<!-- Container needed to contain the icon in a green circle. --> <!-- Container needed to contain the icon in a green circle. -->
<div id="sync-logo-container" class="logo"> <div id="sync-logo-container" class="logo">
...@@ -244,59 +208,16 @@ ...@@ -244,59 +208,16 @@
on-click="onConfirm_" consent-confirmation> on-click="onConfirm_" consent-confirmation>
$i18n{syncConfirmationConfirmLabel} $i18n{syncConfirmationConfirmLabel}
</paper-button> </paper-button>
<paper-button on-click="onUndo_" hidden="[[isConsentBump_]]"> <paper-button on-click="onUndo_">
$i18n{syncConfirmationUndoLabel} $i18n{syncConfirmationUndoLabel}
</paper-button> </paper-button>
<paper-button id="settingsButton" on-click="onGoToSettings_" <paper-button id="settingsButton" on-click="onGoToSettings_"
hidden="[[isConsentBump_]]" consent-confirmation> consent-confirmation>
$i18n{syncConfirmationSettingsLabel} $i18n{syncConfirmationSettingsLabel}
</paper-button> </paper-button>
<paper-button on-click="onMoreOptions_" hidden="[[!isConsentBump_]]">
$i18n{syncConfirmationMoreOptionsLabel}
</paper-button>
</div> </div>
</div> </div>
<!-- More options dialog for the consent bump -->
<template is="dom-if" if="[[showMoreOptions_]]">
<div id="options-container">
<h3 id="options-heading" consent-description>
$i18n{syncConfirmationOptionsTitle}
</h3>
<div id="options-description" class="subtitle-text"
consent-description>
$i18n{syncConfirmationOptionsSubtitle}
</div>
<cr-radio-group selected="noChanges">
<cr-radio-button name="noChanges">
$i18n{syncConfirmationOptionsMakeNoChangesTitle}
<div class="subtitle-text">
$i18n{syncConfirmationOptionsMakeNoChangesSubtitle}
</div>
</cr-radio-button>
<cr-radio-button name="reviewSettings">
$i18n{syncConfirmationOptionsReviewSettingsTitle}
</cr-radio-button>
<cr-radio-button name="defaultSettings">
<div consent-description>
$i18n{syncConfirmationOptionsUseDefaultTitle}
</div>
<div class="subtitle-text" consent-description>
$i18n{syncConfirmationOptionsUseDefaultSubtitle}
</div>
</cr-radio-button>
</cr-radio-group>
<div class="action-container">
<paper-button class="action-button" on-click="onOK_"
consent-confirmation>
$i18n{syncConfirmationOptionsConfirmLabel}
</paper-button>
<paper-button on-click="onBack_">
$i18n{syncConfirmationOptionsBackLabel}
</paper-button>
</div>
</div>
</template>
</div> </div>
</template> </template>
<script src="sync_confirmation_app.js"></script> <script src="sync_confirmation_app.js"></script>
......
...@@ -10,20 +10,6 @@ Polymer({ ...@@ -10,20 +10,6 @@ Polymer({
], ],
properties: { properties: {
/** @private */
isConsentBump_: {
type: Boolean,
value: function() {
return window.location.search.includes('consent-bump');
},
},
/** @private */
showMoreOptions_: {
type: Boolean,
value: false,
},
/** @private */ /** @private */
accountImageSrc_: { accountImageSrc_: {
type: String, type: String,
...@@ -61,20 +47,18 @@ Polymer({ ...@@ -61,20 +47,18 @@ Polymer({
/** @private */ /** @private */
onConfirm_: function(e) { onConfirm_: function(e) {
this.syncConfirmationBrowserProxy_.confirm( this.syncConfirmationBrowserProxy_.confirm(
this.getConsentDescription_(), this.getConsentConfirmation_(e.path), this.getConsentDescription_(), this.getConsentConfirmation_(e.path));
this.isConsentBump_, this.showMoreOptions_);
}, },
/** @private */ /** @private */
onUndo_: function() { onUndo_: function() {
this.syncConfirmationBrowserProxy_.undo(this.isConsentBump_); this.syncConfirmationBrowserProxy_.undo();
}, },
/** @private */ /** @private */
onGoToSettings_: function(e) { onGoToSettings_: function(e) {
this.syncConfirmationBrowserProxy_.goToSettings( this.syncConfirmationBrowserProxy_.goToSettings(
this.getConsentDescription_(), this.getConsentConfirmation_(e.path), this.getConsentDescription_(), this.getConsentConfirmation_(e.path));
this.isConsentBump_);
}, },
/** @private */ /** @private */
...@@ -112,32 +96,6 @@ Polymer({ ...@@ -112,32 +96,6 @@ Polymer({
return consentDescription; return consentDescription;
}, },
/** @private */
onOK_: function(e) {
switch (this.$$('cr-radio-group').selected) {
case 'reviewSettings':
this.onGoToSettings_(e);
break;
case 'noChanges':
this.onUndo_();
break;
case 'defaultSettings':
this.onConfirm_(e);
break;
}
assertNotReached();
},
/** @private */
onMoreOptions_: function() {
this.showMoreOptions_ = true;
},
/** @private */
onBack_: function() {
this.showMoreOptions_ = false;
},
/** /**
* Called when the account image changes. * Called when the account image changes.
* @param {string} imageSrc * @param {string} imageSrc
......
...@@ -9,32 +9,6 @@ ...@@ -9,32 +9,6 @@
cr.define('sync.confirmation', function() { cr.define('sync.confirmation', function() {
/**
* ConsentBumpAction enum.
* These values are persisted to logs and should not be renumbered or re-used.
* See tools/metrics/histograms/enums.xml.
* @enum {number}
*/
const ConsentBumpAction = {
DEFAULT_OPT_IN: 0,
MORE_OPTIONS_OPT_IN: 1,
MORE_OPTIONS_REVIEW_SETTINGS: 2,
MORE_OPTIONS_MAKE_NO_CHANGES: 3,
ABORT: 4, // Not actually used in JS, but here to match the C++ type.
};
/**
* The number of enum values in ConsentBumpAction. This should
* be kept in sync with the enum count in tools/metrics/histograms/enums.xml.
* @type {number}
*/
const CONSENT_BUMP_ACTION_COUNT = Object.keys(ConsentBumpAction).length;
/**
* The metrics name corresponding to ConsentBumpAction.
*/
const CONSENT_BUMP_ACTION_METRIC_NAME = 'UnifiedConsent.ConsentBump.Action';
/** @interface */ /** @interface */
class SyncConfirmationBrowserProxy { class SyncConfirmationBrowserProxy {
/** /**
...@@ -43,18 +17,12 @@ cr.define('sync.confirmation', function() { ...@@ -43,18 +17,12 @@ cr.define('sync.confirmation', function() {
* with in the UI. * with in the UI.
* @param {string} confirmation Text of the element that the user * @param {string} confirmation Text of the element that the user
* clicked on. * clicked on.
* @param {boolean} isConsentBump Boolean indicating whether the
* confirmation dialog was a consent bump.
* @param {boolean} moreOptionsPage Boolean indicating whether the user
* selected confirm from the moreOptions page in the consent bump.
*/ */
confirm(description, confirmation, isConsentBump, moreOptionsPage) {} confirm(description, confirmation) {}
/** Called when the user undoes the Sync confirmation. /** Called when the user undoes the Sync confirmation.
* @param {boolean} isConsentBump Boolean indicating whether the
* confirmation dialog was a consent bump.
*/ */
undo(isConsentBump) {} undo() {}
/** /**
* Called when the user clicks on the Settings link in * Called when the user clicks on the Settings link in
...@@ -63,10 +31,8 @@ cr.define('sync.confirmation', function() { ...@@ -63,10 +31,8 @@ cr.define('sync.confirmation', function() {
* with in the UI. * with in the UI.
* @param {string} confirmation Text of the element that the user * @param {string} confirmation Text of the element that the user
* clicked on. * clicked on.
* @param {boolean} isConsentBump Boolean indicating whether the
* confirmation dialog was a consent bump.
*/ */
goToSettings(description, confirmation, isConsentBump) {} goToSettings(description, confirmation) {}
/** @param {!Array<number>} height */ /** @param {!Array<number>} height */
initializedWithSize(height) {} initializedWithSize(height) {}
...@@ -80,30 +46,17 @@ cr.define('sync.confirmation', function() { ...@@ -80,30 +46,17 @@ cr.define('sync.confirmation', function() {
/** @implements {sync.confirmation.SyncConfirmationBrowserProxy} */ /** @implements {sync.confirmation.SyncConfirmationBrowserProxy} */
class SyncConfirmationBrowserProxyImpl { class SyncConfirmationBrowserProxyImpl {
/** @override */ /** @override */
confirm(description, confirmation, isConsentBump, moreOptionsPage) { confirm(description, confirmation) {
if (isConsentBump) {
this.recordConsentBumpAction_(
moreOptionsPage ? ConsentBumpAction.MORE_OPTIONS_OPT_IN :
ConsentBumpAction.DEFAULT_OPT_IN);
}
chrome.send('confirm', [description, confirmation]); chrome.send('confirm', [description, confirmation]);
} }
/** @override */ /** @override */
undo(isConsentBump) { undo() {
if (isConsentBump) {
this.recordConsentBumpAction_(
ConsentBumpAction.MORE_OPTIONS_MAKE_NO_CHANGES);
}
chrome.send('undo'); chrome.send('undo');
} }
/** @override */ /** @override */
goToSettings(description, confirmation, isConsentBump) { goToSettings(description, confirmation) {
if (isConsentBump) {
this.recordConsentBumpAction_(
ConsentBumpAction.MORE_OPTIONS_REVIEW_SETTINGS);
}
chrome.send('goToSettings', [description, confirmation]); chrome.send('goToSettings', [description, confirmation]);
} }
...@@ -116,12 +69,6 @@ cr.define('sync.confirmation', function() { ...@@ -116,12 +69,6 @@ cr.define('sync.confirmation', function() {
requestAccountImage() { requestAccountImage() {
chrome.send('accountImageRequest'); chrome.send('accountImageRequest');
} }
/** @private */
recordConsentBumpAction_(action) {
chrome.metricsPrivate.recordEnumerationValue(
CONSENT_BUMP_ACTION_METRIC_NAME, action, CONSENT_BUMP_ACTION_COUNT);
}
} }
cr.addSingletonGetter(SyncConfirmationBrowserProxyImpl); cr.addSingletonGetter(SyncConfirmationBrowserProxyImpl);
......
...@@ -165,21 +165,11 @@ void SigninViewController::ShowModalSyncConfirmationDialog(Browser* browser) { ...@@ -165,21 +165,11 @@ void SigninViewController::ShowModalSyncConfirmationDialog(Browser* browser) {
// The delegate will delete itself on request of the UI code when the widget // The delegate will delete itself on request of the UI code when the widget
// is closed. // is closed.
delegate_ = SigninViewControllerDelegate::CreateSyncConfirmationDelegate( delegate_ = SigninViewControllerDelegate::CreateSyncConfirmationDelegate(
this, browser, false /* is consent bump */); this, browser);
chrome::RecordDialogCreation( chrome::RecordDialogCreation(
chrome::DialogIdentifier::SIGN_IN_SYNC_CONFIRMATION); chrome::DialogIdentifier::SIGN_IN_SYNC_CONFIRMATION);
} }
void SigninViewController::ShowModalSyncConsentBump(Browser* browser) {
CloseModalSignin();
// The delegate will delete itself on request of the UI code when the widget
// is closed.
delegate_ = SigninViewControllerDelegate::CreateSyncConfirmationDelegate(
this, browser, true /* is consent bump */);
chrome::RecordDialogCreation(
chrome::DialogIdentifier::UNITY_SYNC_CONSENT_BUMP);
}
void SigninViewController::ShowModalSigninErrorDialog(Browser* browser) { void SigninViewController::ShowModalSigninErrorDialog(Browser* browser) {
CloseModalSignin(); CloseModalSignin();
// The delegate will delete itself on request of the UI code when the widget // The delegate will delete itself on request of the UI code when the widget
......
...@@ -61,10 +61,6 @@ class SigninViewController { ...@@ -61,10 +61,6 @@ class SigninViewController {
// of the |browser|'s window. // of the |browser|'s window.
void ShowModalSyncConfirmationDialog(Browser* browser); void ShowModalSyncConfirmationDialog(Browser* browser);
// Shows the modal sync consent bump as a browser-modal dialog on top
// of the |browser|'s window.
void ShowModalSyncConsentBump(Browser* browser);
// Shows the modal sign-in error dialog as a browser-modal dialog on top of // Shows the modal sign-in error dialog as a browser-modal dialog on top of
// the |browser|'s window. // the |browser|'s window.
void ShowModalSigninErrorDialog(Browser* browser); void ShowModalSigninErrorDialog(Browser* browser);
......
...@@ -41,8 +41,7 @@ class SigninViewControllerDelegate ...@@ -41,8 +41,7 @@ class SigninViewControllerDelegate
// itself when the window it's managing is closed. // itself when the window it's managing is closed.
static SigninViewControllerDelegate* CreateSyncConfirmationDelegate( static SigninViewControllerDelegate* CreateSyncConfirmationDelegate(
SigninViewController* signin_view_controller, SigninViewController* signin_view_controller,
Browser* browser, Browser* browser);
bool is_consent_bump = false);
// Returns a platform-specific SigninViewControllerDelegate instance that // Returns a platform-specific SigninViewControllerDelegate instance that
// displays the modal sign in error dialog. The returned object should delete // displays the modal sign in error dialog. The returned object should delete
......
...@@ -197,12 +197,9 @@ SigninViewControllerDelegateViews::CreateGaiaWebView( ...@@ -197,12 +197,9 @@ SigninViewControllerDelegateViews::CreateGaiaWebView(
std::unique_ptr<views::WebView> std::unique_ptr<views::WebView>
SigninViewControllerDelegateViews::CreateSyncConfirmationWebView( SigninViewControllerDelegateViews::CreateSyncConfirmationWebView(
Browser* browser, Browser* browser) {
bool is_consent_bump) {
return CreateDialogWebView( return CreateDialogWebView(
browser, browser, chrome::kChromeUISyncConfirmationURL,
is_consent_bump ? chrome::kChromeUISyncConsentBumpURL
: chrome::kChromeUISyncConfirmationURL,
GetSyncConfirmationDialogPreferredHeight(browser->profile()), GetSyncConfirmationDialogPreferredHeight(browser->profile()),
GetSyncConfirmationDialogPreferredWidth(browser->profile())); GetSyncConfirmationDialogPreferredWidth(browser->profile()));
} }
...@@ -256,12 +253,10 @@ SigninViewControllerDelegate::CreateModalSigninDelegate( ...@@ -256,12 +253,10 @@ SigninViewControllerDelegate::CreateModalSigninDelegate(
SigninViewControllerDelegate* SigninViewControllerDelegate*
SigninViewControllerDelegate::CreateSyncConfirmationDelegate( SigninViewControllerDelegate::CreateSyncConfirmationDelegate(
SigninViewController* signin_view_controller, SigninViewController* signin_view_controller,
Browser* browser, Browser* browser) {
bool is_consent_bump) {
return new SigninViewControllerDelegateViews( return new SigninViewControllerDelegateViews(
signin_view_controller, signin_view_controller,
SigninViewControllerDelegateViews::CreateSyncConfirmationWebView( SigninViewControllerDelegateViews::CreateSyncConfirmationWebView(browser),
browser, is_consent_bump),
browser, ui::MODAL_TYPE_WINDOW, true); browser, ui::MODAL_TYPE_WINDOW, true);
} }
......
...@@ -42,8 +42,7 @@ class SigninViewControllerDelegateViews : public views::DialogDelegateView, ...@@ -42,8 +42,7 @@ class SigninViewControllerDelegateViews : public views::DialogDelegateView,
signin_metrics::AccessPoint access_point); signin_metrics::AccessPoint access_point);
static std::unique_ptr<views::WebView> CreateSyncConfirmationWebView( static std::unique_ptr<views::WebView> CreateSyncConfirmationWebView(
Browser* browser, Browser* browser);
bool is_consent_bump = false);
static std::unique_ptr<views::WebView> CreateSigninErrorWebView( static std::unique_ptr<views::WebView> CreateSigninErrorWebView(
Browser* browser); Browser* browser);
......
...@@ -21,160 +21,7 @@ ...@@ -21,160 +21,7 @@
#include "components/signin/core/browser/signin_header_helper.h" #include "components/signin/core/browser/signin_header_helper.h"
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
#include "base/scoped_observer.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/sync_ui_util.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_list_observer.h"
#include "chrome/browser/ui/user_manager.h" #include "chrome/browser/ui/user_manager.h"
#include "chrome/browser/unified_consent/unified_consent_service_factory.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/sync/base/sync_prefs.h"
#include "components/unified_consent/feature.h"
#include "components/unified_consent/pref_names.h"
#include "components/unified_consent/unified_consent_service.h"
// The sync consent bump is shown after startup when a profile's browser
// instance becomes active or when there is already an active instance.
// It is only shown when |ShouldShowConsentBumpFor(profile)| returns true for a
// given profile |profile|.
class ConsentBumpActivator : public BrowserListObserver,
public LoginUIService::Observer,
public OAuth2TokenService::Observer {
public:
// Creates a ConsentBumpActivator for |profile| which is owned by
// |login_ui_service|.
ConsentBumpActivator(LoginUIService* login_ui_service, Profile* profile)
: login_ui_service_(login_ui_service),
profile_(profile),
scoped_browser_list_observer_(this),
scoped_login_ui_service_observer_(this),
scoped_token_service_observer_(this) {
ProfileOAuth2TokenService* token_service =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
if (token_service->AreAllCredentialsLoaded())
OnRefreshTokensLoaded();
else
scoped_token_service_observer_.Add(token_service);
}
// OAuth2TokenService::Observer:
void OnRefreshTokensLoaded() override {
scoped_token_service_observer_.RemoveAll();
SigninManager* signin_manager =
SigninManagerFactory::GetForProfile(profile_);
ProfileOAuth2TokenService* token_service =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
// Avoid showing the consent bump if the refresh token is missing or is in
// an permanent auth error state. When the tokens are loaded, this
// corresponds to the case when the refresh token was invalidated
// client-side after the user signed out of a Google website (e.g. the user
// signed out of Gmail).
if (token_service->RefreshTokenHasError(
signin_manager->GetAuthenticatedAccountId())) {
unified_consent::UnifiedConsentService* consent_service =
UnifiedConsentServiceFactory::GetForProfile(profile_);
if (consent_service->ShouldShowConsentBump()) {
consent_service->RecordConsentBumpSuppressReason(
unified_consent::metrics::ConsentBumpSuppressReason::kSyncPaused);
}
return;
}
// Check if there is already an active browser window for |profile|.
Browser* active_browser = chrome::FindLastActiveWithProfile(profile_);
if (active_browser)
OnBrowserSetLastActive(active_browser);
else
scoped_browser_list_observer_.Add(BrowserList::GetInstance());
}
// BrowserListObserver:
void OnBrowserSetLastActive(Browser* browser) override {
if (browser->profile() != profile_)
return;
// We only try to show the consent bump once after startup, so remove |this|
// as a |BrowserListObserver|.
scoped_browser_list_observer_.RemoveAll();
if (ShouldShowConsentBumpFor(profile_)) {
selected_browser_ = browser;
scoped_login_ui_service_observer_.Add(login_ui_service_);
selected_browser_->signin_view_controller()->ShowModalSyncConsentBump(
selected_browser_);
}
}
// LoginUIService::Observer:
void OnSyncConfirmationUIClosed(
LoginUIService::SyncConfirmationUIClosedResult result) override {
scoped_login_ui_service_observer_.RemoveAll();
unified_consent::UnifiedConsentService* consent_service =
UnifiedConsentServiceFactory::GetForProfile(profile_);
consent_service->MarkConsentBumpShown();
switch (result) {
case LoginUIService::CONFIGURE_SYNC_FIRST:
// Opt into Unity and open settings page to make configurations.
consent_service->EnableGoogleServices();
chrome::ShowSettingsSubPage(selected_browser_,
chrome::kSyncSetupSubPage);
break;
case LoginUIService::SYNC_WITH_DEFAULT_SETTINGS:
// Opt into Unity with default configuration.
consent_service->EnableGoogleServices();
break;
case LoginUIService::ABORT_SIGNIN:
// "Make no changes" was selected.
break;
}
}
// This should only be called after the browser has been set up, otherwise
// this might crash because the profile has not been fully initialized yet.
static bool ShouldShowConsentBumpFor(Profile* profile) {
if (!profile->IsSyncAllowed() ||
!unified_consent::IsUnifiedConsentFeatureWithBumpEnabled() ||
!ProfileSyncServiceFactory::HasProfileSyncService(profile))
return false;
unified_consent::UnifiedConsentService* consent_service =
UnifiedConsentServiceFactory::GetForProfile(profile);
if (!consent_service->ShouldShowConsentBump())
return false;
sync_ui_util::MessageType sync_status = sync_ui_util::GetStatus(
profile, ProfileSyncServiceFactory::GetForProfile(profile),
*SigninManagerFactory::GetForProfile(profile));
return sync_status == sync_ui_util::SYNCED;
}
private:
LoginUIService* login_ui_service_; // owner
Profile* profile_;
ScopedObserver<BrowserList, ConsentBumpActivator>
scoped_browser_list_observer_;
ScopedObserver<LoginUIService, ConsentBumpActivator>
scoped_login_ui_service_observer_;
ScopedObserver<OAuth2TokenService, ConsentBumpActivator>
scoped_token_service_observer_;
// Used for the action handling of the consent bump.
Browser* selected_browser_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(ConsentBumpActivator);
};
#endif // !defined(OS_CHROMEOS) #endif // !defined(OS_CHROMEOS)
LoginUIService::LoginUIService(Profile* profile) LoginUIService::LoginUIService(Profile* profile)
...@@ -182,12 +29,6 @@ LoginUIService::LoginUIService(Profile* profile) ...@@ -182,12 +29,6 @@ LoginUIService::LoginUIService(Profile* profile)
: profile_(profile) : profile_(profile)
#endif #endif
{ {
#if !defined(OS_CHROMEOS)
if (unified_consent::IsUnifiedConsentFeatureWithBumpEnabled()) {
consent_bump_activator_ =
std::make_unique<ConsentBumpActivator>(this, profile);
}
#endif
} }
LoginUIService::~LoginUIService() {} LoginUIService::~LoginUIService() {}
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
class Browser; class Browser;
class Profile; class Profile;
class ConsentBumpActivator;
// The LoginUIService helps track per-profile information for the login related // The LoginUIService helps track per-profile information for the login related
// UIs - for example, whether there is login UI currently on-screen. // UIs - for example, whether there is login UI currently on-screen.
...@@ -107,7 +106,6 @@ class LoginUIService : public KeyedService { ...@@ -107,7 +106,6 @@ class LoginUIService : public KeyedService {
std::list<LoginUI*> ui_list_; std::list<LoginUI*> ui_list_;
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
Profile* profile_; Profile* profile_;
std::unique_ptr<ConsentBumpActivator> consent_bump_activator_;
#endif #endif
// List of observers. // List of observers.
......
...@@ -30,19 +30,6 @@ ...@@ -30,19 +30,6 @@
#include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace {
// Used for UMA. Do not reorder, append new values at the end.
enum class UnifiedConsentBumpAction {
kOptIn = 0,
kMoreOptionsOptIn = 1,
kMoreOptionsSettings = 2,
kMoreOptionsNoChanges = 3,
kAbort = 4,
kMaxValue = kAbort
};
} // namespace
const int kProfileImageSize = 128; const int kProfileImageSize = 128;
SyncConfirmationHandler::SyncConfirmationHandler( SyncConfirmationHandler::SyncConfirmationHandler(
...@@ -67,12 +54,7 @@ SyncConfirmationHandler::~SyncConfirmationHandler() { ...@@ -67,12 +54,7 @@ SyncConfirmationHandler::~SyncConfirmationHandler() {
// sync confirmation dialog are taken by the user. // sync confirmation dialog are taken by the user.
if (!did_user_explicitly_interact) { if (!did_user_explicitly_interact) {
HandleUndo(nullptr); HandleUndo(nullptr);
if (IsUnifiedConsentBumpDialog()) { base::RecordAction(base::UserMetricsAction("Signin_Abort_Signin"));
UMA_HISTOGRAM_ENUMERATION("UnifiedConsent.ConsentBump.Action",
UnifiedConsentBumpAction::kAbort);
} else {
base::RecordAction(base::UserMetricsAction("Signin_Abort_Signin"));
}
} }
} }
...@@ -221,22 +203,18 @@ void SyncConfirmationHandler::OnAccountUpdated(const AccountInfo& info) { ...@@ -221,22 +203,18 @@ void SyncConfirmationHandler::OnAccountUpdated(const AccountInfo& info) {
void SyncConfirmationHandler::CloseModalSigninWindow( void SyncConfirmationHandler::CloseModalSigninWindow(
LoginUIService::SyncConfirmationUIClosedResult result) { LoginUIService::SyncConfirmationUIClosedResult result) {
if (!IsUnifiedConsentBumpDialog()) { switch (result) {
// Metrics for the unified consent bump are recorded directly from case LoginUIService::CONFIGURE_SYNC_FIRST:
// javascript. base::RecordAction(
switch (result) { base::UserMetricsAction("Signin_Signin_WithAdvancedSyncSettings"));
case LoginUIService::CONFIGURE_SYNC_FIRST: break;
base::RecordAction( case LoginUIService::SYNC_WITH_DEFAULT_SETTINGS:
base::UserMetricsAction("Signin_Signin_WithAdvancedSyncSettings")); base::RecordAction(
break; base::UserMetricsAction("Signin_Signin_WithDefaultSyncSettings"));
case LoginUIService::SYNC_WITH_DEFAULT_SETTINGS: break;
base::RecordAction( case LoginUIService::ABORT_SIGNIN:
base::UserMetricsAction("Signin_Signin_WithDefaultSyncSettings")); base::RecordAction(base::UserMetricsAction("Signin_Undo_Signin"));
break; break;
case LoginUIService::ABORT_SIGNIN:
base::RecordAction(base::UserMetricsAction("Signin_Undo_Signin"));
break;
}
} }
LoginUIServiceFactory::GetForProfile(profile_)->SyncConfirmationUIClosed( LoginUIServiceFactory::GetForProfile(profile_)->SyncConfirmationUIClosed(
result); result);
...@@ -276,8 +254,3 @@ void SyncConfirmationHandler::HandleInitializedWithSize( ...@@ -276,8 +254,3 @@ void SyncConfirmationHandler::HandleInitializedWithSize(
// workaround. // workaround.
web_ui()->CallJavascriptFunctionUnsafe("sync.confirmation.clearFocus"); web_ui()->CallJavascriptFunctionUnsafe("sync.confirmation.clearFocus");
} }
bool SyncConfirmationHandler::IsUnifiedConsentBumpDialog() {
return web_ui()->GetWebContents()->GetVisibleURL() ==
chrome::kChromeUISyncConsentBumpURL;
}
...@@ -87,10 +87,6 @@ class SyncConfirmationHandler : public content::WebUIMessageHandler, ...@@ -87,10 +87,6 @@ class SyncConfirmationHandler : public content::WebUIMessageHandler,
void CloseModalSigninWindow( void CloseModalSigninWindow(
LoginUIService::SyncConfirmationUIClosedResult result); LoginUIService::SyncConfirmationUIClosedResult result);
// Returns true if this is a unified consent bump dialog, and false if this is
// a regular sync confirmation.
bool IsUnifiedConsentBumpDialog();
private: private:
Profile* profile_; Profile* profile_;
......
...@@ -65,7 +65,6 @@ class TestingSyncConfirmationHandler : public SyncConfirmationHandler { ...@@ -65,7 +65,6 @@ class TestingSyncConfirmationHandler : public SyncConfirmationHandler {
using SyncConfirmationHandler::HandleGoToSettings; using SyncConfirmationHandler::HandleGoToSettings;
using SyncConfirmationHandler::RecordConsent; using SyncConfirmationHandler::RecordConsent;
using SyncConfirmationHandler::SetUserImageURL; using SyncConfirmationHandler::SetUserImageURL;
using SyncConfirmationHandler::IsUnifiedConsentBumpDialog;
private: private:
DISALLOW_COPY_AND_ASSIGN(TestingSyncConfirmationHandler); DISALLOW_COPY_AND_ASSIGN(TestingSyncConfirmationHandler);
...@@ -105,32 +104,16 @@ class SyncConfirmationHandlerTest : public BrowserWithTestWindowTest, ...@@ -105,32 +104,16 @@ class SyncConfirmationHandlerTest : public BrowserWithTestWindowTest,
signin_manager()->CompletePendingSignin(); signin_manager()->CompletePendingSignin();
login_ui_service_observer_.Add( login_ui_service_observer_.Add(
LoginUIServiceFactory::GetForProfile(profile())); LoginUIServiceFactory::GetForProfile(profile()));
EXPECT_FALSE(handler_->IsUnifiedConsentBumpDialog());
} }
void TearDown() override { void TearDown() override {
bool is_unified_consent_bump_dialog =
handler_->IsUnifiedConsentBumpDialog();
login_ui_service_observer_.RemoveAll(); login_ui_service_observer_.RemoveAll();
sync_confirmation_ui_.reset(); sync_confirmation_ui_.reset();
web_ui_.reset(); web_ui_.reset();
BrowserWithTestWindowTest::TearDown(); BrowserWithTestWindowTest::TearDown();
if (!did_user_explicitly_interact && is_unified_consent_bump_dialog) { EXPECT_EQ(did_user_explicitly_interact ? 0 : 1,
const int kAbort = 4; user_action_tester()->GetActionCount("Signin_Abort_Signin"));
histogram_tester_.ExpectUniqueSample("UnifiedConsent.ConsentBump.Action",
kAbort, 1);
EXPECT_EQ(0, user_action_tester()->GetActionCount("Signin_Abort_Signin"));
} else {
histogram_tester_.ExpectTotalCount("UnifiedConsent.ConsentBump.Action",
0);
}
EXPECT_EQ(
did_user_explicitly_interact || is_unified_consent_bump_dialog ? 0 : 1,
user_action_tester()->GetActionCount("Signin_Abort_Signin"));
} }
TestingSyncConfirmationHandler* handler() { return handler_; } TestingSyncConfirmationHandler* handler() { return handler_; }
...@@ -347,31 +330,6 @@ TEST_F(SyncConfirmationHandlerTest, TestHandleUndo) { ...@@ -347,31 +330,6 @@ TEST_F(SyncConfirmationHandlerTest, TestHandleUndo) {
"Signin_Signin_WithAdvancedSyncSettings")); "Signin_Signin_WithAdvancedSyncSettings"));
} }
TEST_F(SyncConfirmationHandlerTest, TestConsentBump) {
// Enable the consent bump by setting the URL of the web ui.
NavigateAndCommit(&web_ui()->GetWebContents()->GetController(),
GURL(chrome::kChromeUISyncConsentBumpURL));
EXPECT_TRUE(handler()->IsUnifiedConsentBumpDialog());
handler()->HandleUndo(nullptr);
did_user_explicitly_interact = true;
ASSERT_TRUE(on_sync_confirmation_ui_closed_called_);
ASSERT_EQ(LoginUIService::ABORT_SIGNIN, sync_confirmation_ui_closed_result_);
// The regular sync confirmation metrics are not recorded for the consent
// bump.
EXPECT_EQ(0, user_action_tester()->GetActionCount("Signin_Undo_Signin"));
}
TEST_F(SyncConfirmationHandlerTest, TestConsentBumpAbort) {
// Enable the consent bump by setting the URL of the web ui.
NavigateAndCommit(&web_ui()->GetWebContents()->GetController(),
GURL(chrome::kChromeUISyncConsentBumpURL));
EXPECT_TRUE(handler()->IsUnifiedConsentBumpDialog());
// The histogram sample will be tested in TearDown().
}
TEST_F(SyncConfirmationHandlerTest, TestHandleConfirm) { TEST_F(SyncConfirmationHandlerTest, TestHandleConfirm) {
// The consent description consists of strings 1, 2, and 4. // The consent description consists of strings 1, 2, and 4.
base::ListValue consent_description; base::ListValue consent_description;
......
...@@ -69,31 +69,6 @@ SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui) ...@@ -69,31 +69,6 @@ SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui)
AddStringResource(source, "syncConfirmationSettingsLabel", AddStringResource(source, "syncConfirmationSettingsLabel",
IDS_SYNC_CONFIRMATION_DICE_SETTINGS_BUTTON_LABEL); IDS_SYNC_CONFIRMATION_DICE_SETTINGS_BUTTON_LABEL);
AddStringResource(source, "syncConfirmationMoreOptionsLabel",
IDS_SYNC_CONFIRMATION_UNITY_MORE_OPTIONS_BUTTON_LABEL);
AddStringResource(source, "syncConfirmationOptionsTitle",
IDS_SYNC_CONFIRMATION_UNITY_MORE_OPTIONS_TITLE);
AddStringResource(source, "syncConfirmationOptionsSubtitle",
IDS_SYNC_CONFIRMATION_UNITY_MORE_OPTIONS_SUBTITLE);
AddStringResource(
source, "syncConfirmationOptionsReviewSettingsTitle",
IDS_SYNC_CONFIRMATION_UNITY_OPTIONS_REVIEW_SETTINGS_TITLE);
AddStringResource(
source, "syncConfirmationOptionsMakeNoChangesTitle",
IDS_SYNC_CONFIRMATION_UNITY_OPTIONS_MAKE_NO_CHANGES_TITLE);
AddStringResource(
source, "syncConfirmationOptionsMakeNoChangesSubtitle",
IDS_SYNC_CONFIRMATION_UNITY_OPTIONS_MAKE_NO_CHANGES_SUBTITLE);
AddStringResource(source, "syncConfirmationOptionsUseDefaultTitle",
IDS_SYNC_CONFIRMATION_UNITY_OPTIONS_USE_DEFAULT_TITLE);
AddStringResource(source, "syncConfirmationOptionsUseDefaultSubtitle",
IDS_SYNC_CONFIRMATION_UNITY_OPTIONS_USE_DEFAULT_SUBTITLE);
AddStringResource(source, "syncConfirmationOptionsConfirmLabel", IDS_OK);
AddStringResource(source, "syncConfirmationOptionsBackLabel",
IDS_SYNC_CONFIRMATION_UNITY_OPTIONS_BACK_BUTTON_LABEL);
AddStringResource(source, "syncConsentBumpTitle",
IDS_SYNC_CONFIRMATION_UNITY_CONSENT_BUMP_TITLE);
constexpr int kAccountPictureSize = 68; constexpr int kAccountPictureSize = 68;
std::string custom_picture_url = profiles::GetPlaceholderAvatarIconUrl(); std::string custom_picture_url = profiles::GetPlaceholderAvatarIconUrl();
GURL account_picture_url(IdentityManagerFactory::GetForProfile(profile) GURL account_picture_url(IdentityManagerFactory::GetForProfile(profile)
......
...@@ -143,8 +143,6 @@ const char kChromeUISupervisedUserPassphrasePageHost[] = ...@@ -143,8 +143,6 @@ const char kChromeUISupervisedUserPassphrasePageHost[] =
"managed-user-passphrase"; "managed-user-passphrase";
const char kChromeUISyncConfirmationHost[] = "sync-confirmation"; const char kChromeUISyncConfirmationHost[] = "sync-confirmation";
const char kChromeUISyncConfirmationURL[] = "chrome://sync-confirmation/"; const char kChromeUISyncConfirmationURL[] = "chrome://sync-confirmation/";
const char kChromeUISyncConsentBumpURL[] =
"chrome://sync-confirmation/?consent-bump";
const char kChromeUISyncFileSystemInternalsHost[] = "syncfs-internals"; const char kChromeUISyncFileSystemInternalsHost[] = "syncfs-internals";
const char kChromeUISyncHost[] = "sync"; const char kChromeUISyncHost[] = "sync";
const char kChromeUISyncInternalsHost[] = "sync-internals"; const char kChromeUISyncInternalsHost[] = "sync-internals";
......
...@@ -144,7 +144,6 @@ extern const char kChromeUISupervisedUserInternalsHost[]; ...@@ -144,7 +144,6 @@ extern const char kChromeUISupervisedUserInternalsHost[];
extern const char kChromeUISupervisedUserPassphrasePageHost[]; extern const char kChromeUISupervisedUserPassphrasePageHost[];
extern const char kChromeUISyncConfirmationHost[]; extern const char kChromeUISyncConfirmationHost[];
extern const char kChromeUISyncConfirmationURL[]; extern const char kChromeUISyncConfirmationURL[];
extern const char kChromeUISyncConsentBumpURL[];
extern const char kChromeUISyncFileSystemInternalsHost[]; extern const char kChromeUISyncFileSystemInternalsHost[];
extern const char kChromeUISyncHost[]; extern const char kChromeUISyncHost[];
extern const char kChromeUISyncInternalsHost[]; extern const char kChromeUISyncInternalsHost[];
......
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