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._ensureExtensionServer = function() 27 { 28 if (!WebInspector.extensionServer) 29 WebInspector.extensionServer = self.runtime.instance(WebInspector.ExtensionServerAPI); 30 }, 31 32 WebInspector.ExtensionServerProxy.prototype = { 33 setFrontendReady: function() 34 { 35 this._frontendReady = true; 36 this._pushExtensionsToServer(); 37 }, 38 39 _addExtensions: function(extensions) 40 { 41 if (extensions.length === 0) 42 return; 43 44 console.assert(!this._pendingExtensions); 45 this._pendingExtensions = extensions; 46 this._pushExtensionsToServer(); 47 }, 48 49 _pushExtensionsToServer: function() 50 { 51 if (!this._frontendReady || !this._pendingExtensions) 52 return; 53 WebInspector.ExtensionServerProxy._ensureExtensionServer(); 54 WebInspector.extensionServer.addExtensions(this._pendingExtensions); 55 delete this._pendingExtensions; 56 } 57 } 58 59 WebInspector.extensionServerProxy = new WebInspector.ExtensionServerProxy(); 60 61 WebInspector.addExtensions = function(extensions) 62 { 63 WebInspector.extensionServerProxy._addExtensions(extensions); 64 } 65 66 WebInspector.setInspectedTabId = function(tabId) 67 { 68 WebInspector._inspectedTabId = tabId; 69 } 70