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

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

Issue 1365433002: Add setSelection function to automation API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@nobrailleautostartintests
Patch Set: Fix style and remove console.log Created 5 years, 2 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();
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 }); 120 });
121 121
122 function addTreeChangeObserver(observer) { 122 function addTreeChangeObserver(observer) {
123 removeTreeChangeObserver(observer); 123 removeTreeChangeObserver(observer);
124 automationUtil.treeChangeObservers.push(observer); 124 automationUtil.treeChangeObservers.push(observer);
125 } 125 }
126 apiFunctions.setHandleRequest('addTreeChangeObserver', function(observer) { 126 apiFunctions.setHandleRequest('addTreeChangeObserver', function(observer) {
127 addTreeChangeObserver(observer); 127 addTreeChangeObserver(observer);
128 }); 128 });
129 129
130 apiFunctions.setHandleRequest('setDocumentSelection', function(anchorNode,
131 anchorOffset,
132 focusNode,
133 focusOffset) {
134 var anchorNodeImpl = privates(anchorNode).impl;
135 var focusNodeImpl = privates(focusNode).impl;
136 if (anchorNodeImpl.treeID !== focusNodeImpl.treeID)
137 throw new Error('Selection anchor and focus must be in the same tree.');
138 if (anchorNodeImpl.treeID === DESKTOP_TREE_ID) {
139 throw new Error('Use AutomationNode.setSelection to set the selection ' +
140 'in the desktop tree.');
141 }
142 automationInternal.performAction({ treeID: anchorNodeImpl.treeID,
143 automationNodeID: anchorNodeImpl.id,
144 actionType: 'setSelection'},
145 { focusNodeID: focusNodeImpl.id,
146 anchorOffset: anchorOffset,
147 focusOffset: focusOffset });
148 });
149
130 }); 150 });
131 151
132 automationInternal.onTreeChange.addListener(function(treeID, 152 automationInternal.onTreeChange.addListener(function(treeID,
133 nodeID, 153 nodeID,
134 changeType) { 154 changeType) {
135 var tree = AutomationRootNode.getOrCreate(treeID); 155 var tree = AutomationRootNode.getOrCreate(treeID);
136 if (!tree) 156 if (!tree)
137 return; 157 return;
138 158
139 var node = privates(tree).impl.get(nodeID); 159 var node = privates(tree).impl.get(nodeID);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 }); 254 });
235 255
236 exports.binding = automation.generate(); 256 exports.binding = automation.generate();
237 257
238 // Add additional accessibility bindings not specified in the automation IDL. 258 // Add additional accessibility bindings not specified in the automation IDL.
239 // Accessibility and automation share some APIs (see 259 // Accessibility and automation share some APIs (see
240 // ui/accessibility/ax_enums.idl). 260 // ui/accessibility/ax_enums.idl).
241 forEach(schema, function(k, v) { 261 forEach(schema, function(k, v) {
242 exports.binding[k] = v; 262 exports.binding[k] = v;
243 }); 263 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698