Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
index 2776b6f9f258bd456373611be8168bacd825b788..c1b5bb45c435478c15618bcb701e8b6860a2825e 100644 |
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
@@ -16,7 +16,6 @@ goog.require('Output'); |
goog.require('Output.EventType'); |
goog.require('cursors.Cursor'); |
goog.require('cvox.ChromeVoxEditableTextBase'); |
-goog.require('cvox.TabsApiHandler'); |
// Define types here due to editable_text.js's implicit dependency with |
// ChromeVoxEventWatcher. |
@@ -46,14 +45,6 @@ Background = function() { |
this.whitelist_ = ['chromevox_next_test']; |
/** |
- * @type {cvox.TabsApiHandler} |
- * @private |
- */ |
- this.tabsHandler_ = new cvox.TabsApiHandler(cvox.ChromeVox.tts, |
- cvox.ChromeVox.braille, |
- cvox.ChromeVox.earcons); |
- |
- /** |
* @type {cursors.Range} |
* @private |
*/ |
@@ -91,7 +82,7 @@ Background = function() { |
// Register listeners for ... |
// Desktop. |
- chrome.automation.getDesktop(this.onGotTree); |
+ chrome.automation.getDesktop(this.onGotDesktop); |
// Tabs. |
chrome.tabs.onUpdated.addListener(this.onTabUpdated); |
@@ -118,14 +109,16 @@ Background.prototype = { |
/** |
* Handles all setup once a new automation tree appears. |
- * @param {chrome.automation.AutomationNode} root |
+ * @param {chrome.automation.AutomationNode} desktop |
*/ |
- onGotTree: function(root) { |
+ onGotDesktop: function(desktop) { |
// Register all automation event listeners. |
for (var eventType in this.listeners_) |
- root.addEventListener(eventType, this.listeners_[eventType], true); |
+ desktop.addEventListener(eventType, this.listeners_[eventType], true); |
- if (root.attributes.docLoaded) { |
+ var root = desktop.find({role: chrome.automation.RoleType.rootWebArea, |
+ state: {focused: true}}); |
+ if (root && root.attributes.docLoaded) { |
this.onLoadComplete( |
{target: root, type: chrome.automation.EventType.loadComplete}); |
} |
@@ -371,21 +364,11 @@ Background.prototype = { |
if (opt_options.next) { |
if (!chrome.commands.onCommand.hasListener(this.onGotCommand)) |
- chrome.commands.onCommand.addListener(this.onGotCommand); |
- |
- if (!this.active_) |
- chrome.automation.getTree(this.onGotTree); |
- this.active_ = true; |
+ chrome.commands.onCommand.addListener(this.onGotCommand); |
+ this.active_ = true; |
} else { |
if (chrome.commands.onCommand.hasListener(this.onGotCommand)) |
chrome.commands.onCommand.removeListener(this.onGotCommand); |
- |
- if (this.active_) { |
- for (var eventType in this.listeners_) { |
- this.currentRange_.getStart().getNode().root.removeEventListener( |
- eventType, this.listeners_[eventType], true); |
- } |
- } |
this.active_ = false; |
} |