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

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

Issue 308003003: Allow requesting Automation tree by tabId (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 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 | Annotate | Revision Log
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 AutomationTree = require('automationTree').AutomationTree; 7 var AutomationTree = require('automationTree').AutomationTree;
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();
(...skipping 17 matching lines...) Expand all
28 var createAutomationTreeID = function(pid, rid) { 28 var createAutomationTreeID = function(pid, rid) {
29 return pid + '_' + rid; 29 return pid + '_' + rid;
30 }; 30 };
31 31
32 var DESKTOP_TREE_ID = createAutomationTreeID(0, 0); 32 var DESKTOP_TREE_ID = createAutomationTreeID(0, 0);
33 33
34 automation.registerCustomHook(function(bindingsAPI) { 34 automation.registerCustomHook(function(bindingsAPI) {
35 var apiFunctions = bindingsAPI.apiFunctions; 35 var apiFunctions = bindingsAPI.apiFunctions;
36 36
37 // TODO(aboxhall, dtseng): Make this return the speced AutomationRootNode obj. 37 // TODO(aboxhall, dtseng): Make this return the speced AutomationRootNode obj.
38 apiFunctions.setHandleRequest('getTree', function(callback) { 38 apiFunctions.setHandleRequest('getTree', function getTree(tabId, callback) {
39 // enableCurrentTab() ensures the renderer for the current tab has 39 // enableTab() ensures the renderer for the active or specified tab has
40 // accessibility enabled, and fetches its process and routing ids to use as 40 // accessibility enabled, and fetches its process and routing ids to use as
41 // a key in the idToAutomationTree map. The callback to enableCurrentTab is 41 // a key in the idToAutomationTree map. The callback to enableActiveTab is
42 // bound to the callback passed in to getTree(), so that once the tree is 42 // bound to the callback passed in to getTree(), so that once the tree is
43 // available (either due to having been cached earlier, or after an 43 // available (either due to having been cached earlier, or after an
44 // accessibility event occurs which causes the tree to be populated), the 44 // accessibility event occurs which causes the tree to be populated), the
45 // callback can be called. 45 // callback can be called.
46 automationInternal.enableCurrentTab(function(pid, rid) { 46 automationInternal.enableTab(tabId, function onEnable(pid, rid) {
47 if (lastError.hasError(chrome)) { 47 if (lastError.hasError(chrome)) {
48 callback(); 48 callback();
49 return; 49 return;
50 } 50 }
51 var id = createAutomationTreeID(pid, rid); 51 var id = createAutomationTreeID(pid, rid);
52 var targetTree = idToAutomationTree[id]; 52 var targetTree = idToAutomationTree[id];
53 if (!targetTree) { 53 if (!targetTree) {
54 // If we haven't cached the tree, hold the callback until the tree is 54 // If we haven't cached the tree, hold the callback until the tree is
55 // populated by the initial onAccessibilityEvent call. 55 // populated by the initial onAccessibilityEvent call.
56 if (id in idToCallback) 56 if (id in idToCallback)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 }); 119 });
120 120
121 exports.binding = automation.generate(); 121 exports.binding = automation.generate();
122 122
123 // Add additional accessibility bindings not specified in the automation IDL. 123 // Add additional accessibility bindings not specified in the automation IDL.
124 // Accessibility and automation share some APIs (see 124 // Accessibility and automation share some APIs (see
125 // ui/accessibility/ax_enums.idl). 125 // ui/accessibility/ax_enums.idl).
126 forEach(schema, function(k, v) { 126 forEach(schema, function(k, v) {
127 exports.binding[k] = v; 127 exports.binding[k] = v;
128 }); 128 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698