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

Unified Diff: Source/devtools/front_end/ActionRegistry.js

Issue 218613013: DevTools: Decouple shortcuts from actions, introduce shortcut contexts (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased patch Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/devtools.gypi ('k') | Source/devtools/front_end/AdvancedSearchView.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..19a668c08bd07fafbb0100a36d06472861962151
--- /dev/null
+++ b/Source/devtools/front_end/ActionRegistry.js
@@ -0,0 +1,63 @@
+// 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
+ */
+WebInspector.ActionRegistry = function()
+{
+ /** @type {!StringMap.<!WebInspector.ModuleManager.Extension>} */
+ this._actionsById = new StringMap();
+ this._registerActions();
+}
+
+WebInspector.ActionRegistry.prototype = {
+ _registerActions: function()
+ {
+ WebInspector.moduleManager.extensions(WebInspector.ActionDelegate).forEach(registerExtension, this);
+
+ /**
+ * @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)
+ {
+ var extension = this._actionsById.get(actionId);
+ console.assert(extension, "No action found for actionId '" + actionId + "'");
+ return extension.instance().handleAction(WebInspector.context, event);
+ }
+}
+
+/**
+ * @interface
+ */
+WebInspector.ActionDelegate = function()
+{
+}
+
+WebInspector.ActionDelegate.prototype = {
+ /**
+ * @param {!WebInspector.Context} context
+ * @param {!Event} event
+ * @return {boolean}
+ */
+ handleAction: function(context, event) {}
+}
+
+/** @type {!WebInspector.ActionRegistry} */
+WebInspector.actionRegistry;
« no previous file with comments | « Source/devtools/devtools.gypi ('k') | Source/devtools/front_end/AdvancedSearchView.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698