Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @typedef {{hasChildren: boolean, | |
| 7 * id: string, | |
| 8 * title: string, | |
| 9 * totalUsage: string, | |
| 10 * type: string}} | |
| 11 */ | |
| 12 var CookieDetails; | |
| 13 | |
| 14 /** | |
| 15 * @typedef {{content: string, | |
| 16 * label: string}} | |
| 17 */ | |
| 18 var CookieDataForDisplay; | |
| 19 | |
| 20 /** | |
| 21 * @typedef {{title: string, | 6 * @typedef {{title: string, |
| 22 * id: string, | 7 * id: string, |
| 23 * data: CookieDetails}} | 8 * data: CookieDetails}} |
| 24 */ | 9 */ |
| 25 var CookieDataItem; | 10 var CookieDataItem; |
| 26 | 11 |
| 27 /** | 12 /** |
| 28 * @typedef {{site: string, | 13 * @typedef {{site: string, |
| 29 * id: string, | 14 * id: string, |
| 30 * localData: string}} | 15 * localData: string}} |
| 31 */ | 16 */ |
| 32 var CookieDataSummaryItem; | 17 var CookieDataSummaryItem; |
| 33 | 18 |
| 34 /** | 19 /** |
| 35 * @typedef {{id: string, | 20 * @typedef {{id: string, |
| 36 * start: number, | 21 * start: number, |
| 37 * children: !Array<CookieDetails>}} | 22 * children: !Array<CookieDetails>}} |
| 38 */ | 23 */ |
| 39 var CookieList; | 24 var CookieList; |
| 40 | 25 |
| 41 /** | 26 /** |
| 42 * @typedef {{id: string, | 27 * @typedef {{id: string, |
| 43 * start: !number, | 28 * start: number, |
| 44 * count: !number}} | 29 * count: number}} |
| 45 */ | 30 */ |
| 46 var CookieRemovePacket; | 31 var CookieRemovePacket; |
| 47 | 32 |
| 48 var categoryLabels = { | 33 var categoryLabels = { |
| 49 'app_cache': loadTimeData.getString('cookieAppCache'), | 34 'app_cache': loadTimeData.getString('cookieAppCache'), |
| 50 'cache_storage': loadTimeData.getString('cookieCacheStorage'), | 35 'cache_storage': loadTimeData.getString('cookieCacheStorage'), |
| 51 'channel_id': loadTimeData.getString('cookieChannelId'), | 36 'channel_id': loadTimeData.getString('cookieChannelId'), |
| 52 'cookie': loadTimeData.getString('cookieSingular'), | 37 'cookie': loadTimeData.getString('cookieSingular'), |
| 53 'database': loadTimeData.getString('cookieDatabaseStorage'), | 38 'database': loadTimeData.getString('cookieDatabaseStorage'), |
| 54 'file_system': loadTimeData.getString('cookieFileSystem'), | 39 'file_system': loadTimeData.getString('cookieFileSystem'), |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 * @param {!Array<!CookieDetails>} newNodes The list containing the data to | 85 * @param {!Array<!CookieDetails>} newNodes The list containing the data to |
| 101 * add. | 86 * add. |
| 102 */ | 87 */ |
| 103 addChildNodes: function(parentNode, newNodes) { | 88 addChildNodes: function(parentNode, newNodes) { |
| 104 var nodes = newNodes.map(function(x) { | 89 var nodes = newNodes.map(function(x) { |
| 105 return new settings.CookieTreeNode(x); | 90 return new settings.CookieTreeNode(x); |
| 106 }); | 91 }); |
| 107 parentNode.children_ = nodes; | 92 parentNode.children_ = nodes; |
| 108 }, | 93 }, |
| 109 | 94 |
| 95 /** @return {!CookieDetails} */ | |
| 96 getCookieDetails: function() { | |
|
Dan Beam
2016/10/27 21:05:10
this works, but why not just ... make data_ public
dschuyler
2016/10/27 22:54:25
Done.
| |
| 97 return this.data_; | |
| 98 }, | |
| 99 | |
| 110 /** | 100 /** |
| 111 * Looks up a parent node and adds a list of CookieTreeNodes to them. | 101 * Looks up a parent node and adds a list of CookieTreeNodes to them. |
| 112 * @param {string} parentId The ID of the parent to add the nodes to. | 102 * @param {string} parentId The ID of the parent to add the nodes to. |
| 113 * @param {!settings.CookieTreeNode} startingNode The node to start with | 103 * @param {!settings.CookieTreeNode} startingNode The node to start with |
| 114 * when looking for the parent node to add the children to. | 104 * when looking for the parent node to add the children to. |
| 115 * @param {!Array<!CookieDetails>} newNodes The list containing the data to | 105 * @param {!Array<!CookieDetails>} newNodes The list containing the data to |
| 116 add. | 106 add. |
| 117 * @return {boolean} True if the parent node was found. | 107 * @return {boolean} True if the parent node was found. |
| 118 */ | 108 */ |
| 119 populateChildNodes: function(parentId, startingNode, newNodes) { | 109 populateChildNodes: function(parentId, startingNode, newNodes) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 if (this.children_[i].data_.id == id) | 212 if (this.children_[i].data_.id == id) |
| 223 return this.children_[i]; | 213 return this.children_[i]; |
| 224 if (recursive) { | 214 if (recursive) { |
| 225 var node = this.children_[i].fetchNodeById(id, true); | 215 var node = this.children_[i].fetchNodeById(id, true); |
| 226 if (node != null) | 216 if (node != null) |
| 227 return node; | 217 return node; |
| 228 } | 218 } |
| 229 } | 219 } |
| 230 return null; | 220 return null; |
| 231 }, | 221 }, |
| 232 | |
| 233 /** | |
| 234 * Get cookie data for a given HTML node. | |
| 235 * @return {!Array<CookieDataForDisplay>} | |
| 236 */ | |
| 237 getCookieData: function(item) { | |
| 238 /** @type {!Array<CookieDataForDisplay>} */ | |
| 239 var out = []; | |
| 240 var fields = cookieInfo[item.data_.type]; | |
| 241 for (var field of fields) { | |
| 242 // Iterate through the keys found in |cookieInfo| for the given |type| | |
| 243 // and see if those keys are present in the data. If so, display them | |
| 244 // (in the order determined by |cookieInfo|). | |
| 245 var key = field[0]; | |
| 246 if (item.data_[key].length > 0) { | |
| 247 var entry = /** @type {CookieDataForDisplay} */({ | |
| 248 label: loadTimeData.getString(field[1]), | |
| 249 content: item.data_[key], | |
| 250 }); | |
| 251 out.push(entry); | |
| 252 } | |
| 253 } | |
| 254 return out; | |
| 255 }, | |
| 256 }; | 222 }; |
| 257 | 223 |
| 258 return { | 224 return { |
| 259 CookieTreeNode: CookieTreeNode, | 225 CookieTreeNode: CookieTreeNode, |
| 260 }; | 226 }; |
| 261 }); | 227 }); |
| OLD | NEW |