[omnibox] Add accessibility label to suggestions with tab switch button
For suggestions with a tab switch button, advertise the ability to tab
over to it and press enter, in the accessibility label.
Bug: 780835, 853911, 853929
Change-Id: I91649d0517ab6e75970e49b5358e7d210c914071
Reviewed-on: https://chromium-review.googlesource.com/1106706
Reviewed-by: Aaron Leventhal <[email protected]>
Reviewed-by: Justin Donnelly <[email protected]>
Commit-Queue: Kevin Bailey <[email protected]>
Cr-Commit-Position: refs/heads/master@{#575283}
diff --git a/components/omnibox/browser/autocomplete_match_type.cc b/components/omnibox/browser/autocomplete_match_type.cc
index 803b262..65145ee2 100644
--- a/components/omnibox/browser/autocomplete_match_type.cc
+++ b/components/omnibox/browser/autocomplete_match_type.cc
@@ -106,8 +106,12 @@
*label_prefix_length = 0;
int message = message_ids[match.type];
- if (!message)
- return match_text;
+ if (!message) {
+ if (!match.has_tab_match)
+ return match_text;
+ else
+ return l10n_util::GetStringFUTF16(IDS_ACC_TAB_SWITCH_SUFFIX, match_text);
+ }
const base::string16 sentinal =
base::WideToUTF16(kAccessibilityLabelPrefixEndSentinal);
@@ -159,9 +163,14 @@
l10n_util::GetStringFUTF16(message, sentinal));
}
- return has_description
- ? l10n_util::GetStringFUTF16(message, match_text, description)
- : l10n_util::GetStringFUTF16(message, match_text);
+ const base::string16 base_message =
+ has_description
+ ? l10n_util::GetStringFUTF16(message, match_text, description)
+ : l10n_util::GetStringFUTF16(message, match_text);
+ if (!match.has_tab_match)
+ return base_message;
+ else
+ return l10n_util::GetStringFUTF16(IDS_ACC_TAB_SWITCH_SUFFIX, base_message);
}
// static
diff --git a/components/omnibox_strings.grdp b/components/omnibox_strings.grdp
index 330c6d2..9a87a8c 100644
--- a/components/omnibox_strings.grdp
+++ b/components/omnibox_strings.grdp
@@ -87,4 +87,8 @@
<message name="IDS_ACC_AUTOCOMPLETE_N_OF_M" desc="Text for screenreaders describing the current matche's position in the list of suggestions.">
<ph name="FRIENDLY_MATCH_TEXT">$1<ex>The Chromium Projects http://www.chromium.org bookmark</ex></ph>, <ph name="MATCH_POSITION">$2<ex>2</ex></ph> of <ph name="NUM_MATCHES">$3<ex>3</ex></ph>
</message>
+ <!-- Accessibility suffix for suggestions with a tab switch match. Comma is important. -->
+ <message name="IDS_ACC_TAB_SWITCH_SUFFIX" desc="Suffix for tab switch suggestions to explain keystroke used to switch.">
+ <ph name="TAB_SWITCH_SUFFIX">$1, currently open, press tab then enter to switch to the open tab</ph>
+ </message>
</grit-part>