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}
35 * @param {!WebInspector.ExtensionServer} server
36 * @param {string} panelName
38 * @param {string} pageURL
40 WebInspector
.ExtensionPanel = function(server
, panelName
, id
, pageURL
)
42 WebInspector
.Panel
.call(this, panelName
);
43 this._server
= server
;
45 this.setHideOnDetach();
46 this._panelToolbar
= new WebInspector
.Toolbar(this.element
);
47 this._panelToolbar
.element
.classList
.add("hidden");
49 this._searchableView
= new WebInspector
.SearchableView(this);
50 this._searchableView
.show(this.element
);
52 var extensionView
= new WebInspector
.ExtensionView(server
, this._id
, pageURL
, "extension");
53 extensionView
.show(this._searchableView
.element
);
54 this.setDefaultFocusedElement(extensionView
.defaultFocusedElement());
57 WebInspector
.ExtensionPanel
.prototype = {
62 defaultFocusedElement: function()
64 return WebInspector
.Widget
.prototype.defaultFocusedElement
.call(this);
68 * @param {!WebInspector.ToolbarItem} item
70 addToolbarItem: function(item
)
72 this._panelToolbar
.element
.classList
.remove("hidden");
73 this._panelToolbar
.appendToolbarItem(item
);
79 searchCanceled: function()
81 this._server
.notifySearchAction(this._id
, WebInspector
.extensionAPI
.panels
.SearchAction
.CancelSearch
);
82 this._searchableView
.updateSearchMatchesCount(0);
87 * @return {!WebInspector.SearchableView}
89 searchableView: function()
91 return this._searchableView
;
96 * @param {!WebInspector.SearchableView.SearchConfig} searchConfig
97 * @param {boolean} shouldJump
98 * @param {boolean=} jumpBackwards
100 performSearch: function(searchConfig
, shouldJump
, jumpBackwards
)
102 var query
= searchConfig
.query
;
103 this._server
.notifySearchAction(this._id
, WebInspector
.extensionAPI
.panels
.SearchAction
.PerformSearch
, query
);
109 jumpToNextSearchResult: function()
111 this._server
.notifySearchAction(this._id
, WebInspector
.extensionAPI
.panels
.SearchAction
.NextSearchResult
);
117 jumpToPreviousSearchResult: function()
119 this._server
.notifySearchAction(this._id
, WebInspector
.extensionAPI
.panels
.SearchAction
.PreviousSearchResult
);
126 supportsCaseSensitiveSearch: function()
135 supportsRegexSearch: function()
140 __proto__
: WebInspector
.Panel
.prototype
145 * @param {!WebInspector.ExtensionServer} server
147 * @param {string} iconURL
148 * @param {string=} tooltip
149 * @param {boolean=} disabled
151 WebInspector
.ExtensionButton = function(server
, id
, iconURL
, tooltip
, disabled
)
155 this._toolbarButton
= new WebInspector
.ToolbarButton("", "extension");
156 this._toolbarButton
.addEventListener("click", server
.notifyButtonClicked
.bind(server
, this._id
));
157 this.update(iconURL
, tooltip
, disabled
);
160 WebInspector
.ExtensionButton
.prototype = {
162 * @param {string} iconURL
163 * @param {string=} tooltip
164 * @param {boolean=} disabled
166 update: function(iconURL
, tooltip
, disabled
)
168 if (typeof iconURL
=== "string")
169 this._toolbarButton
.setBackgroundImage(iconURL
);
170 if (typeof tooltip
=== "string")
171 this._toolbarButton
.setTitle(tooltip
);
172 if (typeof disabled
=== "boolean")
173 this._toolbarButton
.setEnabled(!disabled
);
177 * @return {!WebInspector.ToolbarButton}
179 toolbarButton: function()
181 return this._toolbarButton
;
187 * @extends {WebInspector.SidebarPane}
188 * @param {!WebInspector.ExtensionServer} server
189 * @param {string} panelName
190 * @param {string} title
193 WebInspector
.ExtensionSidebarPane = function(server
, panelName
, title
, id
)
195 WebInspector
.SidebarPane
.call(this, title
);
196 this._panelName
= panelName
;
197 this._server
= server
;
201 WebInspector
.ExtensionSidebarPane
.prototype = {
213 panelName: function()
215 return this._panelName
;
219 * @param {!Object} object
220 * @param {string} title
221 * @param {function(?string=)} callback
223 setObject: function(object
, title
, callback
)
225 this._createObjectPropertiesView();
226 this._setObject(WebInspector
.RemoteObject
.fromLocalObject(object
), title
, callback
);
230 * @param {string} expression
231 * @param {string} title
232 * @param {!Object} evaluateOptions
233 * @param {string} securityOrigin
234 * @param {function(?string=)} callback
236 setExpression: function(expression
, title
, evaluateOptions
, securityOrigin
, callback
)
238 this._createObjectPropertiesView();
239 this._server
.evaluate(expression
, true, false, evaluateOptions
, securityOrigin
, this._onEvaluate
.bind(this, title
, callback
));
243 * @param {string} url
245 setPage: function(url
)
247 if (this._objectPropertiesView
) {
248 this._objectPropertiesView
.detach();
249 delete this._objectPropertiesView
;
251 if (this._extensionView
)
252 this._extensionView
.detach(true);
254 this._extensionView
= new WebInspector
.ExtensionView(this._server
, this._id
, url
, "extension fill");
255 this._extensionView
.show(this.element
);
257 if (!this.element
.style
.height
)
258 this.setHeight("150px");
262 * @param {string} height
264 setHeight: function(height
)
266 this.element
.style
.height
= height
;
270 * @param {string} title
271 * @param {function(?string=)} callback
272 * @param {?Protocol.Error} error
273 * @param {?WebInspector.RemoteObject} result
274 * @param {boolean=} wasThrown
276 _onEvaluate: function(title
, callback
, error
, result
, wasThrown
)
279 callback(error
.toString());
281 this._setObject(/** @type {!WebInspector.RemoteObject} */ (result
), title
, callback
);
284 _createObjectPropertiesView: function()
286 if (this._objectPropertiesView
)
288 if (this._extensionView
) {
289 this._extensionView
.detach(true);
290 delete this._extensionView
;
292 this._objectPropertiesView
= new WebInspector
.ExtensionNotifierView(this._server
, this._id
);
293 this._objectPropertiesView
.show(this.element
);
297 * @param {!WebInspector.RemoteObject} object
298 * @param {string} title
299 * @param {function(?string=)} callback
301 _setObject: function(object
, title
, callback
)
303 // This may only happen if setPage() was called while we were evaluating the expression.
304 if (!this._objectPropertiesView
) {
305 callback("operation cancelled");
308 this._objectPropertiesView
.element
.removeChildren();
309 var section
= new WebInspector
.ObjectPropertiesSection(object
, title
);
311 section
.titleLessMode();
313 section
.editable
= false;
314 this._objectPropertiesView
.element
.appendChild(section
.element
);
318 __proto__
: WebInspector
.SidebarPane
.prototype