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 {!StringMap.<!Runtime.Extension>} */ | 10 /** @type {!StringMap.<!Runtime.Extension>} */ |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 if (extension) | 43 if (extension) |
44 extensions.push(extension); | 44 extensions.push(extension); |
45 }, this); | 45 }, this); |
46 return context.applicableExtensions(extensions).values().map(function(ex
tension) { | 46 return context.applicableExtensions(extensions).values().map(function(ex
tension) { |
47 return extension.descriptor()["actionId"]; | 47 return extension.descriptor()["actionId"]; |
48 }); | 48 }); |
49 }, | 49 }, |
50 | 50 |
51 /** | 51 /** |
52 * @param {string} actionId | 52 * @param {string} actionId |
53 * @return {boolean} | 53 * @return {!Promise.<boolean>} |
54 */ | 54 */ |
55 execute: function(actionId) | 55 execute: function(actionId) |
56 { | 56 { |
57 var extension = this._actionsById.get(actionId); | 57 var extension = this._actionsById.get(actionId); |
58 console.assert(extension, "No action found for actionId '" + actionId +
"'"); | 58 console.assert(extension, "No action found for actionId '" + actionId +
"'"); |
59 extension.instancePromise().then(handleAction).done(); | 59 return extension.instancePromise().then(handleAction); |
60 return !!extension; | |
61 | 60 |
62 /** | 61 /** |
63 * @param {!Object} actionDelegate | 62 * @param {!Object} actionDelegate |
| 63 * @return {boolean} |
64 */ | 64 */ |
65 function handleAction(actionDelegate) | 65 function handleAction(actionDelegate) |
66 { | 66 { |
67 /** @type {!WebInspector.ActionDelegate} */(actionDelegate).handleAc
tion(WebInspector.context); | 67 return /** @type {!WebInspector.ActionDelegate} */(actionDelegate).h
andleAction(WebInspector.context); |
68 } | 68 } |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 /** | 72 /** |
73 * @interface | 73 * @interface |
74 */ | 74 */ |
75 WebInspector.ActionDelegate = function() | 75 WebInspector.ActionDelegate = function() |
76 { | 76 { |
77 } | 77 } |
78 | 78 |
79 WebInspector.ActionDelegate.prototype = { | 79 WebInspector.ActionDelegate.prototype = { |
80 /** | 80 /** |
81 * @param {!WebInspector.Context} context | 81 * @param {!WebInspector.Context} context |
82 * @return {boolean} | 82 * @return {boolean} |
83 */ | 83 */ |
84 handleAction: function(context) {} | 84 handleAction: function(context) {} |
85 } | 85 } |
86 | 86 |
87 /** @type {!WebInspector.ActionRegistry} */ | 87 /** @type {!WebInspector.ActionRegistry} */ |
88 WebInspector.actionRegistry; | 88 WebInspector.actionRegistry; |
OLD | NEW |