RequestCookiesView.js [plain text]
WebInspector.RequestCookiesView = function(request)
{
WebInspector.View.call(this);
this.element.addStyleClass("resource-cookies-view");
this._request = request;
}
WebInspector.RequestCookiesView.prototype = {
wasShown: function()
{
this._request.addEventListener(WebInspector.NetworkRequest.Events.RequestHeadersChanged, this._refreshCookies, this);
this._request.addEventListener(WebInspector.NetworkRequest.Events.ResponseHeadersChanged, this._refreshCookies, this);
if (!this._gotCookies) {
if (!this._emptyView) {
this._emptyView = new WebInspector.EmptyView(WebInspector.UIString("This request has no cookies."));
this._emptyView.show(this.element);
}
return;
}
if (!this._cookiesTable)
this._buildCookiesTable();
},
willHide: function()
{
this._request.removeEventListener(WebInspector.NetworkRequest.Events.RequestHeadersChanged, this._refreshCookies, this);
this._request.removeEventListener(WebInspector.NetworkRequest.Events.ResponseHeadersChanged, this._refreshCookies, this);
},
get _gotCookies()
{
return (this._request.requestCookies && this._request.requestCookies.length) || (this._request.responseCookies && this._request.responseCookies.length);
},
_buildCookiesTable: function()
{
this.detachChildViews();
this._cookiesTable = new WebInspector.CookiesTable(true);
this._cookiesTable.setCookieFolders([
{folderName: WebInspector.UIString("Request Cookies"), cookies: this._request.requestCookies},
{folderName: WebInspector.UIString("Response Cookies"), cookies: this._request.responseCookies}
]);
this._cookiesTable.show(this.element);
},
_refreshCookies: function()
{
delete this._cookiesTable;
if (!this._gotCookies || !this.isShowing())
return;
this._buildCookiesTable();
this._cookiesTable.updateWidths();
},
__proto__: WebInspector.View.prototype
}