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.Context = function() | 8 WebInspector.Context = function() |
9 { | 9 { |
10 this._flavors = new Map(); | 10 this._flavors = new Map(); |
(...skipping 26 matching lines...) Expand all Loading... |
37 this._dispatchFlavorChange(flavorType, flavorValue); | 37 this._dispatchFlavorChange(flavorType, flavorValue); |
38 }, | 38 }, |
39 | 39 |
40 /** | 40 /** |
41 * @param {function(new:T, ...)} flavorType | 41 * @param {function(new:T, ...)} flavorType |
42 * @param {?T} flavorValue | 42 * @param {?T} flavorValue |
43 * @template T | 43 * @template T |
44 */ | 44 */ |
45 _dispatchFlavorChange: function(flavorType, flavorValue) | 45 _dispatchFlavorChange: function(flavorType, flavorValue) |
46 { | 46 { |
| 47 self.runtime.extensions(WebInspector.ContextFlavorListener, flavorValue)
.map(extension => { |
| 48 extension.instance().then(instance => /** @type {!WebInspector.Conte
xtFlavorListener} */ (instance).flavorChanged(flavorValue)); |
| 49 }); |
| 50 |
47 var dispatcher = this._eventDispatchers.get(flavorType); | 51 var dispatcher = this._eventDispatchers.get(flavorType); |
48 if (!dispatcher) | 52 if (!dispatcher) |
49 return; | 53 return; |
50 dispatcher.dispatchEventToListeners(WebInspector.Context.Events.FlavorCh
anged, flavorValue); | 54 dispatcher.dispatchEventToListeners(WebInspector.Context.Events.FlavorCh
anged, flavorValue); |
51 }, | 55 }, |
52 | 56 |
53 /** | 57 /** |
54 * @param {function(new:Object, ...)} flavorType | 58 * @param {function(new:Object, ...)} flavorType |
55 * @param {function(!WebInspector.Event)} listener | 59 * @param {function(!WebInspector.Event)} listener |
56 * @param {!Object=} thisObject | 60 * @param {!Object=} thisObject |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 var availableFlavors = this.flavors(); | 113 var availableFlavors = this.flavors(); |
110 extensions.forEach(function(extension) { | 114 extensions.forEach(function(extension) { |
111 if (self.runtime.isExtensionApplicableToContextTypes(extension, avai
lableFlavors)) | 115 if (self.runtime.isExtensionApplicableToContextTypes(extension, avai
lableFlavors)) |
112 targetExtensionSet.add(extension); | 116 targetExtensionSet.add(extension); |
113 }); | 117 }); |
114 | 118 |
115 return targetExtensionSet; | 119 return targetExtensionSet; |
116 } | 120 } |
117 } | 121 } |
118 | 122 |
| 123 /** |
| 124 * @interface |
| 125 */ |
| 126 WebInspector.ContextFlavorListener = function() { } |
| 127 |
| 128 WebInspector.ContextFlavorListener.prototype = { |
| 129 /** |
| 130 * @param {?Object} object |
| 131 */ |
| 132 flavorChanged: function(object) { } |
| 133 } |
| 134 |
119 WebInspector.context = new WebInspector.Context(); | 135 WebInspector.context = new WebInspector.Context(); |
OLD | NEW |