Index: chrome/browser/resources/access_chromevox/chromevox/injected/init.js |
=================================================================== |
--- chrome/browser/resources/access_chromevox/chromevox/injected/init.js (revision 0) |
+++ chrome/browser/resources/access_chromevox/chromevox/injected/init.js (revision 0) |
@@ -0,0 +1,222 @@ |
+// 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. |
+ |
+/** |
+ * @fileoverview Initializes the injected content script. |
+ */ |
+ |
+goog.provide('cvox.ChromeVoxInit'); |
+ |
+goog.require('chromevis.ChromeVisLens'); |
+goog.require('cvox.AndroidDevTtsEngine'); |
+goog.require('cvox.AndroidEarcons'); |
+goog.require('cvox.AndroidRelTtsEngine'); |
+goog.require('cvox.BuildConfig'); |
+goog.require('cvox.ChromeVox'); |
+goog.require('cvox.ChromeVoxEventWatcher'); |
+goog.require('cvox.ChromeVoxKbHandler'); |
+goog.require('cvox.ChromeVoxNavigationManager'); |
+goog.require('cvox.ChromeVoxSearch'); |
+goog.require('cvox.ExtensionBridge'); |
+goog.require('cvox.LocalEarconsManager'); |
+goog.require('cvox.LocalTtsManager'); |
+goog.require('cvox.RemoteEarconsManager'); |
+goog.require('cvox.RemoteTtsManager'); |
+goog.require('cvox.SiteSpecificEnhancements'); |
+goog.require('cvox.TraverseContent'); |
+ |
+/** |
+ * Initializes cvox.ChromeVox. |
+ */ |
+cvox.ChromeVox.init = function() { |
+ if (!goog.isDefAndNotNull(BUILD_TYPE)) { |
+ return; |
+ } |
+ |
+ // Setup globals |
+ cvox.ChromeVox.isActive = true; |
+ cvox.ChromeVox.lens = new chromevis.ChromeVisLens(); |
+ cvox.ChromeVox.traverseContent = new cvox.TraverseContent(); |
+ cvox.ChromeVox.navigationManager = |
+ new cvox.ChromeVoxNavigationManager(); |
+ cvox.ChromeVox.tts = cvox.ChromeVox.createTtsManager(); |
+ cvox.ChromeVox.earcons = cvox.ChromeVox.createEarconsManager( |
+ cvox.ChromeVox.tts); |
+ |
+ // Initialize common components |
+ cvox.ChromeVoxSearch.init(); |
+ |
+ // Start the event watchers |
+ cvox.ChromeVoxEventWatcher.addEventListeners(); |
+ |
+ // Load enhancements |
+ cvox.SiteSpecificEnhancements.load(); |
+ |
+ // Perform build type specific initialization |
+ cvox.ChromeVox.performBuildTypeSpecificInitialization(); |
+ |
+ // Read the settings |
+ cvox.ChromeVox.loadKeyBindings(); |
+}; |
+ |
+/** |
+ * @return {cvox.AbstractTtsManager} New initialized TTS manager. |
+ */ |
+cvox.ChromeVox.createTtsManager = function() { |
+ if (BUILD_TYPE == BUILD_TYPE_CHROME) { |
+ return new cvox.RemoteTtsManager(); |
+ } else if (BUILD_TYPE == BUILD_TYPE_ANDROID) { |
+ return new cvox.LocalTtsManager([cvox.AndroidRelTtsEngine], null); |
+ } else if (BUILD_TYPE == BUILD_TYPE_ANDROID_DEV) { |
+ return new cvox.LocalTtsManager([cvox.AndroidDevTtsEngine], null); |
+ } else { |
+ throw 'Unknown build type: ' + BUILD_TYPE; |
+ } |
+}; |
+ |
+/** |
+ * @return {Object} New initialized earcons manager. |
+ * @param {cvox.AbstractTtsManager} ttsManager A TTS Manager. |
+ */ |
+cvox.ChromeVox.createEarconsManager = function(ttsManager) { |
+ if (BUILD_TYPE == BUILD_TYPE_CHROME) { |
+ return new cvox.RemoteEarconsManager(); |
+ } else if (BUILD_TYPE == BUILD_TYPE_ANDROID || |
+ BUILD_TYPE == BUILD_TYPE_ANDROID_DEV) { |
+ return new cvox.LocalEarconsManager([cvox.AndroidEarcons], ttsManager); |
+ } else { |
+ throw 'Unknown build type: ' + BUILD_TYPE; |
+ } |
+}; |
+ |
+/** |
+ * Performs initialization that is build type specific. |
+ */ |
+cvox.ChromeVox.performBuildTypeSpecificInitialization = function() { |
+ if (BUILD_TYPE == BUILD_TYPE_CHROME) { |
+ // request settings |
+ cvox.ExtensionBridge.send({ |
+ 'target': 'Options', |
+ 'action': 'getSettings' |
+ }); |
+ // Speak the title of the page |
+ cvox.ChromeVox.tts.speak(document.title, 0, null); |
+ } else if (BUILD_TYPE == BUILD_TYPE_ANDROID || |
+ BUILD_TYPE == BUILD_TYPE_ANDROID_DEV) { |
+ /* do nothing */ |
+ } else { |
+ throw 'Unknown build type: ' + BUILD_TYPE; |
+ } |
+}; |
+ |
+/** |
+ * Loads the key bindings. |
+ */ |
+cvox.ChromeVox.loadKeyBindings = function() { |
+ if (BUILD_TYPE == BUILD_TYPE_CHROME) { |
+ cvox.ExtensionBridge.addMessageListener(function(message) { |
+ if (message.keyBindings) { |
+ cvox.ChromeVoxKbHandler.loadKeyToFunctionsTable(message.keyBindings); |
+ } |
+ }); |
+ } else if (BUILD_TYPE == BUILD_TYPE_ANDROID || |
+ BUILD_TYPE == BUILD_TYPE_ANDROID_DEV) { |
+ var keyBindings = cvox.ChromeVox.getStringifiedAndroidKeyBindings(); |
+ cvox.ChromeVoxKbHandler.loadKeyToFunctionsTable( |
+ cvox.ChromeVoxJSON.parse(keyBindings, null)); |
+ return; |
+ } else { |
+ throw 'Unknown build type: ' + BUILD_TYPE; |
+ } |
+}; |
+ |
+/** |
+ * @return {string} The Android key bindings as a JSON string. |
+ */ |
+cvox.ChromeVox.getStringifiedAndroidKeyBindings = function() { |
+ // TODO(svetoslavganov): Change the bindings for Android |
+ return JSON.stringify({ |
+ // Stop TTS |
+ '#17' : 'stopSpeech', // Ctrl |
+ |
+ // TODO(svetoslavganov): Uncomment the key bindings below once |
+ // our handleTab implementation is fixed and the handeShiftTab |
+ // is implemented. For now we use the default browser behavior. |
+ // TAB/Shift+TAB |
+ // '#9' : 'handleTab', // Tab |
+ // 'Shift+#9' : 'handleShiftTab', |
+ |
+ // Basic navigation |
+ // Note that the arrows are bound this way so they |
+ // are consistent with the built-in accessibility support |
+ // in the case of disabled JavaScript. |
+ '#38' : 'backward', |
+ '#40' : 'forward', |
+ 'Shift+#38' : 'nop', // swallow Shift + up arrow |
+ 'Shift+#40' : 'nop', // swallow Shift + down arrow |
+ '#37' : 'nop', // swallow left arrow |
+ '#39' : 'nop', // swallow right arrow |
+ 'Shift+#37' : 'up', |
+ 'Shift+#39' : 'down', |
+ '#13' : 'actOnCurrentItem', // ENTER |
+ 'Shift+#16' : 'nop', // swallow Shift |
+ |
+ // General commands |
+ 'Ctrl+Alt+#191' : 'toggleSearchWidget', // '/' |
+ 'Ctrl+Alt+B' : 'showBookmarkManager', |
+ 'Ctrl+Alt+A' : 'nextTtsEngine', |
+ 'Ctrl+Alt+#189' : 'decreaseTtsRate', // '-' |
+ 'Ctrl+Alt+#187' : 'increaseTtsRate', // '=' |
+ 'Ctrl+Alt+Shift+#189' : 'decreaseTtsPitch', // '-' |
+ 'Ctrl+Alt+Shift+#187' : 'increaseTtsPitch', // '=' |
+ 'Ctrl+Alt+#219' : 'decreaseTtsVolume', // '[' |
+ 'Ctrl+Alt+#221' : 'increaseTtsVolume', // ']' |
+ |
+ // Jump commands |
+ 'Ctrl+Alt+1' : 'nextHeading1', |
+ 'Ctrl+Alt+Shift+1' : 'previousHeading1', |
+ 'Ctrl+Alt+2' : 'nextHeading2', |
+ 'Ctrl+Alt+Shift+2' : 'previousHeading2', |
+ 'Ctrl+Alt+3' : 'nextHeading3', |
+ 'Ctrl+Alt+Shift+3' : 'previousHeading3', |
+ 'Ctrl+Alt+4' : 'nextHeading4', |
+ 'Ctrl+Alt+Shift+4' : 'previousHeading4', |
+ 'Ctrl+Alt+5' : 'nextHeading5', |
+ 'Ctrl+Alt+Shift+5' : 'previousHeading5', |
+ 'Ctrl+Alt+6' : 'nextHeading6', |
+ 'Ctrl+Alt+Shift+6' : 'previousHeading6', |
+ 'Ctrl+Alt+C' : 'nextCheckbox', |
+ 'Ctrl+Alt+Shift+C' : 'previousCheckbox', |
+ 'Ctrl+Alt+E' : 'nextEditText', |
+ 'Ctrl+Alt+Shift+E' : 'previousEditText', |
+ 'Ctrl+Alt+F' : 'nextFormField', |
+ 'Ctrl+Alt+Shift+F' : 'previousFormField', |
+ 'Ctrl+Alt+G' : 'nextGraphic', |
+ 'Ctrl+Alt+Shift+G' : 'previousGraphic', |
+ 'Ctrl+Alt+H' : 'nextHeading', |
+ 'Ctrl+Alt+Shift+H' : 'previousHeading', |
+ 'Ctrl+Alt+I' : 'nextListItem', |
+ 'Ctrl+Alt+Shift+I' : 'previousListItem', |
+ 'Ctrl+Alt+L' : 'nextLink', |
+ 'Ctrl+Alt+Shift+L' : 'previousLink', |
+ 'Ctrl+Alt+N' : 'nextNotLink', |
+ 'Ctrl+Alt+Shift+N' : 'previousNotLink', |
+ 'Ctrl+Alt+O' : 'nextList', |
+ 'Ctrl+Alt+Shift+O' : 'previousList', |
+ 'Ctrl+Alt+Q' : 'nextBlockquote', |
+ 'Ctrl+Alt+Shift+Q' : 'previousBlockquote', |
+ 'Ctrl+Alt+R' : 'nextRadio', |
+ 'Ctrl+Alt+Shift+R' : 'previousRadio', |
+ 'Ctrl+Alt+S' : 'nextSlider', |
+ 'Ctrl+Alt+Shift+S' : 'previousSlider', |
+ 'Ctrl+Alt+T' : 'nextTable', |
+ 'Ctrl+Alt+Shift+T' : 'previousTable', |
+ 'Ctrl+Alt+U' : 'nextButton', |
+ 'Ctrl+Alt+Shift+U' : 'previousButton', |
+ 'Ctrl+Alt+X' : 'nextComboBox', |
+ 'Ctrl+Alt+Shift+X' : 'previousComboBox' |
+ }); |
+}; |
+ |
+window.setTimeout(cvox.ChromeVox.init, 0); |
Property changes on: chrome/browser/resources/access_chromevox/chromevox/injected/init.js |
___________________________________________________________________ |
Added: svn:executable |
+ * |
Added: svn:eol-style |
+ LF |