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

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

Issue 880063002: Ensure WebView notifies desktop automation on creation, destruction, and change (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 The entry point for all ChromeVox2 related code for the 6 * @fileoverview The entry point for all ChromeVox2 related code for the
7 * background page. 7 * background page.
8 */ 8 */
9 9
10 goog.provide('Background'); 10 goog.provide('Background');
11 goog.provide('global'); 11 goog.provide('global');
12 12
13 goog.require('AutomationPredicate'); 13 goog.require('AutomationPredicate');
14 goog.require('AutomationUtil'); 14 goog.require('AutomationUtil');
15 goog.require('Output'); 15 goog.require('Output');
16 goog.require('Output.EventType'); 16 goog.require('Output.EventType');
17 goog.require('cursors.Cursor'); 17 goog.require('cursors.Cursor');
18 goog.require('cvox.ChromeVoxEditableTextBase'); 18 goog.require('cvox.ChromeVoxEditableTextBase');
19 goog.require('cvox.TabsApiHandler');
20 19
21 // Define types here due to editable_text.js's implicit dependency with 20 // Define types here due to editable_text.js's implicit dependency with
22 // ChromeVoxEventWatcher. 21 // ChromeVoxEventWatcher.
23 /** @type {Object} */ 22 /** @type {Object} */
24 cvox.ChromeVoxEventWatcher; 23 cvox.ChromeVoxEventWatcher;
25 /** @type {function(boolean)} */ 24 /** @type {function(boolean)} */
26 cvox.ChromeVoxEventWatcher.handleTextChanged; 25 cvox.ChromeVoxEventWatcher.handleTextChanged;
27 /** @type {function()} */ 26 /** @type {function()} */
28 cvox.ChromeVoxEventWatcher.setUpTextHandler; 27 cvox.ChromeVoxEventWatcher.setUpTextHandler;
29 28
30 goog.scope(function() { 29 goog.scope(function() {
31 var AutomationNode = chrome.automation.AutomationNode; 30 var AutomationNode = chrome.automation.AutomationNode;
32 var Dir = AutomationUtil.Dir; 31 var Dir = AutomationUtil.Dir;
33 var EventType = chrome.automation.EventType; 32 var EventType = chrome.automation.EventType;
34 33
35 /** 34 /**
36 * ChromeVox2 background page. 35 * ChromeVox2 background page.
37 * @constructor 36 * @constructor
38 */ 37 */
39 Background = function() { 38 Background = function() {
40 /** 39 /**
41 * A list of site substring patterns to use with ChromeVox next. Keep these 40 * A list of site substring patterns to use with ChromeVox next. Keep these
42 * strings relatively specific. 41 * strings relatively specific.
43 * @type {!Array.<string>} 42 * @type {!Array.<string>}
44 * @private 43 * @private
45 */ 44 */
46 this.whitelist_ = ['chromevox_next_test']; 45 this.whitelist_ = ['chromevox_next_test'];
47 46
48 /** 47 /**
49 * @type {cvox.TabsApiHandler}
50 * @private
51 */
52 this.tabsHandler_ = new cvox.TabsApiHandler(cvox.ChromeVox.tts,
53 cvox.ChromeVox.braille,
54 cvox.ChromeVox.earcons);
55
56 /**
57 * @type {cursors.Range} 48 * @type {cursors.Range}
58 * @private 49 * @private
59 */ 50 */
60 this.currentRange_ = null; 51 this.currentRange_ = null;
61 52
62 /** 53 /**
63 * Whether ChromeVox Next is active. 54 * Whether ChromeVox Next is active.
64 * @type {boolean} 55 * @type {boolean}
65 * @private 56 * @private
66 */ 57 */
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 */ 355 */
365 toggleChromeVoxVersion: function(opt_options) { 356 toggleChromeVoxVersion: function(opt_options) {
366 if (!opt_options) { 357 if (!opt_options) {
367 opt_options = {}; 358 opt_options = {};
368 opt_options.next = !this.active_; 359 opt_options.next = !this.active_;
369 opt_options.classic = !opt_options.next; 360 opt_options.classic = !opt_options.next;
370 } 361 }
371 362
372 if (opt_options.next) { 363 if (opt_options.next) {
373 if (!chrome.commands.onCommand.hasListener(this.onGotCommand)) 364 if (!chrome.commands.onCommand.hasListener(this.onGotCommand))
374 chrome.commands.onCommand.addListener(this.onGotCommand); 365 chrome.commands.onCommand.addListener(this.onGotCommand);
375 366 this.active_ = true;
376 if (!this.active_)
377 chrome.automation.getTree(this.onGotTree);
378 this.active_ = true;
379 } else { 367 } else {
380 if (chrome.commands.onCommand.hasListener(this.onGotCommand)) 368 if (chrome.commands.onCommand.hasListener(this.onGotCommand))
381 chrome.commands.onCommand.removeListener(this.onGotCommand); 369 chrome.commands.onCommand.removeListener(this.onGotCommand);
382
383 if (this.active_) {
384 for (var eventType in this.listeners_) {
385 this.currentRange_.getStart().getNode().root.removeEventListener(
386 eventType, this.listeners_[eventType], true);
387 }
388 }
389 this.active_ = false; 370 this.active_ = false;
390 } 371 }
391 372
392 chrome.tabs.query({active: true}, function(tabs) { 373 chrome.tabs.query({active: true}, function(tabs) {
393 if (opt_options.classic) { 374 if (opt_options.classic) {
394 // This case should do nothing because Classic gets injected by the 375 // This case should do nothing because Classic gets injected by the
395 // extension system via our manifest. Once ChromeVox Next is enabled 376 // extension system via our manifest. Once ChromeVox Next is enabled
396 // for tabs, re-enable. 377 // for tabs, re-enable.
397 // cvox.ChromeVox.injectChromeVoxIntoTabs(tabs); 378 // cvox.ChromeVox.injectChromeVoxIntoTabs(tabs);
398 } else { 379 } else {
399 tabs.forEach(function(tab) { 380 tabs.forEach(function(tab) {
400 this.disableClassicChromeVox_(tab.id); 381 this.disableClassicChromeVox_(tab.id);
401 }.bind(this)); 382 }.bind(this));
402 } 383 }
403 }.bind(this)); 384 }.bind(this));
404 } 385 }
405 }; 386 };
406 387
407 /** @type {Background} */ 388 /** @type {Background} */
408 global.backgroundObj = new Background(); 389 global.backgroundObj = new Background();
409 390
410 }); // goog.scope 391 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698