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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/devtools/devtools.gypi ('k') | Source/devtools/front_end/AdvancedSearchView.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 */
8 WebInspector.ActionRegistry = function()
9 {
10 /** @type {!StringMap.<!WebInspector.ModuleManager.Extension>} */
11 this._actionsById = new StringMap();
12 this._registerActions();
13 }
14
15 WebInspector.ActionRegistry.prototype = {
16 _registerActions: function()
17 {
18 WebInspector.moduleManager.extensions(WebInspector.ActionDelegate).forEa ch(registerExtension, this);
19
20 /**
21 * @param {!WebInspector.ModuleManager.Extension} extension
22 * @this {WebInspector.ActionRegistry}
23 */
24 function registerExtension(extension)
25 {
26 var actionId = extension.descriptor()["actionId"];
27 console.assert(actionId);
28 console.assert(!this._actionsById.get(actionId));
29 this._actionsById.put(actionId, extension);
30 }
31 },
32
33 /**
34 * @param {string} actionId
35 * @param {!Event} event
36 * @return {boolean}
37 */
38 execute: function(actionId, event)
39 {
40 var extension = this._actionsById.get(actionId);
41 console.assert(extension, "No action found for actionId '" + actionId + "'");
42 return extension.instance().handleAction(WebInspector.context, event);
43 }
44 }
45
46 /**
47 * @interface
48 */
49 WebInspector.ActionDelegate = function()
50 {
51 }
52
53 WebInspector.ActionDelegate.prototype = {
54 /**
55 * @param {!WebInspector.Context} context
56 * @param {!Event} event
57 * @return {boolean}
58 */
59 handleAction: function(context, event) {}
60 }
61
62 /** @type {!WebInspector.ActionRegistry} */
63 WebInspector.actionRegistry;
OLDNEW
« 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