Index: chrome/browser/resources/keyboard_overlay_accessibility_helper.js |
diff --git a/chrome/browser/resources/keyboard_overlay_accessibility_helper.js b/chrome/browser/resources/keyboard_overlay_accessibility_helper.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..79d3300edc59a4bc036b5ed1bb558bfdf7079ec5 |
--- /dev/null |
+++ b/chrome/browser/resources/keyboard_overlay_accessibility_helper.js |
@@ -0,0 +1,55 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// An object to implement keyboard overlay accessiblity. |
+var KeyboardOverlayAccessibilityHelper = { |
+ // Returns true when ChromeVox is loaded and active, false otherwise. |
+ cvoxIsActive: function() { |
+ try { |
+ if (cvox.Api.isChromeVoxActive()) |
+ return true; |
+ } catch (e) { |
+ if (!(e instanceof ReferenceError)) |
mazda
2011/08/16 05:15:46
The following check may work though I haven't test
hashimoto
2011/08/16 07:54:56
Thank you for the suggestion, fixed.
On 2011/08/1
|
+ throw e; |
+ } |
+ return false; |
+ }, |
+ // Speaks given string when ChromeVox is active, do nothing otherwise. |
+ maybeSpeak: function(textString, queueMode, properties) { |
mazda
2011/08/16 05:15:46
This function can be private.
maybeSpeak_
hashimoto
2011/08/16 07:54:56
This method is removed in the new patch set
|
+ if (this.cvoxIsActive()) |
+ cvox.Api.speak(textString, queueMode, properties); |
+ }, |
+ // Stops speaking when ChromeVox is active, do nothing otherwise. |
+ maybeStop: function() { |
mazda
2011/08/16 05:15:46
Ditto
hashimoto
2011/08/16 07:54:56
This method is removed in the new patch set
|
+ if (this.cvoxIsActive()) |
+ cvox.Api.stop(); |
+ }, |
+ // Speaks given shortcut description. |
+ maybeSpeakShortcut: function(keysText, shortcutText) { |
mazda
2011/08/16 05:15:46
Ditto
hashimoto
2011/08/16 07:54:56
Made private
|
+ keysText = keysText.toLowerCase(); // For correct pronunciation. |
+ this.maybeSpeak(keysText, 1, {}); |
+ this.maybeSpeak(shortcutText, 1, {}); |
+ }, |
+ // Speaks all the shortcut with the given modifiers. |
+ maybeSpeakAllShortcuts: function(modifiers) { |
mazda
2011/08/16 05:15:46
How about inserting early exit if cvoxIsActive ret
hashimoto
2011/08/16 07:54:56
Fixed.
|
+ this.maybeStop(); |
+ var keyboardGlyphData = getKeyboardGlyphData(); |
+ var shortcutData = getShortcutData(); |
+ var layout = getLayouts()[keyboardGlyphData.layoutName]; |
+ var keysToShortcutText = {}; |
+ for (var i = 0; i < layout.length; ++i) { |
+ var identifier = remapIdentifier(layout[i][0]); |
+ var keyData = keyboardGlyphData.keys[identifier]; |
+ var keyLabel = getKeyLabel(keyData, modifiers); |
+ var shortcutId = shortcutData[getAction(keyLabel, modifiers)]; |
+ var shortcutText = templateData[shortcutId]; |
+ var keysText = modifiers.concat(keyLabel).join(' + '); |
+ if (shortcutText) |
+ keysToShortcutText[keysText] = shortcutText; |
+ } |
+ for (var keysText in keysToShortcutText) { |
+ this.maybeSpeakShortcut(keysText, keysToShortcutText[keysText]); |
+ } |
+ } |
+}; |