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 * @implements {WebInspector.Searchable}
34 * @extends {WebInspector.Panel}
36 * @param {string} pageURL
38 WebInspector.ExtensionPanel = function(id, pageURL)
40 WebInspector.Panel.call(this, id);
41 this.setHideOnDetach();
42 this.element.classList.add("extension-panel");
43 this._panelStatusBarElement = this.element.createChild("div", "panel-status-bar hidden");
45 this._searchableView = new WebInspector.SearchableView(this);
46 this._searchableView.show(this.element);
48 var extensionView = new WebInspector.ExtensionView(id, pageURL, "extension panel");
49 extensionView.show(this._searchableView.element);
50 this.setDefaultFocusedElement(extensionView.defaultFocusedElement());
53 WebInspector.ExtensionPanel.prototype = {
57 defaultFocusedElement: function()
59 return WebInspector.View.prototype.defaultFocusedElement.call(this);
63 * @param {!Element} element
65 addStatusBarItem: function(element)
67 this._panelStatusBarElement.classList.remove("hidden");
68 this._panelStatusBarElement.appendChild(element);
71 searchCanceled: function()
73 WebInspector.extensionServer.notifySearchAction(this.name, WebInspector.extensionAPI.panels.SearchAction.CancelSearch);
74 this._searchableView.updateSearchMatchesCount(0);
78 * @return {!WebInspector.SearchableView}
80 searchableView: function()
82 return this._searchableView;
86 * @param {string} query
87 * @param {boolean} shouldJump
88 * @param {boolean=} jumpBackwards
90 performSearch: function(query, shouldJump, jumpBackwards)
92 WebInspector.extensionServer.notifySearchAction(this.name, WebInspector.extensionAPI.panels.SearchAction.PerformSearch, query);
95 jumpToNextSearchResult: function()
97 WebInspector.extensionServer.notifySearchAction(this.name, WebInspector.extensionAPI.panels.SearchAction.NextSearchResult);
100 jumpToPreviousSearchResult: function()
102 WebInspector.extensionServer.notifySearchAction(this.name, WebInspector.extensionAPI.panels.SearchAction.PreviousSearchResult);
105 __proto__: WebInspector.Panel.prototype
111 * @param {string} iconURL
112 * @param {string=} tooltip
113 * @param {boolean=} disabled
115 WebInspector.ExtensionButton = function(id, iconURL, tooltip, disabled)
118 this.element = document.createElement("button");
119 this.element.className = "status-bar-item extension";
120 this.element.addEventListener("click", this._onClicked.bind(this), false);
121 this.update(iconURL, tooltip, disabled);
124 WebInspector.ExtensionButton.prototype = {
126 * @param {string} iconURL
127 * @param {string=} tooltip
128 * @param {boolean=} disabled
130 update: function(iconURL, tooltip, disabled)
132 if (typeof iconURL === "string")
133 this.element.style.backgroundImage = "url(" + iconURL + ")";
134 if (typeof tooltip === "string")
135 this.element.title = tooltip;
136 if (typeof disabled === "boolean")
137 this.element.disabled = disabled;
140 _onClicked: function()
142 WebInspector.extensionServer.notifyButtonClicked(this._id);
148 * @extends {WebInspector.SidebarPane}
149 * @param {string} title
152 WebInspector.ExtensionSidebarPane = function(title, id)
154 WebInspector.SidebarPane.call(this, title);
155 this.setHideOnDetach();
159 WebInspector.ExtensionSidebarPane.prototype = {
161 * @param {!Object} object
162 * @param {string} title
163 * @param {function(?string=)} callback
165 setObject: function(object, title, callback)
167 this._createObjectPropertiesView();
168 this._setObject(WebInspector.RemoteObject.fromLocalObject(object), title, callback);
172 * @param {string} expression
173 * @param {string} title
174 * @param {function(?string=)} callback
176 setExpression: function(expression, title, evaluateOptions, securityOrigin, callback)
178 this._createObjectPropertiesView();
179 WebInspector.extensionServer.evaluate(expression, true, false, evaluateOptions, securityOrigin, this._onEvaluate.bind(this, title, callback));
183 * @param {string} url
185 setPage: function(url)
187 if (this._objectPropertiesView) {
188 this._objectPropertiesView.detach();
189 delete this._objectPropertiesView;
191 if (this._extensionView)
192 this._extensionView.detach(true);
194 this._extensionView = new WebInspector.ExtensionView(this._id, url, "extension fill");
195 this._extensionView.show(this.bodyElement);
197 if (!this.bodyElement.style.height)
198 this.setHeight("150px");
202 * @param {string} height
204 setHeight: function(height)
206 this.bodyElement.style.height = height;
210 * @param {string} title
211 * @param {function(?string=)} callback
212 * @param {?Protocol.Error} error
213 * @param {!RuntimeAgent.RemoteObject} result
214 * @param {boolean=} wasThrown
216 _onEvaluate: function(title, callback, error, result, wasThrown)
219 callback(error.toString());
221 this._setObject(WebInspector.runtimeModel.createRemoteObject(result), title, callback);
224 _createObjectPropertiesView: function()
226 if (this._objectPropertiesView)
228 if (this._extensionView) {
229 this._extensionView.detach(true);
230 delete this._extensionView;
232 this._objectPropertiesView = new WebInspector.ExtensionNotifierView(this._id);
233 this._objectPropertiesView.show(this.bodyElement);
237 * @param {!WebInspector.RemoteObject} object
238 * @param {string} title
239 * @param {function(?string=)} callback
241 _setObject: function(object, title, callback)
243 // This may only happen if setPage() was called while we were evaluating the expression.
244 if (!this._objectPropertiesView) {
245 callback("operation cancelled");
248 this._objectPropertiesView.element.removeChildren();
249 var section = new WebInspector.ObjectPropertiesSection(object, title);
251 section.headerElement.classList.add("hidden");
252 section.expanded = true;
253 section.editable = false;
254 this._objectPropertiesView.element.appendChild(section.element);
258 __proto__: WebInspector.SidebarPane.prototype