2 * Copyright (C) 2010 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.NetworkItemView = function(resource)
33 WebInspector.TabbedPane.call(this);
35 this.element.addStyleClass("network-item-view");
37 var headersView = new WebInspector.ResourceHeadersView(resource);
38 this.appendTab("headers", WebInspector.UIString("Headers"), headersView);
40 var responseView = new WebInspector.ResourceResponseView(resource);
41 var previewView = new WebInspector.ResourcePreviewView(resource, responseView);
43 this.appendTab("preview", WebInspector.UIString("Preview"), previewView);
44 this.appendTab("response", WebInspector.UIString("Response"), responseView);
46 if (Preferences.showCookiesTab) {
47 this._cookiesView = new WebInspector.ResourceCookiesView(resource);
48 this.appendTab("cookies", WebInspector.UIString("Cookies"), this._cookiesView);
51 if (Preferences.showTimingTab) {
52 var timingView = new WebInspector.ResourceTimingView(resource);
53 this.appendTab("timing", WebInspector.UIString("Timing"), timingView);
56 this.addEventListener("tab-selected", this._tabSelected, this);
59 WebInspector.NetworkItemView.prototype = {
60 show: function(parentElement)
62 WebInspector.TabbedPane.prototype.show.call(this, parentElement);
66 _selectTab: function(tabId)
69 tabId = WebInspector.settings.resourceViewTab.get();
71 if (!this.selectTab(tabId)) {
72 this._isInFallbackSelection = true;
73 this.selectTab("headers");
74 delete this._isInFallbackSelection;
78 _tabSelected: function(event)
80 if (event.data.isUserGesture)
81 WebInspector.settings.resourceViewTab.set(event.data.tabId);
82 this._installHighlightSupport(event.data.view);
85 _installHighlightSupport: function(view)
87 if (typeof view.highlightLine === "function")
88 this.highlightLine = view.highlightLine.bind(view);
90 delete this.highlightLine;
94 WebInspector.NetworkItemView.prototype.__proto__ = WebInspector.TabbedPane.prototype;
96 WebInspector.ResourceContentView = function(resource)
98 WebInspector.ResourceView.call(this, resource);
101 WebInspector.ResourceContentView.prototype = {
102 hasContent: function()
109 return this._innerView;
112 set innerView(innerView)
114 this._innerView = innerView;
117 show: function(parentElement)
119 WebInspector.ResourceView.prototype.show.call(this, parentElement);
120 this._ensureInnerViewShown();
126 this._innerView.hide();
127 WebInspector.ResourceView.prototype.hide.call(this);
130 _ensureInnerViewShown: function()
132 if (this._innerViewShowRequested)
134 this._innerViewShowRequested = true;
138 this._innerViewShowRequested = false;
139 this.contentLoaded();
142 this.resource.requestContent(callback.bind(this));
145 contentLoaded: function()
147 // Should be implemented by subclasses.
151 WebInspector.ResourceContentView.prototype.__proto__ = WebInspector.ResourceView.prototype;