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 24 matching lines...) Expand all Loading... |
35 this._dispatchFlavorChange(flavorType, flavorValue); | 35 this._dispatchFlavorChange(flavorType, flavorValue); |
36 }, | 36 }, |
37 | 37 |
38 /** | 38 /** |
39 * @param {function(new:T, ...)} flavorType | 39 * @param {function(new:T, ...)} flavorType |
40 * @param {?T} flavorValue | 40 * @param {?T} flavorValue |
41 * @template T | 41 * @template T |
42 */ | 42 */ |
43 _dispatchFlavorChange: function(flavorType, flavorValue) | 43 _dispatchFlavorChange: function(flavorType, flavorValue) |
44 { | 44 { |
45 self.runtime.extensions(WebInspector.ContextFlavorListener, flavorValue)
.map(extension => { | 45 for (var extension of self.runtime.extensions(WebInspector.ContextFlavor
Listener)) { |
46 extension.instance().then(instance => /** @type {!WebInspector.Conte
xtFlavorListener} */ (instance).flavorChanged(flavorValue)); | 46 if (extension.hasContextType(flavorType)) |
47 }); | 47 extension.instance().then(instance => /** @type {!WebInspector.C
ontextFlavorListener} */ (instance).flavorChanged(flavorValue)); |
48 | 48 } |
49 var dispatcher = this._eventDispatchers.get(flavorType); | 49 var dispatcher = this._eventDispatchers.get(flavorType); |
50 if (!dispatcher) | 50 if (!dispatcher) |
51 return; | 51 return; |
52 dispatcher.dispatchEventToListeners(WebInspector.Context.Events.FlavorCh
anged, flavorValue); | 52 dispatcher.dispatchEventToListeners(WebInspector.Context.Events.FlavorCh
anged, flavorValue); |
53 }, | 53 }, |
54 | 54 |
55 /** | 55 /** |
56 * @param {function(new:Object, ...)} flavorType | 56 * @param {function(new:Object, ...)} flavorType |
57 * @param {function(!WebInspector.Event)} listener | 57 * @param {function(!WebInspector.Event)} listener |
58 * @param {!Object=} thisObject | 58 * @param {!Object=} thisObject |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 WebInspector.ContextFlavorListener = function() { } | 124 WebInspector.ContextFlavorListener = function() { } |
125 | 125 |
126 WebInspector.ContextFlavorListener.prototype = { | 126 WebInspector.ContextFlavorListener.prototype = { |
127 /** | 127 /** |
128 * @param {?Object} object | 128 * @param {?Object} object |
129 */ | 129 */ |
130 flavorChanged: function(object) { } | 130 flavorChanged: function(object) { } |
131 } | 131 } |
132 | 132 |
133 WebInspector.context = new WebInspector.Context(); | 133 WebInspector.context = new WebInspector.Context(); |
OLD | NEW |