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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/desktop_automation_handler.js

Issue 2601333002: Update json_schema_compiler to handle the Automation extension API (Closed)
Patch Set: Better solution Created 3 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Handles automation from a desktop automation node. 6 * @fileoverview Handles automation from a desktop automation node.
7 */ 7 */
8 8
9 goog.provide('DesktopAutomationHandler'); 9 goog.provide('DesktopAutomationHandler');
10 10
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 this.addListener_(e.textChanged, this.onTextChanged); 65 this.addListener_(e.textChanged, this.onTextChanged);
66 this.addListener_(e.textSelectionChanged, this.onTextSelectionChanged); 66 this.addListener_(e.textSelectionChanged, this.onTextSelectionChanged);
67 this.addListener_(e.valueChanged, this.onValueChanged); 67 this.addListener_(e.valueChanged, this.onValueChanged);
68 68
69 AutomationObjectConstructorInstaller.init(node, function() { 69 AutomationObjectConstructorInstaller.init(node, function() {
70 chrome.automation.getFocus((function(focus) { 70 chrome.automation.getFocus((function(focus) {
71 if (ChromeVoxState.instance.mode != ChromeVoxMode.FORCE_NEXT) 71 if (ChromeVoxState.instance.mode != ChromeVoxMode.FORCE_NEXT)
72 return; 72 return;
73 73
74 if (focus) { 74 if (focus) {
75 this.onFocus( 75 » var event = new chrome.automation.AutomationEvent();
Devlin 2017/01/04 23:54:21 rietveld thinks there's an illegal character here,
76 new chrome.automation.AutomationEvent( 76 » event.type = EventType.focus;
77 EventType.focus, focus, 'page')); 77 » event.target = focus;
78 » event.eventFrom = 'page';
79 this.onFocus(event);
78 } 80 }
79 }).bind(this)); 81 }).bind(this));
80 }.bind(this)); 82 }.bind(this));
81 }; 83 };
82 84
83 /** 85 /**
84 * Time to wait until processing more value changed events. 86 * Time to wait until processing more value changed events.
85 * @const {number} 87 * @const {number}
86 */ 88 */
87 DesktopAutomationHandler.VMIN_VALUE_CHANGE_DELAY_MS = 500; 89 DesktopAutomationHandler.VMIN_VALUE_CHANGE_DELAY_MS = 500;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 this.onEventDefault(evt); 200 this.onEventDefault(evt);
199 }, 201 },
200 202
201 /** 203 /**
202 * Makes an announcement without changing focus. 204 * Makes an announcement without changing focus.
203 * @param {!AutomationEvent} evt 205 * @param {!AutomationEvent} evt
204 */ 206 */
205 onActiveDescendantChanged: function(evt) { 207 onActiveDescendantChanged: function(evt) {
206 if (!evt.target.activeDescendant || !evt.target.state.focused) 208 if (!evt.target.activeDescendant || !evt.target.state.focused)
207 return; 209 return;
208 this.onEventDefault(new chrome.automation.AutomationEvent( 210 var event = new chrome.automation.AutomationEvent();
209 EventType.focus, evt.target.activeDescendant, evt.eventFrom)); 211 event.type = EventType.focus;
212 event.target = evt.target.activeDescendant;
213 event.eventFrom = evt.eventFrom;
214 this.onEventDefault(event);
210 }, 215 },
211 216
212 /** 217 /**
213 * Makes an announcement without changing focus. 218 * Makes an announcement without changing focus.
214 * @param {!AutomationEvent} evt 219 * @param {!AutomationEvent} evt
215 */ 220 */
216 onAlert: function(evt) { 221 onAlert: function(evt) {
217 var node = evt.target; 222 var node = evt.target;
218 if (!node || !this.shouldOutput_(evt)) 223 if (!node || !this.shouldOutput_(evt))
219 return; 224 return;
220 225
221 var range = cursors.Range.fromNode(node); 226 var range = cursors.Range.fromNode(node);
222 227
223 new Output().withSpeechAndBraille(range, null, evt.type).go(); 228 new Output().withSpeechAndBraille(range, null, evt.type).go();
224 }, 229 },
225 230
226 /** 231 /**
227 * Provides all feedback once a checked state changed event fires. 232 * Provides all feedback once a checked state changed event fires.
228 * @param {!AutomationEvent} evt 233 * @param {!AutomationEvent} evt
229 */ 234 */
230 onCheckedStateChanged: function(evt) { 235 onCheckedStateChanged: function(evt) {
231 if (!AutomationPredicate.checkable(evt.target)) 236 if (!AutomationPredicate.checkable(evt.target))
232 return; 237 return;
233 238
234 Output.forceModeForNextSpeechUtterance(cvox.QueueMode.CATEGORY_FLUSH); 239 Output.forceModeForNextSpeechUtterance(cvox.QueueMode.CATEGORY_FLUSH);
235 this.onEventIfInRange( 240 var event = new chrome.automation.AutomationEvent();
236 new chrome.automation.AutomationEvent( 241 event.type = EventType.checkedStateChanged;
237 EventType.checkedStateChanged, evt.target, evt.eventFrom)); 242 event.target = evt.target;
243 event.eventFrom = evt.eventFrom;
244 this.onEventIfInRange(event);
238 }, 245 },
239 246
240 /** 247 /**
241 * Provides all feedback once a focus event fires. 248 * Provides all feedback once a focus event fires.
242 * @param {!AutomationEvent} evt 249 * @param {!AutomationEvent} evt
243 */ 250 */
244 onFocus: function(evt) { 251 onFocus: function(evt) {
245 // Invalidate any previous editable text handler state. 252 // Invalidate any previous editable text handler state.
246 this.textEditHandler_ = null; 253 this.textEditHandler_ = null;
247 254
(...skipping 24 matching lines...) Expand all
272 } 279 }
273 280
274 // If a previous node was saved for this focus, restore it. 281 // If a previous node was saved for this focus, restore it.
275 var savedRange = ChromeVoxState.instance.focusRecoveryMap.get(root); 282 var savedRange = ChromeVoxState.instance.focusRecoveryMap.get(root);
276 ChromeVoxState.instance.focusRecoveryMap.delete(root); 283 ChromeVoxState.instance.focusRecoveryMap.delete(root);
277 if (savedRange) { 284 if (savedRange) {
278 ChromeVoxState.instance.navigateToRange(savedRange, false); 285 ChromeVoxState.instance.navigateToRange(savedRange, false);
279 return; 286 return;
280 } 287 }
281 288
282 this.onEventDefault(new chrome.automation.AutomationEvent( 289 var event = new chrome.automation.AutomationEvent();
283 EventType.focus, node, evt.eventFrom)); 290 event.type = EventType.focus;
291 event.target = node;
292 event.eventFrom = evt.eventFrom;
293 this.onEventDefault(event);
284 }, 294 },
285 295
286 /** 296 /**
287 * Provides all feedback once a load complete event fires. 297 * Provides all feedback once a load complete event fires.
288 * @param {!AutomationEvent} evt 298 * @param {!AutomationEvent} evt
289 */ 299 */
290 onLoadComplete: function(evt) { 300 onLoadComplete: function(evt) {
291 chrome.automation.getFocus(function(focus) { 301 chrome.automation.getFocus(function(focus) {
292 if (!focus || !AutomationUtil.isDescendantOf(focus, evt.target)) 302 if (!focus || !AutomationUtil.isDescendantOf(focus, evt.target))
293 return; 303 return;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 * Provides all feedback once a menu end event fires. 490 * Provides all feedback once a menu end event fires.
481 * @param {!AutomationEvent} evt 491 * @param {!AutomationEvent} evt
482 */ 492 */
483 onMenuEnd: function(evt) { 493 onMenuEnd: function(evt) {
484 this.onEventDefault(evt); 494 this.onEventDefault(evt);
485 495
486 // This is a work around for Chrome context menus not firing a focus event 496 // This is a work around for Chrome context menus not firing a focus event
487 // after you close them. 497 // after you close them.
488 chrome.automation.getFocus(function(focus) { 498 chrome.automation.getFocus(function(focus) {
489 if (focus) { 499 if (focus) {
490 this.onFocus( 500 » var event = new chrome.automation.AutomationEvent();
491 new chrome.automation.AutomationEvent( 501 » event.type = EventType.focus;
492 EventType.focus, focus, 'page')); 502 » event.target = focus;
503 » event.eventFrom = 'page';
504 this.onFocus(event);
493 } 505 }
494 }.bind(this)); 506 }.bind(this));
495 }, 507 },
496 508
497 /** 509 /**
498 * Create an editable text handler for the given node if needed. 510 * Create an editable text handler for the given node if needed.
499 * @param {!AutomationNode} node 511 * @param {!AutomationNode} node
500 */ 512 */
501 createTextEditHandlerIfNeeded_: function(node) { 513 createTextEditHandlerIfNeeded_: function(node) {
502 if (!this.textEditHandler_ || 514 if (!this.textEditHandler_ ||
(...skipping 24 matching lines...) Expand all
527 DesktopAutomationHandler.init_ = function() { 539 DesktopAutomationHandler.init_ = function() {
528 chrome.automation.getDesktop(function(desktop) { 540 chrome.automation.getDesktop(function(desktop) {
529 ChromeVoxState.desktopAutomationHandler = 541 ChromeVoxState.desktopAutomationHandler =
530 new DesktopAutomationHandler(desktop); 542 new DesktopAutomationHandler(desktop);
531 }); 543 });
532 }; 544 };
533 545
534 DesktopAutomationHandler.init_(); 546 DesktopAutomationHandler.init_();
535 547
536 }); // goog.scope 548 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698