| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 } | 177 } |
| 178 | 178 |
| 179 var count = | 179 var count = |
| 180 (dataType == 'cookie') ? descriptionNode.children_.length : 0; | 180 (dataType == 'cookie') ? descriptionNode.children_.length : 0; |
| 181 if (count > 1) { | 181 if (count > 1) { |
| 182 description += loadTimeData.getStringF('cookiePlural', count); | 182 description += loadTimeData.getStringF('cookiePlural', count); |
| 183 } else { | 183 } else { |
| 184 description += getCookieDataCategoryText( | 184 description += getCookieDataCategoryText( |
| 185 dataType, descriptionNode.data.totalUsage); | 185 dataType, descriptionNode.data.totalUsage); |
| 186 } | 186 } |
| 187 | |
| 188 } | 187 } |
| 189 list.push({ site: title, id: id, localData: description }); | 188 list.push({ site: title, id: id, localData: description }); |
| 190 } | 189 } |
| 191 list.sort(function(a, b) { | 190 list.sort(function(a, b) { |
| 192 return a.site.localeCompare(b.site); | 191 return a.site.localeCompare(b.site); |
| 193 }); | 192 }); |
| 194 return list; | 193 return list; |
| 195 }, | 194 }, |
| 196 | 195 |
| 197 /** | 196 /** |
| 198 * Fetch a CookieTreeNode by ID. | 197 * Fetch a CookieTreeNode by ID. |
| 199 * @param {string} id The ID to look up. | 198 * @param {string} id The ID to look up. |
| 200 * @param {boolean} recursive Whether to search the children also. | 199 * @param {boolean} recursive Whether to search the children also. |
| 201 * @return {settings.CookieTreeNode} The node found, if any. | 200 * @return {settings.CookieTreeNode} The node found, if any. |
| 202 */ | 201 */ |
| 203 fetchNodeById: function(id, recursive) { | 202 fetchNodeById: function(id, recursive) { |
| 204 for (var i = 0; i < this.children_.length; ++i) { | 203 for (var i = 0; i < this.children_.length; ++i) { |
| 205 if (this.children_[i] == null) | 204 if (this.children_[i] == null) |
| 206 return null; | 205 return null; |
| 207 if (this.children_[i].data.id == id) | 206 if (this.children_[i].data.id == id) |
| 208 return this.children_[i]; | 207 return this.children_[i]; |
| 209 if (recursive) { | 208 if (recursive) { |
| 210 var node = this.children_[i].fetchNodeById(id, true); | 209 var node = this.children_[i].fetchNodeById(id, true); |
| 211 if (node != null) | 210 if (node != null) |
| 212 return node; | 211 return node; |
| 213 } | 212 } |
| 214 } | 213 } |
| 215 return null; | 214 return null; |
| 216 }, | 215 }, |
| 216 |
| 217 /** |
| 218 * Fetch a CookieTreeNode by site. |
| 219 * @param {string} site The web site to look up. |
| 220 * @return {?settings.CookieTreeNode} The node found, if any. |
| 221 */ |
| 222 fetchNodeBySite: function(site) { |
| 223 for (var i = 0; i < this.children_.length; ++i) { |
| 224 if (this.children_[i].data.title == site) |
| 225 return this.children_[i]; |
| 226 } |
| 227 return null; |
| 228 }, |
| 217 }; | 229 }; |
| 218 | 230 |
| 219 return { | 231 return { |
| 220 CookieTreeNode: CookieTreeNode, | 232 CookieTreeNode: CookieTreeNode, |
| 221 }; | 233 }; |
| 222 }); | 234 }); |
| OLD | NEW |