Commit 246e9095 authored by Rafał Godlewski's avatar Rafał Godlewski Committed by Commit Bot

Remove link to passwords.google.com from the Settings UI if passphrase is enabled

Bug: 724869
Change-Id: I07b9db1021f7256dfe363f6f22857b29ffeaf51c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1718425
Commit-Queue: Rafał Godlewski <rgod@google.com>
Reviewed-by: default avatarDan Beam <dbeam@chromium.org>
Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#685521}
parent 032c3bea
......@@ -117,6 +117,7 @@ js_library("passwords_section") {
":password_list_item",
":password_manager_proxy",
"..:global_scroll_target_behavior",
"../people_page:sync_browser_proxy",
"//third_party/polymer/v1_0/components-chromium/iron-a11y-announcer:iron-a11y-announcer-extracted",
"//third_party/polymer/v1_0/components-chromium/iron-a11y-keys-behavior:iron-a11y-keys-behavior-extracted",
"//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
......@@ -125,6 +126,7 @@ js_library("passwords_section") {
"//ui/webui/resources/js:i18n_behavior",
"//ui/webui/resources/js:list_property_update_behavior",
"//ui/webui/resources/js:util",
"//ui/webui/resources/js:web_ui_listener_behavior",
"//ui/webui/resources/js/cr/ui:focus_without_ink",
]
externs_list = [ "$externs_path/passwords_private.js" ]
......
......@@ -77,7 +77,8 @@
label="$i18n{passwordsAutosigninLabel}"
sub-label="$i18n{passwordsAutosigninDescription}">
</settings-toggle-button>
<div id="manageLink" class="settings-box first two-line">
<div id="manageLink" class="settings-box first two-line"
hidden$="[[hidePasswordsLink_]]">
<!-- This span lays out the url correctly, relative to the label. -->
<span>$i18nRaw{managePasswordsLabel}</span>
</div>
......
......@@ -36,6 +36,7 @@ Polymer({
behaviors: [
I18nBehavior,
WebUIListenerBehavior,
ListPropertyUpdateBehavior,
Polymer.IronA11yKeysBehavior,
settings.GlobalScrollTargetBehavior,
......@@ -93,6 +94,12 @@ Polymer({
value: () => document,
},
/** @private */
hidePasswordsLink_: {
type: Boolean,
computed: 'computeHidePasswordsLink_(syncPrefs_, syncStatus_)',
},
/** @private */
showExportPasswords_: {
type: Boolean,
......@@ -111,6 +118,12 @@ Polymer({
/** @private */
showPasswordEditDialog_: Boolean,
/** @private {settings.SyncPrefs} */
syncPrefs_: Object,
/** @private {settings.SyncStatus} */
syncStatus_: Object,
/** Filter on the saved passwords and exceptions. */
filter: {
type: String,
......@@ -229,6 +242,16 @@ Polymer({
this.notifySplices('savedPasswords', []);
const syncBrowserProxy = settings.SyncBrowserProxyImpl.getInstance();
const syncStatusChanged = syncStatus => this.syncStatus_ = syncStatus;
syncBrowserProxy.getSyncStatus().then(syncStatusChanged);
this.addWebUIListener('sync-status-changed', syncStatusChanged);
const syncPrefsChanged = syncPrefs => this.syncPrefs_ = syncPrefs;
this.addWebUIListener('sync-prefs-changed', syncPrefsChanged);
syncBrowserProxy.sendSyncPrefsChanged();
Polymer.RenderStatus.afterNextRender(this, function() {
Polymer.IronA11yAnnouncer.requestAvailability();
});
......@@ -305,6 +328,15 @@ Polymer({
this.activePassword.notifyPath('item.password');
},
/**
* @return {boolean}
* @private
*/
computeHidePasswordsLink_: function() {
return !!this.syncStatus_ && !!this.syncStatus_.signedIn &&
!!this.syncPrefs_ && !!this.syncPrefs_.encryptAllData;
},
/**
* @param {string} filter
* @return {!Array<!PasswordManagerProxy.UiEntryWithPassword>}
......
......@@ -211,6 +211,13 @@ cr.define('settings', function() {
* Opens the Google Activity Controls url in a new tab.
*/
openActivityControlsUrl() {}
/**
* Function to dispatch event sync-prefs-changed even without a change.
* This is used to decide whether we should show the link to password
* manager in passwords section on page load.
*/
sendSyncPrefsChanged() {}
}
/**
......@@ -298,6 +305,11 @@ cr.define('settings', function() {
chrome.metricsPrivate.recordUserAction(
'Signin_AccountSettings_GoogleActivityControlsClicked');
}
/** @override */
sendSyncPrefsChanged() {
chrome.send('SyncPrefsDispatch');
}
}
cr.addSingletonGetter(SyncBrowserProxyImpl);
......
......@@ -303,6 +303,10 @@ void PeopleHandler::RegisterMessages() {
"SyncSetupGetSyncStatus",
base::BindRepeating(&PeopleHandler::HandleGetSyncStatus,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"SyncPrefsDispatch",
base::BindRepeating(&PeopleHandler::HandleSyncPrefsDispatch,
base::Unretained(this)));
#if defined(OS_CHROMEOS)
web_ui()->RegisterMessageCallback(
"AttemptUserExit",
......@@ -850,6 +854,11 @@ void PeopleHandler::HandleGetSyncStatus(const base::ListValue* args) {
ResolveJavascriptCallback(*callback_id, *GetSyncStatusDictionary());
}
void PeopleHandler::HandleSyncPrefsDispatch(const base::ListValue* args) {
AllowJavascript();
PushSyncPrefs();
}
void PeopleHandler::CloseSyncSetup() {
// Stop a timer to handle timeout in waiting for checking network connection.
engine_start_timer_.reset();
......
......@@ -176,6 +176,7 @@ class PeopleHandler : public SettingsPageUIHandler,
void HandleSetEncryption(const base::ListValue* args);
void HandleShowSetupUI(const base::ListValue* args);
void HandleAttemptUserExit(const base::ListValue* args);
void HandleSyncPrefsDispatch(const base::ListValue* args);
#if defined(OS_CHROMEOS)
void HandleRequestPinLoginState(const base::ListValue* args);
#endif
......
......@@ -365,6 +365,7 @@ CrSettingsPasswordsSectionTest.prototype = {
'../test_browser_proxy.js',
'passwords_and_autofill_fake_data.js',
'passwords_section_test.js',
'sync_test_util.js',
'test_password_manager_proxy.js',
'../test_util.js',
]),
......@@ -745,6 +746,7 @@ CrSettingsPeoplePageSyncControlsTest.prototype = {
/** @override */
extraLibraries: CrSettingsBrowserTest.prototype.extraLibraries.concat([
'../test_browser_proxy.js',
'sync_test_util.js',
'test_sync_browser_proxy.js',
'test_util.js',
'people_page_sync_controls_test.js',
......
......@@ -844,5 +844,36 @@ cr.define('settings_passwords_section', function() {
{status: chrome.passwordsPrivate.ExportProgressStatus.SUCCEEDED});
return wait;
});
test('hideLinkToPasswordManagerWhenEncrypted', function() {
const passwordsSection =
elementFactory.createPasswordsSection(passwordManager, [], []);
const prefs = sync_test_util.getSyncAllPrefs();
prefs.encryptAllData = true;
cr.webUIListenerCallback('sync-prefs-changed', prefs);
sync_test_util.simulateSyncStatus({signedIn: true});
Polymer.dom.flush();
assertTrue(passwordsSection.$.manageLink.hidden);
});
test('showLinkToPasswordManagerWhenNotEncrypted', function() {
const passwordsSection =
elementFactory.createPasswordsSection(passwordManager, [], []);
const prefs = sync_test_util.getSyncAllPrefs();
prefs.encryptAllData = false;
cr.webUIListenerCallback('sync-prefs-changed', prefs);
Polymer.dom.flush();
assertFalse(passwordsSection.$.manageLink.hidden);
});
test('showLinkToPasswordManagerWhenNotSignedIn', function() {
const passwordsSection =
elementFactory.createPasswordsSection(passwordManager, [], []);
const prefs = sync_test_util.getSyncAllPrefs();
sync_test_util.simulateSyncStatus({signedIn: false});
cr.webUIListenerCallback('sync-prefs-changed', prefs);
Polymer.dom.flush();
assertFalse(passwordsSection.$.manageLink.hidden);
});
});
});
......@@ -7,44 +7,6 @@ cr.define('settings_people_page_sync_controls', function() {
let syncControls = null;
let browserProxy = null;
/**
* Returns sync prefs with everything synced.
* @return {!settings.SyncPrefs}
*/
function getSyncAllPrefs() {
return {
appsEnforced: false,
appsRegistered: true,
appsSynced: true,
autofillEnforced: false,
autofillRegistered: true,
autofillSynced: true,
bookmarksEnforced: false,
bookmarksRegistered: true,
bookmarksSynced: true,
extensionsEnforced: false,
extensionsRegistered: true,
extensionsSynced: true,
passwordsEnforced: false,
passwordsRegistered: true,
passwordsSynced: true,
paymentsIntegrationEnabled: true,
preferencesEnforced: false,
preferencesRegistered: true,
preferencesSynced: true,
syncAllDataTypes: true,
tabsEnforced: false,
tabsRegistered: true,
tabsSynced: true,
themesEnforced: false,
themesRegistered: true,
themesSynced: true,
typedUrlsEnforced: false,
typedUrlsRegistered: true,
typedUrlsSynced: true,
};
}
setup(function() {
browserProxy = new TestSyncBrowserProxy();
settings.SyncBrowserProxyImpl.instance_ = browserProxy;
......@@ -54,7 +16,8 @@ cr.define('settings_people_page_sync_controls', function() {
document.body.appendChild(syncControls);
// Start with Sync All.
cr.webUIListenerCallback('sync-prefs-changed', getSyncAllPrefs());
cr.webUIListenerCallback(
'sync-prefs-changed', sync_test_util.getSyncAllPrefs());
Polymer.dom.flush();
});
......@@ -79,7 +42,7 @@ cr.define('settings_people_page_sync_controls', function() {
syncAllDataTypesControl.click();
function verifyPrefs(prefs) {
const expected = getSyncAllPrefs();
const expected = sync_test_util.getSyncAllPrefs();
expected.syncAllDataTypes = false;
assertEquals(JSON.stringify(expected), JSON.stringify(prefs));
......@@ -97,7 +60,7 @@ cr.define('settings_people_page_sync_controls', function() {
datatypeControls[2].click();
return browserProxy.whenCalled('setSyncDatatypes')
.then(function(prefs) {
const expected = getSyncAllPrefs();
const expected = sync_test_util.getSyncAllPrefs();
expected.syncAllDataTypes = false;
expected.extensionsSynced = false;
assertEquals(JSON.stringify(expected), JSON.stringify(prefs));
......
......@@ -9,51 +9,6 @@ cr.define('settings_people_page_sync_page', function() {
let encryptWithGoogle = null;
let encryptWithPassphrase = null;
/**
* Returns sync prefs with everything synced and no passphrase required.
* @return {!settings.SyncPrefs}
*/
function getSyncAllPrefs() {
return {
appsEnforced: false,
appsRegistered: true,
appsSynced: true,
autofillEnforced: false,
autofillRegistered: true,
autofillSynced: true,
bookmarksEnforced: false,
bookmarksRegistered: true,
bookmarksSynced: true,
encryptAllData: false,
encryptAllDataAllowed: true,
enterPassphraseBody: 'Enter custom passphrase.',
extensionsEnforced: false,
extensionsRegistered: true,
extensionsSynced: true,
fullEncryptionBody: '',
passphrase: '',
passphraseRequired: false,
passwordsEnforced: false,
passwordsRegistered: true,
passwordsSynced: true,
paymentsIntegrationEnabled: true,
preferencesEnforced: false,
preferencesRegistered: true,
preferencesSynced: true,
setNewPassphrase: false,
syncAllDataTypes: true,
tabsEnforced: false,
tabsRegistered: true,
tabsSynced: true,
themesEnforced: false,
themesRegistered: true,
themesSynced: true,
typedUrlsEnforced: false,
typedUrlsRegistered: true,
typedUrlsSynced: true,
};
}
setup(function() {
browserProxy = new TestSyncBrowserProxy();
settings.SyncBrowserProxyImpl.instance_ = browserProxy;
......@@ -72,7 +27,8 @@ cr.define('settings_people_page_sync_page', function() {
// Start with Sync All with no encryption selected. Also, ensure that
// this is not a supervised user, so that Sync Passphrase is enabled.
cr.webUIListenerCallback('sync-prefs-changed', getSyncAllPrefs());
cr.webUIListenerCallback(
'sync-prefs-changed', sync_test_util.getSyncAllPrefs());
syncPage.set('syncStatus', {supervisedUser: false});
Polymer.dom.flush();
......@@ -258,7 +214,8 @@ cr.define('settings_people_page_sync_page', function() {
assertTrue(!!saveNewPassphrase);
// Test that a sync prefs update does not reset the selection.
cr.webUIListenerCallback('sync-prefs-changed', getSyncAllPrefs());
cr.webUIListenerCallback(
'sync-prefs-changed', sync_test_util.getSyncAllPrefs());
Polymer.dom.flush();
assertTrue(encryptWithPassphrase.checked);
});
......@@ -347,7 +304,7 @@ cr.define('settings_people_page_sync_page', function() {
saveNewPassphrase.click();
function verifyPrefs(prefs) {
const expected = getSyncAllPrefs();
const expected = sync_test_util.getSyncAllPrefs();
expected.setNewPassphrase = true;
expected.passphrase = 'foo';
expected.encryptAllData = true;
......@@ -374,7 +331,7 @@ cr.define('settings_people_page_sync_page', function() {
});
test('RadioBoxesHiddenWhenEncrypted', function() {
const prefs = getSyncAllPrefs();
const prefs = sync_test_util.getSyncAllPrefs();
prefs.encryptAllData = true;
prefs.passphraseRequired = true;
prefs.fullEncryptionBody = 'Sync already encrypted.';
......@@ -389,7 +346,7 @@ cr.define('settings_people_page_sync_page', function() {
test(
'ExistingPassphraseSubmitButtonDisabledWhenExistingPassphraseEmpty',
function() {
const prefs = getSyncAllPrefs();
const prefs = sync_test_util.getSyncAllPrefs();
prefs.encryptAllData = true;
prefs.passphraseRequired = true;
cr.webUIListenerCallback('sync-prefs-changed', prefs);
......@@ -410,7 +367,7 @@ cr.define('settings_people_page_sync_page', function() {
});
test('EnterExistingWrongPassphrase', function() {
const prefs = getSyncAllPrefs();
const prefs = sync_test_util.getSyncAllPrefs();
prefs.encryptAllData = true;
prefs.passphraseRequired = true;
cr.webUIListenerCallback('sync-prefs-changed', prefs);
......@@ -428,7 +385,7 @@ cr.define('settings_people_page_sync_page', function() {
submitExistingPassphrase.click();
return browserProxy.whenCalled('setSyncEncryption').then(function(prefs) {
const expected = getSyncAllPrefs();
const expected = sync_test_util.getSyncAllPrefs();
expected.setNewPassphrase = false;
expected.passphrase = 'wrong';
expected.encryptAllData = true;
......@@ -442,7 +399,7 @@ cr.define('settings_people_page_sync_page', function() {
});
test('EnterExistingCorrectPassphrase', function() {
const prefs = getSyncAllPrefs();
const prefs = sync_test_util.getSyncAllPrefs();
prefs.encryptAllData = true;
prefs.passphraseRequired = true;
cr.webUIListenerCallback('sync-prefs-changed', prefs);
......@@ -460,14 +417,14 @@ cr.define('settings_people_page_sync_page', function() {
submitExistingPassphrase.click();
return browserProxy.whenCalled('setSyncEncryption').then(function(prefs) {
const expected = getSyncAllPrefs();
const expected = sync_test_util.getSyncAllPrefs();
expected.setNewPassphrase = false;
expected.passphrase = 'right';
expected.encryptAllData = true;
expected.passphraseRequired = true;
assertEquals(JSON.stringify(expected), JSON.stringify(prefs));
const newPrefs = getSyncAllPrefs();
const newPrefs = sync_test_util.getSyncAllPrefs();
newPrefs.encryptAllData = true;
cr.webUIListenerCallback('sync-prefs-changed', newPrefs);
......@@ -502,7 +459,7 @@ cr.define('settings_people_page_sync_page', function() {
// 1) Normal user (full data encryption allowed)
// EXPECTED: encryptionOptions enabled
const prefs1 = getSyncAllPrefs();
const prefs1 = sync_test_util.getSyncAllPrefs();
prefs1.encryptAllDataAllowed = true;
cr.webUIListenerCallback('sync-prefs-changed', prefs1);
syncPage.syncStatus = {supervisedUser: false};
......@@ -514,7 +471,7 @@ cr.define('settings_people_page_sync_page', function() {
// encryptAllDataAllowed is usually false only for supervised
// users, but it's better to be check this case.
// EXPECTED: encryptionOptions disabled
const prefs2 = getSyncAllPrefs();
const prefs2 = sync_test_util.getSyncAllPrefs();
prefs2.encryptAllDataAllowed = false;
cr.webUIListenerCallback('sync-prefs-changed', prefs2);
syncPage.syncStatus = {supervisedUser: false};
......@@ -524,7 +481,7 @@ cr.define('settings_people_page_sync_page', function() {
// 3) Supervised user (full data encryption not allowed)
// EXPECTED: encryptionOptions disabled
const prefs3 = getSyncAllPrefs();
const prefs3 = sync_test_util.getSyncAllPrefs();
prefs3.encryptAllDataAllowed = false;
cr.webUIListenerCallback('sync-prefs-changed', prefs3);
syncPage.syncStatus = {supervisedUser: true};
......@@ -535,7 +492,7 @@ cr.define('settings_people_page_sync_page', function() {
// 4) Supervised user (full data encryption allowed)
// This never happens in practice, but just to be safe.
// EXPECTED: encryptionOptions disabled
const prefs4 = getSyncAllPrefs();
const prefs4 = sync_test_util.getSyncAllPrefs();
prefs4.encryptAllDataAllowed = true;
cr.webUIListenerCallback('sync-prefs-changed', prefs4);
syncPage.syncStatus = {supervisedUser: true};
......@@ -549,7 +506,7 @@ cr.define('settings_people_page_sync_page', function() {
test('SyncDashboardHiddenFromSupervisedUsers', function() {
const dashboardLink = syncPage.$$('#syncDashboardLink');
const prefs = getSyncAllPrefs();
const prefs = sync_test_util.getSyncAllPrefs();
cr.webUIListenerCallback('sync-prefs-changed', prefs);
// Normal user
......
......@@ -3,6 +3,51 @@
// found in the LICENSE file.
cr.define('sync_test_util', function() {
/**
* Returns sync prefs with everything synced and no passphrase required.
* @return {!settings.SyncPrefs}
*/
function getSyncAllPrefs() {
return {
appsEnforced: false,
appsRegistered: true,
appsSynced: true,
autofillEnforced: false,
autofillRegistered: true,
autofillSynced: true,
bookmarksEnforced: false,
bookmarksRegistered: true,
bookmarksSynced: true,
encryptAllData: false,
encryptAllDataAllowed: true,
enterPassphraseBody: 'Enter custom passphrase.',
extensionsEnforced: false,
extensionsRegistered: true,
extensionsSynced: true,
fullEncryptionBody: '',
passphrase: '',
passphraseRequired: false,
passwordsEnforced: false,
passwordsRegistered: true,
passwordsSynced: true,
paymentsIntegrationEnabled: true,
preferencesEnforced: false,
preferencesRegistered: true,
preferencesSynced: true,
setNewPassphrase: false,
syncAllDataTypes: true,
tabsEnforced: false,
tabsRegistered: true,
tabsSynced: true,
themesEnforced: false,
themesRegistered: true,
themesSynced: true,
typedUrlsEnforced: false,
typedUrlsRegistered: true,
typedUrlsSynced: true,
};
}
/** @param {!settings.SyncStatus} */
function simulateSyncStatus(status) {
cr.webUIListenerCallback('sync-status-changed', status);
......@@ -16,7 +61,8 @@ cr.define('sync_test_util', function() {
}
return {
getSyncAllPrefs: getSyncAllPrefs,
simulateSyncStatus: simulateSyncStatus,
simulateStoredAccounts: simulateStoredAccounts,
};
});
\ No newline at end of file
});
......@@ -16,6 +16,7 @@ class TestSyncBrowserProxy extends TestBrowserProxy {
'setSyncEncryption',
'signOut',
'pauseSync',
'sendSyncPrefsChanged',
'startSignIn',
'startSyncingWithEmail',
]);
......@@ -95,4 +96,9 @@ class TestSyncBrowserProxy extends TestBrowserProxy {
this.methodCalled('setSyncEncryption', syncPrefs);
return Promise.resolve(this.encryptionResponse);
}
/** @override */
sendSyncPrefsChanged() {
this.methodCalled('sendSyncPrefsChanged');
}
}
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