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

Side by Side Diff: chrome/renderer/resources/extensions/automation_custom_bindings.js

Issue 1151523009: Forward accessibility events to the automation extension process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@step1
Patch Set: Own a message filter rather than inheriting Created 5 years, 6 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 // Custom bindings for the automation API. 5 // Custom bindings for the automation API.
6 var AutomationNode = require('automationNode').AutomationNode; 6 var AutomationNode = require('automationNode').AutomationNode;
7 var AutomationRootNode = require('automationNode').AutomationRootNode; 7 var AutomationRootNode = require('automationNode').AutomationRootNode;
8 var automation = require('binding').Binding.create('automation'); 8 var automation = require('binding').Binding.create('automation');
9 var automationInternal = 9 var automationInternal =
10 require('binding').Binding.create('automationInternal').generate(); 10 require('binding').Binding.create('automationInternal').generate();
11 var eventBindings = require('event_bindings'); 11 var eventBindings = require('event_bindings');
12 var Event = eventBindings.Event; 12 var Event = eventBindings.Event;
13 var forEach = require('utils').forEach; 13 var forEach = require('utils').forEach;
14 var lastError = require('lastError'); 14 var lastError = require('lastError');
15 var logging = requireNative('logging'); 15 var logging = requireNative('logging');
16 var schema = requireNative('automationInternal').GetSchemaAdditions(); 16 var schema = requireNative('automationInternal').GetSchemaAdditions();
17 var GetRoutingID = requireNative('automationInternal').GetRoutingID;
not at google - send to devlin 2015/06/04 23:03:29 rather than requiring automationInternal 3 times,
dmazzoni 2015/06/08 18:02:58 Done.
17 18
18 /** 19 /**
19 * A namespace to export utility functions to other files in automation. 20 * A namespace to export utility functions to other files in automation.
20 */ 21 */
21 window.automationUtil = function() {}; 22 window.automationUtil = function() {};
22 23
23 // TODO(aboxhall): Look into using WeakMap 24 // TODO(aboxhall): Look into using WeakMap
24 var idToAutomationRootNode = {}; 25 var idToAutomationRootNode = {};
25 var idToCallback = {}; 26 var idToCallback = {};
26 27
(...skipping 19 matching lines...) Expand all
46 /** 47 /**
47 * Global list of tree change observers. 48 * Global list of tree change observers.
48 * @type {Array<TreeChangeObserver>} 49 * @type {Array<TreeChangeObserver>}
49 */ 50 */
50 automationUtil.treeChangeObservers = []; 51 automationUtil.treeChangeObservers = [];
51 52
52 automation.registerCustomHook(function(bindingsAPI) { 53 automation.registerCustomHook(function(bindingsAPI) {
53 var apiFunctions = bindingsAPI.apiFunctions; 54 var apiFunctions = bindingsAPI.apiFunctions;
54 55
55 // TODO(aboxhall, dtseng): Make this return the speced AutomationRootNode obj. 56 // TODO(aboxhall, dtseng): Make this return the speced AutomationRootNode obj.
56 apiFunctions.setHandleRequest('getTree', function getTree(tabId, callback) { 57 apiFunctions.setHandleRequest('getTree', function getTree(tabID, callback) {
58 var routingID = GetRoutingID();
59
57 // enableTab() ensures the renderer for the active or specified tab has 60 // enableTab() ensures the renderer for the active or specified tab has
58 // accessibility enabled, and fetches its ax tree id to use as 61 // accessibility enabled, and fetches its ax tree id to use as
59 // a key in the idToAutomationRootNode map. The callback to 62 // a key in the idToAutomationRootNode map. The callback to
60 // enableTab is bound to the callback passed in to getTree(), so that once 63 // enableTab is bound to the callback passed in to getTree(), so that once
61 // the tree is available (either due to having been cached earlier, or after 64 // the tree is available (either due to having been cached earlier, or after
62 // an accessibility event occurs which causes the tree to be populated), the 65 // an accessibility event occurs which causes the tree to be populated), the
63 // callback can be called. 66 // callback can be called.
64 automationInternal.enableTab(tabId, function onEnable(id) { 67 var params = { routingID: routingID, tabID: tabID };
65 if (lastError.hasError(chrome)) { 68 automationInternal.enableTab(params,
66 callback(); 69 function onEnable(id) {
67 return; 70 if (lastError.hasError(chrome)) {
68 } 71 callback();
69 automationUtil.storeTreeCallback(id, callback); 72 return;
70 }); 73 }
74 automationUtil.storeTreeCallback(id, callback);
75 });
71 }); 76 });
72 77
73 var desktopTree = null; 78 var desktopTree = null;
74 apiFunctions.setHandleRequest('getDesktop', function(callback) { 79 apiFunctions.setHandleRequest('getDesktop', function(callback) {
75 desktopTree = 80 desktopTree =
76 idToAutomationRootNode[DESKTOP_TREE_ID]; 81 idToAutomationRootNode[DESKTOP_TREE_ID];
77 if (!desktopTree) { 82 if (!desktopTree) {
78 if (DESKTOP_TREE_ID in idToCallback) 83 if (DESKTOP_TREE_ID in idToCallback)
79 idToCallback[DESKTOP_TREE_ID].push(callback); 84 idToCallback[DESKTOP_TREE_ID].push(callback);
80 else 85 else
81 idToCallback[DESKTOP_TREE_ID] = [callback]; 86 idToCallback[DESKTOP_TREE_ID] = [callback];
82 87
88 var routingID = GetRoutingID();
89
83 // TODO(dtseng): Disable desktop tree once desktop object goes out of 90 // TODO(dtseng): Disable desktop tree once desktop object goes out of
84 // scope. 91 // scope.
85 automationInternal.enableDesktop(function() { 92 automationInternal.enableDesktop(routingID, function() {
86 if (lastError.hasError(chrome)) { 93 if (lastError.hasError(chrome)) {
87 delete idToAutomationRootNode[ 94 delete idToAutomationRootNode[
88 DESKTOP_TREE_ID]; 95 DESKTOP_TREE_ID];
89 callback(); 96 callback();
90 return; 97 return;
91 } 98 }
92 }); 99 });
93 } else { 100 } else {
94 callback(desktopTree); 101 callback(desktopTree);
95 } 102 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 }); 175 });
169 176
170 exports.binding = automation.generate(); 177 exports.binding = automation.generate();
171 178
172 // Add additional accessibility bindings not specified in the automation IDL. 179 // Add additional accessibility bindings not specified in the automation IDL.
173 // Accessibility and automation share some APIs (see 180 // Accessibility and automation share some APIs (see
174 // ui/accessibility/ax_enums.idl). 181 // ui/accessibility/ax_enums.idl).
175 forEach(schema, function(k, v) { 182 forEach(schema, function(k, v) {
176 exports.binding[k] = v; 183 exports.binding[k] = v;
177 }); 184 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698