Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1072)

Side by Side Diff: chrome/browser/resources/access_chromevox/chromevox/injected/init.js

Issue 6254007: Adding ChromeVox as a component extensions (enabled only for ChromeOS, for no... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:executable
+ *
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview Initializes the injected content script.
7 */
8
9 goog.provide('cvox.ChromeVoxInit');
10
11 goog.require('chromevis.ChromeVisLens');
12 goog.require('cvox.AndroidDevTtsEngine');
13 goog.require('cvox.AndroidEarcons');
14 goog.require('cvox.AndroidRelTtsEngine');
15 goog.require('cvox.BuildConfig');
16 goog.require('cvox.ChromeVox');
17 goog.require('cvox.ChromeVoxEventWatcher');
18 goog.require('cvox.ChromeVoxKbHandler');
19 goog.require('cvox.ChromeVoxNavigationManager');
20 goog.require('cvox.ChromeVoxSearch');
21 goog.require('cvox.ExtensionBridge');
22 goog.require('cvox.LocalEarconsManager');
23 goog.require('cvox.LocalTtsManager');
24 goog.require('cvox.RemoteEarconsManager');
25 goog.require('cvox.RemoteTtsManager');
26 goog.require('cvox.SiteSpecificEnhancements');
27 goog.require('cvox.TraverseContent');
28
29 /**
30 * Initializes cvox.ChromeVox.
31 */
32 cvox.ChromeVox.init = function() {
33 if (!goog.isDefAndNotNull(BUILD_TYPE)) {
34 return;
35 }
36
37 // Setup globals
38 cvox.ChromeVox.isActive = true;
39 cvox.ChromeVox.lens = new chromevis.ChromeVisLens();
40 cvox.ChromeVox.traverseContent = new cvox.TraverseContent();
41 cvox.ChromeVox.navigationManager =
42 new cvox.ChromeVoxNavigationManager();
43 cvox.ChromeVox.tts = cvox.ChromeVox.createTtsManager();
44 cvox.ChromeVox.earcons = cvox.ChromeVox.createEarconsManager(
45 cvox.ChromeVox.tts);
46
47 // Initialize common components
48 cvox.ChromeVoxSearch.init();
49
50 // Start the event watchers
51 cvox.ChromeVoxEventWatcher.addEventListeners();
52
53 // Load enhancements
54 cvox.SiteSpecificEnhancements.load();
55
56 // Perform build type specific initialization
57 cvox.ChromeVox.performBuildTypeSpecificInitialization();
58
59 // Read the settings
60 cvox.ChromeVox.loadKeyBindings();
61 };
62
63 /**
64 * @return {cvox.AbstractTtsManager} New initialized TTS manager.
65 */
66 cvox.ChromeVox.createTtsManager = function() {
67 if (BUILD_TYPE == BUILD_TYPE_CHROME) {
68 return new cvox.RemoteTtsManager();
69 } else if (BUILD_TYPE == BUILD_TYPE_ANDROID) {
70 return new cvox.LocalTtsManager([cvox.AndroidRelTtsEngine], null);
71 } else if (BUILD_TYPE == BUILD_TYPE_ANDROID_DEV) {
72 return new cvox.LocalTtsManager([cvox.AndroidDevTtsEngine], null);
73 } else {
74 throw 'Unknown build type: ' + BUILD_TYPE;
75 }
76 };
77
78 /**
79 * @return {Object} New initialized earcons manager.
80 * @param {cvox.AbstractTtsManager} ttsManager A TTS Manager.
81 */
82 cvox.ChromeVox.createEarconsManager = function(ttsManager) {
83 if (BUILD_TYPE == BUILD_TYPE_CHROME) {
84 return new cvox.RemoteEarconsManager();
85 } else if (BUILD_TYPE == BUILD_TYPE_ANDROID ||
86 BUILD_TYPE == BUILD_TYPE_ANDROID_DEV) {
87 return new cvox.LocalEarconsManager([cvox.AndroidEarcons], ttsManager);
88 } else {
89 throw 'Unknown build type: ' + BUILD_TYPE;
90 }
91 };
92
93 /**
94 * Performs initialization that is build type specific.
95 */
96 cvox.ChromeVox.performBuildTypeSpecificInitialization = function() {
97 if (BUILD_TYPE == BUILD_TYPE_CHROME) {
98 // request settings
99 cvox.ExtensionBridge.send({
100 'target': 'Options',
101 'action': 'getSettings'
102 });
103 // Speak the title of the page
104 cvox.ChromeVox.tts.speak(document.title, 0, null);
105 } else if (BUILD_TYPE == BUILD_TYPE_ANDROID ||
106 BUILD_TYPE == BUILD_TYPE_ANDROID_DEV) {
107 /* do nothing */
108 } else {
109 throw 'Unknown build type: ' + BUILD_TYPE;
110 }
111 };
112
113 /**
114 * Loads the key bindings.
115 */
116 cvox.ChromeVox.loadKeyBindings = function() {
117 if (BUILD_TYPE == BUILD_TYPE_CHROME) {
118 cvox.ExtensionBridge.addMessageListener(function(message) {
119 if (message.keyBindings) {
120 cvox.ChromeVoxKbHandler.loadKeyToFunctionsTable(message.keyBindings);
121 }
122 });
123 } else if (BUILD_TYPE == BUILD_TYPE_ANDROID ||
124 BUILD_TYPE == BUILD_TYPE_ANDROID_DEV) {
125 var keyBindings = cvox.ChromeVox.getStringifiedAndroidKeyBindings();
126 cvox.ChromeVoxKbHandler.loadKeyToFunctionsTable(
127 cvox.ChromeVoxJSON.parse(keyBindings, null));
128 return;
129 } else {
130 throw 'Unknown build type: ' + BUILD_TYPE;
131 }
132 };
133
134 /**
135 * @return {string} The Android key bindings as a JSON string.
136 */
137 cvox.ChromeVox.getStringifiedAndroidKeyBindings = function() {
138 // TODO(svetoslavganov): Change the bindings for Android
139 return JSON.stringify({
140 // Stop TTS
141 '#17' : 'stopSpeech', // Ctrl
142
143 // TODO(svetoslavganov): Uncomment the key bindings below once
144 // our handleTab implementation is fixed and the handeShiftTab
145 // is implemented. For now we use the default browser behavior.
146 // TAB/Shift+TAB
147 // '#9' : 'handleTab', // Tab
148 // 'Shift+#9' : 'handleShiftTab',
149
150 // Basic navigation
151 // Note that the arrows are bound this way so they
152 // are consistent with the built-in accessibility support
153 // in the case of disabled JavaScript.
154 '#38' : 'backward',
155 '#40' : 'forward',
156 'Shift+#38' : 'nop', // swallow Shift + up arrow
157 'Shift+#40' : 'nop', // swallow Shift + down arrow
158 '#37' : 'nop', // swallow left arrow
159 '#39' : 'nop', // swallow right arrow
160 'Shift+#37' : 'up',
161 'Shift+#39' : 'down',
162 '#13' : 'actOnCurrentItem', // ENTER
163 'Shift+#16' : 'nop', // swallow Shift
164
165 // General commands
166 'Ctrl+Alt+#191' : 'toggleSearchWidget', // '/'
167 'Ctrl+Alt+B' : 'showBookmarkManager',
168 'Ctrl+Alt+A' : 'nextTtsEngine',
169 'Ctrl+Alt+#189' : 'decreaseTtsRate', // '-'
170 'Ctrl+Alt+#187' : 'increaseTtsRate', // '='
171 'Ctrl+Alt+Shift+#189' : 'decreaseTtsPitch', // '-'
172 'Ctrl+Alt+Shift+#187' : 'increaseTtsPitch', // '='
173 'Ctrl+Alt+#219' : 'decreaseTtsVolume', // '['
174 'Ctrl+Alt+#221' : 'increaseTtsVolume', // ']'
175
176 // Jump commands
177 'Ctrl+Alt+1' : 'nextHeading1',
178 'Ctrl+Alt+Shift+1' : 'previousHeading1',
179 'Ctrl+Alt+2' : 'nextHeading2',
180 'Ctrl+Alt+Shift+2' : 'previousHeading2',
181 'Ctrl+Alt+3' : 'nextHeading3',
182 'Ctrl+Alt+Shift+3' : 'previousHeading3',
183 'Ctrl+Alt+4' : 'nextHeading4',
184 'Ctrl+Alt+Shift+4' : 'previousHeading4',
185 'Ctrl+Alt+5' : 'nextHeading5',
186 'Ctrl+Alt+Shift+5' : 'previousHeading5',
187 'Ctrl+Alt+6' : 'nextHeading6',
188 'Ctrl+Alt+Shift+6' : 'previousHeading6',
189 'Ctrl+Alt+C' : 'nextCheckbox',
190 'Ctrl+Alt+Shift+C' : 'previousCheckbox',
191 'Ctrl+Alt+E' : 'nextEditText',
192 'Ctrl+Alt+Shift+E' : 'previousEditText',
193 'Ctrl+Alt+F' : 'nextFormField',
194 'Ctrl+Alt+Shift+F' : 'previousFormField',
195 'Ctrl+Alt+G' : 'nextGraphic',
196 'Ctrl+Alt+Shift+G' : 'previousGraphic',
197 'Ctrl+Alt+H' : 'nextHeading',
198 'Ctrl+Alt+Shift+H' : 'previousHeading',
199 'Ctrl+Alt+I' : 'nextListItem',
200 'Ctrl+Alt+Shift+I' : 'previousListItem',
201 'Ctrl+Alt+L' : 'nextLink',
202 'Ctrl+Alt+Shift+L' : 'previousLink',
203 'Ctrl+Alt+N' : 'nextNotLink',
204 'Ctrl+Alt+Shift+N' : 'previousNotLink',
205 'Ctrl+Alt+O' : 'nextList',
206 'Ctrl+Alt+Shift+O' : 'previousList',
207 'Ctrl+Alt+Q' : 'nextBlockquote',
208 'Ctrl+Alt+Shift+Q' : 'previousBlockquote',
209 'Ctrl+Alt+R' : 'nextRadio',
210 'Ctrl+Alt+Shift+R' : 'previousRadio',
211 'Ctrl+Alt+S' : 'nextSlider',
212 'Ctrl+Alt+Shift+S' : 'previousSlider',
213 'Ctrl+Alt+T' : 'nextTable',
214 'Ctrl+Alt+Shift+T' : 'previousTable',
215 'Ctrl+Alt+U' : 'nextButton',
216 'Ctrl+Alt+Shift+U' : 'previousButton',
217 'Ctrl+Alt+X' : 'nextComboBox',
218 'Ctrl+Alt+Shift+X' : 'previousComboBox'
219 });
220 };
221
222 window.setTimeout(cvox.ChromeVox.init, 0);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698