Commit 62c906a0 authored by James Cook's avatar James Cook Committed by Commit Bot

chromeos: Add settings-sync-account-control to browser people settings

Chrome OS with SplitSettingsSync will use this control to show sync
status, just like other platforms.

Linux, syncing (unchanged):
https://screenshot.googleplex.com/t74uFT5iEsL

Linux, not syncing (unchanged):
https://screenshot.googleplex.com/SJGC3rbtGnw

Chrome OS, pre-SplitSettingsSync (unchanged):
https://screenshot.googleplex.com/EKZDSEqVBYy

Chrome OS, post-SplitSettingsSync (new):
https://screenshot.googleplex.com/fLYerpP60rg

Remove some unused references to diceEnabled_.

TODO: Make the "turn off" button actually work.

Bug: 1013466
Test: browser_tests
Change-Id: I2bb50ffdd7bcb408a13885740440ff752ff2fd2c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2003758
Commit-Queue: James Cook <jamescook@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733860}
parent 32a1f8bf
......@@ -3,6 +3,7 @@
<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html">
<link rel="import" href="chrome://resources/cr_elements/cr_link_row/cr_link_row.html">
<link rel="import" href="chrome://resources/cr_elements/cr_toast/cr_toast.html">
<link rel="import" href="chrome://resources/cr_elements/icons.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_indicator.html">
<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html">
......@@ -32,7 +33,6 @@
<link rel="import" href="chrome://resources/cr_elements/chromeos/cr_picture/cr_png_behavior.html">
</if>
<if expr="not chromeos">
<link rel="import" href="chrome://resources/cr_elements/cr_toast/cr_toast.html">
<link rel="import" href="import_data_dialog.html">
<link rel="import" href="manage_profile.html">
</if>
......@@ -76,7 +76,6 @@
width: 40px;
}
<if expr="not chromeos">
#toast {
left: 0;
z-index: 1;
......@@ -98,12 +97,10 @@
font-size: 1.1rem;
line-height: 1.625rem;
}
</if>
</style>
<settings-animated-pages id="pages" section="people"
focus-config="[[focusConfig_]]">
<div route-path="default">
<if expr="not chromeos">
<template is="dom-if" if="[[shouldShowSyncAccountControl_(
syncStatus.syncSystemEnabled, syncStatus.signinAllowed)]]">
<settings-sync-account-control
......@@ -117,8 +114,8 @@
"$i18n{peopleSignInPromptSecondaryWithNoAccount}">
</settings-sync-account-control>
</template>
<template is="dom-if" if="[[!diceEnabled_]]">
</if>
<template is="dom-if" if="[[shouldShowProfile_(
syncStatus.syncSystemEnabled, syncStatus.signinAllowed)]]" restamp>
<div id="picture-subpage-trigger" class="settings-box first two-line">
<template is="dom-if" if="[[syncStatus]]">
<div id="profile-icon" on-click="onProfileTap_"
......@@ -151,6 +148,7 @@
aria-describedby="profile-name"></cr-icon-button>
</if>
</div>
<!-- Chrome OS is always signed-in and does not show a sign-out button. -->
<if expr="not chromeos">
<template is="dom-if" if="[[showSignin_(syncStatus)]]">
<div class="separator"></div>
......@@ -169,14 +167,12 @@
</if>
</template>
</div>
<if expr="not chromeos">
</template> <!-- if="[[!diceEnabled_]]" -->
</if>
</template> <!-- if="[[shouldShowProfile_()]]" -->
<template is="dom-if" if="[[!syncStatus.signedIn]]">
<!-- Chrome OS uses settings-sync-account-control for sync promos. -->
<if expr="not chromeos">
<template is="dom-if" if="[[!syncStatus.signedIn]]">
<template is="dom-if" if="[[!diceEnabled_]]">
</if>
<div class="settings-box two-line" id="sync-overview"
hidden="[[!syncStatus.signinAllowed]]">
<div class="start settings-box-text">
......@@ -186,10 +182,9 @@
</a>
</div>
</div>
<if expr="not chromeos">
</template> <!-- if="[[!diceEnabled_]]" -->
</if>
</template>
</if>
<cr-link-row id="sync-setup"
label="$i18n{syncAndNonPersonalizedServices}"
......@@ -230,9 +225,6 @@
page-title="$i18n{syncPageTitle}"
learn-more-url="$i18n{syncAndGoogleServicesLearnMoreURL}">
<settings-sync-page
<if expr="not chromeos">
dice-enabled="[[diceEnabled_]]"
</if>
sync-status="[[syncStatus]]" prefs="{{prefs}}"
page-visibility="[[pageVisibility.privacy]]">
</settings-sync-page>
......@@ -272,11 +264,9 @@
on-close="onImportDataDialogClosed_">
</settings-import-data-dialog>
</template>
<if expr="not chromeos">
<cr-toast duration="3000" id="toast">
<span>$i18n{syncSettingsSavedToast}</span>
</cr-toast>
</if>
</template>
<script src="people_page.js"></script>
</dom-module>
......@@ -25,6 +25,7 @@ Polymer({
notify: true,
},
// Chrome OS does not support DICE.
// <if expr="not chromeos">
/**
* This flag is used to conditionally show a set of new sign-in UIs to the
......@@ -278,13 +279,7 @@ Polymer({
this.syncStatus = syncStatus;
if (
shouldRecordSigninImpression
// <if expr="not chromeos">
// Sync account control is not shown on Chrome OS.
&& !this.shouldShowSyncAccountControl_()
// </if>
) {
if (shouldRecordSigninImpression && !this.shouldShowSyncAccountControl_()) {
// SyncAccountControl records the impressions user actions.
chrome.metricsPrivate.recordUserAction('Signin_Impression_FromSettings');
}
......@@ -334,10 +329,6 @@ Polymer({
}
// </if>
// <if expr="chromeos">
cr.ui.focusWithoutInk(assert(this.$$('#disconnectButton')));
// </if>
if (settings.Router.getInstance().getCurrentRoute() ==
settings.routes.SIGN_OUT) {
settings.Router.getInstance().navigateToPreviousRoute();
......@@ -366,6 +357,7 @@ Polymer({
settings.Router.getInstance().navigateToPreviousRoute();
cr.ui.focusWithoutInk(assert(this.$.importDataDialogTrigger));
},
// </if>
/**
* Open URL for managing your Google Account.
......@@ -385,11 +377,30 @@ Polymer({
if (this.syncStatus == undefined) {
return false;
}
// <if expr="chromeos">
if (!loadTimeData.getBoolean('splitSettingsSyncEnabled')) {
return false;
}
// </if>
return !!this.syncStatus.syncSystemEnabled &&
!!this.syncStatus.signinAllowed;
},
// </if>
/**
* @return {boolean} Whether to show the profile row and associated controls.
* @private
*/
shouldShowProfile_() {
// Closure compiler doesn't understand <if> so use a variable.
let show = false;
// <if expr="chromeos">
show = !this.shouldShowSyncAccountControl_();
// </if>
// <if expr="not chromeos">
show = !this.diceEnabled_;
// </if>
return show;
},
/**
* @param {string} iconUrl
......
......@@ -147,10 +147,6 @@ Polymer({
'syncPrefs.trustedVaultKeysRequired)',
},
// <if expr="not chromeos">
diceEnabled: Boolean,
// </if>
/** @private */
showSetupCancelDialog_: {
type: Boolean,
......
......@@ -17,14 +17,14 @@ cr.define('settings_people_page', function() {
}
}
suite('ProfileInfoTests', function() {
/** @type {SettingsPeoplePageElement} */
let peoplePage = null;
/** @type {settings.ProfileInfoBrowserProxy} */
let browserProxy = null;
/** @type {settings.SyncBrowserProxy} */
let syncBrowserProxy = null;
/** @type {?SettingsPeoplePageElement} */
let peoplePage = null;
/** @type {?settings.ProfileInfoBrowserProxy} */
let profileInfoBrowserProxy = null;
/** @type {?settings.SyncBrowserProxy} */
let syncBrowserProxy = null;
suite('ProfileInfoTests', function() {
suiteSetup(function() {
loadTimeData.overrideValues({
// Force Dice off. Dice is tested in the DiceUITest suite.
......@@ -39,8 +39,8 @@ cr.define('settings_people_page', function() {
});
setup(async function() {
browserProxy = new TestProfileInfoBrowserProxy();
settings.ProfileInfoBrowserProxyImpl.instance_ = browserProxy;
profileInfoBrowserProxy = new TestProfileInfoBrowserProxy();
settings.ProfileInfoBrowserProxyImpl.instance_ = profileInfoBrowserProxy;
syncBrowserProxy = new TestSyncBrowserProxy();
settings.SyncBrowserProxyImpl.instance_ = syncBrowserProxy;
......@@ -51,7 +51,7 @@ cr.define('settings_people_page', function() {
document.body.appendChild(peoplePage);
await syncBrowserProxy.whenCalled('getSyncStatus');
await browserProxy.whenCalled('getProfileInfo');
await profileInfoBrowserProxy.whenCalled('getProfileInfo');
Polymer.dom.flush();
});
......@@ -61,10 +61,10 @@ cr.define('settings_people_page', function() {
test('GetProfileInfo', function() {
assertEquals(
browserProxy.fakeProfileInfo.name,
profileInfoBrowserProxy.fakeProfileInfo.name,
peoplePage.$$('#profile-name').textContent.trim());
const bg = peoplePage.$$('#profile-icon').style.backgroundImage;
assertTrue(bg.includes(browserProxy.fakeProfileInfo.iconUrl));
assertTrue(bg.includes(profileInfoBrowserProxy.fakeProfileInfo.iconUrl));
const iconDataUrl = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEA' +
'LAAAAAABAAEAAAICTAEAOw==';
......@@ -81,16 +81,9 @@ cr.define('settings_people_page', function() {
if (!cr.isChromeOS) {
suite('SyncStatusTests', function() {
/** @type {SettingsPeoplePageElement} */
let peoplePage = null;
/** @type {settings.SyncBrowserProxy} */
let browserProxy = null;
/** @type {settings.ProfileInfoBrowserProxy} */
let profileInfoBrowserProxy = null;
setup(function() {
browserProxy = new TestSyncBrowserProxy();
settings.SyncBrowserProxyImpl.instance_ = browserProxy;
syncBrowserProxy = new TestSyncBrowserProxy();
settings.SyncBrowserProxyImpl.instance_ = syncBrowserProxy;
profileInfoBrowserProxy = new TestProfileInfoBrowserProxy();
settings.ProfileInfoBrowserProxyImpl.instance_ =
......@@ -122,7 +115,7 @@ cr.define('settings_people_page', function() {
test('GetProfileInfo', function() {
let disconnectButton = null;
return browserProxy.whenCalled('getSyncStatus')
return syncBrowserProxy.whenCalled('getSyncStatus')
.then(function() {
Polymer.dom.flush();
disconnectButton = peoplePage.$$('#disconnectButton');
......@@ -154,7 +147,7 @@ cr.define('settings_people_page', function() {
return popstatePromise;
})
.then(function() {
return browserProxy.whenCalled('signOut');
return syncBrowserProxy.whenCalled('signOut');
})
.then(function(deleteProfile) {
assertFalse(deleteProfile);
......@@ -182,7 +175,7 @@ cr.define('settings_people_page', function() {
assertTrue(!!disconnectManagedProfileConfirm);
assertFalse(disconnectManagedProfileConfirm.hidden);
browserProxy.resetResolver('signOut');
syncBrowserProxy.resetResolver('signOut');
const popstatePromise = new Promise(function(resolve) {
listenOnce(window, 'popstate', resolve);
......@@ -193,7 +186,7 @@ cr.define('settings_people_page', function() {
return popstatePromise;
})
.then(function() {
return browserProxy.whenCalled('signOut');
return syncBrowserProxy.whenCalled('signOut');
})
.then(function(deleteProfile) {
assertTrue(deleteProfile);
......@@ -201,7 +194,7 @@ cr.define('settings_people_page', function() {
});
test('getProfileStatsCount', function() {
return browserProxy.whenCalled('getSyncStatus')
return syncBrowserProxy.whenCalled('getSyncStatus')
.then(function() {
Polymer.dom.flush();
......@@ -279,7 +272,7 @@ cr.define('settings_people_page', function() {
});
test('Signout dialog suppressed when not signed in', function() {
return browserProxy.whenCalled('getSyncStatus')
return syncBrowserProxy.whenCalled('getSyncStatus')
.then(function() {
settings.Router.getInstance().navigateTo(
settings.routes.SIGN_OUT);
......@@ -315,13 +308,6 @@ cr.define('settings_people_page', function() {
});
suite('DiceUITest', function() {
/** @type {SettingsPeoplePageElement} */
let peoplePage = null;
/** @type {settings.SyncBrowserProxy} */
let browserProxy = null;
/** @type {settings.ProfileInfoBrowserProxy} */
let profileInfoBrowserProxy = null;
suiteSetup(function() {
// Force UIs to think DICE is enabled for this profile.
loadTimeData.overrideValues({
......@@ -330,8 +316,8 @@ cr.define('settings_people_page', function() {
});
setup(function() {
browserProxy = new TestSyncBrowserProxy();
settings.SyncBrowserProxyImpl.instance_ = browserProxy;
syncBrowserProxy = new TestSyncBrowserProxy();
settings.SyncBrowserProxyImpl.instance_ = syncBrowserProxy;
profileInfoBrowserProxy = new TestProfileInfoBrowserProxy();
settings.ProfileInfoBrowserProxyImpl.instance_ =
......@@ -350,7 +336,7 @@ cr.define('settings_people_page', function() {
});
test('ShowCorrectRows', function() {
return browserProxy.whenCalled('getSyncStatus').then(function() {
return syncBrowserProxy.whenCalled('getSyncStatus').then(function() {
// The correct /manageProfile link row is shown.
assertTrue(!!peoplePage.$$('#edit-profile'));
assertFalse(!!peoplePage.$$('#picture-subpage-trigger'));
......@@ -455,16 +441,9 @@ cr.define('settings_people_page', function() {
}
suite('SyncSettings', function() {
/** @type {SettingsPeoplePageElement} */
let peoplePage = null;
/** @type {settings.SyncBrowserProxy} */
let browserProxy = null;
/** @type {settings.ProfileInfoBrowserProxy} */
let profileInfoBrowserProxy = null;
setup(async function() {
browserProxy = new TestSyncBrowserProxy();
settings.SyncBrowserProxyImpl.instance_ = browserProxy;
syncBrowserProxy = new TestSyncBrowserProxy();
settings.SyncBrowserProxyImpl.instance_ = syncBrowserProxy;
profileInfoBrowserProxy = new TestProfileInfoBrowserProxy();
settings.ProfileInfoBrowserProxyImpl.instance_ = profileInfoBrowserProxy;
......@@ -474,7 +453,7 @@ cr.define('settings_people_page', function() {
peoplePage.pageVisibility = settings.pageVisibility;
document.body.appendChild(peoplePage);
await browserProxy.whenCalled('getSyncStatus');
await syncBrowserProxy.whenCalled('getSyncStatus');
Polymer.dom.flush();
});
......@@ -550,16 +529,22 @@ cr.define('settings_people_page', function() {
}
}
suite('Chrome OS', function() {
/** @type {SettingsPeoplePageElement} */
let peoplePage = null;
/** @type {settings.SyncBrowserProxy} */
let browserProxy = null;
/** @type {settings.ProfileInfoBrowserProxy} */
let profileInfoBrowserProxy = null;
/** @type {settings.AccountManagerBrowserProxy} */
let accountManagerBrowserProxy = null;
/** @type {?settings.AccountManagerBrowserProxy} */
let accountManagerBrowserProxy = null;
// Preferences should exist for embedded 'personalization_options.html'.
// We don't perform tests on them.
const DEFAULT_PREFS = {
profile: {password_manager_leak_detection: {value: true}},
signin: {
allowed_on_next_startup:
{type: chrome.settingsPrivate.PrefType.BOOLEAN, value: true}
},
safebrowsing:
{enabled: {value: true}, scout_reporting_enabled: {value: true}},
};
suite('Chrome OS', function() {
suiteSetup(function() {
loadTimeData.overrideValues({
// Simulate SplitSettings (OS settings in their own surface).
......@@ -570,8 +555,8 @@ cr.define('settings_people_page', function() {
});
setup(async function() {
browserProxy = new TestSyncBrowserProxy();
settings.SyncBrowserProxyImpl.instance_ = browserProxy;
syncBrowserProxy = new TestSyncBrowserProxy();
settings.SyncBrowserProxyImpl.instance_ = syncBrowserProxy;
profileInfoBrowserProxy = new TestProfileInfoBrowserProxy();
settings.ProfileInfoBrowserProxyImpl.instance_ =
......@@ -583,18 +568,12 @@ cr.define('settings_people_page', function() {
PolymerTest.clearBody();
peoplePage = document.createElement('settings-people-page');
// Preferences should exist for embedded 'personalization_options.html'.
// We don't perform tests on them.
peoplePage.prefs = {
profile: {password_manager_leak_detection: {value: true}},
safebrowsing:
{enabled: {value: true}, scout_reporting_enabled: {value: true}},
};
peoplePage.prefs = DEFAULT_PREFS;
peoplePage.pageVisibility = settings.pageVisibility;
document.body.appendChild(peoplePage);
await accountManagerBrowserProxy.whenCalled('getAccounts');
await browserProxy.whenCalled('getSyncStatus');
await syncBrowserProxy.whenCalled('getSyncStatus');
Polymer.dom.flush();
});
......@@ -628,10 +607,6 @@ cr.define('settings_people_page', function() {
});
suite('Chrome OS with account manager disabled', function() {
let peoplePage = null;
let syncBrowserProxy = null;
let profileInfoBrowserProxy = null;
suiteSetup(function() {
loadTimeData.overrideValues({
// Simulate SplitSettings (OS settings in their own surface).
......@@ -651,13 +626,7 @@ cr.define('settings_people_page', function() {
PolymerTest.clearBody();
peoplePage = document.createElement('settings-people-page');
// Preferences should exist for embedded 'personalization_options.html'.
// We don't perform tests on them.
peoplePage.prefs = {
profile: {password_manager_leak_detection: {value: true}},
safebrowsing:
{enabled: {value: true}, scout_reporting_enabled: {value: true}},
};
peoplePage.prefs = DEFAULT_PREFS;
peoplePage.pageVisibility = settings.pageVisibility;
document.body.appendChild(peoplePage);
......@@ -689,5 +658,51 @@ cr.define('settings_people_page', function() {
assertEquals(oldRoute, settings.Router.getInstance().getCurrentRoute());
});
});
suite('Chrome OS with SplitSettingsSync', function() {
suiteSetup(function() {
loadTimeData.overrideValues({
splitSettingsSyncEnabled: true,
});
});
setup(async function() {
syncBrowserProxy = new TestSyncBrowserProxy();
settings.SyncBrowserProxyImpl.instance_ = syncBrowserProxy;
profileInfoBrowserProxy = new TestProfileInfoBrowserProxy();
settings.ProfileInfoBrowserProxyImpl.instance_ =
profileInfoBrowserProxy;
PolymerTest.clearBody();
peoplePage = document.createElement('settings-people-page');
peoplePage.prefs = DEFAULT_PREFS;
peoplePage.pageVisibility = settings.pageVisibility;
document.body.appendChild(peoplePage);
await syncBrowserProxy.whenCalled('getSyncStatus');
Polymer.dom.flush();
});
teardown(function() {
peoplePage.remove();
});
test('Sync account control is shown', () => {
sync_test_util.simulateSyncStatus({
signinAllowed: true,
syncSystemEnabled: true,
});
// Account control is visible.
const accountControl = peoplePage.$$('settings-sync-account-control');
assertNotEquals(
'none', window.getComputedStyle(accountControl).display);
// Profile row items are not available.
assertFalse(!!peoplePage.$$('#profile-icon'));
assertFalse(!!peoplePage.$$('#profile-row'));
});
});
}
});
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