Chromium Code Reviews| Index: chrome/renderer/resources/extensions/automation/automation_node.js |
| diff --git a/chrome/renderer/resources/extensions/automation/automation_node.js b/chrome/renderer/resources/extensions/automation/automation_node.js |
| index 19e4cb815f870e475db45e672f9f85481b2944dc..b637720a4c333de3b4afb089c10f9ded609b8c80 100644 |
| --- a/chrome/renderer/resources/extensions/automation/automation_node.js |
| +++ b/chrome/renderer/resources/extensions/automation/automation_node.js |
| @@ -2,6 +2,8 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +var automationInternal = |
| + require('binding').Binding.create('automationInternal').generate(); |
| var utils = require('utils'); |
| /** |
| @@ -12,8 +14,8 @@ var utils = require('utils'); |
| var AutomationNodeImpl = function(owner) { |
| this.owner = owner; |
| this.child_ids = []; |
| - |
| this.attributes = {}; |
| + this.listeners = {}; |
| }; |
| AutomationNodeImpl.prototype = { |
| @@ -52,8 +54,64 @@ AutomationNodeImpl.prototype = { |
| return parent.children()[this.index_in_parent + 1]; |
| return undefined; |
| }, |
| -}; |
| + doDefault: function() { |
| + this.performAction_('doDefault'); |
| + }, |
|
not at google - send to devlin
2014/04/02 21:52:14
indent -= 2
David Tseng
2014/04/03 01:27:41
Done.
|
| + |
| + focus: function() { |
| + this.performAction_('focus'); |
| + }, |
| + |
| + makeVisible: function() { |
| + this.performAction_('makeVisible'); |
| + }, |
| + |
| + setSelection: function(startIndex, endIndex) { |
| + this.performAction_('setSelection', |
| + {start_index: startIndex, end_index: endIndex}); |
| + }, |
| + |
| + addEventListener: function(eventType, callback, capture) { |
| + this.removeEventListener(eventType, callback); |
| + if (!this.listeners[eventType]) |
| + this.listeners[eventType] = []; |
| + this.listeners[eventType].push([callback, capture]); |
| + }, |
| + |
| + // TODO(dtseng/aboxhall): Check this impl against spec. |
|
not at google - send to devlin
2014/04/02 21:52:14
maybe this is too hacky, and I wish you could just
aboxhall
2014/04/02 22:01:15
That won't work: note that we plan to implement ca
not at google - send to devlin
2014/04/02 22:09:40
Ok.
I hope that eventually you can pull that out
David Tseng
2014/04/02 22:14:56
That's sort of what I think we had in mind; this c
|
| + removeEventListener: function(eventType, callback) { |
| + if (this.listeners[eventType]) { |
| + var listeners = this.listeners[eventType]; |
| + for (var i = 0; i < listeners.length; i++) { |
| + if (callback === listeners[i][0]) |
| + listeners.splice(i, 1); |
| + } |
| + } |
| + }, |
| + |
| + notifyEventListeners: function(eventType) { |
| + var listeners = this.listeners[eventType]; |
| + if (!listeners) |
| + return; |
| + // TODO(dtseng/aboxhall): Implement capture/bubble. |
| + for (var i = 0; i < listeners.length; i++) |
| + listeners[i][0](); |
| + }, |
| + |
| + performAction_: function(actionType, opt_args) { |
| + // Not yet initialized. |
| + if (!this.owner.processId || |
| + !this.owner.routingId || |
| + !this.wrapper.id) |
| + return; |
| + automationInternal.performAction(this.owner.processId, |
| + this.owner.routingId, |
| + this.wrapper.id, |
| + actionType, |
| + opt_args ? opt_args : {}); |
| + }, |
| +}; |
| var AutomationNode = utils.expose('AutomationNode', |
| AutomationNodeImpl, |
| @@ -62,5 +120,11 @@ var AutomationNode = utils.expose('AutomationNode', |
| 'lastChild', |
| 'children', |
| 'previousSibling', |
| - 'nextSibling']); |
| + 'nextSibling', |
| + 'doDefault', |
| + 'focus', |
| + 'makeVisible', |
| + 'setSelection', |
| + 'addEventListener', |
| + 'removeEventListener']); |
| exports.AutomationNode = AutomationNode; |