2 * Copyright (C) 2011 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.
31 WebInspector.ExtensionPanel = function(id, label, iconURL, options)
33 this.toolbarItemLabel = label;
35 this._addStyleRule(".toolbar-item." + id + " .toolbar-icon", "background-image: url(" + iconURL + ");");
36 WebInspector.Panel.call(this, id);
39 WebInspector.ExtensionPanel.prototype = {
40 get defaultFocusedElement()
42 return this.sidebarTreeElement || this.element;
45 searchCanceled: function(startingNewSearch)
47 WebInspector.extensionServer.notifySearchAction(this._id, "cancelSearch");
48 WebInspector.Panel.prototype.searchCanceled.apply(this, arguments);
51 performSearch: function(query)
53 WebInspector.extensionServer.notifySearchAction(this._id, "performSearch", query);
54 WebInspector.Panel.prototype.performSearch.apply(this, arguments);
57 jumpToNextSearchResult: function()
59 WebInspector.extensionServer.notifySearchAction(this._id, "nextSearchResult");
60 WebInspector.Panel.prototype.jumpToNextSearchResult.call(this);
63 jumpToPreviousSearchResult: function()
65 WebInspector.extensionServer.notifySearchAction(this._id, "previousSearchResult");
66 WebInspector.Panel.prototype.jumpToPreviousSearchResult.call(this);
69 _addStyleRule: function(selector, body)
71 var style = document.createElement("style");
72 style.textContent = selector + " { " + body + " }";
73 document.head.appendChild(style);
77 WebInspector.ExtensionPanel.prototype.__proto__ = WebInspector.Panel.prototype;
79 WebInspector.ExtensionSidebarPane = function(title, id)
81 WebInspector.SidebarPane.call(this, title);
85 WebInspector.ExtensionSidebarPane.prototype = {
86 setObject: function(object, title)
88 this._setObject(WebInspector.RemoteObject.fromLocalObject(object), title);
91 setExpression: function(expression, title)
93 RuntimeAgent.evaluate(expression, "extension-watch", true, this._onEvaluate.bind(this, title));
96 setPage: function(url)
98 this.bodyElement.removeChildren();
99 WebInspector.extensionServer.createClientIframe(this.bodyElement, url);
100 // TODO: Consider doing this upon load event.
101 WebInspector.extensionServer.notifyExtensionSidebarUpdated(this._id);
104 _onEvaluate: function(title, error, result, wasThrown)
107 this._setObject(WebInspector.RemoteObject.fromPayload(result), title);
110 _setObject: function(object, title)
112 this.bodyElement.removeChildren();
113 var section = new WebInspector.ObjectPropertiesSection(object, title);
115 section.headerElement.addStyleClass("hidden");
116 section.expanded = true;
117 section.editable = false;
118 this.bodyElement.appendChild(section.element);
119 WebInspector.extensionServer.notifyExtensionSidebarUpdated(this._id);
123 WebInspector.ExtensionSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype;