Commit c1ac4f71 authored by Leonard Grey's avatar Leonard Grey Committed by Commit Bot

Ensure password delete bubble is announced to screen readers

Bug: 956433
Change-Id: I7991566418c52643711d79c7fe9d20852ae203b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1729469Reviewed-by: default avatarHector Carmona <hcarmona@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Auto-Submit: Leonard Grey <lgrey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#684334}
parent 9bf39c36
......@@ -1725,7 +1725,7 @@ are declared in tools/grit/grit_rule.gni.
desc="Indicates a download was started in Incognito mode.">
Downloaded in Incognito
</message>
<message name="IDS_DOWNLOAD_UNDO_DESCRIPTION" desc="Shortcut description for undoing an operation, used as a hint for keyboard users">
<message name="IDS_UNDO_DESCRIPTION" desc="Shortcut description for undoing an operation, used as a hint for keyboard users">
Press <ph name="MODIFIER_KEY_DESCRIPTION">$1<ex>Control Z</ex></ph> to undo
</message>
<message name="IDS_DOWNLOAD_UNDO" desc="Menu title for undoing an operation">
......
......@@ -120,7 +120,7 @@ js_library("passwords_section") {
"//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",
"//ui/webui/resources/cr_elements/cr_toast:cr_toast",
"//ui/webui/resources/cr_elements/cr_toast:cr_toast_manager",
"//ui/webui/resources/js:assert",
"//ui/webui/resources/js:i18n_behavior",
"//ui/webui/resources/js:list_property_update_behavior",
......
......@@ -3,7 +3,7 @@
<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_icon_button/cr_icon_button.html">
<link rel="import" href="chrome://resources/cr_elements/cr_toast/cr_toast.html">
<link rel="import" href="chrome://resources/cr_elements/cr_toast/cr_toast_manager.html">
<link rel="import" href="chrome://resources/cr_elements/icons.html">
<link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html">
......@@ -163,12 +163,11 @@
</settings-password-prompt-dialog>
</template>
</if>
<cr-toast id="undoToast" duration="[[toastDuration_]]">
<div id="undoLabel">$i18n{passwordDeleted}</div>
<cr-button on-click="onUndoButtonTap_">
$i18n{undoRemovePassword}
</cr-button>
</cr-toast>
<cr-toast-manager on-undo-click="onUndoButtonTap_"
undo-label="$i18n{undoRemovePassword}"
undo-description="$i18n{undoDescription}"
duration="[[toastDuration_]]">
</cr-toast-manager>
<div class="settings-box block first">
<h2>$i18n{passwordExceptionsHeading}</h2>
</div>
......
......@@ -246,9 +246,8 @@ Polymer({
* @type {function(!Array<PasswordManagerProxy.ExceptionEntry>):void}
*/
(this.setPasswordExceptionsListener_));
if (this.$.undoToast.open) {
this.$.undoToast.hide();
if (cr.toastManager.getInstance().isToastOpen) {
cr.toastManager.getInstance().hide();
}
},
......@@ -338,8 +337,7 @@ Polymer({
onMenuRemovePasswordTap_: function() {
this.passwordManager_.removeSavedPassword(
this.activePassword.item.entry.id);
this.fire('iron-announce', {text: this.$.undoLabel.textContent});
this.$.undoToast.show();
cr.toastManager.getInstance().show(this.i18n('passwordDeleted'));
/** @type {CrActionMenuElement} */ (this.$.menu).close();
},
......@@ -352,7 +350,7 @@ Polymer({
const activeElement = getDeepActiveElement();
if (!activeElement || !isEditable(activeElement)) {
this.passwordManager_.undoRemoveSavedPasswordOrException();
this.$.undoToast.hide();
cr.toastManager.getInstance().hide();
// Preventing the default is necessary to not conflict with a possible
// search action.
event.preventDefault();
......@@ -361,7 +359,7 @@ Polymer({
onUndoButtonTap_: function() {
this.passwordManager_.undoRemoveSavedPasswordOrException();
this.$.undoToast.hide();
cr.toastManager.getInstance().hide();
},
/**
* Fires an event that should delete the password exception.
......
......@@ -52,7 +52,7 @@ content::WebUIDataSource* CreateBookmarksUIHTMLSource(Profile* profile) {
// definitions from JS to C++.
ui::Accelerator undoAccelerator(ui::VKEY_Z, ui::EF_PLATFORM_ACCELERATOR);
source->AddString("undoDescription", l10n_util::GetStringFUTF16(
IDS_BOOKMARK_BAR_UNDO_DESCRIPTION,
IDS_UNDO_DESCRIPTION,
undoAccelerator.GetShortcutText()));
// Localized strings (alphabetical order).
......
......@@ -117,7 +117,7 @@ content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) {
// definitions from JS to C++.
ui::Accelerator undoAccelerator(ui::VKEY_Z, ui::EF_PLATFORM_ACCELERATOR);
source->AddString("undoDescription", l10n_util::GetStringFUTF16(
IDS_DOWNLOAD_UNDO_DESCRIPTION,
IDS_UNDO_DESCRIPTION,
undoAccelerator.GetShortcutText()));
PrefService* prefs = profile->GetPrefs();
......
......@@ -60,6 +60,7 @@
#include "net/base/url_util.h"
#include "services/device/public/cpp/device_features.h"
#include "ui/accessibility/accessibility_switches.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/base/l10n/l10n_util.h"
#if defined(OS_CHROMEOS)
......@@ -1770,6 +1771,12 @@ void AddAutofillStrings(content::WebUIDataSource* html_source,
/*is_test_mode=*/false,
/*log_manager=*/nullptr));
ui::Accelerator undoAccelerator(ui::VKEY_Z, ui::EF_PLATFORM_ACCELERATOR);
html_source->AddString(
"undoDescription",
l10n_util::GetStringFUTF16(IDS_UNDO_DESCRIPTION,
undoAccelerator.GetShortcutText()));
AddLocalizedStringsBulk(html_source, kLocalizedStrings,
base::size(kLocalizedStrings));
}
......
......@@ -559,17 +559,18 @@ cr.define('settings_passwords_section', function() {
const passwordEntry = FakeDataMaker.passwordEntry('goo.gl', 'bart', 1);
const passwordsSection = elementFactory.createPasswordsSection(
passwordManager, [passwordEntry], []);
const toastManager = cr.toastManager.getInstance();
// Click the remove button on the first password and assert that an undo
// toast is shown.
getFirstPasswordListItem(passwordsSection).$$('#passwordMenu').click();
passwordsSection.$.menuRemovePassword.click();
assertTrue(passwordsSection.$.undoToast.open);
assertTrue(toastManager.isToastOpen);
// Remove the passwords section from the DOM and check that this closes
// the undo toast.
document.body.removeChild(passwordsSection);
assertFalse(passwordsSection.$.undoToast.open);
assertFalse(toastManager.isToastOpen);
done();
});
......
<?xml version="1.0" encoding="utf-8"?>
<grit-part>
<message name="IDS_BOOKMARK_BAR_UNDO_DESCRIPTION" desc="Shortcut description for undoing a bookmark operation, used as a hint for keyboard users">
press <ph name="MODIFIER_KEY_DESCRIPTION">$1<ex>Control Z</ex></ph> to undo
</message>
<if expr="not use_titlecase">
<message name="IDS_BOOKMARK_BAR_UNDO" desc="Menu title for undoing a bookmark operation">
&amp;Undo
......
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