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..3fe9075db18de4ff48f8136b684f1e00c1a51041 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,59 @@ AutomationNodeImpl.prototype = { |
| return parent.children()[this.index_in_parent + 1]; |
| return undefined; |
| }, |
| -}; |
| + doDefault: function() { |
| + this.performAction('doDefault', []); |
| + }, |
| + |
| + focus: function() { |
| + this.performAction('focus', []); |
| + }, |
| + |
| + makeVisible: function() { |
| + this.performAction('makeVisible', []); |
| + }, |
| + |
| + setSelection: function(startIndex, endIndex) { |
| + this.performAction('setSelection', [startIndex, endIndex]); |
| + }, |
| + |
| + addEventListener: function(eventType, callback, capture) { |
| + if (! this.listeners[eventType]) |
|
dmazzoni
2014/04/01 17:05:25
Nit: no space after !
David Tseng
2014/04/01 21:27:15
Done.
|
| + this.listeners[eventType] = []; |
| + this.listeners[eventType].push([callback, capture]); |
| + }, |
| + |
| + // TODO(dtseng/aboxhall): Implement. |
| + removeEventListener: function(callback) { |
|
dmazzoni
2014/04/01 17:05:25
Should this take eventType and capture as paramete
David Tseng
2014/04/01 21:27:15
Added as part of TODO. I'm not sure if we want to
|
| + }, |
| + |
| + /* @private */ |
| + performAction: function(actionType, opt_args) { |
|
aboxhall
2014/04/01 17:49:51
Use performAction_ naming scheme for private metho
David Tseng
2014/04/01 21:27:15
Removed the private annotation and added the under
|
| +// Not yet initialized. |
|
dmazzoni
2014/04/01 17:05:25
Nit: indent
David Tseng
2014/04/01 21:27:15
Done.
|
| +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); |
| + }, |
| + |
| + /* @private */ |
| + updateEventListeners: function(eventType) { |
|
aboxhall
2014/04/01 17:49:51
notifyEventListeners_ ?
David Tseng
2014/04/01 21:27:15
Notify is fine. Actually not private though since
|
| + var listeners = this.listeners[eventType]; |
| + if (!listeners) |
| + return; |
| + // TODO(dtseng/aboxhall): Implement capture/bubble. |
| + for (var i = 0; i < listeners.length; i++) { |
| + var listener = listeners[i][0]; |
| + listener(); |
| + } |
| + }, |
| +}; |
| var AutomationNode = utils.expose('AutomationNode', |
| AutomationNodeImpl, |
| @@ -62,5 +115,11 @@ var AutomationNode = utils.expose('AutomationNode', |
| 'lastChild', |
| 'children', |
| 'previousSibling', |
| - 'nextSibling']); |
| + 'nextSibling', |
| + 'doDefault', |
| + 'focus', |
| + 'makeVisible', |
| + 'setSelection', |
| + 'addEventListener', |
| + 'removeEventListener']); |
| exports.AutomationNode = AutomationNode; |