Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(542)

Side by Side Diff: chrome/browser/resources/settings/site_settings/cookie_tree_node.js

Issue 2617663002: WIP: run clang-format-js on lots of things (Closed)
Patch Set: merge Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 child of this.children_) { 137 for (var child of this.children_) {
138 for (var cookie of child.children_) { 138 for (var cookie of child.children_) {
139 list.push({title: cookie.data.title, 139 list.push({
140 id: cookie.data.id, 140 title: cookie.data.title,
141 data: cookie.data}); 141 id: cookie.data.id,
142 data: cookie.data
143 });
142 } 144 }
143 } 145 }
144 146
145 return list; 147 return list;
146 }, 148 },
147 149
148 /** 150 /**
149 * Get a summary list of all sites and their stored data. 151 * Get a summary list of all sites and their stored data.
150 * @return {!Array<!CookieDataSummaryItem>} The summary list. 152 * @return {!Array<!CookieDataSummaryItem>} The summary list.
151 */ 153 */
(...skipping 25 matching lines...) Expand all
177 179
178 var count = 180 var count =
179 (dataType == 'cookie') ? descriptionNode.children_.length : 0; 181 (dataType == 'cookie') ? descriptionNode.children_.length : 0;
180 if (count > 1) { 182 if (count > 1) {
181 description += loadTimeData.getStringF('cookiePlural', count); 183 description += loadTimeData.getStringF('cookiePlural', count);
182 } else { 184 } else {
183 description += getCookieDataCategoryText( 185 description += getCookieDataCategoryText(
184 dataType, descriptionNode.data.totalUsage); 186 dataType, descriptionNode.data.totalUsage);
185 } 187 }
186 } 188 }
187 list.push({ site: title, id: id, localData: description }); 189 list.push({site: title, id: id, localData: description});
188 } 190 }
189 list.sort(function(a, b) { 191 list.sort(function(a, b) {
190 return a.site.localeCompare(b.site); 192 return a.site.localeCompare(b.site);
191 }); 193 });
192 return list; 194 return list;
193 }, 195 },
194 196
195 /** 197 /**
196 * Fetch a CookieTreeNode by ID. 198 * Fetch a CookieTreeNode by ID.
197 * @param {string} id The ID to look up. 199 * @param {string} id The ID to look up.
(...skipping 26 matching lines...) Expand all
224 return this.children_[i]; 226 return this.children_[i];
225 } 227 }
226 return null; 228 return null;
227 }, 229 },
228 }; 230 };
229 231
230 return { 232 return {
231 CookieTreeNode: CookieTreeNode, 233 CookieTreeNode: CookieTreeNode,
232 }; 234 };
233 }); 235 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698