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 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 exceptionHandler = require('uncaught_exception_handler'); | 13 var exceptionHandler = require('uncaught_exception_handler'); |
14 var forEach = require('utils').forEach; | 14 var forEach = require('utils').forEach; |
15 var lastError = require('lastError'); | 15 var lastError = require('lastError'); |
16 var logging = requireNative('logging'); | 16 var logging = requireNative('logging'); |
17 var nativeAutomationInternal = requireNative('automationInternal'); | 17 var nativeAutomationInternal = requireNative('automationInternal'); |
18 var GetRoutingID = nativeAutomationInternal.GetRoutingID; | 18 var GetRoutingID = nativeAutomationInternal.GetRoutingID; |
19 var GetSchemaAdditions = nativeAutomationInternal.GetSchemaAdditions; | 19 var GetSchemaAdditions = nativeAutomationInternal.GetSchemaAdditions; |
20 var DestroyAccessibilityTree = | 20 var DestroyAccessibilityTree = |
21 nativeAutomationInternal.DestroyAccessibilityTree; | 21 nativeAutomationInternal.DestroyAccessibilityTree; |
22 var GetIntAttribute = nativeAutomationInternal.GetIntAttribute; | 22 var GetIntAttribute = nativeAutomationInternal.GetIntAttribute; |
23 var StartCachingAccessibilityTrees = | 23 var StartCachingAccessibilityTrees = |
24 nativeAutomationInternal.StartCachingAccessibilityTrees; | 24 nativeAutomationInternal.StartCachingAccessibilityTrees; |
| 25 var SetTreeChangeObserverMask = |
| 26 nativeAutomationInternal.SetTreeChangeObserverMask; |
25 var schema = GetSchemaAdditions(); | 27 var schema = GetSchemaAdditions(); |
26 | 28 |
27 /** | 29 /** |
28 * A namespace to export utility functions to other files in automation. | 30 * A namespace to export utility functions to other files in automation. |
29 */ | 31 */ |
30 window.automationUtil = function() {}; | 32 window.automationUtil = function() {}; |
31 | 33 |
32 // TODO(aboxhall): Look into using WeakMap | 34 // TODO(aboxhall): Look into using WeakMap |
33 var idToCallback = {}; | 35 var idToCallback = {}; |
34 | 36 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 }); | 123 }); |
122 | 124 |
123 function addTreeChangeObserver(observer) { | 125 function addTreeChangeObserver(observer) { |
124 removeTreeChangeObserver(observer); | 126 removeTreeChangeObserver(observer); |
125 automationUtil.treeChangeObservers.push(observer); | 127 automationUtil.treeChangeObservers.push(observer); |
126 } | 128 } |
127 apiFunctions.setHandleRequest('addTreeChangeObserver', function(observer) { | 129 apiFunctions.setHandleRequest('addTreeChangeObserver', function(observer) { |
128 addTreeChangeObserver(observer); | 130 addTreeChangeObserver(observer); |
129 }); | 131 }); |
130 | 132 |
| 133 function setTreeChangeObserverMask(mask) { |
| 134 SetTreeChangeObserverMask(mask); |
| 135 } |
| 136 apiFunctions.setHandleRequest('setTreeChangeObserverMask', |
| 137 function(mask) { |
| 138 setTreeChangeObserverMask(mask); |
| 139 }); |
| 140 |
131 apiFunctions.setHandleRequest('setDocumentSelection', function(params) { | 141 apiFunctions.setHandleRequest('setDocumentSelection', function(params) { |
132 var anchorNodeImpl = privates(params.anchorObject).impl; | 142 var anchorNodeImpl = privates(params.anchorObject).impl; |
133 var focusNodeImpl = privates(params.focusObject).impl; | 143 var focusNodeImpl = privates(params.focusObject).impl; |
134 if (anchorNodeImpl.treeID !== focusNodeImpl.treeID) | 144 if (anchorNodeImpl.treeID !== focusNodeImpl.treeID) |
135 throw new Error('Selection anchor and focus must be in the same tree.'); | 145 throw new Error('Selection anchor and focus must be in the same tree.'); |
136 if (anchorNodeImpl.treeID === DESKTOP_TREE_ID) { | 146 if (anchorNodeImpl.treeID === DESKTOP_TREE_ID) { |
137 throw new Error('Use AutomationNode.setSelection to set the selection ' + | 147 throw new Error('Use AutomationNode.setSelection to set the selection ' + |
138 'in the desktop tree.'); | 148 'in the desktop tree.'); |
139 } | 149 } |
140 automationInternal.performAction({ treeID: anchorNodeImpl.treeID, | 150 automationInternal.performAction({ treeID: anchorNodeImpl.treeID, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 }); | 261 }); |
252 | 262 |
253 exports.binding = automation.generate(); | 263 exports.binding = automation.generate(); |
254 | 264 |
255 // Add additional accessibility bindings not specified in the automation IDL. | 265 // Add additional accessibility bindings not specified in the automation IDL. |
256 // Accessibility and automation share some APIs (see | 266 // Accessibility and automation share some APIs (see |
257 // ui/accessibility/ax_enums.idl). | 267 // ui/accessibility/ax_enums.idl). |
258 forEach(schema, function(k, v) { | 268 forEach(schema, function(k, v) { |
259 exports.binding[k] = v; | 269 exports.binding[k] = v; |
260 }); | 270 }); |
OLD | NEW |