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 {{title: string, | 6 * @typedef {{title: string, |
7 * id: string, | 7 * id: string, |
8 * data: CookieDetails}} | 8 * data: CookieDetails}} |
9 */ | 9 */ |
10 var CookieDataItem; | 10 var CookieDataItem; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 * @return {boolean} True if the parent node was found. | 102 * @return {boolean} True if the parent node was found. |
103 */ | 103 */ |
104 populateChildNodes: function(parentId, startingNode, newNodes) { | 104 populateChildNodes: function(parentId, startingNode, newNodes) { |
105 for (var i = 0; i < startingNode.children_.length; ++i) { | 105 for (var i = 0; i < startingNode.children_.length; ++i) { |
106 if (startingNode.children_[i].data.id == parentId) { | 106 if (startingNode.children_[i].data.id == parentId) { |
107 this.addChildNodes(startingNode.children_[i], newNodes); | 107 this.addChildNodes(startingNode.children_[i], newNodes); |
108 return true; | 108 return true; |
109 } | 109 } |
110 | 110 |
111 if (this.populateChildNodes( | 111 if (this.populateChildNodes( |
112 parentId, startingNode.children_[i], newNodes)) { | 112 parentId, startingNode.children_[i], newNodes)) { |
113 return true; | 113 return true; |
114 } | 114 } |
115 } | 115 } |
116 return false; | 116 return false; |
117 }, | 117 }, |
118 | 118 |
119 /** | 119 /** |
120 * Removes child nodes from a node with a given id. | 120 * Removes child nodes from a node with a given id. |
121 * @param {string} id The id of the parent node to delete from. | 121 * @param {string} id The id of the parent node to delete from. |
122 * @param {number} firstChild The index of the first child to start deleting | 122 * @param {number} firstChild The index of the first child to start deleting |
123 * from. | 123 * from. |
124 * @param {number} count The number of children to delete. | 124 * @param {number} count The number of children to delete. |
125 */ | 125 */ |
126 removeByParentId: function(id, firstChild, count) { | 126 removeByParentId: function(id, firstChild, count) { |
127 var node = id == null ? this : this.fetchNodeById(id, true); | 127 var node = id == null ? this : this.fetchNodeById(id, true); |
128 node.children_.splice(firstChild, count); | 128 node.children_.splice(firstChild, count); |
129 }, | 129 }, |
130 | 130 |
131 /** | 131 /** |
132 * Returns an array of cookies from the current node within the cookie tree. | 132 * Returns an array of cookies from the current node within the cookie tree. |
133 * @return {!Array<!CookieDataItem>} The Cookie List. | 133 * @return {!Array<!CookieDataItem>} The Cookie List. |
134 */ | 134 */ |
135 getCookieList: function() { | 135 getCookieList: function() { |
136 var list = []; | 136 var list = []; |
137 for (var i = 0; i < this.children_.length; i++) { | 137 for (var i = 0; i < this.children_.length; i++) { |
138 var child = this.children_[i]; | 138 var child = this.children_[i]; |
139 for (var j = 0; j < child.children_.length; j++) { | 139 for (var j = 0; j < child.children_.length; j++) { |
140 var cookie = child.children_[j]; | 140 var cookie = child.children_[j]; |
141 list.push({title: cookie.data.title, | 141 list.push({ |
142 id: cookie.data.id, | 142 title: cookie.data.title, |
143 data: cookie.data}); | 143 id: cookie.data.id, |
| 144 data: cookie.data |
| 145 }); |
144 } | 146 } |
145 } | 147 } |
146 | 148 |
147 return list; | 149 return list; |
148 }, | 150 }, |
149 | 151 |
150 /** | 152 /** |
151 * Get a summary list of all sites and their stored data. | 153 * Get a summary list of all sites and their stored data. |
152 * @return {!Array<!CookieDataSummaryItem>} The summary list. | 154 * @return {!Array<!CookieDataSummaryItem>} The summary list. |
153 */ | 155 */ |
(...skipping 25 matching lines...) Expand all Loading... |
179 | 181 |
180 var count = | 182 var count = |
181 (dataType == 'cookie') ? descriptionNode.children_.length : 0; | 183 (dataType == 'cookie') ? descriptionNode.children_.length : 0; |
182 if (count > 1) { | 184 if (count > 1) { |
183 description += loadTimeData.getStringF('cookiePlural', count); | 185 description += loadTimeData.getStringF('cookiePlural', count); |
184 } else { | 186 } else { |
185 description += getCookieDataCategoryText( | 187 description += getCookieDataCategoryText( |
186 dataType, descriptionNode.data.totalUsage); | 188 dataType, descriptionNode.data.totalUsage); |
187 } | 189 } |
188 } | 190 } |
189 list.push({ site: title, id: id, localData: description }); | 191 list.push({site: title, id: id, localData: description}); |
190 } | 192 } |
191 list.sort(function(a, b) { | 193 list.sort(function(a, b) { |
192 return a.site.localeCompare(b.site); | 194 return a.site.localeCompare(b.site); |
193 }); | 195 }); |
194 return list; | 196 return list; |
195 }, | 197 }, |
196 | 198 |
197 /** | 199 /** |
198 * Fetch a CookieTreeNode by ID. | 200 * Fetch a CookieTreeNode by ID. |
199 * @param {string} id The ID to look up. | 201 * @param {string} id The ID to look up. |
(...skipping 26 matching lines...) Expand all Loading... |
226 return this.children_[i]; | 228 return this.children_[i]; |
227 } | 229 } |
228 return null; | 230 return null; |
229 }, | 231 }, |
230 }; | 232 }; |
231 | 233 |
232 return { | 234 return { |
233 CookieTreeNode: CookieTreeNode, | 235 CookieTreeNode: CookieTreeNode, |
234 }; | 236 }; |
235 }); | 237 }); |
OLD | NEW |