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

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

Issue 304293002: Add human readable programmatic enum name/values to chrome.automation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: <= Created 6 years, 6 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 | Annotate | Revision Log
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 AutomationTree = require('automationTree').AutomationTree; 7 var AutomationTree = require('automationTree').AutomationTree;
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 lastError = require('lastError'); 13 var lastError = require('lastError');
14 var schema =
15 requireNative('automationInternal').GetSchemaAdditions();
14 16
15 // TODO(aboxhall): Look into using WeakMap 17 // TODO(aboxhall): Look into using WeakMap
16 var idToAutomationTree = {}; 18 var idToAutomationTree = {};
17 var idToCallback = {}; 19 var idToCallback = {};
18 20
19 // TODO(dtseng): Move out to automation/automation_util.js or as a static member 21 // TODO(dtseng): Move out to automation/automation_util.js or as a static member
20 // of AutomationTree to keep this file clean. 22 // of AutomationTree to keep this file clean.
21 /* 23 /*
22 * Creates an id associated with a particular AutomationTree based upon a 24 * Creates an id associated with a particular AutomationTree based upon a
23 * renderer/renderer host pair's process and routing id. 25 * renderer/renderer host pair's process and routing id.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 for (var i = 0; i < idToCallback[id].length; i++) { 107 for (var i = 0; i < idToCallback[id].length; i++) {
106 var callback = idToCallback[id][i]; 108 var callback = idToCallback[id][i];
107 callback(targetTree); 109 callback(targetTree);
108 } 110 }
109 delete idToCallback[id]; 111 delete idToCallback[id];
110 } 112 }
111 } 113 }
112 }); 114 });
113 115
114 exports.binding = automation.generate(); 116 exports.binding = automation.generate();
117
118 // Additional bindings adopted from Accessibility.
119 exports.binding.Event = schema.Event;
120 exports.binding.Role = schema.Role;
121 exports.binding.State = schema.State;
not at google - send to devlin 2014/05/29 18:26:21 you could go: forEach(schema, function(k, v) {
aboxhall 2014/05/29 18:35:49 -1 current code has same number of lines and is mo
not at google - send to devlin 2014/05/29 18:45:50 I don't think it's the job of this code to know wh
David Tseng 2014/05/29 19:04:40 Do you feel strongly? I could go either way on thi
not at google - send to devlin 2014/05/29 19:48:14 I rarely feel strongly to push back on a push back
David Tseng 2014/05/29 22:12:25 Ok; I've left a better comment. Also, I think we m
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698