Commit 782edc3e authored by Olesia Marukhno's avatar Olesia Marukhno Committed by Commit Bot

[omnibox] Implementing accessibility for dedicated row and pedals

Add accessibility support for pedals and dedicated row. Updated
announcements for normal state to include information about available
actions (pedals, search, switch to tab). If there are multiple actions
available, they aren't read individually but suggestion to iterate over
them is read. Added announcements for pedal buttons and search button
when they are focused. Message for focused pedals doesn't include
information about suggestion because the suggestion information doesn't
contain any additional information about pedal.

Bug: 1104264
Change-Id: I740afef8c8bc39cadd4ca5f5d5d263f4481d32af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2339626Reviewed-by: default avatarAaron Leventhal <aleventhal@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Commit-Queue: Olesia Marukhno <olesiamarukhno@google.com>
Cr-Commit-Position: refs/heads/master@{#796942}
parent 4de0f84b
......@@ -44,10 +44,18 @@ bool EraseTokenSubsequence(OmniboxPedal::Tokens* from,
OmniboxPedal::LabelStrings::LabelStrings(int id_hint,
int id_hint_short,
int id_suggestion_contents)
int id_suggestion_contents,
int id_accessibility_suffix,
int id_accessibility_hint)
: hint(l10n_util::GetStringUTF16(id_hint)),
hint_short(l10n_util::GetStringUTF16(id_hint_short)),
suggestion_contents(l10n_util::GetStringUTF16(id_suggestion_contents)) {}
suggestion_contents(l10n_util::GetStringUTF16(id_suggestion_contents)),
id_accessibility_suffix(id_accessibility_suffix),
accessibility_hint(l10n_util::GetStringUTF16(id_accessibility_hint)) {}
OmniboxPedal::LabelStrings::LabelStrings(const LabelStrings&) = default;
OmniboxPedal::LabelStrings::~LabelStrings() = default;
// =============================================================================
......
......@@ -37,10 +37,18 @@ class OmniboxPedal {
typedef std::vector<int> Tokens;
struct LabelStrings {
LabelStrings(int id_hint, int id_hint_short, int id_suggestion_contents);
LabelStrings(int id_hint,
int id_hint_short,
int id_suggestion_contents,
int id_accessibility_suffix,
int id_accessibility_hint);
LabelStrings(const LabelStrings&);
~LabelStrings();
const base::string16 hint;
const base::string16 hint_short;
const base::string16 suggestion_contents;
const int id_accessibility_suffix;
const base::string16 accessibility_hint;
};
class SynonymGroup {
......
......@@ -25,7 +25,9 @@ class OmniboxPedalClearBrowsingData : public OmniboxPedal {
LabelStrings(
IDS_OMNIBOX_PEDAL_CLEAR_BROWSING_DATA_HINT,
IDS_OMNIBOX_PEDAL_CLEAR_BROWSING_DATA_HINT_SHORT,
IDS_OMNIBOX_PEDAL_CLEAR_BROWSING_DATA_SUGGESTION_CONTENTS),
IDS_OMNIBOX_PEDAL_CLEAR_BROWSING_DATA_SUGGESTION_CONTENTS,
IDS_ACC_OMNIBOX_PEDAL_CLEAR_BROWSING_DATA_SUFFIX,
IDS_ACC_OMNIBOX_PEDAL_CLEAR_BROWSING_DATA),
GURL("chrome://settings/clearBrowserData")) {}
};
......@@ -35,10 +37,11 @@ class OmniboxPedalManagePasswords : public OmniboxPedal {
public:
OmniboxPedalManagePasswords()
: OmniboxPedal(
LabelStrings(
IDS_OMNIBOX_PEDAL_MANAGE_PASSWORDS_HINT,
IDS_OMNIBOX_PEDAL_MANAGE_PASSWORDS_HINT_SHORT,
IDS_OMNIBOX_PEDAL_MANAGE_PASSWORDS_SUGGESTION_CONTENTS),
LabelStrings(IDS_OMNIBOX_PEDAL_MANAGE_PASSWORDS_HINT,
IDS_OMNIBOX_PEDAL_MANAGE_PASSWORDS_HINT_SHORT,
IDS_OMNIBOX_PEDAL_MANAGE_PASSWORDS_SUGGESTION_CONTENTS,
IDS_ACC_OMNIBOX_PEDAL_MANAGE_PASSWORDS_SUFFIX,
IDS_ACC_OMNIBOX_PEDAL_MANAGE_PASSWORDS),
GURL("chrome://settings/passwords")) {}
};
......@@ -51,7 +54,9 @@ class OmniboxPedalUpdateCreditCard : public OmniboxPedal {
OmniboxPedal::LabelStrings(
IDS_OMNIBOX_PEDAL_UPDATE_CREDIT_CARD_HINT,
IDS_OMNIBOX_PEDAL_UPDATE_CREDIT_CARD_HINT_SHORT,
IDS_OMNIBOX_PEDAL_UPDATE_CREDIT_CARD_SUGGESTION_CONTENTS),
IDS_OMNIBOX_PEDAL_UPDATE_CREDIT_CARD_SUGGESTION_CONTENTS,
IDS_ACC_OMNIBOX_PEDAL_UPDATE_CREDIT_CARD_SUFFIX,
IDS_ACC_OMNIBOX_PEDAL_UPDATE_CREDIT_CARD),
GURL("chrome://settings/payments")) {}
};
......@@ -61,10 +66,11 @@ class OmniboxPedalLaunchIncognito : public OmniboxPedal {
public:
OmniboxPedalLaunchIncognito()
: OmniboxPedal(
LabelStrings(
IDS_OMNIBOX_PEDAL_LAUNCH_INCOGNITO_HINT,
IDS_OMNIBOX_PEDAL_LAUNCH_INCOGNITO_HINT_SHORT,
IDS_OMNIBOX_PEDAL_LAUNCH_INCOGNITO_SUGGESTION_CONTENTS),
LabelStrings(IDS_OMNIBOX_PEDAL_LAUNCH_INCOGNITO_HINT,
IDS_OMNIBOX_PEDAL_LAUNCH_INCOGNITO_HINT_SHORT,
IDS_OMNIBOX_PEDAL_LAUNCH_INCOGNITO_SUGGESTION_CONTENTS,
IDS_ACC_OMNIBOX_PEDAL_LAUNCH_INCOGNITO_SUFFIX,
IDS_ACC_OMNIBOX_PEDAL_LAUNCH_INCOGNITO),
// Fake URL to distinguish matches.
GURL("chrome://newtab?incognito=true")) {}
......@@ -81,7 +87,9 @@ class OmniboxPedalTranslate : public OmniboxPedal {
: OmniboxPedal(
LabelStrings(IDS_OMNIBOX_PEDAL_TRANSLATE_HINT,
IDS_OMNIBOX_PEDAL_TRANSLATE_HINT_SHORT,
IDS_OMNIBOX_PEDAL_TRANSLATE_SUGGESTION_CONTENTS),
IDS_OMNIBOX_PEDAL_TRANSLATE_SUGGESTION_CONTENTS,
IDS_ACC_OMNIBOX_PEDAL_TRANSLATE_SUFFIX,
IDS_ACC_OMNIBOX_PEDAL_TRANSLATE),
// Fake URL to distinguish matches.
GURL("chrome://translate/pedals")) {}
......@@ -98,7 +106,9 @@ class OmniboxPedalUpdateChrome : public OmniboxPedal {
: OmniboxPedal(
LabelStrings(IDS_OMNIBOX_PEDAL_UPDATE_CHROME_HINT,
IDS_OMNIBOX_PEDAL_UPDATE_CHROME_HINT_SHORT,
IDS_OMNIBOX_PEDAL_UPDATE_CHROME_SUGGESTION_CONTENTS),
IDS_OMNIBOX_PEDAL_UPDATE_CHROME_SUGGESTION_CONTENTS,
IDS_ACC_OMNIBOX_PEDAL_UPDATE_CHROME_SUFFIX,
IDS_ACC_OMNIBOX_PEDAL_UPDATE_CHROME),
GURL("chrome://settings/help")) {}
};
......
......@@ -52,7 +52,9 @@ TEST_F(OmniboxPedalTest, SynonymGroupsDriveConceptMatches) {
OmniboxPedal::LabelStrings(
IDS_OMNIBOX_PEDAL_CLEAR_BROWSING_DATA_HINT,
IDS_OMNIBOX_PEDAL_CLEAR_BROWSING_DATA_HINT_SHORT,
IDS_OMNIBOX_PEDAL_CLEAR_BROWSING_DATA_SUGGESTION_CONTENTS),
IDS_OMNIBOX_PEDAL_CLEAR_BROWSING_DATA_SUGGESTION_CONTENTS,
IDS_ACC_OMNIBOX_PEDAL_CLEAR_BROWSING_DATA_SUFFIX,
IDS_ACC_OMNIBOX_PEDAL_CLEAR_BROWSING_DATA),
GURL());
const auto add_group = [&](bool required, int token) {
OmniboxPedal::SynonymGroup group(required, true, 1);
......
......@@ -15,6 +15,7 @@
#include "components/omnibox/browser/omnibox_client.h"
#include "components/omnibox/browser/omnibox_edit_controller.h"
#include "components/omnibox/browser/omnibox_field_trial.h"
#include "components/omnibox/browser/omnibox_pedal.h"
#include "components/omnibox/browser/omnibox_popup_view.h"
#include "components/omnibox/browser/omnibox_prefs.h"
#include "components/strings/grit/components_strings.h"
......@@ -608,28 +609,43 @@ base::string16 OmniboxPopupModel::GetAccessibilityLabelForCurrentSelection(
message_id,
result().GetHeaderForGroupId(match.suggestion_group_id.value()));
}
case NORMAL:
case NORMAL: {
int available_actions_count = 0;
if (IsControlPresentOnMatch(Selection(line, FOCUSED_BUTTON_TAB_SWITCH))) {
additional_message_id = IDS_ACC_TAB_SWITCH_SUFFIX;
available_actions_count++;
}
if (IsControlPresentOnMatch(Selection(line, FOCUSED_BUTTON_KEYWORD))) {
additional_message_id = IDS_ACC_KEYWORD_SUFFIX;
available_actions_count++;
}
if (IsControlPresentOnMatch(Selection(line, FOCUSED_BUTTON_PEDAL))) {
additional_message_id =
match.pedal->GetLabelStrings().id_accessibility_suffix;
available_actions_count++;
}
DCHECK_EQ(LINE_STATE_MAX_VALUE, 7);
if (available_actions_count > 1)
additional_message_id = IDS_ACC_MULTIPLE_ACTIONS_SUFFIX;
// Don't add an additional message for removable suggestions without
// button focus, since they are relatively common.
break;
}
case KEYWORD_MODE:
// TODO(tommycli): Investigate whether the accessibility messaging for
// Keyword mode belongs here.
break;
case FOCUSED_BUTTON_KEYWORD:
// TODO(yoangela): Add an accessibility message for the Keyword button
// in the button-row UI configuration.
additional_message_id = IDS_ACC_KEYWORD_BUTTON;
break;
case FOCUSED_BUTTON_TAB_SWITCH:
additional_message_id = IDS_ACC_TAB_SWITCH_BUTTON_FOCUSED_PREFIX;
break;
case FOCUSED_BUTTON_PEDAL:
// TODO(orinj): Add an accessibility message for the Pedal button
// in the button-row UI configuration.
break;
// When pedal button is focused, the autocomplete suggestion isn't
// read because it's not relevant to the button's action.
return match.pedal->GetLabelStrings().accessibility_hint;
case FOCUSED_BUTTON_REMOVE_SUGGESTION:
additional_message_id = IDS_ACC_REMOVE_SUGGESTION_FOCUSED_PREFIX;
break;
......
......@@ -81,6 +81,11 @@ class OmniboxPopupModel {
// FOCUSED_BUTTON_REMOVE_SUGGESTION state means the Remove Suggestion (X)
// button is focused. Pressing enter will attempt to remove this suggestion.
FOCUSED_BUTTON_REMOVE_SUGGESTION = 6,
// Whenever new line state is added, accessibility label for current
// selection should be revisited
// (OmniboxPopupModel::GetAccessibilityLabelForCurrentSelection).
LINE_STATE_MAX_VALUE
};
struct Selection {
......
......@@ -109,6 +109,12 @@
<message name="IDS_OMNIBOX_PEDAL_CLEAR_BROWSING_DATA_SUGGESTION_CONTENTS" desc="The suggestion content text to suggest pedal action, clear browsing data.">
Clear your browsing history, cookies, cache, and more in Chrome settings
</message>
<message name="IDS_ACC_OMNIBOX_PEDAL_CLEAR_BROWSING_DATA_SUFFIX" desc="Suffix for spoken suggestion description with clear data pedal action to explain keystroke used to clear browsing data.">
<ph name="CLEAR_BROWSING_DATA_FOCUSED_FRIENDLY_MATCH_TEXT">$1<ex>The Chromium Projects http://www.chromium.org bookmark</ex></ph>, press Tab then Enter to clear Chrome's browsing history data
</message>
<message name="IDS_ACC_OMNIBOX_PEDAL_CLEAR_BROWSING_DATA" desc="Announcement when clear browsing data pedal button is focused.">
Clear Data button, press Enter to clear Chrome's browsing history data
</message>
<message name="IDS_OMNIBOX_PEDAL_MANAGE_PASSWORDS_HINT" desc="The button text contents to suggest pedal action, manage passwords.">
Manage passwords
......@@ -119,6 +125,12 @@
<message name="IDS_OMNIBOX_PEDAL_MANAGE_PASSWORDS_SUGGESTION_CONTENTS" desc="The suggestion content text to suggest pedal action, change language.">
View and manage your passwords in Chrome settings
</message>
<message name="IDS_ACC_OMNIBOX_PEDAL_MANAGE_PASSWORDS_SUFFIX" desc="Suffix for spoken suggestion description with manage passwords pedal action to explain keystroke used to manage passwords.">
<ph name="MANAGE_PASSWORDS_FOCUSED_FRIENDLY_MATCH_TEXT">$1<ex>The Chromium Projects http://www.chromium.org bookmark</ex></ph>, press Tab then Enter to manage passwords in Chrome settings
</message>
<message name="IDS_ACC_OMNIBOX_PEDAL_MANAGE_PASSWORDS" desc="Announcement when manage passwords pedal button is focused.">
Manage Passwords button, press Enter to manage passwords in Chrome settings
</message>
<message name="IDS_OMNIBOX_PEDAL_UPDATE_CREDIT_CARD_HINT" desc="The button text contents to suggest pedal action, update credit card.">
Manage payment methods
......@@ -129,6 +141,12 @@
<message name="IDS_OMNIBOX_PEDAL_UPDATE_CREDIT_CARD_SUGGESTION_CONTENTS" desc="The suggestion content text to suggest pedal action, update credit card.">
Manage your payments and credit card info in Chrome settings
</message>
<message name="IDS_ACC_OMNIBOX_PEDAL_UPDATE_CREDIT_CARD_SUFFIX" desc="Suffix for spoken suggestion description with update credit card pedal action to explain keystroke used to manage passwords.">
<ph name="UPDATE_CREDIT_CARD_FOCUSED_FRIENDLY_MATCH_TEXT">$1<ex>The Chromium Projects http://www.chromium.org bookmark</ex></ph>, press Tab then Enter to update credit card autofill info in Chrome settings
</message>
<message name="IDS_ACC_OMNIBOX_PEDAL_UPDATE_CREDIT_CARD" desc="Announcement when update credit card pedal button is focused.">
Update Credit Card button, press Enter to update credit card autofill info in Chrome settings
</message>
<message name="IDS_OMNIBOX_PEDAL_LAUNCH_INCOGNITO_HINT" desc="The button text contents to suggest pedal action, launch incognito.">
Open Incognito window
......@@ -139,6 +157,12 @@
<message name="IDS_OMNIBOX_PEDAL_LAUNCH_INCOGNITO_SUGGESTION_CONTENTS" desc="The suggestion content text to suggest pedal action, launch incognito.">
Open a new Incognito window to browse privately
</message>
<message name="IDS_ACC_OMNIBOX_PEDAL_LAUNCH_INCOGNITO_SUFFIX" desc="Suffix for spoken suggestion description with launch incognito pedal action to explain keystroke used to manage passwords.">
<ph name="LAUNCH_INCOGNITO_FOCUSED_FRIENDLY_MATCH_TEXT">$1<ex>The Chromium Projects http://www.chromium.org bookmark</ex></ph>, press Tab then Enter to open new Chrome incognito window
</message>
<message name="IDS_ACC_OMNIBOX_PEDAL_LAUNCH_INCOGNITO" desc="Announcement when launch incognito pedal button is focused.">
Open Incognito Window button, press Enter to open new Chrome incognito window
</message>
<message name="IDS_OMNIBOX_PEDAL_TRANSLATE_HINT" desc="The button text contents to suggest pedal action, translate.">
Translate page
......@@ -149,6 +173,12 @@
<message name="IDS_OMNIBOX_PEDAL_TRANSLATE_SUGGESTION_CONTENTS" desc="The suggestion content text to suggest pedal action, translate.">
Translate this page with Google Translate
</message>
<message name="IDS_ACC_OMNIBOX_PEDAL_TRANSLATE_SUFFIX" desc="Suffix for spoken suggestion description with translate pedal action to explain keystroke used to manage passwords.">
<ph name="TRANSLATE_FOCUSED_FRIENDLY_MATCH_TEXT">$1<ex>The Chromium Projects http://www.chromium.org bookmark</ex></ph>, press Tab then Enter to translate this page
</message>
<message name="IDS_ACC_OMNIBOX_PEDAL_TRANSLATE" desc="Announcement when translate pedal button is focused.">
Translate Page button, press Enter to translate this page
</message>
<message name="IDS_OMNIBOX_PEDAL_UPDATE_CHROME_HINT" desc="The button text contents to suggest pedal action, update chrome.">
Update Chrome
......@@ -159,6 +189,12 @@
<message name="IDS_OMNIBOX_PEDAL_UPDATE_CHROME_SUGGESTION_CONTENTS" desc="The suggestion content text to suggest pedal action, update chrome.">
Update Chrome from your Chrome settings
</message>
<message name="IDS_ACC_OMNIBOX_PEDAL_UPDATE_CHROME_SUFFIX" desc="Suffix for spoken suggestion description with update chrome pedal action to explain keystroke used to manage passwords.">
<ph name="UPDATE_CHROME_FOCUSED_FRIENDLY_MATCH_TEXT">$1<ex>The Chromium Projects http://www.chromium.org bookmark</ex></ph>, press Tab then Enter to update Chrome
</message>
<message name="IDS_ACC_OMNIBOX_PEDAL_UPDATE_CHROME" desc="Announcement when update chrome pedal button is focused.">
Relaunch to Update button, press Enter to update Chrome
</message>
<!-- Accessibility labels for autocomplete match types.
These are parameterized on the text being completed into the omnibox.
......@@ -211,6 +247,17 @@
<message name="IDS_ACC_TAB_SWITCH_BUTTON" desc="Announcement when tab switch button focused.">
Tab switch button, press Enter to switch to this tab
</message>
<message name="IDS_ACC_MULTIPLE_ACTIONS_SUFFIX" desc="Suffix for spoken suggestion description with multiple actions available (pedals, switch tab, keyword search) to indicate that this suggestion has multiple actions available.">
<ph name="MULTIPLE_ACTIONS_FOCUSED_FRIENDLY_MATCH_TEXT">$1<ex>The Chromium Projects http://www.chromium.org bookmark</ex></ph>, multiple actions are available, press Tab to cycle through them
</message>
<message name="IDS_ACC_KEYWORD_SUFFIX" desc="Suffix for spoken keyword suggestion description to explain keystroke used to search.">
<ph name="KEYWORD_FOCUSED_FRIENDLY_MATCH_TEXT">$1<ex>The Chromium Projects http://www.chromium.org bookmark</ex></ph>, press Tab then Enter to search
</message>
<message name="IDS_ACC_KEYWORD_BUTTON" desc="Announcement when keyword search button focused.">
Search button, press Enter to search <ph name="KEYWORD_SUFFIX">$1<ex>Search Youtube</ex></ph>
</message>
<!-- Accessibility suffix for suggestions when the remove button is focused. -->
<message name="IDS_ACC_REMOVE_SUGGESTION_FOCUSED_PREFIX" desc="Announcement when remove suggestion button is focused.">
Remove Suggestion button, press Enter to remove, <ph name="REMOVE_BUTTON_FOCUSED_FRIENDLY_MATCH_TEXT">$1<ex>The Chromium Projects http://www.chromium.org bookmark</ex></ph>
......
006b4c3d0255628f837e20c319c10676cef37109
\ No newline at end of file
167e3431478cbfd40c8ac92b77b246b5c9202358
\ No newline at end of file
e17c4ab73d17f200fae391851dc4f98ce5817ef2
\ No newline at end of file
4361ca28e97038007846b05a11ff6b4f669f6c20
\ No newline at end of file
1de3f2f59c873f339459f3144c42a51fa61df8af
\ No newline at end of file
9271ad409aabe1ff88f4038500a0122a1d3b9920
\ No newline at end of file
1643cbffd07497fd70b09c01493aafdef0ec5ac0
\ No newline at end of file
02dc80bf06286f288fe3afcd62ed6e470936946a
\ No newline at end of file
e39177ad8f4c1195f2f8397d62394110b77d62c1
\ No newline at end of file
d35a775dc904ac5bb6c5de015eb8f824c8532616
\ No newline at end of file
80917d536b163b57c1111331cdcfdb982167639c
\ No newline at end of file
1d06b2efdb6b0314f979665c025ce1c1577d327c
\ No newline at end of file
be0b21c471c6a17df3d466b7136f73796c77b4c4
\ No newline at end of file
f17c75e5b016def05c96fad398d44921f5d2242e
\ No newline at end of file
d8eefdbdef87e96900e627d107e8ca910dabb8eb
\ No newline at end of file
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