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

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

Issue 2395883003: Not For Review - using dom-repeat (Closed)
Patch Set: Created 4 years, 2 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 {{hasChildren: boolean, 6 * @typedef {{hasChildren: boolean,
7 * id: string, 7 * id: string,
8 * title: string, 8 * title: string,
9 * totalUsage: string, 9 * totalUsage: string,
10 * type: string}} 10 * type: string}}
11 */ 11 */
12 var CookieDetails; 12 var CookieDetails;
13 13
14 /** 14 /**
15 * @typedef {{content: string,
16 * label: string}}
17 */
18 var CookieDataForDisplay;
19
20 /**
15 * @typedef {{title: string, 21 * @typedef {{title: string,
16 * id: string, 22 * id: string,
17 * data: CookieDetails}} 23 * data: CookieDetails}}
18 */ 24 */
19 var CookieDataItem; 25 var CookieDataItem;
20 26
21 /** 27 /**
22 * @typedef {{site: string, 28 * @typedef {{site: string,
23 * id: string, 29 * id: string,
24 * localData: string}} 30 * localData: string}}
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 * @return {!Array<!CookieDataSummaryItem>} The summary list. 165 * @return {!Array<!CookieDataSummaryItem>} The summary list.
160 */ 166 */
161 getSummaryList: function() { 167 getSummaryList: function() {
162 var list = []; 168 var list = [];
163 for (var i = 0; i < this.children_.length; ++i) { 169 for (var i = 0; i < this.children_.length; ++i) {
164 var siteEntry = this.children_[i]; 170 var siteEntry = this.children_[i];
165 var title = siteEntry.data_.title; 171 var title = siteEntry.data_.title;
166 var id = siteEntry.data_.id; 172 var id = siteEntry.data_.id;
167 var description = ''; 173 var description = '';
168 174
175 if (siteEntry.children_.length == 0)
176 continue;
177
169 for (var j = 0; j < siteEntry.children_.length; ++j) { 178 for (var j = 0; j < siteEntry.children_.length; ++j) {
170 var descriptionNode = siteEntry.children_[j]; 179 var descriptionNode = siteEntry.children_[j];
171 if (j > 0) 180 if (j > 0)
172 description += ', '; 181 description += ', ';
173 182
174 // Some types, like quota, have no description nodes. 183 // Some types, like quota, have no description nodes.
175 var dataType = ''; 184 var dataType = '';
176 if (descriptionNode.data_.type != undefined) { 185 if (descriptionNode.data_.type != undefined) {
177 dataType = descriptionNode.data_.type; 186 dataType = descriptionNode.data_.type;
178 } else { 187 } else {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 if (recursive) { 223 if (recursive) {
215 var node = this.children_[i].fetchNodeById(id, true); 224 var node = this.children_[i].fetchNodeById(id, true);
216 if (node != null) 225 if (node != null)
217 return node; 226 return node;
218 } 227 }
219 } 228 }
220 return null; 229 return null;
221 }, 230 },
222 231
223 /** 232 /**
224 * Add cookie data to a given HTML node. 233 * Get cookie data for a given HTML node.
225 * @param {HTMLElement} root The node to add the data to.
226 * @param {!settings.CookieTreeNode} item The data to add. 234 * @param {!settings.CookieTreeNode} item The data to add.
235 * @return {!Array<CookieDataForDisplay>}
227 */ 236 */
228 addCookieData: function(root, item) { 237 getCookieData: function(item) {
238 var out = [];
229 var fields = cookieInfo[item.data_.type]; 239 var fields = cookieInfo[item.data_.type];
230 for (var field of fields) { 240 for (var field of fields) {
231 // Iterate through the keys found in |cookieInfo| for the given |type| 241 // Iterate through the keys found in |cookieInfo| for the given |type|
232 // and see if those keys are present in the data. If so, display them 242 // and see if those keys are present in the data. If so, display them
233 // (in the order determined by |cookieInfo|). 243 // (in the order determined by |cookieInfo|).
234 var key = field[0]; 244 var key = field[0];
235 if (item.data_[key].length > 0) { 245 if (item.data_[key].length > 0) {
236 var label = loadTimeData.getString(field[1]); 246 var entry = {};
237 247 entry.label = loadTimeData.getString(field[1]);
238 var header = document.createElement('div'); 248 entry.content = item.data_[key];
239 header.appendChild(document.createTextNode(label)); 249 out.push(entry);
240 var content = document.createElement('div');
241 content.appendChild(document.createTextNode(item.data_[key]));
242 root.appendChild(header);
243 root.appendChild(content);
244 } 250 }
245 } 251 }
252 return out;
246 }, 253 },
247 }; 254 };
248 255
249 return { 256 return {
250 CookieTreeNode: CookieTreeNode, 257 CookieTreeNode: CookieTreeNode,
251 }; 258 };
252 }); 259 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698