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

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

Issue 2268273002: Site Settings Desktop: Show the type of cookie in dropdown (instead of url). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Polish Created 4 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/resources/settings/site_settings/site_data_details_dialog.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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}}
(...skipping 21 matching lines...) Expand all
32 */ 32 */
33 var CookieList; 33 var CookieList;
34 34
35 /** 35 /**
36 * @typedef {{id: string, 36 * @typedef {{id: string,
37 * start: !number, 37 * start: !number,
38 * count: !number}} 38 * count: !number}}
39 */ 39 */
40 var CookieRemovePacket; 40 var CookieRemovePacket;
41 41
42 var categoryLabels = {
43 'app_cache': loadTimeData.getString('cookieAppCache'),
44 'cache_storage': loadTimeData.getString('cookieCacheStorage'),
45 'channel_id': loadTimeData.getString('cookieChannelId'),
46 'cookie': loadTimeData.getString('cookieSingular'),
47 'database': loadTimeData.getString('cookieDatabaseStorage'),
48 'file_system': loadTimeData.getString('cookieFileSystem'),
49 'flash_lso': loadTimeData.getString('cookieFlashLso'),
50 'indexed_db': loadTimeData.getString('cookieLocalStorage'),
51 'local_storage': loadTimeData.getString('cookieLocalStorage'),
52 'service_worker': loadTimeData.getString('cookieServiceWorker'),
53 };
54
55 /**
56 * Retrieves the human friendly text to show for the type of cookie.
57 * @param {string} dataType The datatype to look up.
58 * @param {string} totalUsage How much data is being consumed.
59 * @return {string} The human-friendly description for this cookie.
60 */
61 function getCookieDataCategoryText(dataType, totalUsage) {
62 if (dataType == 'quota')
63 return totalUsage;
64 return categoryLabels[dataType];
65 }
66
42 cr.define('settings', function() { 67 cr.define('settings', function() {
43 'use strict'; 68 'use strict';
44 69
45 /** 70 /**
46 * @constructor 71 * @constructor
47 */ 72 */
48 function CookieTreeNode(data) { 73 function CookieTreeNode(data) {
49 /** 74 /**
50 * The data for this cookie node. 75 * The data for this cookie node.
51 * @private {CookieDetails} 76 * @private {CookieDetails}
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 if (j > 0) 171 if (j > 0)
147 description += ', '; 172 description += ', ';
148 173
149 // Some types, like quota, have no description nodes. 174 // Some types, like quota, have no description nodes.
150 var dataType = ''; 175 var dataType = '';
151 if (descriptionNode.data_.type != undefined) 176 if (descriptionNode.data_.type != undefined)
152 dataType = descriptionNode.data_.type; 177 dataType = descriptionNode.data_.type;
153 else 178 else
154 dataType = descriptionNode.children_[0].data_.type; 179 dataType = descriptionNode.children_[0].data_.type;
155 180
156 var category = ''; 181 var count =
157 if (dataType == 'cookie') { 182 (dataType == 'cookie') ? descriptionNode.children_.length : 0;
158 var cookieCount = descriptionNode.children_.length; 183 if (count > 1) {
159 if (cookieCount > 1) 184 description += loadTimeData.getStringF('cookiePlural', count);
160 category = loadTimeData.getStringF('cookiePlural', cookieCount); 185 } else {
161 else 186 description += getCookieDataCategoryText(
162 category = loadTimeData.getString('cookieSingular'); 187 dataType, descriptionNode.data_.totalUsage);
163 } else if (dataType == 'database') {
164 category = loadTimeData.getString('cookieDatabaseStorage');
165 } else if (dataType == 'local_storage' || dataType == 'indexed_db') {
166 category = loadTimeData.getString('cookieLocalStorage');
167 } else if (dataType == 'app_cache') {
168 category = loadTimeData.getString('cookieAppCache');
169 } else if (dataType == 'file_system') {
170 category = loadTimeData.getString('cookieFileSystem');
171 } else if (dataType == 'quota') {
172 category = descriptionNode.data_.totalUsage;
173 } else if (dataType == 'channel_id') {
174 category = loadTimeData.getString('cookieChannelId');
175 } else if (dataType == 'service_worker') {
176 category = loadTimeData.getString('cookieServiceWorker');
177 } else if (dataType == 'cache_storage') {
178 category = loadTimeData.getString('cookieCacheStorage');
179 } else if (dataType == 'flash_lso') {
180 category = loadTimeData.getString('cookieFlashLso');
181 } 188 }
182 189
183 description += category;
184 } 190 }
185 list.push({ site: title, id: id, localData: description }); 191 list.push({ site: title, id: id, localData: description });
186 } 192 }
187 list.sort(function(a, b) { 193 list.sort(function(a, b) {
188 return a.site.localeCompare(b.site); 194 return a.site.localeCompare(b.site);
189 }); 195 });
190 return list; 196 return list;
191 }, 197 },
192 198
193 /** 199 /**
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 root.appendChild(content); 240 root.appendChild(content);
235 } 241 }
236 } 242 }
237 }, 243 },
238 }; 244 };
239 245
240 return { 246 return {
241 CookieTreeNode: CookieTreeNode, 247 CookieTreeNode: CookieTreeNode,
242 }; 248 };
243 }); 249 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/settings/site_settings/site_data_details_dialog.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698