| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| 11 * copyright notice, this list of conditions and the following disclaimer | 11 * copyright notice, this list of conditions and the following disclaimer |
| 12 * in the documentation and/or other materials provided with the | 12 * in the documentation and/or other materials provided with the |
| 13 * distribution. | 13 * distribution. |
| 14 * * Neither the name of Google Inc. nor the names of its | 14 * * Neither the name of Google Inc. nor the names of its |
| 15 * contributors may be used to endorse or promote products derived from | 15 * contributors may be used to endorse or promote products derived from |
| 16 * this software without specific prior written permission. | 16 * this software without specific prior written permission. |
| 17 * | 17 * |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 /** |
| 31 * @unrestricted |
| 32 */ |
| 33 WebInspector.NetworkItemView = class extends WebInspector.TabbedPane { |
| 34 /** |
| 35 * @param {!WebInspector.NetworkRequest} request |
| 36 * @param {!WebInspector.NetworkTimeCalculator} calculator |
| 37 */ |
| 38 constructor(request, calculator) { |
| 39 super(); |
| 40 this.renderWithNoHeaderBackground(); |
| 41 this.element.classList.add('network-item-view'); |
| 30 | 42 |
| 31 /** | 43 this._resourceViewTabSetting = WebInspector.settings.createSetting('resource
ViewTab', 'preview'); |
| 32 * @constructor | |
| 33 * @extends {WebInspector.TabbedPane} | |
| 34 * @param {!WebInspector.NetworkRequest} request | |
| 35 * @param {!WebInspector.NetworkTimeCalculator} calculator | |
| 36 */ | |
| 37 WebInspector.NetworkItemView = function(request, calculator) | |
| 38 { | |
| 39 WebInspector.TabbedPane.call(this); | |
| 40 this.renderWithNoHeaderBackground(); | |
| 41 this.element.classList.add("network-item-view"); | |
| 42 | |
| 43 this._resourceViewTabSetting = WebInspector.settings.createSetting("resource
ViewTab", "preview"); | |
| 44 | 44 |
| 45 var headersView = new WebInspector.RequestHeadersView(request); | 45 var headersView = new WebInspector.RequestHeadersView(request); |
| 46 this.appendTab("headers", WebInspector.UIString("Headers"), headersView); | 46 this.appendTab('headers', WebInspector.UIString('Headers'), headersView); |
| 47 | 47 |
| 48 this.addEventListener(WebInspector.TabbedPane.Events.TabSelected, this._tabS
elected, this); | 48 this.addEventListener(WebInspector.TabbedPane.Events.TabSelected, this._tabS
elected, this); |
| 49 | 49 |
| 50 if (request.resourceType() === WebInspector.resourceTypes.WebSocket) { | 50 if (request.resourceType() === WebInspector.resourceTypes.WebSocket) { |
| 51 var frameView = new WebInspector.ResourceWebSocketFrameView(request); | 51 var frameView = new WebInspector.ResourceWebSocketFrameView(request); |
| 52 this.appendTab("webSocketFrames", WebInspector.UIString("Frames"), frame
View); | 52 this.appendTab('webSocketFrames', WebInspector.UIString('Frames'), frameVi
ew); |
| 53 } else if (request.mimeType === "text/event-stream") { | 53 } else if (request.mimeType === 'text/event-stream') { |
| 54 this.appendTab("eventSource", WebInspector.UIString("EventStream"), new
WebInspector.EventSourceMessagesView(request)); | 54 this.appendTab( |
| 55 'eventSource', WebInspector.UIString('EventStream'), new WebInspector.
EventSourceMessagesView(request)); |
| 55 } else { | 56 } else { |
| 56 var responseView = new WebInspector.RequestResponseView(request); | 57 var responseView = new WebInspector.RequestResponseView(request); |
| 57 var previewView = new WebInspector.RequestPreviewView(request, responseV
iew); | 58 var previewView = new WebInspector.RequestPreviewView(request, responseVie
w); |
| 58 this.appendTab("preview", WebInspector.UIString("Preview"), previewView)
; | 59 this.appendTab('preview', WebInspector.UIString('Preview'), previewView); |
| 59 this.appendTab("response", WebInspector.UIString("Response"), responseVi
ew); | 60 this.appendTab('response', WebInspector.UIString('Response'), responseView
); |
| 60 } | 61 } |
| 61 | 62 |
| 62 if (request.requestCookies || request.responseCookies) { | 63 if (request.requestCookies || request.responseCookies) { |
| 63 this._cookiesView = new WebInspector.RequestCookiesView(request); | 64 this._cookiesView = new WebInspector.RequestCookiesView(request); |
| 64 this.appendTab("cookies", WebInspector.UIString("Cookies"), this._cookie
sView); | 65 this.appendTab('cookies', WebInspector.UIString('Cookies'), this._cookiesV
iew); |
| 65 } | 66 } |
| 66 | 67 |
| 67 this.appendTab("timing", WebInspector.UIString("Timing"), new WebInspector.R
equestTimingView(request, calculator)); | 68 this.appendTab('timing', WebInspector.UIString('Timing'), new WebInspector.R
equestTimingView(request, calculator)); |
| 68 | 69 |
| 69 this._request = request; | 70 this._request = request; |
| 70 }; | 71 } |
| 71 | 72 |
| 72 WebInspector.NetworkItemView.prototype = { | 73 /** |
| 73 wasShown: function() | 74 * @override |
| 74 { | 75 */ |
| 75 WebInspector.TabbedPane.prototype.wasShown.call(this); | 76 wasShown() { |
| 76 this._selectTab(); | 77 super.wasShown(); |
| 77 }, | 78 this._selectTab(); |
| 79 } |
| 78 | 80 |
| 79 /** | 81 /** |
| 80 * @param {string=} tabId | 82 * @param {string=} tabId |
| 81 */ | 83 */ |
| 82 _selectTab: function(tabId) | 84 _selectTab(tabId) { |
| 83 { | 85 if (!tabId) |
| 84 if (!tabId) | 86 tabId = this._resourceViewTabSetting.get(); |
| 85 tabId = this._resourceViewTabSetting.get(); | |
| 86 | 87 |
| 87 if (!this.selectTab(tabId)) | 88 if (!this.selectTab(tabId)) |
| 88 this.selectTab("headers"); | 89 this.selectTab('headers'); |
| 89 }, | 90 } |
| 90 | 91 |
| 91 _tabSelected: function(event) | 92 _tabSelected(event) { |
| 92 { | 93 if (!event.data.isUserGesture) |
| 93 if (!event.data.isUserGesture) | 94 return; |
| 94 return; | |
| 95 | 95 |
| 96 this._resourceViewTabSetting.set(event.data.tabId); | 96 this._resourceViewTabSetting.set(event.data.tabId); |
| 97 }, | 97 } |
| 98 | 98 |
| 99 /** | 99 /** |
| 100 * @return {!WebInspector.NetworkRequest} | 100 * @return {!WebInspector.NetworkRequest} |
| 101 */ | 101 */ |
| 102 request: function() | 102 request() { |
| 103 { | 103 return this._request; |
| 104 return this._request; | 104 } |
| 105 }, | |
| 106 | |
| 107 __proto__: WebInspector.TabbedPane.prototype | |
| 108 }; | 105 }; |
| 109 | 106 |
| 110 /** | 107 /** |
| 111 * @constructor | 108 * @unrestricted |
| 112 * @extends {WebInspector.RequestView} | |
| 113 * @param {!WebInspector.NetworkRequest} request | |
| 114 */ | 109 */ |
| 115 WebInspector.RequestContentView = function(request) | 110 WebInspector.RequestContentView = class extends WebInspector.RequestView { |
| 116 { | 111 /** |
| 117 WebInspector.RequestView.call(this, request); | 112 * @param {!WebInspector.NetworkRequest} request |
| 113 */ |
| 114 constructor(request) { |
| 115 super(request); |
| 116 } |
| 117 |
| 118 /** |
| 119 * @override |
| 120 */ |
| 121 wasShown() { |
| 122 this._ensureInnerViewShown(); |
| 123 } |
| 124 |
| 125 _ensureInnerViewShown() { |
| 126 if (this._innerViewShowRequested) |
| 127 return; |
| 128 this._innerViewShowRequested = true; |
| 129 |
| 130 /** |
| 131 * @param {?string} content |
| 132 * @this {WebInspector.RequestContentView} |
| 133 */ |
| 134 function callback(content) { |
| 135 this._innerViewShowRequested = false; |
| 136 this.contentLoaded(); |
| 137 } |
| 138 |
| 139 this.request.requestContent().then(callback.bind(this)); |
| 140 } |
| 141 |
| 142 contentLoaded() { |
| 143 // Should be implemented by subclasses. |
| 144 } |
| 118 }; | 145 }; |
| 119 | |
| 120 WebInspector.RequestContentView.prototype = { | |
| 121 wasShown: function() | |
| 122 { | |
| 123 this._ensureInnerViewShown(); | |
| 124 }, | |
| 125 | |
| 126 _ensureInnerViewShown: function() | |
| 127 { | |
| 128 if (this._innerViewShowRequested) | |
| 129 return; | |
| 130 this._innerViewShowRequested = true; | |
| 131 | |
| 132 /** | |
| 133 * @param {?string} content | |
| 134 * @this {WebInspector.RequestContentView} | |
| 135 */ | |
| 136 function callback(content) | |
| 137 { | |
| 138 this._innerViewShowRequested = false; | |
| 139 this.contentLoaded(); | |
| 140 } | |
| 141 | |
| 142 this.request.requestContent().then(callback.bind(this)); | |
| 143 }, | |
| 144 | |
| 145 contentLoaded: function() | |
| 146 { | |
| 147 // Should be implemented by subclasses. | |
| 148 }, | |
| 149 | |
| 150 __proto__: WebInspector.RequestView.prototype | |
| 151 }; | |
| OLD | NEW |