Commit 8419c0a4 authored by David Roger's avatar David Roger Committed by Commit Bot

[settings] Cleanup shouldShowProfile_ and related code

This CL removes a reference to diceEnabled in shouldShowProfile_.
Additionally it removes dead code: on desktop this branch is only used
when signin is disallowed and the user is signed out.

The tests related to the signout button are converted to use the Dice
flow.

Bug: 891781
Change-Id: I227bdbce52c38c24920433d6b2c8d21a4c6f3bd5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2015247
Commit-Queue: David Roger <droger@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735370}
parent 463b9cdd
......@@ -107,9 +107,6 @@
</message>
<!-- Sync Page -->
<message name="IDS_SETTINGS_SYNC_SIGNIN" desc="The label that appears on the sync button in the options dialog when sync has not been set up by the user.">
Sign in to Chromium
</message>
<message name="IDS_SETTINGS_SYNC_DATA_ENCRYPTED_TEXT" desc="Text alerting the user that synced data is encrypted.">
For added security, Chromium will encrypt your data.
</message>
......
......@@ -107,9 +107,6 @@
</message>
<!-- Sync Page -->
<message name="IDS_SETTINGS_SYNC_SIGNIN" desc="The label that appears on the sync button in the options dialog when sync has not been set up by the user.">
Sign in to Chrome
</message>
<message name="IDS_SETTINGS_SYNC_DATA_ENCRYPTED_TEXT" desc="Text alerting the user that synced data is encrypted.">
For added security, Google Chrome will encrypt your data
</message>
......
......@@ -114,7 +114,7 @@
"$i18n{peopleSignInPromptSecondaryWithNoAccount}">
</settings-sync-account-control>
</template>
<template is="dom-if" if="[[shouldShowProfile_(
<template is="dom-if" if="[[!shouldShowSyncAccountControl_(
syncStatus.syncSystemEnabled, syncStatus.signinAllowed)]]" restamp>
<div id="picture-subpage-trigger" class="settings-box first two-line">
<template is="dom-if" if="[[syncStatus]]">
......@@ -129,9 +129,13 @@
actionable$="[[isProfileActionable_]]">
<div class="flex text-elide settings-box-text">
<span id="profile-name">[[profileName_]]</span>
<!-- When the user is signed-in, the settings-sync-account-control is always
shown on non-ChromeOS platforms -->
<if expr="chromeos">
<div class="secondary" hidden="[[!syncStatus.signedIn]]">
[[syncStatus.signedInUsername]]
</div>
</if>
</div>
<if expr="not chromeos">
<cr-icon-button class="subpage-arrow"
......@@ -148,26 +152,9 @@
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>
<cr-button class="action-button" on-click="onSigninTap_"
disabled="[[syncStatus.firstSetupInProgress]]">
$i18n{syncSignin}
</cr-button>
</template>
<template is="dom-if" if="[[syncStatus.signedIn]]">
<div class="separator"></div>
<cr-button id="disconnectButton" on-click="onDisconnectTap_"
disabled="[[syncStatus.firstSetupInProgress]]">
$i18n{syncDisconnect}
</cr-button>
</template>
</if>
</template>
</div>
</template> <!-- if="[[shouldShowProfile_()]]" -->
</template> <!-- if="[[!shouldShowSyncAccountControl_()]]" -->
<!-- Chrome OS uses settings-sync-account-control for sync promos. -->
<if expr="not chromeos">
......
......@@ -275,8 +275,8 @@ Polymer({
// Sign-in impressions should be recorded only if the sign-in promo is
// shown. They should be recorder only once, the first time
// |this.syncStatus| is set.
const shouldRecordSigninImpression =
!this.syncStatus && syncStatus && this.showSignin_(syncStatus);
const shouldRecordSigninImpression = !this.syncStatus && syncStatus &&
!!syncStatus.signinAllowed && !syncStatus.signedIn;
this.syncStatus = syncStatus;
......@@ -315,20 +315,9 @@ Polymer({
// </if>
},
/** @private */
onSigninTap_() {
this.syncBrowserProxy_.startSignIn();
},
/** @private */
onDisconnectDialogClosed_(e) {
this.showSignoutDialog_ = false;
// <if expr="not chromeos">
if (!this.diceEnabled_) {
// If DICE-enabled, this button won't exist here.
cr.ui.focusWithoutInk(assert(this.$$('#disconnectButton')));
}
// </if>
if (settings.Router.getInstance().getCurrentRoute() ==
settings.routes.SIGN_OUT) {
......@@ -336,11 +325,6 @@ Polymer({
}
},
/** @private */
onDisconnectTap_() {
settings.Router.getInstance().navigateTo(settings.routes.SIGN_OUT);
},
/** @private */
onSyncTap_() {
// Users can go to sync subpage regardless of sync status.
......@@ -387,22 +371,6 @@ Polymer({
!!this.syncStatus.signinAllowed;
},
/**
* @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
* @return {string} A CSS image-set for multiple scale factors.
......@@ -411,13 +379,4 @@ Polymer({
getIconImageSet_(iconUrl) {
return cr.icon.getImage(iconUrl);
},
/**
* @param {!settings.SyncStatus} syncStatus
* @return {boolean} Whether to show the "Sign in to Chrome" button.
* @private
*/
showSignin_(syncStatus) {
return !!syncStatus.signinAllowed && !syncStatus.signedIn;
},
});
......@@ -1960,7 +1960,6 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
{"syncOverview", IDS_SETTINGS_SYNC_OVERVIEW},
{"syncDisabled", IDS_PROFILES_DICE_SYNC_DISABLED_TITLE},
{"syncDisabledByAdministrator", IDS_SIGNED_IN_WITH_SYNC_DISABLED_BY_POLICY},
{"syncSignin", IDS_SETTINGS_SYNC_SIGNIN},
{"syncDisconnect", IDS_SETTINGS_PEOPLE_SIGN_OUT},
{"syncDisconnectTitle", IDS_SETTINGS_SYNC_DISCONNECT_TITLE},
{"syncDisconnectDeleteProfile",
......
......@@ -455,6 +455,7 @@ CrSettingsPeoplePageTest.prototype = {
/** @override */
extraLibraries: CrSettingsBrowserTest.prototype.extraLibraries.concat([
'../test_browser_proxy.js',
'../test_util.js',
'sync_test_util.js',
'test_profile_info_browser_proxy.js',
'test_sync_browser_proxy.js',
......
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