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

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: Fix context-related sort order Created 6 years, 9 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
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);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698