OLD | NEW |
---|---|
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 automation = require('binding').Binding.create('automation'); | 6 var automation = require('binding').Binding.create('automation'); |
7 var automationInternal = | 7 var automationInternal = |
8 require('binding').Binding.create('automationInternal').generate(); | 8 require('binding').Binding.create('automationInternal').generate(); |
9 var eventBindings = require('event_bindings'); | 9 var eventBindings = require('event_bindings'); |
10 var Event = eventBindings.Event; | 10 var Event = eventBindings.Event; |
(...skipping 10 matching lines...) Expand all Loading... | |
21 * Creates an id associated with a particular AutomationTree based upon a | 21 * Creates an id associated with a particular AutomationTree based upon a |
22 * renderer/renderer host pair's process and routing id. | 22 * renderer/renderer host pair's process and routing id. |
23 */ | 23 */ |
24 var createAutomationTreeID = function(pid, rid) { | 24 var createAutomationTreeID = function(pid, rid) { |
25 return pid + '_' + rid; | 25 return pid + '_' + rid; |
26 }; | 26 }; |
27 | 27 |
28 automation.registerCustomHook(function(bindingsAPI) { | 28 automation.registerCustomHook(function(bindingsAPI) { |
29 var apiFunctions = bindingsAPI.apiFunctions; | 29 var apiFunctions = bindingsAPI.apiFunctions; |
30 | 30 |
31 // TODO(aboxhall/dtseng): Re-work once 'desktop' object is fully specced | 31 // TODO(aboxhall, dtseng): Make this return the speced AutomationRootNode obj. |
aboxhall
2014/04/28 19:50:38
Nit: align comment with function call below (inden
David Tseng
2014/04/29 01:35:03
Done.
| |
32 apiFunctions.setHandleRequest('getTree', function(callback) { | 32 apiFunctions.setHandleRequest('getTree', function(callback) { |
33 // enableCurrentTab() ensures the renderer for the current tab has | 33 // enableCurrentTab() ensures the renderer for the current tab has |
34 // accessibility enabled, and fetches its process and routing ids to use as | 34 // accessibility enabled, and fetches its process and routing ids to use as |
35 // a key in the idToAutomationTree map. The callback to enableCurrentTab is | 35 // a key in the idToAutomationTree map. The callback to enableCurrentTab is |
36 // bound to the callback passed in to getTree(), so that once the tree is | 36 // bound to the callback passed in to getTree(), so that once the tree is |
37 // available (either due to having been cached earlier, or after an | 37 // available (either due to having been cached earlier, or after an |
38 // accessibility event occurs which causes the tree to be populated), the | 38 // accessibility event occurs which causes the tree to be populated), the |
39 // callback can be called. | 39 // callback can be called. |
40 automationInternal.enableCurrentTab(function(pid, rid) { | 40 automationInternal.enableCurrentTab(function(pid, rid) { |
41 var id = createAutomationTreeID(pid, rid); | 41 var id = createAutomationTreeID(pid, rid); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 for (var i = 0; i < idToCallback[id].length; i++) { | 80 for (var i = 0; i < idToCallback[id].length; i++) { |
81 var callback = idToCallback[id][i]; | 81 var callback = idToCallback[id][i]; |
82 callback(targetTree); | 82 callback(targetTree); |
83 } | 83 } |
84 delete idToCallback[id]; | 84 delete idToCallback[id]; |
85 } | 85 } |
86 } | 86 } |
87 }); | 87 }); |
88 | 88 |
89 exports.binding = automation.generate(); | 89 exports.binding = automation.generate(); |
OLD | NEW |