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.
33 * @extends {WebInspector.TabbedPane}
34 * @param {!WebInspector.NetworkRequest} request
36 WebInspector.NetworkItemView = function(request)
38 WebInspector.TabbedPane.call(this);
39 this.element.classList.add("network-item-view");
41 var headersView = new WebInspector.RequestHeadersView(request);
42 this.appendTab("headers", WebInspector.UIString("Headers"), headersView);
44 this.addEventListener(WebInspector.TabbedPane.EventTypes.TabSelected, this._tabSelected, this);
46 if (request.resourceType() === WebInspector.resourceTypes.WebSocket) {
47 var frameView = new WebInspector.ResourceWebSocketFrameView(request);
48 this.appendTab("webSocketFrames", WebInspector.UIString("Frames"), frameView);
50 var responseView = new WebInspector.RequestResponseView(request);
51 var previewView = new WebInspector.RequestPreviewView(request, responseView);
52 this.appendTab("preview", WebInspector.UIString("Preview"), previewView);
53 this.appendTab("response", WebInspector.UIString("Response"), responseView);
56 if (request.requestCookies || request.responseCookies) {
57 this._cookiesView = new WebInspector.RequestCookiesView(request);
58 this.appendTab("cookies", WebInspector.UIString("Cookies"), this._cookiesView);
62 var timingView = new WebInspector.RequestTimingView(request);
63 this.appendTab("timing", WebInspector.UIString("Timing"), timingView);
65 this._request = request;
68 WebInspector.NetworkItemView.prototype = {
71 WebInspector.TabbedPane.prototype.wasShown.call(this);
76 * @return {?WebInspector.SourceFrame}
78 currentSourceFrame: function()
80 var view = this.visibleView;
81 if (view && view instanceof WebInspector.SourceFrame)
82 return /** @type {!WebInspector.SourceFrame} */ (view);
87 * @param {string=} tabId
89 _selectTab: function(tabId)
92 tabId = WebInspector.settings.resourceViewTab.get();
94 if (!this.selectTab(tabId))
95 this.selectTab("headers");
98 _tabSelected: function(event)
100 if (!event.data.isUserGesture)
103 WebInspector.settings.resourceViewTab.set(event.data.tabId);
105 WebInspector.notifications.dispatchEventToListeners(WebInspector.UserMetrics.UserAction, {
106 action: WebInspector.UserMetrics.UserActionNames.NetworkRequestTabSelected,
107 tab: event.data.tabId,
108 url: this._request.url
113 * @return {!WebInspector.NetworkRequest}
117 return this._request;
120 __proto__: WebInspector.TabbedPane.prototype
125 * @extends {WebInspector.RequestView}
126 * @param {!WebInspector.NetworkRequest} request
128 WebInspector.RequestContentView = function(request)
130 WebInspector.RequestView.call(this, request);
133 WebInspector.RequestContentView.prototype = {
135 * @return {!WebInspector.View}
139 return this._innerView;
142 set innerView(innerView)
144 this._innerView = innerView;
149 this._ensureInnerViewShown();
152 _ensureInnerViewShown: function()
154 if (this._innerViewShowRequested)
156 this._innerViewShowRequested = true;
159 * @param {?string} content
160 * @this {WebInspector.RequestContentView}
162 function callback(content)
164 this._innerViewShowRequested = false;
165 this.contentLoaded();
168 this.request.requestContent(callback.bind(this));
171 contentLoaded: function()
173 // Should be implemented by subclasses.
176 __proto__: WebInspector.RequestView.prototype