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

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

Issue 1942683005: Refactor event handler classes to make it easier to add new event type listeners. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 tabs automation node. 6 * @fileoverview Handles automation from a tabs automation node.
7 */ 7 */
8 8
9 goog.provide('TabsAutomationHandler'); 9 goog.provide('TabsAutomationHandler');
10 10
11 goog.require('DesktopAutomationHandler'); 11 goog.require('DesktopAutomationHandler');
12 12
13 goog.scope(function() { 13 goog.scope(function() {
14 var EventType = chrome.automation.EventType; 14 var EventType = chrome.automation.EventType;
15 var RoleType = chrome.automation.RoleType; 15 var RoleType = chrome.automation.RoleType;
16 16
17 /** 17 /**
18 * @param {!chrome.automation.AutomationNode} tabRoot 18 * @param {!chrome.automation.AutomationNode} tabRoot
19 * @constructor 19 * @constructor
20 * @extends {DesktopAutomationHandler} 20 * @extends {DesktopAutomationHandler}
21 */ 21 */
22 TabsAutomationHandler = function(tabRoot) { 22 TabsAutomationHandler = function(tabRoot) {
23 DesktopAutomationHandler.call(this, tabRoot); 23 DesktopAutomationHandler.call(this, tabRoot);
24 24
25 if (tabRoot.role != RoleType.rootWebArea) 25 if (tabRoot.role != RoleType.rootWebArea)
26 throw new Error('Expected rootWebArea node but got ' + tabRoot.role); 26 throw new Error('Expected rootWebArea node but got ' + tabRoot.role);
27 27
28 // When the root is focused, simulate what happens on a load complete. 28 // When the root is focused, simulate what happens on a load complete.
29 if (tabRoot.state.focused) 29 if (tabRoot.state.focused) {
30 this.onLoadComplete({target: tabRoot, type: EventType.loadComplete}); 30 this.onLoadComplete(
31 new chrome.automation.AutomationEvent(EventType.loadComplete, tabRoot));
32 }
31 }; 33 };
32 34
33 TabsAutomationHandler.prototype = { 35 TabsAutomationHandler.prototype = {
34 __proto__: DesktopAutomationHandler.prototype, 36 __proto__: DesktopAutomationHandler.prototype,
35 37
36 /** @override */ 38 /** @override */
37 didHandleEvent_: function(evt) { 39 didHandleEvent_: function(evt) {
38 evt.stopPropagation(); 40 evt.stopPropagation();
39 }, 41 },
40 42
41 /** @override */ 43 /** @override */
42 onLoadComplete: function(evt) { 44 onLoadComplete: function(evt) {
43 ChromeVoxState.instance.refreshMode(evt.target.docUrl); 45 ChromeVoxState.instance.refreshMode(evt.target.docUrl);
44 var focused = evt.target.find({state: {focused: true}}) || evt.target; 46 var focused = evt.target.find({state: {focused: true}}) || evt.target;
45 this.onFocus({target: focused, type: EventType.focus}); 47 this.onFocus(new chrome.automation.AutomationEvent(
48 EventType.focus, focused));
46 } 49 }
47 }; 50 };
48 51
49 }); // goog.scope 52 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698