| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 /** | 30 /** |
| 32 * @constructor | 31 * @unrestricted |
| 33 * @extends {WebInspector.VBox} | |
| 34 * @param {!WebInspector.NetworkRequest} request | |
| 35 */ | 32 */ |
| 36 WebInspector.RequestCookiesView = function(request) | 33 WebInspector.RequestCookiesView = class extends WebInspector.VBox { |
| 37 { | 34 /** |
| 38 WebInspector.VBox.call(this); | 35 * @param {!WebInspector.NetworkRequest} request |
| 39 this.registerRequiredCSS("network/requestCookiesView.css"); | 36 */ |
| 40 this.element.classList.add("request-cookies-view"); | 37 constructor(request) { |
| 38 super(); |
| 39 this.registerRequiredCSS('network/requestCookiesView.css'); |
| 40 this.element.classList.add('request-cookies-view'); |
| 41 | 41 |
| 42 this._request = request; | 42 this._request = request; |
| 43 } |
| 44 |
| 45 /** |
| 46 * @override |
| 47 */ |
| 48 wasShown() { |
| 49 this._request.addEventListener( |
| 50 WebInspector.NetworkRequest.Events.RequestHeadersChanged, this._refreshC
ookies, this); |
| 51 this._request.addEventListener( |
| 52 WebInspector.NetworkRequest.Events.ResponseHeadersChanged, this._refresh
Cookies, this); |
| 53 |
| 54 if (!this._gotCookies) { |
| 55 if (!this._emptyWidget) { |
| 56 this._emptyWidget = new WebInspector.EmptyWidget(WebInspector.UIString('
This request has no cookies.')); |
| 57 this._emptyWidget.show(this.element); |
| 58 } |
| 59 return; |
| 60 } |
| 61 |
| 62 if (!this._cookiesTable) |
| 63 this._buildCookiesTable(); |
| 64 } |
| 65 |
| 66 /** |
| 67 * @override |
| 68 */ |
| 69 willHide() { |
| 70 this._request.removeEventListener( |
| 71 WebInspector.NetworkRequest.Events.RequestHeadersChanged, this._refreshC
ookies, this); |
| 72 this._request.removeEventListener( |
| 73 WebInspector.NetworkRequest.Events.ResponseHeadersChanged, this._refresh
Cookies, this); |
| 74 } |
| 75 |
| 76 get _gotCookies() { |
| 77 return (this._request.requestCookies && this._request.requestCookies.length)
|| |
| 78 (this._request.responseCookies && this._request.responseCookies.length); |
| 79 } |
| 80 |
| 81 _buildCookiesTable() { |
| 82 this.detachChildWidgets(); |
| 83 |
| 84 this._cookiesTable = new WebInspector.CookiesTable(true); |
| 85 this._cookiesTable.setCookieFolders([ |
| 86 {folderName: WebInspector.UIString('Request Cookies'), cookies: this._requ
est.requestCookies}, |
| 87 {folderName: WebInspector.UIString('Response Cookies'), cookies: this._req
uest.responseCookies} |
| 88 ]); |
| 89 this._cookiesTable.show(this.element); |
| 90 } |
| 91 |
| 92 _refreshCookies() { |
| 93 delete this._cookiesTable; |
| 94 if (!this._gotCookies || !this.isShowing()) |
| 95 return; |
| 96 this._buildCookiesTable(); |
| 97 } |
| 43 }; | 98 }; |
| 44 | |
| 45 WebInspector.RequestCookiesView.prototype = { | |
| 46 wasShown: function() | |
| 47 { | |
| 48 this._request.addEventListener(WebInspector.NetworkRequest.Events.Reques
tHeadersChanged, this._refreshCookies, this); | |
| 49 this._request.addEventListener(WebInspector.NetworkRequest.Events.Respon
seHeadersChanged, this._refreshCookies, this); | |
| 50 | |
| 51 if (!this._gotCookies) { | |
| 52 if (!this._emptyWidget) { | |
| 53 this._emptyWidget = new WebInspector.EmptyWidget(WebInspector.UI
String("This request has no cookies.")); | |
| 54 this._emptyWidget.show(this.element); | |
| 55 } | |
| 56 return; | |
| 57 } | |
| 58 | |
| 59 if (!this._cookiesTable) | |
| 60 this._buildCookiesTable(); | |
| 61 }, | |
| 62 | |
| 63 willHide: function() | |
| 64 { | |
| 65 this._request.removeEventListener(WebInspector.NetworkRequest.Events.Req
uestHeadersChanged, this._refreshCookies, this); | |
| 66 this._request.removeEventListener(WebInspector.NetworkRequest.Events.Res
ponseHeadersChanged, this._refreshCookies, this); | |
| 67 }, | |
| 68 | |
| 69 get _gotCookies() | |
| 70 { | |
| 71 return (this._request.requestCookies && this._request.requestCookies.len
gth) || (this._request.responseCookies && this._request.responseCookies.length); | |
| 72 }, | |
| 73 | |
| 74 _buildCookiesTable: function() | |
| 75 { | |
| 76 this.detachChildWidgets(); | |
| 77 | |
| 78 this._cookiesTable = new WebInspector.CookiesTable(true); | |
| 79 this._cookiesTable.setCookieFolders([ | |
| 80 {folderName: WebInspector.UIString("Request Cookies"), cookies: this
._request.requestCookies}, | |
| 81 {folderName: WebInspector.UIString("Response Cookies"), cookies: thi
s._request.responseCookies} | |
| 82 ]); | |
| 83 this._cookiesTable.show(this.element); | |
| 84 }, | |
| 85 | |
| 86 _refreshCookies: function() | |
| 87 { | |
| 88 delete this._cookiesTable; | |
| 89 if (!this._gotCookies || !this.isShowing()) | |
| 90 return; | |
| 91 this._buildCookiesTable(); | |
| 92 }, | |
| 93 | |
| 94 __proto__: WebInspector.VBox.prototype | |
| 95 }; | |
| OLD | NEW |