OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2014 The Chromium Authors. All rights reserved. | |
3 * Use of this source code is governed by a BSD-style license that can be | |
4 * found in the LICENSE file. | |
5 */ | |
6 | |
7 /** | |
8 * @interface | |
9 */ | |
10 WebInspector.ExtensionServerAPI = function() { } | |
11 | |
12 WebInspector.ExtensionServerAPI.prototype = { | |
13 /** | |
14 * @param {!Array.<!ExtensionDescriptor>} descriptors | |
15 */ | |
16 addExtensions: function(descriptors) { } | |
17 } | |
18 | |
19 /** | |
20 * @constructor | |
21 */ | |
22 WebInspector.ExtensionServerProxy = function() | |
23 { | |
24 } | |
25 | |
26 WebInspector.ExtensionServerProxy.prototype = { | |
27 setFrontendReady: function() | |
28 { | |
29 this._frontendReady = true; | |
30 this._pushExtensionsToServer(); | |
31 }, | |
32 | |
33 _addExtensions: function(extensions) | |
34 { | |
35 if (extensions.length === 0) | |
36 return; | |
37 | |
38 console.assert(!this._pendingExtensions); | |
39 this._pendingExtensions = extensions; | |
40 this._pushExtensionsToServer(); | |
41 }, | |
42 | |
43 _pushExtensionsToServer: function() | |
44 { | |
45 if (!this._frontendReady || !this._pendingExtensions) | |
46 return; | |
47 | |
48 self.runtime.instancePromise(WebInspector.ExtensionServerAPI).then(pushE
xtensions.bind(this)).done(); | |
49 | |
50 /** | |
51 * @param {!Object} object | |
52 * @this {WebInspector.ExtensionServerProxy} | |
53 */ | |
54 function pushExtensions(object) | |
55 { | |
56 this._extensionServer = /** @type {!WebInspector.ExtensionServerAPI}
*/ (object); | |
57 | |
58 if (WebInspector.extensionServerProxy._overridePlatformExtensionAPIF
orTest) | |
59 window.buildPlatformExtensionAPI = WebInspector.extensionServerP
roxy._overridePlatformExtensionAPIForTest; | |
60 | |
61 this._extensionServer.addExtensions(this._pendingExtensions); | |
62 delete this._pendingExtensions; | |
63 } | |
64 } | |
65 } | |
66 | |
67 WebInspector.extensionServerProxy = new WebInspector.ExtensionServerProxy(); | |
68 | |
69 WebInspector.addExtensions = function(extensions) | |
70 { | |
71 WebInspector.extensionServerProxy._addExtensions(extensions); | |
72 } | |
73 | |
74 WebInspector.setInspectedTabId = function(tabId) | |
75 { | |
76 WebInspector._inspectedTabId = tabId; | |
77 } | |
OLD | NEW |