Commit 30c13b0b authored by Akihiro Ota's avatar Akihiro Ota Committed by Chromium LUCI CQ

ChromeVox Hint: Ensure the hint is only given once.

This change fixes an issue where giveChromeVoxHint_ was being called
several times. This is likely because it's bound to an event listener,
which isn't removed until several calls have been queued up. To
prevent this, use a variable to track when the hint is given.

Fixed: 1162246
Change-Id: I9e9ed3ac5ce83e7011d29b2edc392d019289803a
AX-Relnotes: N/A
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2613366Reviewed-by: default avatarDenis Kuznetsov [CET] <antrim@chromium.org>
Commit-Queue: Akihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841541}
parent 69f6ce9d
...@@ -129,7 +129,13 @@ Polymer({ ...@@ -129,7 +129,13 @@ Polymer({
* @private {number} * @private {number}
* @const * @const
*/ */
DEFAULT_CHROMEVOX_HINT_TIMEOUT_MS_: {type: Number, value: 40 * 1000} DEFAULT_CHROMEVOX_HINT_TIMEOUT_MS_: {type: Number, value: 40 * 1000},
/**
* Tracks if we've given the ChromeVox hint yet.
* @private
*/
chromeVoxHintGiven_: {type: Boolean, value: false}
}, },
/** Overridden from LoginScreenBehavior. */ /** Overridden from LoginScreenBehavior. */
...@@ -668,7 +674,7 @@ Polymer({ ...@@ -668,7 +674,7 @@ Polymer({
* @private * @private
*/ */
onVoiceNotLoaded_() { onVoiceNotLoaded_() {
if (!this.voicesChangedListenerMaybeGiveChromeVoxHint_) { if (this.voicesChangedListenerMaybeGiveChromeVoxHint_ === undefined) {
// Add voiceschanged listener that tries to give the hint when new voices // Add voiceschanged listener that tries to give the hint when new voices
// are loaded. // are loaded.
this.voicesChangedListenerMaybeGiveChromeVoxHint_ = this.voicesChangedListenerMaybeGiveChromeVoxHint_ =
...@@ -700,6 +706,14 @@ Polymer({ ...@@ -700,6 +706,14 @@ Polymer({
* @private * @private
*/ */
giveChromeVoxHint_(locale, options, isDefaultHint) { giveChromeVoxHint_(locale, options, isDefaultHint) {
if (this.chromeVoxHintGiven_) {
// Only give the hint once.
// Due to event listeners/timeouts, there is the chance that this gets
// called multiple times.
return;
}
this.chromeVoxHintGiven_ = true;
if (isDefaultHint) { if (isDefaultHint) {
console.warn( console.warn(
'No voice available for ' + loadTimeData.getString('language') + 'No voice available for ' + loadTimeData.getString('language') +
......
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