OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
4 * Copyright (C) 2010 Google Inc. All rights reserved. | 4 * Copyright (C) 2010 Google Inc. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 this._refreshCallback = refreshCallback; | 43 this._refreshCallback = refreshCallback; |
44 | 44 |
45 var columns = [ | 45 var columns = [ |
46 {id: "name", title: WebInspector.UIString("Name"), sortable: true, discl
osure: expandable, sort: WebInspector.DataGrid.Order.Ascending, longText: true,
weight: 24}, | 46 {id: "name", title: WebInspector.UIString("Name"), sortable: true, discl
osure: expandable, sort: WebInspector.DataGrid.Order.Ascending, longText: true,
weight: 24}, |
47 {id: "value", title: WebInspector.UIString("Value"), sortable: true, lon
gText: true, weight: 34}, | 47 {id: "value", title: WebInspector.UIString("Value"), sortable: true, lon
gText: true, weight: 34}, |
48 {id: "domain", title: WebInspector.UIString("Domain"), sortable: true, w
eight: 7}, | 48 {id: "domain", title: WebInspector.UIString("Domain"), sortable: true, w
eight: 7}, |
49 {id: "path", title: WebInspector.UIString("Path"), sortable: true, weigh
t: 7}, | 49 {id: "path", title: WebInspector.UIString("Path"), sortable: true, weigh
t: 7}, |
50 {id: "expires", title: WebInspector.UIString("Expires / Max-Age"), sorta
ble: true, weight: 7}, | 50 {id: "expires", title: WebInspector.UIString("Expires / Max-Age"), sorta
ble: true, weight: 7}, |
51 {id: "size", title: WebInspector.UIString("Size"), sortable: true, align
: WebInspector.DataGrid.Align.Right, weight: 7}, | 51 {id: "size", title: WebInspector.UIString("Size"), sortable: true, align
: WebInspector.DataGrid.Align.Right, weight: 7}, |
52 {id: "httpOnly", title: WebInspector.UIString("HTTP"), sortable: true, a
lign: WebInspector.DataGrid.Align.Center, weight: 7}, | 52 {id: "httpOnly", title: WebInspector.UIString("HTTP"), sortable: true, a
lign: WebInspector.DataGrid.Align.Center, weight: 7}, |
53 {id: "secure", title: WebInspector.UIString("Secure"), sortable: true, a
lign: WebInspector.DataGrid.Align.Center, weight: 7} | 53 {id: "secure", title: WebInspector.UIString("Secure"), sortable: true, a
lign: WebInspector.DataGrid.Align.Center, weight: 7}, |
| 54 {id: "firstPartyOnly", title: WebInspector.UIString("First-Party"), sort
able: true, align: WebInspector.DataGrid.Align.Center, weight: 7} |
54 ]; | 55 ]; |
55 | 56 |
56 if (readOnly) | 57 if (readOnly) |
57 this._dataGrid = new WebInspector.DataGrid(columns); | 58 this._dataGrid = new WebInspector.DataGrid(columns); |
58 else | 59 else |
59 this._dataGrid = new WebInspector.DataGrid(columns, undefined, this._onD
eleteCookie.bind(this), refreshCallback, this._onContextMenu.bind(this)); | 60 this._dataGrid = new WebInspector.DataGrid(columns, undefined, this._onD
eleteCookie.bind(this), refreshCallback, this._onContextMenu.bind(this)); |
60 | 61 |
61 this._dataGrid.setName("cookiesTable"); | 62 this._dataGrid.setName("cookiesTable"); |
62 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged,
this._rebuildTable, this); | 63 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged,
this._rebuildTable, this); |
63 | 64 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 }, | 137 }, |
137 | 138 |
138 _rebuildTable: function() | 139 _rebuildTable: function() |
139 { | 140 { |
140 var selectedCookie = this._nextSelectedCookie || this.selectedCookie(); | 141 var selectedCookie = this._nextSelectedCookie || this.selectedCookie(); |
141 this._nextSelectedCookie = null; | 142 this._nextSelectedCookie = null; |
142 this._dataGrid.rootNode().removeChildren(); | 143 this._dataGrid.rootNode().removeChildren(); |
143 for (var i = 0; i < this._data.length; ++i) { | 144 for (var i = 0; i < this._data.length; ++i) { |
144 var item = this._data[i]; | 145 var item = this._data[i]; |
145 if (item.folderName) { | 146 if (item.folderName) { |
146 var groupData = {name: item.folderName, value: "", domain: "", p
ath: "", expires: "", size: this._totalSize(item.cookies), httpOnly: "", secure:
""}; | 147 var groupData = {name: item.folderName, value: "", domain: "", p
ath: "", expires: "", size: this._totalSize(item.cookies), httpOnly: "", secure:
"", firstPartyOnly: ""}; |
147 var groupNode = new WebInspector.DataGridNode(groupData); | 148 var groupNode = new WebInspector.DataGridNode(groupData); |
148 groupNode.selectable = true; | 149 groupNode.selectable = true; |
149 this._dataGrid.rootNode().appendChild(groupNode); | 150 this._dataGrid.rootNode().appendChild(groupNode); |
150 groupNode.element().classList.add("row-group"); | 151 groupNode.element().classList.add("row-group"); |
151 this._populateNode(groupNode, item.cookies, selectedCookie); | 152 this._populateNode(groupNode, item.cookies, selectedCookie); |
152 groupNode.expand(); | 153 groupNode.expand(); |
153 } else | 154 } else |
154 this._populateNode(this._dataGrid.rootNode(), item.cookies, sele
ctedCookie); | 155 this._populateNode(this._dataGrid.rootNode(), item.cookies, sele
ctedCookie); |
155 } | 156 } |
156 }, | 157 }, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 var comparator; | 220 var comparator; |
220 switch (this._dataGrid.sortColumnIdentifier()) { | 221 switch (this._dataGrid.sortColumnIdentifier()) { |
221 case "name": comparator = compareTo.bind(null, WebInspector.Cookie.p
rototype.name); break; | 222 case "name": comparator = compareTo.bind(null, WebInspector.Cookie.p
rototype.name); break; |
222 case "value": comparator = compareTo.bind(null, WebInspector.Cookie.
prototype.value); break; | 223 case "value": comparator = compareTo.bind(null, WebInspector.Cookie.
prototype.value); break; |
223 case "domain": comparator = compareTo.bind(null, WebInspector.Cookie
.prototype.domain); break; | 224 case "domain": comparator = compareTo.bind(null, WebInspector.Cookie
.prototype.domain); break; |
224 case "path": comparator = compareTo.bind(null, WebInspector.Cookie.p
rototype.path); break; | 225 case "path": comparator = compareTo.bind(null, WebInspector.Cookie.p
rototype.path); break; |
225 case "expires": comparator = expiresCompare; break; | 226 case "expires": comparator = expiresCompare; break; |
226 case "size": comparator = numberCompare.bind(null, WebInspector.Cook
ie.prototype.size); break; | 227 case "size": comparator = numberCompare.bind(null, WebInspector.Cook
ie.prototype.size); break; |
227 case "httpOnly": comparator = compareTo.bind(null, WebInspector.Cook
ie.prototype.httpOnly); break; | 228 case "httpOnly": comparator = compareTo.bind(null, WebInspector.Cook
ie.prototype.httpOnly); break; |
228 case "secure": comparator = compareTo.bind(null, WebInspector.Cookie
.prototype.secure); break; | 229 case "secure": comparator = compareTo.bind(null, WebInspector.Cookie
.prototype.secure); break; |
| 230 case "firstPartyOnly": comparator = compareTo.bind(null, WebInspecto
r.Cookie.prototype.firstPartyOnly); break; |
229 default: compareTo.bind(null, WebInspector.Cookie.prototype.name); | 231 default: compareTo.bind(null, WebInspector.Cookie.prototype.name); |
230 } | 232 } |
231 | 233 |
232 cookies.sort(comparator); | 234 cookies.sort(comparator); |
233 }, | 235 }, |
234 | 236 |
235 /** | 237 /** |
236 * @param {!WebInspector.Cookie} cookie | 238 * @param {!WebInspector.Cookie} cookie |
237 * @return {!WebInspector.DataGridNode} | 239 * @return {!WebInspector.DataGridNode} |
238 */ | 240 */ |
(...skipping 13 matching lines...) Expand all Loading... |
252 data.expires = Number.secondsToString(parseInt(cookie.maxAge(),
10)); | 254 data.expires = Number.secondsToString(parseInt(cookie.maxAge(),
10)); |
253 else if (cookie.expires()) | 255 else if (cookie.expires()) |
254 data.expires = new Date(cookie.expires()).toISOString(); | 256 data.expires = new Date(cookie.expires()).toISOString(); |
255 else | 257 else |
256 data.expires = WebInspector.UIString("Session"); | 258 data.expires = WebInspector.UIString("Session"); |
257 } | 259 } |
258 data.size = cookie.size(); | 260 data.size = cookie.size(); |
259 const checkmark = "\u2713"; | 261 const checkmark = "\u2713"; |
260 data.httpOnly = (cookie.httpOnly() ? checkmark : ""); | 262 data.httpOnly = (cookie.httpOnly() ? checkmark : ""); |
261 data.secure = (cookie.secure() ? checkmark : ""); | 263 data.secure = (cookie.secure() ? checkmark : ""); |
| 264 data.firstPartyOnly = (cookie.firstPartyOnly() ? checkmark : ""); |
262 | 265 |
263 var node = new WebInspector.DataGridNode(data); | 266 var node = new WebInspector.DataGridNode(data); |
264 node.cookie = cookie; | 267 node.cookie = cookie; |
265 node.selectable = true; | 268 node.selectable = true; |
266 return node; | 269 return node; |
267 }, | 270 }, |
268 | 271 |
269 _onDeleteCookie: function(node) | 272 _onDeleteCookie: function(node) |
270 { | 273 { |
271 var cookie = node.cookie; | 274 var cookie = node.cookie; |
272 var neighbour = node.traverseNextNode() || node.traversePreviousNode(); | 275 var neighbour = node.traverseNextNode() || node.traversePreviousNode(); |
273 if (neighbour) | 276 if (neighbour) |
274 this._nextSelectedCookie = neighbour.cookie; | 277 this._nextSelectedCookie = neighbour.cookie; |
275 cookie.remove(); | 278 cookie.remove(); |
276 this._refresh(); | 279 this._refresh(); |
277 }, | 280 }, |
278 | 281 |
279 _refresh: function() | 282 _refresh: function() |
280 { | 283 { |
281 if (this._refreshCallback) | 284 if (this._refreshCallback) |
282 this._refreshCallback(); | 285 this._refreshCallback(); |
283 }, | 286 }, |
284 | 287 |
285 __proto__: WebInspector.VBox.prototype | 288 __proto__: WebInspector.VBox.prototype |
286 } | 289 } |
OLD | NEW |