1 /* See license.txt for terms of usage */ 2 3 define([ 4 "firebug/lib/object", 5 "firebug/firebug", 6 "firebug/trace/debug", 7 ], 8 function(Obj, Firebug, Debug) { 9 10 // ************************************************************************************************ 11 // This is a panel implemented as its own browser with its own URL 12 13 Firebug.PluginPanel = function() {}; 14 15 Firebug.PluginPanel.prototype = Obj.extend(Firebug.Panel, 16 { 17 createBrowser: function() 18 { 19 var doc = Firebug.chrome.window.document; 20 this.browser = doc.createElement("browser"); 21 this.browser.addEventListener("DOMContentLoaded", this.browserReady, false); 22 if (FBTrace.DBG_INITIALIZE) 23 FBTrace.sysout("plugin.createBrowser DOMContentLoaded addEventListener\n"); 24 this.browser.className = "pluginBrowser"; 25 this.browser.setAttribute("src", this.url); // see tabContext.createPanelType 26 }, 27 28 destroyBrowser: function() 29 { 30 if (this.browser) 31 { 32 this.browser.parentNode.removeChild(this.browser); 33 delete this.browser; 34 if (FBTrace.DBG_INITIALIZE) 35 FBTrace.sysout("plugin.destroyBrowser \n"); 36 } 37 }, 38 39 browserReady: function() 40 { 41 this.browser.removeEventListener("DOMContentLoaded", this.browserReady, false); 42 if (FBTrace.DBG_INITIALIZE) FBTrace.sysout("plugin.browserReady DOMContentLoaded addEventListener\n"); 43 this.innerPanel = this.browser.contentWindow.FirebugPanel; // XXXjjb ? 44 if (this.visible) 45 { 46 if (this.innerPanel) 47 innerCall(this.innerPanel, "initialize", [this.context.window]); 48 this.updateSelection(this.selection); 49 } 50 }, 51 52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 53 // extends Panel 54 55 initialize: function() 56 { 57 this.browserReady = Obj.bindFixed(this.browserReady, this); 58 Firebug.Panel.initialize.apply(this, arguments); 59 }, 60 61 destroy: function(state) 62 { 63 this.destroyBrowser(); 64 Firebug.Panel.destroy.apply(this, arguments); 65 }, 66 67 show: function(state) 68 { 69 if (!this.browser) 70 this.createBrowser(); 71 }, 72 73 hide: function() 74 { 75 }, 76 77 supportsObject: function(object, type) 78 { 79 if (this.innerPanel) 80 return innerCall(this.innerPanel, "supportsObject", [object, type]); 81 else 82 return 0; 83 }, 84 85 updateSelection: function(object) 86 { 87 if (!this.innerPanel) 88 return; 89 90 innerCall(this.innerPanel, "select", [object]); 91 }, 92 93 getObjectPath: function(object) 94 { 95 }, 96 97 getDefaultSelection: function() 98 { 99 }, 100 101 updateOption: function(name, value) 102 { 103 }, 104 105 getOptionsMenuItems: function() 106 { 107 }, 108 109 getContextMenuItems: function(object, target) 110 { 111 }, 112 113 getEditor: function(target, value) 114 { 115 } 116 }); 117 118 // ************************************************************************************************ 119 120 function innerCall(innerPanel, name, args) 121 { 122 try 123 { 124 innerPanel[name].apply(innerPanel, args); 125 } 126 catch (exc) 127 { 128 Debug.ERROR(exc); 129 } 130 } 131 132 // ************************************************************************************************ 133 // Registration 134 135 return Firebug.PluginPanel; 136 137 // ************************************************************************************************ 138 }); 139