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..c28a5001c2ceede9fae96f14d36943ae1c472a20 |
--- /dev/null |
+++ b/chrome/browser/resources/keyboard_overlay_accessibility_helper.js |
@@ -0,0 +1,40 @@ |
+// 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() { |
+ return window.cvox && window.cvox.Api.isChromeVoxActive(); |
+ }, |
+ // Speaks all the shortcut with the given modifiers. |
+ maybeSpeakAllShortcuts: function(modifiers) { |
+ if (!this.cvoxIsActive()) |
+ return; |
+ cvox.Api.stop(); |
+ 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.speakShortcut_(keysText, keysToShortcutText[keysText]); |
+ } |
+ }, |
+ // Speaks given shortcut description. |
+ speakShortcut_: function(keysText, shortcutText) { |
+ keysText = keysText.toLowerCase(); // For correct pronunciation. |
+ cvox.Api.speak(keysText, 1, {}); |
+ cvox.Api.speak(shortcutText, 1, {}); |
+ }, |
hashimoto
2011/08/16 07:54:56
Moved speakShortcut to the end part of the class b
|
+}; |