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.type === 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._isInFallbackSelection = true;
96 this.selectTab("headers");
97 delete this._isInFallbackSelection;
101 _tabSelected: function(event)
103 if (!event.data.isUserGesture)
106 WebInspector.settings.resourceViewTab.set(event.data.tabId);
108 WebInspector.notifications.dispatchEventToListeners(WebInspector.UserMetrics.UserAction, {
109 action: WebInspector.UserMetrics.UserActionNames.NetworkRequestTabSelected,
110 tab: event.data.tabId,
111 url: this._request.url
116 * @return {!WebInspector.NetworkRequest}
120 return this._request;
123 __proto__: WebInspector.TabbedPane.prototype
128 * @extends {WebInspector.RequestView}
129 * @param {!WebInspector.NetworkRequest} request
131 WebInspector.RequestContentView = function(request)
133 WebInspector.RequestView.call(this, request);
136 WebInspector.RequestContentView.prototype = {
140 hasContent: function()
146 * @return {!WebInspector.View}
150 return this._innerView;
153 set innerView(innerView)
155 this._innerView = innerView;
160 this._ensureInnerViewShown();
163 _ensureInnerViewShown: function()
165 if (this._innerViewShowRequested)
167 this._innerViewShowRequested = true;
170 * @param {?string} content
171 * @this {WebInspector.RequestContentView}
173 function callback(content)
175 this._innerViewShowRequested = false;
176 this.contentLoaded();
179 this.request.requestContent(callback.bind(this));
182 contentLoaded: function()
184 // Should be implemented by subclasses.
187 __proto__: WebInspector.RequestView.prototype