Commit 4d622c5e authored by Victor Hugo Vianna Silva's avatar Victor Hugo Vianna Silva Committed by Commit Bot

Brush up some autofill_page/ code

- Order Polymer properties and methods according to the style guide[1].
- Ensure @private and @return annotations are present.
- Remove unused imports.

[1] https://source.chromium.org/chromium/chromium/src/+/master:styleguide/web/web.md

Bug: None
Change-Id: I4c9c64486944f874cf7c594a8dc43def07e1218c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2431516
Commit-Queue: Victor Vianna <victorvianna@google.com>
Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811617}
parent 8f350fe4
...@@ -70,7 +70,7 @@ Polymer({ ...@@ -70,7 +70,7 @@ Polymer({
* Check if editPasswordsInSettings flag is true and entry isn't federation * Check if editPasswordsInSettings flag is true and entry isn't federation
* credential. * credential.
* @private * @private
* */ */
isEditDialog_: { isEditDialog_: {
type: Boolean, type: Boolean,
computed: 'computeIsEditDialog_(editPasswordsInSettings_, entry)' computed: 'computeIsEditDialog_(editPasswordsInSettings_, entry)'
...@@ -118,21 +118,21 @@ Polymer({ ...@@ -118,21 +118,21 @@ Polymer({
.map(item => item.username)); .map(item => item.username));
}, },
/** Closes the dialog. */
close() {
this.$.dialog.close();
},
/** /**
* Helper function that checks if editPasswordsInSettings flag is true and * Helper function that checks if editPasswordsInSettings flag is true and
* entry isn't federation credential. * entry isn't federation credential.
* @return {boolean} * @return {boolean}
* @private * @private
* */ */
computeIsEditDialog_() { computeIsEditDialog_() {
return this.editPasswordsInSettings_ && !this.entry.federationText; return this.editPasswordsInSettings_ && !this.entry.federationText;
}, },
/** Closes the dialog. */
close() {
this.$.dialog.close();
},
/** /**
* Handler for tapping the 'cancel' button. Should just dismiss the dialog. * Handler for tapping the 'cancel' button. Should just dismiss the dialog.
* @private * @private
...@@ -251,7 +251,10 @@ Polymer({ ...@@ -251,7 +251,10 @@ Polymer({
return this.isEditDialog_ ? this.i18n('save') : this.i18n('done'); return this.isEditDialog_ ? this.i18n('save') : this.i18n('done');
}, },
/** Manually de-select texts for readonly inputs. */ /**
* Manually de-select texts for readonly inputs.
* @private
*/
onInputBlur_() { onInputBlur_() {
this.shadowRoot.getSelection().removeAllRanges(); this.shadowRoot.getSelection().removeAllRanges();
}, },
...@@ -259,6 +262,7 @@ Polymer({ ...@@ -259,6 +262,7 @@ Polymer({
/** /**
* Gets the HTML-formatted message to indicate in which locations the password * Gets the HTML-formatted message to indicate in which locations the password
* is stored. * is stored.
* @private
*/ */
getStorageDetailsMessage_() { getStorageDetailsMessage_() {
if (this.entry.isPresentInAccount() && this.entry.isPresentOnDevice()) { if (this.entry.isPresentInAccount() && this.entry.isPresentOnDevice()) {
......
...@@ -42,9 +42,7 @@ Polymer({ ...@@ -42,9 +42,7 @@ Polymer({
behaviors: [I18nBehavior], behaviors: [I18nBehavior],
properties: { properties: {
/** /** @type {!MultiStorePasswordUiEntry} */
* @type {!MultiStorePasswordUiEntry}
*/
passwordToMove: Object, passwordToMove: Object,
}, },
...@@ -60,9 +58,7 @@ Polymer({ ...@@ -60,9 +58,7 @@ Polymer({
this.$.dialog.showModal(); this.$.dialog.showModal();
}, },
/** /** @private */
* @private
*/
onMoveButtonClick_() { onMoveButtonClick_() {
assert(this.passwordToMove.isPresentOnDevice()); assert(this.passwordToMove.isPresentOnDevice());
PasswordManagerImpl.getInstance() PasswordManagerImpl.getInstance()
...@@ -71,9 +67,7 @@ Polymer({ ...@@ -71,9 +67,7 @@ Polymer({
this.$.dialog.close(); this.$.dialog.close();
}, },
/** /** @private */
* @private
*/
onCancelButtonClick_() { onCancelButtonClick_() {
this.$.dialog.close(); this.$.dialog.close();
} }
......
...@@ -44,9 +44,7 @@ Polymer({ ...@@ -44,9 +44,7 @@ Polymer({
*/ */
duplicatedPassword: Object, duplicatedPassword: Object,
/** /** @private */
* @private
*/
removeFromAccountChecked_: { removeFromAccountChecked_: {
type: Boolean, type: Boolean,
// Both checkboxes are selected by default (see |removeFromDeviceChecked_| // Both checkboxes are selected by default (see |removeFromDeviceChecked_|
...@@ -54,17 +52,13 @@ Polymer({ ...@@ -54,17 +52,13 @@ Polymer({
value: true, value: true,
}, },
/** /** @private */
* @private
*/
removeFromDeviceChecked_: { removeFromDeviceChecked_: {
type: Boolean, type: Boolean,
value: true, value: true,
}, },
/** /** @private */
* @private
*/
accountEmail_: { accountEmail_: {
type: String, type: String,
value: '', value: '',
...@@ -89,9 +83,7 @@ Polymer({ ...@@ -89,9 +83,7 @@ Polymer({
}); });
}, },
/** /** @private */
* @private
*/
onRemoveButtonClick_() { onRemoveButtonClick_() {
/** @type{!Array<number>} */ /** @type{!Array<number>} */
const idsToRemove = []; const idsToRemove = [];
...@@ -110,9 +102,7 @@ Polymer({ ...@@ -110,9 +102,7 @@ Polymer({
}); });
}, },
/** /** @private */
* @private
*/
onCancelButtonClick_() { onCancelButtonClick_() {
this.$.dialog.close(); this.$.dialog.close();
}, },
......
...@@ -29,7 +29,7 @@ import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bun ...@@ -29,7 +29,7 @@ import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bun
import {GlobalScrollTargetBehavior} from '../global_scroll_target_behavior.m.js'; import {GlobalScrollTargetBehavior} from '../global_scroll_target_behavior.m.js';
import {loadTimeData} from '../i18n_setup.js'; import {loadTimeData} from '../i18n_setup.js';
import {OpenWindowProxyImpl} from '../open_window_proxy.js'; import {OpenWindowProxyImpl} from '../open_window_proxy.js';
import {StoredAccount, SyncBrowserProxyImpl, SyncStatus} from '../people_page/sync_browser_proxy.m.js'; import {StoredAccount, SyncBrowserProxyImpl} from '../people_page/sync_browser_proxy.m.js';
import {routes} from '../route.js'; import {routes} from '../route.js';
import {Route, RouteObserverBehavior, Router} from '../router.m.js'; import {Route, RouteObserverBehavior, Router} from '../router.m.js';
...@@ -89,8 +89,7 @@ Polymer({ ...@@ -89,8 +89,7 @@ Polymer({
/** /**
* Passwords displayed in the device-only subsection. * Passwords displayed in the device-only subsection.
* @type {!Array<!MultiStorePasswordUiEntry>} * @private {!Array<!MultiStorePasswordUiEntry>}
* @private
*/ */
deviceOnlyPasswords_: { deviceOnlyPasswords_: {
type: Array, type: Array,
...@@ -101,8 +100,7 @@ Polymer({ ...@@ -101,8 +100,7 @@ Polymer({
/** /**
* Passwords displayed in the 'device and account' subsection. * Passwords displayed in the 'device and account' subsection.
* @type {!Array<!MultiStorePasswordUiEntry>} * @private {!Array<!MultiStorePasswordUiEntry>}
* @private
*/ */
deviceAndAccountPasswords_: { deviceAndAccountPasswords_: {
type: Array, type: Array,
...@@ -120,6 +118,7 @@ Polymer({ ...@@ -120,6 +118,7 @@ Polymer({
/** @private */ /** @private */
accountEmail_: String, accountEmail_: String,
/** @private */
isUserAllowedToAccessPage_: { isUserAllowedToAccessPage_: {
type: Boolean, type: Boolean,
computed: 'computeIsUserAllowedToAccessPage_(signedIn_, syncDisabled_,' + computed: 'computeIsUserAllowedToAccessPage_(signedIn_, syncDisabled_,' +
...@@ -128,8 +127,7 @@ Polymer({ ...@@ -128,8 +127,7 @@ Polymer({
/** /**
* Whether the user is signed in, one of the requirements to view this page. * Whether the user is signed in, one of the requirements to view this page.
* @private * @private {boolean?}
* @type {boolean?}
*/ */
signedIn_: { signedIn_: {
type: Boolean, type: Boolean,
...@@ -138,8 +136,7 @@ Polymer({ ...@@ -138,8 +136,7 @@ Polymer({
/** /**
* Whether Sync is disabled, one of the requirements to view this page. * Whether Sync is disabled, one of the requirements to view this page.
* @private * @private {boolean?}
* @type {boolean?}
*/ */
syncDisabled_: { syncDisabled_: {
type: Boolean, type: Boolean,
...@@ -149,18 +146,14 @@ Polymer({ ...@@ -149,18 +146,14 @@ Polymer({
/** /**
* Whether the user has opted in to the account-scoped password storage, one * Whether the user has opted in to the account-scoped password storage, one
* of the requirements to view this page. * of the requirements to view this page.
* @private * @private {boolean?}
* @type {boolean?}
*/ */
optedInForAccountStorage_: { optedInForAccountStorage_: {
type: Boolean, type: Boolean,
value: null, value: null,
}, },
/** /** @private {Route?} */
* @private
* @type {Route?}
*/
currentRoute_: { currentRoute_: {
type: Object, type: Object,
value: null, value: null,
...@@ -168,13 +161,22 @@ Polymer({ ...@@ -168,13 +161,22 @@ Polymer({
}, },
keyBindings: {
// <if expr="is_macosx">
'meta+z': 'onUndoKeyBinding_',
// </if>
// <if expr="not is_macosx">
'ctrl+z': 'onUndoKeyBinding_',
// </if>
},
/** @private {!function(boolean): void} */
accountStorageOptInStateListener_: Function,
observers: observers:
['maybeRedirectToPasswordsPage_(isUserAllowedToAccessPage_, ' + ['maybeRedirectToPasswordsPage_(isUserAllowedToAccessPage_, ' +
'currentRoute_)'], 'currentRoute_)'],
/** @type {!function(boolean): void} */
accountStorageOptInStateListener_: Function,
/** @override */ /** @override */
attached() { attached() {
this.addListenersForAccountStorageRequirements_(); this.addListenersForAccountStorageRequirements_();
...@@ -196,9 +198,47 @@ Polymer({ ...@@ -196,9 +198,47 @@ Polymer({
this.accountStorageOptInStateListener_); this.accountStorageOptInStateListener_);
}, },
/**
* @return {!Array<!MultiStorePasswordUiEntry>}
* @private
*/
computeDeviceOnlyPasswords_() {
return this.savedPasswords.filter(
p => p.isPresentOnDevice() && !p.isPresentInAccount());
},
/**
* @return {!Array<!MultiStorePasswordUiEntry>}
* @private
*/
computeDeviceAndAccountPasswords_() {
return this.savedPasswords.filter(
p => p.isPresentOnDevice() && p.isPresentInAccount());
},
/** /**
* @private * @private
* @return {boolean}
*/
computeIsUserAllowedToAccessPage_() {
// Only deny access when one of the requirements has already been computed
// and is not satisfied.
return (this.signedIn_ === null || !!this.signedIn_) &&
(this.syncDisabled_ === null || !!this.syncDisabled_) &&
(this.optedInForAccountStorage_ === null ||
!!this.optedInForAccountStorage_);
},
/**
* From RouteObserverBehavior.
* @param {!Route|undefined} route
* @protected
*/ */
currentRouteChanged(route) {
this.currentRoute_ = route || null;
},
/** @private */
addListenersForAccountStorageRequirements_() { addListenersForAccountStorageRequirements_() {
const setSyncDisabled = syncStatus => { const setSyncDisabled = syncStatus => {
this.syncDisabled_ = !syncStatus.signedIn; this.syncDisabled_ = !syncStatus.signedIn;
...@@ -222,15 +262,6 @@ Polymer({ ...@@ -222,15 +262,6 @@ Polymer({
this.accountStorageOptInStateListener_ = setOptedIn; this.accountStorageOptInStateListener_ = setOptedIn;
}, },
/**
* From RouteObserverBehavior.
* @param {!Route|undefined} route
* @protected
*/
currentRouteChanged(route) {
this.currentRoute_ = route || null;
},
/** /**
* @param {!Array<!MultiStorePasswordUiEntry>} passwords * @param {!Array<!MultiStorePasswordUiEntry>} passwords
* @return {boolean} * @return {boolean}
...@@ -240,46 +271,6 @@ Polymer({ ...@@ -240,46 +271,6 @@ Polymer({
return passwords.length > 0; return passwords.length > 0;
}, },
keyBindings: {
// <if expr="is_macosx">
'meta+z': 'onUndoKeyBinding_',
// </if>
// <if expr="not is_macosx">
'ctrl+z': 'onUndoKeyBinding_',
// </if>
},
/**
* @return {!Array<!MultiStorePasswordUiEntry>}
* @private
*/
computeDeviceOnlyPasswords_() {
return this.savedPasswords.filter(
p => p.isPresentOnDevice() && !p.isPresentInAccount());
},
/**
* @return {!Array<!MultiStorePasswordUiEntry>}
* @private
*/
computeDeviceAndAccountPasswords_() {
return this.savedPasswords.filter(
p => p.isPresentOnDevice() && p.isPresentInAccount());
},
/**
* @private
* @return {boolean}
*/
computeIsUserAllowedToAccessPage_() {
// Only deny access when one of the requirements has already been computed
// and is not satisfied.
return (this.signedIn_ === null || !!this.signedIn_) &&
(this.syncDisabled_ === null || !!this.syncDisabled_) &&
(this.optedInForAccountStorage_ === null ||
!!this.optedInForAccountStorage_);
},
/** /**
* @param {!Array<!MultiStorePasswordUiEntry>} passwords * @param {!Array<!MultiStorePasswordUiEntry>} passwords
* @param {string} filter * @param {string} filter
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<cr-action-menu id="menu" role-description="$i18n{menu}"> <cr-action-menu id="menu" role-description="$i18n{menu}">
<button id="menuCopyPassword" class="dropdown-item" <button id="menuCopyPassword" class="dropdown-item"
hidden$="[[activePassword.entry.federationText]]" hidden$="[[activePassword_.entry.federationText]]"
on-click="onMenuCopyPasswordButtonTap_">$i18n{copyPassword}</button> on-click="onMenuCopyPasswordButtonTap_">$i18n{copyPassword}</button>
<button id="menuEditPassword" class="dropdown-item" <button id="menuEditPassword" class="dropdown-item"
on-click="onMenuEditPasswordTap_"> on-click="onMenuEditPasswordTap_">
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
on-click="onMenuRemovePasswordTap_">$i18n{removePassword}</button> on-click="onMenuRemovePasswordTap_">$i18n{removePassword}</button>
<button id="menuMovePasswordToAccount" <button id="menuMovePasswordToAccount"
on-click="onMenuMovePasswordToAccountTap_" on-click="onMenuMovePasswordToAccountTap_"
hidden$="[[!shouldShowMoveToAccountOption_(activePassword, hidden$="[[!shouldShowMoveToAccountOption_(activePassword_,
allowMoveToAccountOption, firstSignedInAccountEmail_)]]" allowMoveToAccountOption, firstSignedInAccountEmail_)]]"
class="dropdown-item">$i18n{movePasswordToAccount}</button> class="dropdown-item">$i18n{movePasswordToAccount}</button>
</cr-action-menu> </cr-action-menu>
...@@ -34,21 +34,21 @@ ...@@ -34,21 +34,21 @@
<if expr="chromeos"> <if expr="chromeos">
token-request-manager="[[tokenRequestManager]]" token-request-manager="[[tokenRequestManager]]"
</if> </if>
entry="[[activePassword.entry]]" saved-passwords="[[savedPasswords]]" entry="[[activePassword_.entry]]" saved-passwords="[[savedPasswords]]"
should-show-storage-details="[[shouldShowStorageDetails]]"> should-show-storage-details="[[shouldShowStorageDetails]]">
</password-edit-dialog> </password-edit-dialog>
</template> </template>
<template is="dom-if" if="[[showPasswordMoveToAccountDialog_]]" restamp> <template is="dom-if" if="[[showPasswordMoveToAccountDialog_]]" restamp>
<password-move-to-account-dialog id="passwordMoveToAccountDialog" <password-move-to-account-dialog id="passwordMoveToAccountDialog"
password-to-move="[[activePassword.entry]]" password-to-move="[[activePassword_.entry]]"
on-close="onPasswordMoveToAccountDialogClosed_"> on-close="onPasswordMoveToAccountDialogClosed_">
</password-move-to-account-dialog> </password-move-to-account-dialog>
</template> </template>
<template is="dom-if" if="[[showPasswordRemoveDialog_]]" restamp> <template is="dom-if" if="[[showPasswordRemoveDialog_]]" restamp>
<password-remove-dialog id="passwordRemoveDialog" <password-remove-dialog id="passwordRemoveDialog"
duplicated-password="[[activePassword.entry]]" duplicated-password="[[activePassword_.entry]]"
on-close="onPasswordRemoveDialogClosed_"> on-close="onPasswordRemoveDialogClosed_">
</password-remove-dialog> </password-remove-dialog>
</template> </template>
......
...@@ -39,6 +39,11 @@ Polymer({ ...@@ -39,6 +39,11 @@ Polymer({
_template: html`{__html_template__}`, _template: html`{__html_template__}`,
behaviors: [
I18nBehavior,
WebUIListenerBehavior,
],
properties: { properties: {
/** /**
* Saved passwords after deduplicating versions that are repeated in the * Saved passwords after deduplicating versions that are repeated in the
...@@ -50,16 +55,6 @@ Polymer({ ...@@ -50,16 +55,6 @@ Polymer({
value: () => [], value: () => [],
}, },
/**
* The model for any active menus or dialogs. The value is reset to null
* whenever actions from the menus/dialogs are concluded.
* @private {?PasswordListItemElement}
*/
activePassword: {
type: Object,
value: null,
},
/** /**
* Whether the edit dialog and removal notification should show information * Whether the edit dialog and removal notification should show information
* about which location(s) a password is stored. * about which location(s) a password is stored.
...@@ -83,6 +78,16 @@ Polymer({ ...@@ -83,6 +78,16 @@ Polymer({
tokenRequestManager: Object, tokenRequestManager: Object,
// </if> // </if>
/**
* The model for any active menus or dialogs. The value is reset to null
* whenever actions from the menus/dialogs are concluded.
* @private {?PasswordListItemElement}
*/
activePassword_: {
type: Object,
value: null,
},
/** @private */ /** @private */
editPasswordsInSettings_: { editPasswordsInSettings_: {
type: Boolean, type: Boolean,
...@@ -95,10 +100,11 @@ Polymer({ ...@@ -95,10 +100,11 @@ Polymer({
* Check if editPasswordsInSettings flag is true and entry isn't federation * Check if editPasswordsInSettings flag is true and entry isn't federation
* credential. * credential.
* @private * @private
* */ */
isEditDialog_: { isEditDialog_: {
type: Boolean, type: Boolean,
computed: 'computeIsEditDialog_(editPasswordsInSettings_, activePassword)' computed:
'computeIsEditDialog_(editPasswordsInSettings_, activePassword_)'
}, },
/** @private */ /** @private */
...@@ -137,20 +143,15 @@ Polymer({ ...@@ -137,20 +143,15 @@ Polymer({
} }
}, },
behaviors: [ /** @private {?PasswordManagerProxy} */
I18nBehavior, passwordManager_: null,
WebUIListenerBehavior,
],
listeners: { listeners: {
'password-more-actions-clicked': 'onPasswordMoreActionsClicked_', 'password-more-actions-clicked': 'passwordMoreActionsClickedHandler_',
'password-remove-dialog-passwords-removed': 'password-remove-dialog-passwords-removed':
'onPasswordRemoveDialogPasswordsRemoved_', 'passwordRemoveDialogPasswordsRemovedHandler_',
}, },
/** @private {?PasswordManagerProxy} */
passwordManager_: null,
/** @override */ /** @override */
attached() { attached() {
this.passwordManager_ = PasswordManagerImpl.getInstance(); this.passwordManager_ = PasswordManagerImpl.getInstance();
...@@ -171,17 +172,6 @@ Polymer({ ...@@ -171,17 +172,6 @@ Polymer({
} }
}, },
/**
* Helper function that checks if editPasswordsInSettings flag is true and
* entry isn't federation credential.
* @return {boolean}
* @private
* */
computeIsEditDialog_() {
return this.editPasswordsInSettings_ &&
(!this.activePassword || !this.activePassword.entry.federationText);
},
/** /**
* Closes the toast manager. * Closes the toast manager.
*/ */
...@@ -194,14 +184,34 @@ Polymer({ ...@@ -194,14 +184,34 @@ Polymer({
* @param {PasswordMoreActionsClickedEvent} event * @param {PasswordMoreActionsClickedEvent} event
* @private * @private
*/ */
onPasswordMoreActionsClicked_(event) { passwordMoreActionsClickedHandler_(event) {
const target = event.detail.target; const target = event.detail.target;
this.activePassword = event.detail.listItem; this.activePassword_ = event.detail.listItem;
this.$.menu.showAt(target); this.$.menu.showAt(target);
this.activeDialogAnchor_ = target; this.activeDialogAnchor_ = target;
}, },
/**
* @param {PasswordRemoveDialogPasswordsRemovedEvent} event
* @private
*/
passwordRemoveDialogPasswordsRemovedHandler_(event) {
this.displayRemovalNotification_(
event.detail.removedFromAccount, event.detail.removedFromDevice);
},
/**
* Helper function that checks if editPasswordsInSettings flag is true and
* entry isn't federation credential.
* @return {boolean}
* @private
*/
computeIsEditDialog_() {
return this.editPasswordsInSettings_ &&
(!this.activePassword_ || !this.activePassword_.entry.federationText);
},
/** /**
* Requests the plaintext password for the current active password. * Requests the plaintext password for the current active password.
* @param {!chrome.passwordsPrivate.PlaintextReason} reason The reason why the * @param {!chrome.passwordsPrivate.PlaintextReason} reason The reason why the
...@@ -212,7 +222,7 @@ Polymer({ ...@@ -212,7 +222,7 @@ Polymer({
*/ */
requestActivePlaintextPassword_(reason, callback) { requestActivePlaintextPassword_(reason, callback) {
this.passwordManager_ this.passwordManager_
.requestPlaintextPassword(this.activePassword.entry.getAnyId(), reason) .requestPlaintextPassword(this.activePassword_.entry.getAnyId(), reason)
.then(callback, error => { .then(callback, error => {
// <if expr="chromeos"> // <if expr="chromeos">
// If no password was found, refresh auth token and retry. // If no password was found, refresh auth token and retry.
...@@ -228,14 +238,14 @@ Polymer({ ...@@ -228,14 +238,14 @@ Polymer({
if (this.isEditDialog_) { if (this.isEditDialog_) {
this.requestActivePlaintextPassword_( this.requestActivePlaintextPassword_(
chrome.passwordsPrivate.PlaintextReason.EDIT, password => { chrome.passwordsPrivate.PlaintextReason.EDIT, password => {
this.set('activePassword.entry.password', password); this.set('activePassword_.entry.password', password);
this.showPasswordEditDialog_ = true; this.showPasswordEditDialog_ = true;
}); });
} else { } else {
this.showPasswordEditDialog_ = true; this.showPasswordEditDialog_ = true;
} }
this.$.menu.close(); this.$.menu.close();
this.activePassword.hide(); this.activePassword_.hide();
}, },
/** /**
...@@ -252,8 +262,8 @@ Polymer({ ...@@ -252,8 +262,8 @@ Polymer({
this.showPasswordEditDialog_ = false; this.showPasswordEditDialog_ = false;
focusWithoutInk(assert(this.activeDialogAnchor_)); focusWithoutInk(assert(this.activeDialogAnchor_));
this.activeDialogAnchor_ = null; this.activeDialogAnchor_ = null;
this.activePassword.hide(); this.activePassword_.hide();
this.activePassword = null; this.activePassword_ = null;
}, },
/** @private */ /** @private */
...@@ -261,7 +271,7 @@ Polymer({ ...@@ -261,7 +271,7 @@ Polymer({
this.showPasswordEditDialog_ = false; this.showPasswordEditDialog_ = false;
focusWithoutInk(assert(this.activeDialogAnchor_)); focusWithoutInk(assert(this.activeDialogAnchor_));
this.activeDialogAnchor_ = null; this.activeDialogAnchor_ = null;
this.activePassword = null; this.activePassword_ = null;
}, },
/** /**
...@@ -273,7 +283,7 @@ Polymer({ ...@@ -273,7 +283,7 @@ Polymer({
// result back to javascript. // result back to javascript.
this.requestActivePlaintextPassword_( this.requestActivePlaintextPassword_(
chrome.passwordsPrivate.PlaintextReason.COPY, _ => { chrome.passwordsPrivate.PlaintextReason.COPY, _ => {
this.activePassword = null; this.activePassword_ = null;
}); });
this.$.menu.close(); this.$.menu.close();
...@@ -288,20 +298,20 @@ Polymer({ ...@@ -288,20 +298,20 @@ Polymer({
onMenuRemovePasswordTap_() { onMenuRemovePasswordTap_() {
this.$.menu.close(); this.$.menu.close();
if (this.activePassword.entry.isPresentOnDevice() && if (this.activePassword_.entry.isPresentOnDevice() &&
this.activePassword.entry.isPresentInAccount()) { this.activePassword_.entry.isPresentInAccount()) {
this.showPasswordRemoveDialog_ = true; this.showPasswordRemoveDialog_ = true;
return; return;
} }
const idToRemove = this.activePassword.entry.isPresentInAccount() ? const idToRemove = this.activePassword_.entry.isPresentInAccount() ?
this.activePassword.entry.accountId : this.activePassword_.entry.accountId :
this.activePassword.entry.deviceId; this.activePassword_.entry.deviceId;
this.passwordManager_.removeSavedPassword(idToRemove); this.passwordManager_.removeSavedPassword(idToRemove);
this.displayRemovalNotification_( this.displayRemovalNotification_(
this.activePassword.entry.isPresentInAccount(), this.activePassword_.entry.isPresentInAccount(),
this.activePassword.entry.isPresentOnDevice()); this.activePassword_.entry.isPresentOnDevice());
this.activePassword = null; this.activePassword_ = null;
}, },
/** /**
...@@ -328,24 +338,14 @@ Polymer({ ...@@ -328,24 +338,14 @@ Polymer({
this.fire('iron-announce', {text: this.i18n('undoDescription')}); this.fire('iron-announce', {text: this.i18n('undoDescription')});
}, },
/** /** @private */
* @param {PasswordRemoveDialogPasswordsRemovedEvent} event
*/
onPasswordRemoveDialogPasswordsRemoved_(event) {
this.displayRemovalNotification_(
event.detail.removedFromAccount, event.detail.removedFromDevice);
},
/**
* @private
*/
onUndoButtonClick_() { onUndoButtonClick_() {
this.passwordManager_.undoRemoveSavedPasswordOrException(); this.passwordManager_.undoRemoveSavedPasswordOrException();
this.onSavedPasswordOrExceptionRemoved(); this.onSavedPasswordOrExceptionRemoved();
}, },
/** /**
* Should only be called when |activePassword| has a device copy. * Should only be called when |activePassword_| has a device copy.
* @private * @private
*/ */
onMenuMovePasswordToAccountTap_() { onMenuMovePasswordToAccountTap_() {
...@@ -353,23 +353,19 @@ Polymer({ ...@@ -353,23 +353,19 @@ Polymer({
this.showPasswordMoveToAccountDialog_ = true; this.showPasswordMoveToAccountDialog_ = true;
}, },
/** /** @private */
* @private
*/
onPasswordMoveToAccountDialogClosed_() { onPasswordMoveToAccountDialogClosed_() {
this.showPasswordMoveToAccountDialog_ = false; this.showPasswordMoveToAccountDialog_ = false;
this.activePassword = null; this.activePassword_ = null;
// The entry possibly disappeared, so don't reset the focus. // The entry possibly disappeared, so don't reset the focus.
this.activeDialogAnchor_ = null; this.activeDialogAnchor_ = null;
}, },
/** /** @private */
* @private
*/
onPasswordRemoveDialogClosed_() { onPasswordRemoveDialogClosed_() {
this.showPasswordRemoveDialog_ = false; this.showPasswordRemoveDialog_ = false;
this.activePassword = null; this.activePassword_ = null;
// A removal possibly happened, so don't reset the focus. // A removal possibly happened, so don't reset the focus.
this.activeDialogAnchor_ = null; this.activeDialogAnchor_ = null;
...@@ -381,9 +377,10 @@ Polymer({ ...@@ -381,9 +377,10 @@ Polymer({
* @return {boolean} * @return {boolean}
*/ */
shouldShowMoveToAccountOption_() { shouldShowMoveToAccountOption_() {
const isFirstSignedInAccountPassword = !!this.activePassword && const isFirstSignedInAccountPassword = !!this.activePassword_ &&
this.activePassword.entry.urls.origin.includes('accounts.google.com') && this.activePassword_.entry.urls.origin.includes(
this.activePassword.entry.username === this.firstSignedInAccountEmail_; 'accounts.google.com') &&
this.activePassword_.entry.username === this.firstSignedInAccountEmail_;
// It's not useful to move a password for an account into that same account. // It's not useful to move a password for an account into that same account.
return this.allowMoveToAccountOption && !isFirstSignedInAccountPassword; return this.allowMoveToAccountOption && !isFirstSignedInAccountPassword;
}, },
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
* save any passwords. * save any passwords.
*/ */
/** @typedef {!{model: !{item: !chrome.passwordsPrivate.ExceptionEntry}}} */ /** @typedef {!{model: !{item: !chrome.passwordsPrivate.ExceptionEntry}}} */
let ExceptionEntryEntryEvent; let ExceptionEntryEntryEvent;
...@@ -23,7 +22,6 @@ import 'chrome://resources/cr_elements/shared_style_css.m.js'; ...@@ -23,7 +22,6 @@ import 'chrome://resources/cr_elements/shared_style_css.m.js';
import {assert} from 'chrome://resources/js/assert.m.js'; import {assert} from 'chrome://resources/js/assert.m.js';
import {focusWithoutInk} from 'chrome://resources/js/cr/ui/focus_without_ink.m.js'; import {focusWithoutInk} from 'chrome://resources/js/cr/ui/focus_without_ink.m.js';
import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js'; import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js';
import {getImage} from 'chrome://resources/js/icon.m.js';
import {getDeepActiveElement} from 'chrome://resources/js/util.m.js'; import {getDeepActiveElement} from 'chrome://resources/js/util.m.js';
import {WebUIListenerBehavior} from 'chrome://resources/js/web_ui_listener_behavior.m.js'; import {WebUIListenerBehavior} from 'chrome://resources/js/web_ui_listener_behavior.m.js';
import {IronA11yAnnouncer} from 'chrome://resources/polymer/v3_0/iron-a11y-announcer/iron-a11y-announcer.js'; import {IronA11yAnnouncer} from 'chrome://resources/polymer/v3_0/iron-a11y-announcer/iron-a11y-announcer.js';
...@@ -42,7 +40,6 @@ import {routes} from '../route.js'; ...@@ -42,7 +40,6 @@ import {routes} from '../route.js';
import {MergeExceptionsStoreCopiesBehavior} from './merge_exceptions_store_copies_behavior.js'; import {MergeExceptionsStoreCopiesBehavior} from './merge_exceptions_store_copies_behavior.js';
import {MergePasswordsStoreCopiesBehavior} from './merge_passwords_store_copies_behavior.js'; import {MergePasswordsStoreCopiesBehavior} from './merge_passwords_store_copies_behavior.js';
import {MultiStorePasswordUiEntry} from './multi_store_password_ui_entry.js'; import {MultiStorePasswordUiEntry} from './multi_store_password_ui_entry.js';
import {MultiStoreExceptionEntry} from './multi_store_exception_entry.js';
import {Router} from '../router.m.js'; import {Router} from '../router.m.js';
import '../settings_shared_css.m.js'; import '../settings_shared_css.m.js';
import '../site_favicon.js'; import '../site_favicon.js';
...@@ -53,7 +50,6 @@ import {PasswordManagerImpl, PasswordManagerProxy} from './password_manager_prox ...@@ -53,7 +50,6 @@ import {PasswordManagerImpl, PasswordManagerProxy} from './password_manager_prox
import './passwords_export_dialog.js'; import './passwords_export_dialog.js';
import './passwords_shared_css.js'; import './passwords_shared_css.js';
import './avatar_icon.js'; import './avatar_icon.js';
import {ProfileInfo, ProfileInfoBrowserProxy, ProfileInfoBrowserProxyImpl} from '../people_page/profile_info_browser_proxy.m.js';
// <if expr="chromeos"> // <if expr="chromeos">
import '../controls/password_prompt_dialog.m.js'; import '../controls/password_prompt_dialog.m.js';
import {BlockingRequestManager} from './blocking_request_manager.js'; import {BlockingRequestManager} from './blocking_request_manager.js';
...@@ -90,10 +86,6 @@ Polymer({ ...@@ -90,10 +86,6 @@ Polymer({
], ],
properties: { properties: {
// <if expr="not chromeos">
/** @private */
storedAccounts_: Array,
// </if>
/** @type {!Map<string, (string|Function)>} */ /** @type {!Map<string, (string|Function)>} */
focusConfig: { focusConfig: {
...@@ -119,6 +111,17 @@ Polymer({ ...@@ -119,6 +111,17 @@ Polymer({
value: () => document, value: () => document,
}, },
/** Filter on the saved passwords and exceptions. */
filter: {
type: String,
value: '',
},
// <if expr="not chromeos">
/** @private */
storedAccounts_: Array,
// </if>
/** @private */ /** @private */
signedIn_: { signedIn_: {
type: Boolean, type: Boolean,
...@@ -163,6 +166,7 @@ Polymer({ ...@@ -163,6 +166,7 @@ Polymer({
computed: 'computeHasPasswordExceptions_(passwordExceptions)', computed: 'computeHasPasswordExceptions_(passwordExceptions)',
}, },
/** @private */
shouldShowBanner_: { shouldShowBanner_: {
type: Boolean, type: Boolean,
value: true, value: true,
...@@ -173,6 +177,7 @@ Polymer({ ...@@ -173,6 +177,7 @@ Polymer({
/** /**
* Whether the edit dialog and removal notification should show * Whether the edit dialog and removal notification should show
* information about which location(s) a password is stored. * information about which location(s) a password is stored.
* @private
*/ */
shouldShowStorageDetails_: { shouldShowStorageDetails_: {
type: Boolean, type: Boolean,
...@@ -252,12 +257,6 @@ Polymer({ ...@@ -252,12 +257,6 @@ Polymer({
/** @private {SyncStatus} */ /** @private {SyncStatus} */
syncStatus_: Object, syncStatus_: Object,
/** Filter on the saved passwords and exceptions. */
filter: {
type: String,
value: '',
},
/** @private {!MultiStorePasswordUiEntry} */ /** @private {!MultiStorePasswordUiEntry} */
lastFocused_: Object, lastFocused_: Object,
...@@ -269,7 +268,7 @@ Polymer({ ...@@ -269,7 +268,7 @@ Polymer({
showPasswordPromptDialog_: Boolean, showPasswordPromptDialog_: Boolean,
/** @private {BlockingRequestManager} */ /** @private {BlockingRequestManager} */
tokenRequestManager_: Object tokenRequestManager_: Object,
// </if> // </if>
}, },
...@@ -295,36 +294,12 @@ Polymer({ ...@@ -295,36 +294,12 @@ Polymer({
/** @private {?PasswordManagerProxy} */ /** @private {?PasswordManagerProxy} */
passwordManager_: null, passwordManager_: null,
/** /** @private {?function(boolean):void} */
* @type {?function(boolean):void}
* @private
*/
setIsOptedInForAccountStorageListener_: null, setIsOptedInForAccountStorageListener_: null,
/** /** @private {?function(!Array<PasswordManagerProxy.ExceptionEntry>):void} */
* @type {?function(!Array<PasswordManagerProxy.ExceptionEntry>):void}
* @private
*/
setPasswordExceptionsListener_: null, setPasswordExceptionsListener_: null,
/**
* @param {!Map<string, string>} newConfig
* @param {?Map<string, string>} oldConfig
* @private
*/
focusConfigChanged_(newConfig, oldConfig) {
// focusConfig is set only once on the parent, so this observer should
// only fire once.
assert(!oldConfig);
// Populate the |focusConfig| map of the parent <settings-autofill-page>
// element, with additional entries that correspond to subpage trigger
// elements residing in this element's Shadow DOM.
this.focusConfig.set(assert(routes.CHECK_PASSWORDS).path, () => {
focusWithoutInk(assert(this.$$('#icon')));
});
},
/** @override */ /** @override */
attached() { attached() {
// Create listener functions. // Create listener functions.
...@@ -387,56 +362,6 @@ Polymer({ ...@@ -387,56 +362,6 @@ Polymer({
assert(this.setIsOptedInForAccountStorageListener_)); assert(this.setIsOptedInForAccountStorageListener_));
}, },
/**
* Shows the check passwords sub page.
* @private
*/
onCheckPasswordsClick_() {
Router.getInstance().navigateTo(
routes.CHECK_PASSWORDS, new URLSearchParams('start=true'));
this.passwordManager_.recordPasswordCheckReferrer(
PasswordManagerProxy.PasswordCheckReferrer.PASSWORD_SETTINGS);
},
/**
* Shows the 'device passwords' page.
*/
onDevicePasswordsLinkClicked_() {
Router.getInstance().navigateTo(routes.DEVICE_PASSWORDS);
},
// <if expr="chromeos">
/**
* When this event fired, it means that the password-prompt-dialog succeeded
* in creating a fresh token in the quickUnlockPrivate API. Because new tokens
* can only ever be created immediately following a GAIA password check, the
* passwordsPrivate API can now safely grant requests for secure data (i.e.
* saved passwords) for a limited time. This observer resolves the request,
* triggering a callback that requires a fresh auth token to succeed and that
* was provided to the BlockingRequestManager by another DOM element seeking
* secure data.
*
* @param {!CustomEvent<!chrome.quickUnlockPrivate.TokenInfo>} e - Contains
* newly created auth token. Note that its precise value is not relevant
* here, only the facts that it's created.
* @private
*/
onTokenObtained_(e) {
assert(e.detail);
this.tokenRequestManager_.resolve();
},
onPasswordPromptClosed_() {
this.showPasswordPromptDialog_ = false;
focusWithoutInk(assert(this.activeDialogAnchorStack_.pop()));
},
openPasswordPromptDialog_() {
this.activeDialogAnchorStack_.push(getDeepActiveElement());
this.showPasswordPromptDialog_ = true;
},
// </if>
/** /**
* @return {boolean} * @return {boolean}
* @private * @private
...@@ -524,6 +449,86 @@ Polymer({ ...@@ -524,6 +449,86 @@ Polymer({
!!this.syncPrefs_ && !!this.syncPrefs_.encryptAllData); !!this.syncPrefs_ && !!this.syncPrefs_.encryptAllData);
}, },
/**
* @private
* @return {boolean}
*/
computeHasLeakedCredentials_() {
return this.leakedPasswords.length > 0;
},
/**
* @private
* @return {boolean}
*/
computeHasNeverCheckedPasswords_() {
return !this.status.elapsedTimeSinceLastCheck;
},
/**
* @private
* @return {string}
*/
computeDevicePasswordsLinkLabel_() {
return this.numberOfDevicePasswords_ === 1 ?
this.i18n('devicePasswordsLinkLabelSingular') :
this.i18n(
'devicePasswordsLinkLabelPlural', this.numberOfDevicePasswords_);
},
/**
* Shows the check passwords sub page.
* @private
*/
onCheckPasswordsClick_() {
Router.getInstance().navigateTo(
routes.CHECK_PASSWORDS, new URLSearchParams('start=true'));
this.passwordManager_.recordPasswordCheckReferrer(
PasswordManagerProxy.PasswordCheckReferrer.PASSWORD_SETTINGS);
},
/**
* Shows the 'device passwords' page.
* @private
*/
onDevicePasswordsLinkClicked_() {
Router.getInstance().navigateTo(routes.DEVICE_PASSWORDS);
},
// <if expr="chromeos">
/**
* When this event fired, it means that the password-prompt-dialog succeeded
* in creating a fresh token in the quickUnlockPrivate API. Because new tokens
* can only ever be created immediately following a GAIA password check, the
* passwordsPrivate API can now safely grant requests for secure data (i.e.
* saved passwords) for a limited time. This observer resolves the request,
* triggering a callback that requires a fresh auth token to succeed and that
* was provided to the BlockingRequestManager by another DOM element seeking
* secure data.
*
* @param {!CustomEvent<!chrome.quickUnlockPrivate.TokenInfo>} e - Contains
* newly created auth token. Note that its precise value is not relevant
* here, only the facts that it's created.
* @private
*/
onTokenObtained_(e) {
assert(e.detail);
this.tokenRequestManager_.resolve();
},
/** @private */
onPasswordPromptClosed_() {
this.showPasswordPromptDialog_ = false;
focusWithoutInk(assert(this.activeDialogAnchorStack_.pop()));
},
/** @private */
openPasswordPromptDialog_() {
this.activeDialogAnchorStack_.push(getDeepActiveElement());
this.showPasswordPromptDialog_ = true;
},
// </if>
/** /**
* @param {string} filter * @param {string} filter
* @return {!Array<!MultiStorePasswordUiEntry>} * @return {!Array<!MultiStorePasswordUiEntry>}
...@@ -643,33 +648,6 @@ Polymer({ ...@@ -643,33 +648,6 @@ Polymer({
return this.hasSavedPasswords_ || this.showImportPasswords_; return this.hasSavedPasswords_ || this.showImportPasswords_;
}, },
/**
* @private
* @return {boolean}
*/
computeHasLeakedCredentials_() {
return this.leakedPasswords.length > 0;
},
/**
* @private
* @return {boolean}
*/
computeHasNeverCheckedPasswords_() {
return !this.status.elapsedTimeSinceLastCheck;
},
/**
* @private
* @return {string}
*/
computeDevicePasswordsLinkLabel_() {
return this.numberOfDevicePasswords_ === 1 ?
this.i18n('devicePasswordsLinkLabelSingular') :
this.i18n(
'devicePasswordsLinkLabelPlural', this.numberOfDevicePasswords_);
},
/** /**
* Return the first available stored account. This is useful when trying to * Return the first available stored account. This is useful when trying to
* figure out the account logged into the content area which seems to always * figure out the account logged into the content area which seems to always
...@@ -683,4 +661,22 @@ Polymer({ ...@@ -683,4 +661,22 @@ Polymer({
this.storedAccounts_[0].email : this.storedAccounts_[0].email :
''; '';
}, },
/**
* @param {!Map<string, string>} newConfig
* @param {?Map<string, string>} oldConfig
* @private
*/
focusConfigChanged_(newConfig, oldConfig) {
// focusConfig is set only once on the parent, so this observer should
// only fire once.
assert(!oldConfig);
// Populate the |focusConfig| map of the parent <settings-autofill-page>
// element, with additional entries that correspond to subpage trigger
// elements residing in this element's Shadow DOM.
this.focusConfig.set(assert(routes.CHECK_PASSWORDS).path, () => {
focusWithoutInk(assert(this.$$('#icon')));
});
},
}); });
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/** @fileoverview Runs the Polymer tests for the PasswordsDeviceSection page. */ /** @fileoverview Runs the Polymer tests for the PasswordsDeviceSection page. */
import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {MultiStorePasswordUiEntry, PasswordManagerImpl, PasswordManagerProxy, Router, routes, SyncBrowserProxyImpl} from 'chrome://settings/settings.js'; import {MultiStorePasswordUiEntry, PasswordManagerImpl, Router, routes, SyncBrowserProxyImpl} from 'chrome://settings/settings.js';
import {createMultiStorePasswordEntry, createPasswordEntry} from 'chrome://test/settings/passwords_and_autofill_fake_data.js'; import {createMultiStorePasswordEntry, createPasswordEntry} from 'chrome://test/settings/passwords_and_autofill_fake_data.js';
import {simulateStoredAccounts, simulateSyncStatus} from 'chrome://test/settings/sync_test_util.m.js'; import {simulateStoredAccounts, simulateSyncStatus} from 'chrome://test/settings/sync_test_util.m.js';
import {TestPasswordManagerProxy} from 'chrome://test/settings/test_password_manager_proxy.js'; import {TestPasswordManagerProxy} from 'chrome://test/settings/test_password_manager_proxy.js';
......
...@@ -8,15 +8,13 @@ ...@@ -8,15 +8,13 @@
import {isChromeOS, webUIListenerCallback} from 'chrome://resources/js/cr.m.js'; import {isChromeOS, webUIListenerCallback} from 'chrome://resources/js/cr.m.js';
import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {MultiStoreExceptionEntry, MultiStorePasswordUiEntry, PasswordManagerImpl, PasswordManagerProxy, ProfileInfoBrowserProxyImpl, Router, routes, SettingsPluralStringProxyImpl} from 'chrome://settings/settings.js'; import {MultiStoreExceptionEntry, MultiStorePasswordUiEntry, PasswordManagerImpl, PasswordManagerProxy, Router, routes, SettingsPluralStringProxyImpl} from 'chrome://settings/settings.js';
import {createExceptionEntry, createMultiStoreExceptionEntry, createMultiStorePasswordEntry, createPasswordEntry, makeCompromisedCredential, makePasswordCheckStatus, PasswordSectionElementFactory} from 'chrome://test/settings/passwords_and_autofill_fake_data.js'; import {createExceptionEntry, createMultiStoreExceptionEntry, createMultiStorePasswordEntry, createPasswordEntry, makeCompromisedCredential, makePasswordCheckStatus, PasswordSectionElementFactory} from 'chrome://test/settings/passwords_and_autofill_fake_data.js';
import {runCancelExportTest, runExportFlowErrorRetryTest, runExportFlowErrorTest, runExportFlowFastTest, runExportFlowSlowTest, runFireCloseEventAfterExportCompleteTest,runStartExportTest} from 'chrome://test/settings/passwords_export_test.js'; import {runCancelExportTest, runExportFlowErrorRetryTest, runExportFlowErrorTest, runExportFlowFastTest, runExportFlowSlowTest, runFireCloseEventAfterExportCompleteTest,runStartExportTest} from 'chrome://test/settings/passwords_export_test.js';
import {getSyncAllPrefs, simulateStoredAccounts, simulateSyncStatus} from 'chrome://test/settings/sync_test_util.m.js'; import {getSyncAllPrefs, simulateStoredAccounts, simulateSyncStatus} from 'chrome://test/settings/sync_test_util.m.js';
import {TestPasswordManagerProxy} from 'chrome://test/settings/test_password_manager_proxy.js'; import {TestPasswordManagerProxy} from 'chrome://test/settings/test_password_manager_proxy.js';
import {TestProfileInfoBrowserProxy} from 'chrome://test/settings/test_profile_info_browser_proxy.m.js';
import {TestPluralStringProxy} from 'chrome://test/test_plural_string_proxy.js'; import {TestPluralStringProxy} from 'chrome://test/test_plural_string_proxy.js';
import {eventToPromise} from 'chrome://test/test_util.m.js'; import {eventToPromise} from 'chrome://test/test_util.m.js';
// clang-format on // clang-format on
const PasswordCheckState = chrome.passwordsPrivate.PasswordCheckState; const PasswordCheckState = chrome.passwordsPrivate.PasswordCheckState;
......
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