Chromium Code Reviews| Index: Source/devtools/front_end/ActionRegistry.js |
| diff --git a/Source/devtools/front_end/ActionRegistry.js b/Source/devtools/front_end/ActionRegistry.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..22b8d83c8ddf7d3a998d63743414e2f0968b2c17 |
| --- /dev/null |
| +++ b/Source/devtools/front_end/ActionRegistry.js |
| @@ -0,0 +1,43 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +/** |
| + * @constructor |
| + * @implements {WebInspector.ActionRegistryAPI} |
| + */ |
| +WebInspector.ActionRegistry = function() |
| +{ |
| + this._actionsById = new StringMap(); |
| +} |
| + |
| +WebInspector.ActionRegistry.prototype = { |
|
pfeldman
2014/04/10 09:35:45
This is a too small step for me to assess if the d
|
| + registerActions: function() |
| + { |
| + WebInspector.moduleManager.extensions(WebInspector.ActionDelegate).forEach(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
|
| + |
| + /** |
| + * @param {!WebInspector.ModuleManager.Extension} extension |
| + * @this {WebInspector.ActionRegistry} |
| + */ |
| + function registerExtension(extension) |
| + { |
| + var actionId = extension.descriptor()["actionId"]; |
| + console.assert(actionId); |
| + console.assert(!this._actionsById.get(actionId)); |
| + this._actionsById.put(actionId, extension); |
| + } |
| + }, |
| + |
| + /** |
| + * @param {string} actionId |
| + * @param {!Event} event |
| + * @return {boolean} |
| + */ |
| + 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.
|
| + { |
| + var extension = this._actionsById.get(actionId); |
| + console.assert(extension, "No action found for actionId '" + actionId + "'"); |
| + return extension.instance().handleAction(event); |
| + } |
| +} |