OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 /** | |
6 * @constructor | |
7 * @implements {WebInspector.ActionRegistryAPI} | |
8 */ | |
9 WebInspector.ActionRegistry = function() | |
10 { | |
11 this._actionsById = new StringMap(); | |
12 } | |
13 | |
14 WebInspector.ActionRegistry.prototype = { | |
pfeldman
2014/04/10 09:35:45
This is a too small step for me to assess if the d
| |
15 registerActions: function() | |
16 { | |
17 WebInspector.moduleManager.extensions(WebInspector.ActionDelegate).forEa ch(registerExtension, this); | |
pfeldman
2014/04/14 13:10:44
Do this from constructor instead?
apavlov
2014/04/15 13:33:14
The registration step requires the ModuleManager t
| |
18 | |
19 /** | |
20 * @param {!WebInspector.ModuleManager.Extension} extension | |
21 * @this {WebInspector.ActionRegistry} | |
22 */ | |
23 function registerExtension(extension) | |
24 { | |
25 var actionId = extension.descriptor()["actionId"]; | |
26 console.assert(actionId); | |
27 console.assert(!this._actionsById.get(actionId)); | |
28 this._actionsById.put(actionId, extension); | |
29 } | |
30 }, | |
31 | |
32 /** | |
33 * @param {string} actionId | |
34 * @param {!Event} event | |
35 * @return {boolean} | |
36 */ | |
37 execute: function(actionId, event) | |
pfeldman
2014/04/14 13:10:44
You would want to expose actions for context here
apavlov
2014/04/15 13:33:14
Done.
| |
38 { | |
39 var extension = this._actionsById.get(actionId); | |
40 console.assert(extension, "No action found for actionId '" + actionId + "'"); | |
41 return extension.instance().handleAction(event); | |
42 } | |
43 } | |
OLD | NEW |