Commit 2f696e77 authored by Thomas Tangl's avatar Thomas Tangl Committed by Commit Bot

[signin] Disable signin-allowed toggle for sync users

When the user is signed in and syncing, the signin-allowed
toggle is now disabled.

Note: This CL is adapted from crrev.com/c/1273517 and
removes the hint, i.e. there are no string changes here.

Bug: 892745
Change-Id: I1778115390518860fca4b4f11588d5ca7c7b9210
Reviewed-on: https://chromium-review.googlesource.com/c/1275849Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Commit-Queue: Thomas Tangl <tangltom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#598901}
parent 32487da8
......@@ -37,6 +37,7 @@ js_library("privacy_page") {
"..:page_visibility",
"..:route",
"../controls:settings_toggle_button",
"../people_page:sync_browser_proxy",
"../settings_page:settings_animated_pages",
"../site_settings:constants",
"../site_settings:site_data_details_subpage",
......
......@@ -95,7 +95,8 @@
pref="{{prefs.signin.allowed_on_next_startup}}"
label="$i18n{signinAllowedTitle}"
sub-label="$i18n{signinAllowedDescription}"
on-settings-boolean-control-change="onSigninAllowedChange_">
on-settings-boolean-control-change="onSigninAllowedChange_"
disabled="[[syncStatus.signedIn]]">
</settings-toggle-button>
</if><!-- not chromeos -->
<template is="dom-if" if="[[!unifiedConsentEnabled_]]">
......
......@@ -35,6 +35,12 @@ Polymer({
notify: true,
},
/**
* The current sync status, supplied by SyncBrowserProxy.
* @type {?settings.SyncStatus}
*/
syncStatus: Object,
/**
* Dictionary defining page visibility.
* @type {!PrivacyPageVisibility}
......@@ -184,6 +190,20 @@ Polymer({
this.addWebUIListener(
'onBlockAutoplayStatusChanged',
this.onBlockAutoplayStatusChanged_.bind(this));
settings.SyncBrowserProxyImpl.getInstance().getSyncStatus().then(
this.handleSyncStatus_.bind(this));
this.addWebUIListener(
'sync-status-changed', this.handleSyncStatus_.bind(this));
},
/**
* Handler for when the sync state is pushed from the browser.
* @param {?settings.SyncStatus} syncStatus
* @private
*/
handleSyncStatus_: function(syncStatus) {
this.syncStatus = syncStatus;
},
/** @protected */
......
......@@ -146,6 +146,19 @@ cr.define('settings_privacy_page', function() {
return test_util.whenAttributeIs(
dialog.$$('#clearBrowsingDataDialog'), 'open', '');
});
if (!cr.isChromeOS) {
test('signinAllowedToggle', function() {
const toggle = page.$.signinAllowedToggle;
page.syncStatus = {signedIn: false};
// When the user is signed out, the toggle is enabled.
assertFalse(toggle.disabled);
page.syncStatus = {signedIn: true};
// When the user is signed in, the toggle is disabled.
assertTrue(toggle.disabled);
});
}
});
}
......
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