| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 */ | 7 */ |
| 8 WebInspector.ActionRegistry = function() | 8 WebInspector.ActionRegistry = function() |
| 9 { | 9 { |
| 10 /** @type {!Map.<string, !WebInspector.Action>} */ | 10 /** @type {!Map.<string, !WebInspector.Action>} */ |
| 11 this._actionsById = new Map(); | 11 this._actionsById = new Map(); |
| 12 this._registerActions(); | 12 this._registerActions(); |
| 13 } | 13 }; |
| 14 | 14 |
| 15 WebInspector.ActionRegistry.prototype = { | 15 WebInspector.ActionRegistry.prototype = { |
| 16 _registerActions: function() | 16 _registerActions: function() |
| 17 { | 17 { |
| 18 self.runtime.extensions(WebInspector.ActionDelegate).forEach(registerExt
ension, this); | 18 self.runtime.extensions(WebInspector.ActionDelegate).forEach(registerExt
ension, this); |
| 19 | 19 |
| 20 /** | 20 /** |
| 21 * @param {!Runtime.Extension} extension | 21 * @param {!Runtime.Extension} extension |
| 22 * @this {WebInspector.ActionRegistry} | 22 * @this {WebInspector.ActionRegistry} |
| 23 */ | 23 */ |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 }, | 65 }, |
| 66 | 66 |
| 67 /** | 67 /** |
| 68 * @param {string} actionId | 68 * @param {string} actionId |
| 69 * @return {?WebInspector.Action} | 69 * @return {?WebInspector.Action} |
| 70 */ | 70 */ |
| 71 action: function(actionId) | 71 action: function(actionId) |
| 72 { | 72 { |
| 73 return this._actionsById.get(actionId) || null; | 73 return this._actionsById.get(actionId) || null; |
| 74 } | 74 } |
| 75 } | 75 }; |
| 76 | 76 |
| 77 /** | 77 /** |
| 78 * @constructor | 78 * @constructor |
| 79 * @extends {WebInspector.Object} | 79 * @extends {WebInspector.Object} |
| 80 * @param {!Runtime.Extension} extension | 80 * @param {!Runtime.Extension} extension |
| 81 */ | 81 */ |
| 82 WebInspector.Action = function(extension) | 82 WebInspector.Action = function(extension) |
| 83 { | 83 { |
| 84 WebInspector.Object.call(this); | 84 WebInspector.Object.call(this); |
| 85 this._extension = extension; | 85 this._extension = extension; |
| 86 this._enabled = true; | 86 this._enabled = true; |
| 87 this._toggled = false; | 87 this._toggled = false; |
| 88 } | 88 }; |
| 89 | 89 |
| 90 /** @enum {symbol} */ | 90 /** @enum {symbol} */ |
| 91 WebInspector.Action.Events = { | 91 WebInspector.Action.Events = { |
| 92 Enabled: Symbol("Enabled"), | 92 Enabled: Symbol("Enabled"), |
| 93 Toggled: Symbol("Toggled") | 93 Toggled: Symbol("Toggled") |
| 94 } | 94 }; |
| 95 | 95 |
| 96 WebInspector.Action.prototype = { | 96 WebInspector.Action.prototype = { |
| 97 /** | 97 /** |
| 98 * @return {string} | 98 * @return {string} |
| 99 */ | 99 */ |
| 100 id: function() | 100 id: function() |
| 101 { | 101 { |
| 102 return this._extension.descriptor()["actionId"]; | 102 return this._extension.descriptor()["actionId"]; |
| 103 }, | 103 }, |
| 104 | 104 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 setToggled: function(toggled) | 196 setToggled: function(toggled) |
| 197 { | 197 { |
| 198 if (this._toggled === toggled) | 198 if (this._toggled === toggled) |
| 199 return; | 199 return; |
| 200 | 200 |
| 201 this._toggled = toggled; | 201 this._toggled = toggled; |
| 202 this.dispatchEventToListeners(WebInspector.Action.Events.Toggled, toggle
d); | 202 this.dispatchEventToListeners(WebInspector.Action.Events.Toggled, toggle
d); |
| 203 }, | 203 }, |
| 204 | 204 |
| 205 __proto__: WebInspector.Object.prototype | 205 __proto__: WebInspector.Object.prototype |
| 206 } | 206 }; |
| 207 | 207 |
| 208 /** | 208 /** |
| 209 * @interface | 209 * @interface |
| 210 */ | 210 */ |
| 211 WebInspector.ActionDelegate = function() | 211 WebInspector.ActionDelegate = function() |
| 212 { | 212 { |
| 213 } | 213 }; |
| 214 | 214 |
| 215 WebInspector.ActionDelegate.prototype = { | 215 WebInspector.ActionDelegate.prototype = { |
| 216 /** | 216 /** |
| 217 * @param {!WebInspector.Context} context | 217 * @param {!WebInspector.Context} context |
| 218 * @param {string} actionId | 218 * @param {string} actionId |
| 219 * @return {boolean} | 219 * @return {boolean} |
| 220 */ | 220 */ |
| 221 handleAction: function(context, actionId) {} | 221 handleAction: function(context, actionId) {} |
| 222 } | 222 }; |
| 223 | 223 |
| 224 /** @type {!WebInspector.ActionRegistry} */ | 224 /** @type {!WebInspector.ActionRegistry} */ |
| 225 WebInspector.actionRegistry; | 225 WebInspector.actionRegistry; |
| OLD | NEW |