2 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 * @extends {WebInspector.Panel}
35 * @param {string} pageURL
37 WebInspector.ExtensionPanel = function(id, pageURL)
39 WebInspector.Panel.call(this, id);
40 this.setHideOnDetach();
41 this.element.addStyleClass("extension-panel");
42 this._panelStatusBarElement = this.element.createChild("div", "panel-status-bar hidden");
44 var extensionView = new WebInspector.ExtensionView(id, pageURL, "extension panel");
45 extensionView.show(this.element);
46 this.setDefaultFocusedElement(extensionView.defaultFocusedElement());
49 WebInspector.ExtensionPanel.prototype = {
50 defaultFocusedElement: function()
52 return WebInspector.View.prototype.defaultFocusedElement.call(this);
56 * @param {Element} element
58 addStatusBarItem: function(element)
60 this._panelStatusBarElement.removeStyleClass("hidden");
61 this._panelStatusBarElement.appendChild(element);
64 searchCanceled: function(startingNewSearch)
66 WebInspector.extensionServer.notifySearchAction(this.name, WebInspector.extensionAPI.panels.SearchAction.CancelSearch);
67 WebInspector.Panel.prototype.searchCanceled.apply(this, arguments);
71 * @param {string} query
72 * @param {boolean} shouldJump
74 performSearch: function(query, shouldJump)
76 WebInspector.extensionServer.notifySearchAction(this.name, WebInspector.extensionAPI.panels.SearchAction.PerformSearch, query);
79 jumpToNextSearchResult: function()
81 WebInspector.extensionServer.notifySearchAction(this.name, WebInspector.extensionAPI.panels.SearchAction.NextSearchResult);
82 WebInspector.Panel.prototype.jumpToNextSearchResult.call(this);
85 jumpToPreviousSearchResult: function()
87 WebInspector.extensionServer.notifySearchAction(this.name, WebInspector.extensionAPI.panels.SearchAction.PreviousSearchResult);
88 WebInspector.Panel.prototype.jumpToPreviousSearchResult.call(this);
91 __proto__: WebInspector.Panel.prototype
97 * @param {string} iconURL
98 * @param {string=} tooltip
99 * @param {boolean=} disabled
101 WebInspector.ExtensionButton = function(id, iconURL, tooltip, disabled)
104 this.element = document.createElement("button");
105 this.element.className = "status-bar-item extension";
106 this.element.addEventListener("click", this._onClicked.bind(this), false);
107 this.update(iconURL, tooltip, disabled);
110 WebInspector.ExtensionButton.prototype = {
112 * @param {string} iconURL
113 * @param {string=} tooltip
114 * @param {boolean=} disabled
116 update: function(iconURL, tooltip, disabled)
118 if (typeof iconURL === "string")
119 this.element.style.backgroundImage = "url(" + iconURL + ")";
120 if (typeof tooltip === "string")
121 this.element.title = tooltip;
122 if (typeof disabled === "boolean")
123 this.element.disabled = disabled;
126 _onClicked: function()
128 WebInspector.extensionServer.notifyButtonClicked(this._id);
134 * @extends {WebInspector.SidebarPane}
135 * @param {string} title
138 WebInspector.ExtensionSidebarPane = function(title, id)
140 WebInspector.SidebarPane.call(this, title);
141 this.setHideOnDetach();
145 WebInspector.ExtensionSidebarPane.prototype = {
147 * @param {Object} object
148 * @param {string} title
149 * @param {function(?string=)} callback
151 setObject: function(object, title, callback)
153 this._createObjectPropertiesView();
154 this._setObject(WebInspector.RemoteObject.fromLocalObject(object), title, callback);
158 * @param {string} expression
159 * @param {string} title
160 * @param {function(?string=)} callback
162 setExpression: function(expression, title, evaluateOptions, securityOrigin, callback)
164 this._createObjectPropertiesView();
165 return WebInspector.extensionServer.evaluate(expression, true, false, evaluateOptions, securityOrigin, this._onEvaluate.bind(this, title, callback));
169 * @param {string} url
171 setPage: function(url)
173 if (this._objectPropertiesView) {
174 this._objectPropertiesView.detach();
175 delete this._objectPropertiesView;
177 if (this._extensionView)
178 this._extensionView.detach(true);
180 this._extensionView = new WebInspector.ExtensionView(this._id, url, "extension fill");
181 this._extensionView.show(this.bodyElement);
183 if (!this.bodyElement.style.height)
184 this.setHeight("150px");
188 * @param {string} height
190 setHeight: function(height)
192 this.bodyElement.style.height = height;
196 * @param {string} title
197 * @param {function(?string=)} callback
198 * @param {?Protocol.Error} error
199 * @param {RuntimeAgent.RemoteObject} result
200 * @param {boolean=} wasThrown
202 _onEvaluate: function(title, callback, error, result, wasThrown)
205 callback(error.toString());
207 this._setObject(WebInspector.RemoteObject.fromPayload(result), title, callback);
210 _createObjectPropertiesView: function()
212 if (this._objectPropertiesView)
214 if (this._extensionView) {
215 this._extensionView.detach(true);
216 delete this._extensionView;
218 this._objectPropertiesView = new WebInspector.ExtensionNotifierView(this._id);
219 this._objectPropertiesView.show(this.bodyElement);
223 * @param {WebInspector.RemoteObject} object
224 * @param {string} title
225 * @param {function(?string=)} callback
227 _setObject: function(object, title, callback)
229 // This may only happen if setPage() was called while we were evaluating the expression.
230 if (!this._objectPropertiesView) {
231 callback("operation cancelled");
234 this._objectPropertiesView.element.removeChildren();
235 var section = new WebInspector.ObjectPropertiesSection(object, title);
237 section.headerElement.addStyleClass("hidden");
238 section.expanded = true;
239 section.editable = false;
240 this._objectPropertiesView.element.appendChild(section.element);
244 __proto__: WebInspector.SidebarPane.prototype