Commit 18ef50e2 authored by Christos Froussios's avatar Christos Froussios Committed by Commit Bot

[Password Manager] Action menu for leaked passwords

This change makes clicking on the dots icon open a menu with action
items for the compromised password.

Bug: 1047726
Change-Id: If192af77ca8dc184670d64cbf99322c29f94b42b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2088151
Commit-Queue: Christos Froussios <cfroussios@chromium.org>
Reviewed-by: default avatardpapad <dpapad@chromium.org>
Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748026}
parent 0dde5e89
...@@ -350,6 +350,15 @@ ...@@ -350,6 +350,15 @@
<message name="IDS_SETTINGS_NO_COMPROMISED_CREDENTIALS_LABEL" desc="Label which is shown when there were no compromised passwords detected."> <message name="IDS_SETTINGS_NO_COMPROMISED_CREDENTIALS_LABEL" desc="Label which is shown when there were no compromised passwords detected.">
Chrome will notify you when you sign in with a compromised password Chrome will notify you when you sign in with a compromised password
</message> </message>
<message name="IDS_SETTINGS_COMPROMISED_PASSWORD_SHOW" desc="Action menu item for a row which displays a compromised password. The password value, which is initialy obfuscated, will be show in plain text.">
Show password
</message>
<message name="IDS_SETTINGS_COMPROMISED_PASSWORD_EDIT" desc="Action menu item for a row which displays a compromised password. It will open a modal dialog which will allow the user to edit the password and other metadata (username, website).">
Edit password
</message>
<message name="IDS_SETTINGS_COMPROMISED_PASSWORD_REMOVE" desc="Action menu item for a row which displays a compromised password. It will open a confirmation dialog for deleting the password.">
Remove password
</message>
<message name="IDS_SETTINGS_PASSWORDS_SAVE_PASSWORDS_TOGGLE_LABEL" desc="Label for a toggle that allows users to be prompted if they want to save their passwords when logging into webpages."> <message name="IDS_SETTINGS_PASSWORDS_SAVE_PASSWORDS_TOGGLE_LABEL" desc="Label for a toggle that allows users to be prompted if they want to save their passwords when logging into webpages.">
Offer to save passwords Offer to save passwords
</message> </message>
......
a0d753efbf2d825c0f85796b6289d1ab03a67cdd
\ No newline at end of file
a0d753efbf2d825c0f85796b6289d1ab03a67cdd
\ No newline at end of file
a0d753efbf2d825c0f85796b6289d1ab03a67cdd
\ No newline at end of file
<link rel="import" href="chrome://resources/html/polymer.html"> <link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/cr_action_menu/cr_action_menu.html">
<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> <link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
<link rel="import" href="../i18n_setup.html"> <link rel="import" href="../i18n_setup.html">
<link rel="import" href="../settings_shared_css.html"> <link rel="import" href="../settings_shared_css.html">
...@@ -58,12 +59,27 @@ ...@@ -58,12 +59,27 @@
<div class="list-frame first"> <div class="list-frame first">
<iron-list id="leakedPasswordList" items="[[leakedPasswords]]"> <iron-list id="leakedPasswordList" items="[[leakedPasswords]]">
<template> <template>
<password-check-list-item item="[[item]]"> <password-check-list-item item="[[item]]"
on-more-actions-click="onMoreActionsClick_">
</password-check-list-item> </password-check-list-item>
</template> </template>
</iron-list> </iron-list>
</div> </div>
</div> </div>
<cr-action-menu id="moreActionsMenu" role-description="$i18n{menu}">
<button id="menuShowPassword" class="dropdown-item"
on-click="onMenuShowPasswordClick_">
$i18n{showCompromisedPassword}
</button>
<button id="menuEditPassword" class="dropdown-item"
on-click="onMenuEditPasswordClick_">
$i18n{editCompromisedPassword}
</button>
<button id="menuRemovePassword" class="dropdown-item"
on-click="onMenuRemovePasswordClick_">
$i18n{removeCompromisedPassword}
</button>
</cr-action-menu>
</template> </template>
<script src="password_check.js"></script> <script src="password_check.js"></script>
</dom-module> </dom-module>
...@@ -41,6 +41,13 @@ Polymer({ ...@@ -41,6 +41,13 @@ Polymer({
*/ */
passwordManager_: null, passwordManager_: null,
/**
* The element to return focus to, when the currently active dialog is
* closed.
* @private {?HTMLElement}
*/
activeDialogAnchor_: null,
/** @override */ /** @override */
attached() { attached() {
// Set the manager. These can be overridden by tests. // Set the manager. These can be overridden by tests.
...@@ -97,4 +104,35 @@ Polymer({ ...@@ -97,4 +104,35 @@ Polymer({
hasLeakedCredentials_(list) { hasLeakedCredentials_(list) {
return !!list.length; return !!list.length;
}, },
/**
* @param {!CustomEvent<{moreActionsButton: !HTMLElement}>} event
* @private
*/
onMoreActionsClick_(event) {
const target = event.detail.moreActionsButton;
this.$.moreActionsMenu.showAt(target);
this.activeDialogAnchor_ = target;
},
/** @private */
onMenuShowPasswordClick_() {
this.$.moreActionsMenu.close();
// TODO(crbug.com/1047726) Implement dialog.
},
/** @private */
onMenuEditPasswordClick_() {
this.$.moreActionsMenu.close();
// TODO(crbug.com/1047726) Implement dialog.
},
/** @private */
onMenuRemovePasswordClick_() {
this.$.moreActionsMenu.close();
// TODO(crbug.com/1047726) Implement dialog.
},
}); });
...@@ -73,8 +73,9 @@ ...@@ -73,8 +73,9 @@
</iron-icon> </iron-icon>
</cr-button> </cr-button>
</div> </div>
<cr-icon-button class="icon-more-vert" <cr-icon-button class="icon-more-vert" id="more"
title="$i18n{moreActions}"></cr-icon-button> title="$i18n{moreActions}" on-click="onMoreClick_">
</cr-icon-button>
</div> </div>
</template> </template>
<script src="password_check_list_item.js"></script> <script src="password_check_list_item.js"></script>
......
...@@ -40,8 +40,16 @@ Polymer({ ...@@ -40,8 +40,16 @@ Polymer({
*/ */
onChangePasswordClick_() { onChangePasswordClick_() {
const url = this.item.changePasswordUrl; const url = this.item.changePasswordUrl;
if(url) { if (url) {
settings.OpenWindowProxyImpl.getInstance().openURL(url); settings.OpenWindowProxyImpl.getInstance().openURL(url);
} }
}, },
/**
* @param {!Event} event
* @private
*/
onMoreClick_(event) {
this.fire('more-actions-click', {moreActionsButton: event.target});
},
}); });
...@@ -741,6 +741,9 @@ void AddAutofillStrings(content::WebUIDataSource* html_source, ...@@ -741,6 +741,9 @@ void AddAutofillStrings(content::WebUIDataSource* html_source,
{"phishedPassword", IDS_SETTINGS_COMPROMISED_PASSWORD_REASON_PHISHED}, {"phishedPassword", IDS_SETTINGS_COMPROMISED_PASSWORD_REASON_PHISHED},
{"noCompromisedCredentials", {"noCompromisedCredentials",
IDS_SETTINGS_NO_COMPROMISED_CREDENTIALS_LABEL}, IDS_SETTINGS_NO_COMPROMISED_CREDENTIALS_LABEL},
{"showCompromisedPassword", IDS_SETTINGS_COMPROMISED_PASSWORD_SHOW},
{"editCompromisedPassword", IDS_SETTINGS_COMPROMISED_PASSWORD_EDIT},
{"removeCompromisedPassword", IDS_SETTINGS_COMPROMISED_PASSWORD_REMOVE},
{"creditCards", IDS_AUTOFILL_PAYMENT_METHODS}, {"creditCards", IDS_AUTOFILL_PAYMENT_METHODS},
{"noPaymentMethodsFound", IDS_SETTINGS_PAYMENT_METHODS_NONE}, {"noPaymentMethodsFound", IDS_SETTINGS_PAYMENT_METHODS_NONE},
{"googlePayments", IDS_SETTINGS_GOOGLE_PAYMENTS}, {"googlePayments", IDS_SETTINGS_GOOGLE_PAYMENTS},
......
...@@ -97,5 +97,31 @@ cr.define('settings_passwords_check', function() { ...@@ -97,5 +97,31 @@ cr.define('settings_passwords_check', function() {
checkPasswordSection.$.leakedPasswordList, leakedPasswords); checkPasswordSection.$.leakedPasswordList, leakedPasswords);
}); });
}); });
// Verify that the More Actions menu opens when the button is clicked.
test('testMoreActionsMenu', function() {
const leakedPasswords = [
autofill_test_util.makeCompromisedCredentials(
'google.com', 'jdoerrie', 'LEAKED'),
];
const leakedPasswordsInfo =
autofill_test_util.makeCompromisedCredentialsInfo(
leakedPasswords, '5 min ago');
passwordManager.data.leakedCredentials = leakedPasswordsInfo;
const checkPasswordSection = createCheckPasswordSection();
return passwordManager.whenCalled('getCompromisedCredentialsInfo')
.then(() => {
Polymer.dom.flush();
assertFalse(checkPasswordSection.$.passwordCheckBody.hidden);
const listElements = checkPasswordSection.$.leakedPasswordList;
const node = Polymer.dom(listElements).children[1];
const menu = checkPasswordSection.$.moreActionsMenu;
assertFalse(menu.open);
node.$.more.click();
assertTrue(menu.open);
});
});
}); });
}); });
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