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