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

Side by Side Diff: chrome/browser/resources/options/cookies_list.js

Issue 7387007: Adding usage and quota entry to chrome://settings/cookies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Omit column header Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 cr.define('options', function() { 5 cr.define('options', function() {
6 const DeletableItemList = options.DeletableItemList; 6 const DeletableItemList = options.DeletableItemList;
7 const DeletableItem = options.DeletableItem; 7 const DeletableItem = options.DeletableItem;
8 const ArrayDataModel = cr.ui.ArrayDataModel; 8 const ArrayDataModel = cr.ui.ArrayDataModel;
9 const ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; 9 const ListSingleSelectionModel = cr.ui.ListSingleSelectionModel;
10 10
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 CookieListItem.prototype = { 95 CookieListItem.prototype = {
96 __proto__: DeletableItem.prototype, 96 __proto__: DeletableItem.prototype,
97 97
98 /** @inheritDoc */ 98 /** @inheritDoc */
99 decorate: function() { 99 decorate: function() {
100 this.siteChild = this.ownerDocument.createElement('div'); 100 this.siteChild = this.ownerDocument.createElement('div');
101 this.siteChild.className = 'cookie-site'; 101 this.siteChild.className = 'cookie-site';
102 this.dataChild = this.ownerDocument.createElement('div'); 102 this.dataChild = this.ownerDocument.createElement('div');
103 this.dataChild.className = 'cookie-data'; 103 this.dataChild.className = 'cookie-data';
104 this.sizeChild = this.ownerDocument.createElement('div');
105 this.sizeChild.className = 'cookie-size';
104 this.itemsChild = this.ownerDocument.createElement('div'); 106 this.itemsChild = this.ownerDocument.createElement('div');
105 this.itemsChild.className = 'cookie-items'; 107 this.itemsChild.className = 'cookie-items';
106 this.infoChild = this.ownerDocument.createElement('div'); 108 this.infoChild = this.ownerDocument.createElement('div');
107 this.infoChild.className = 'cookie-details'; 109 this.infoChild.className = 'cookie-details';
108 this.infoChild.hidden = true; 110 this.infoChild.hidden = true;
109 var remove = this.ownerDocument.createElement('button'); 111 var remove = this.ownerDocument.createElement('button');
110 remove.textContent = localStrings.getString('remove_cookie'); 112 remove.textContent = localStrings.getString('remove_cookie');
111 remove.onclick = this.removeCookie_.bind(this); 113 remove.onclick = this.removeCookie_.bind(this);
112 this.infoChild.appendChild(remove); 114 this.infoChild.appendChild(remove);
113 var content = this.contentElement; 115 var content = this.contentElement;
114 content.appendChild(this.siteChild); 116 content.appendChild(this.siteChild);
115 content.appendChild(this.dataChild); 117 content.appendChild(this.dataChild);
118 content.appendChild(this.sizeChild);
116 content.appendChild(this.itemsChild); 119 content.appendChild(this.itemsChild);
117 this.itemsChild.appendChild(this.infoChild); 120 this.itemsChild.appendChild(this.infoChild);
118 if (this.origin && this.origin.data) { 121 if (this.origin && this.origin.data) {
119 this.siteChild.textContent = this.origin.data.title; 122 this.siteChild.textContent = this.origin.data.title;
120 this.siteChild.setAttribute('title', this.origin.data.title); 123 this.siteChild.setAttribute('title', this.origin.data.title);
121 } 124 }
122 this.itemList_ = []; 125 this.itemList_ = [];
123 }, 126 },
124 127
125 /** @type {boolean} */ 128 /** @type {boolean} */
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 list.push(localStrings.getString('cookie_app_cache')); 228 list.push(localStrings.getString('cookie_app_cache'));
226 if (info.fileSystem) 229 if (info.fileSystem)
227 list.push(localStrings.getString('cookie_file_system')); 230 list.push(localStrings.getString('cookie_file_system'));
228 var text = ''; 231 var text = '';
229 for (var i = 0; i < list.length; ++i) 232 for (var i = 0; i < list.length; ++i)
230 if (text.length > 0) 233 if (text.length > 0)
231 text += ', ' + list[i]; 234 text += ', ' + list[i];
232 else 235 else
233 text = list[i]; 236 text = list[i];
234 this.dataChild.textContent = text; 237 this.dataChild.textContent = text;
238 if (info.quota && info.quota.totalUsage) {
239 this.sizeChild.textContent = info.quota.totalUsage;
240 } else {
241 this.sizeChild.textContent =
242 localStrings.getString('usage_unavailable');
Mike Mammarella 2011/07/29 17:59:26 Without the header it might be better to leave thi
tzik 2011/08/01 02:46:26 Done.
243 }
244
235 if (this.expanded) 245 if (this.expanded)
236 this.updateItems_(); 246 this.updateItems_();
237 }, 247 },
238 248
239 /** 249 /**
240 * Updates the items section to reflect changes, animating to the new state. 250 * Updates the items section to reflect changes, animating to the new state.
241 * Removes existing contents and calls @{code CookieTreeNode.createItems}. 251 * Removes existing contents and calls @{code CookieTreeNode.createItems}.
242 * @private 252 * @private
243 */ 253 */
244 updateItems_: function() { 254 updateItems_: function() {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 /** 415 /**
406 * Summarize the information in this node and update @{code info}. 416 * Summarize the information in this node and update @{code info}.
407 * This will recurse into child nodes to summarize all descendants. 417 * This will recurse into child nodes to summarize all descendants.
408 * @param {Object} info The info object from @{code updateOrigin}. 418 * @param {Object} info The info object from @{code updateOrigin}.
409 */ 419 */
410 collectSummaryInfo: function(info) { 420 collectSummaryInfo: function(info) {
411 if (this.children.length > 0) { 421 if (this.children.length > 0) {
412 for (var i = 0; i < this.children.length; ++i) 422 for (var i = 0; i < this.children.length; ++i)
413 this.children[i].collectSummaryInfo(info); 423 this.children[i].collectSummaryInfo(info);
414 } else if (this.data && !this.data.hasChildren) { 424 } else if (this.data && !this.data.hasChildren) {
415 if (this.data.type == 'cookie') 425 if (this.data.type == 'cookie') {
416 info.cookies++; 426 info.cookies++;
417 else if (this.data.type == 'database') 427 } else if (this.data.type == 'database') {
418 info.database = true; 428 info.database = true;
419 else if (this.data.type == 'local_storage') 429 } else if (this.data.type == 'local_storage') {
420 info.localStorage = true; 430 info.localStorage = true;
421 else if (this.data.type == 'app_cache') 431 } else if (this.data.type == 'app_cache') {
422 info.appCache = true; 432 info.appCache = true;
423 else if (this.data.type == 'indexed_db') 433 } else if (this.data.type == 'indexed_db') {
424 info.indexedDb = true; 434 info.indexedDb = true;
425 else if (this.data.type == 'file_system') 435 } else if (this.data.type == 'file_system') {
426 info.fileSystem = true; 436 info.fileSystem = true;
437 } else if (this.data.type == 'quota') {
438 info.quota = {
439 totalUsage: this.data.totalUsage,
440 temporaryUsage: this.data.temporaryUsage,
441 persistentUsage: this.data.persistentUsage,
442 persistentQuota: this.data.persistentQuota,
443 };
444 }
427 } 445 }
428 }, 446 },
429 447
430 /** 448 /**
431 * Create the cookie "bubbles" for this node, recursing into children 449 * Create the cookie "bubbles" for this node, recursing into children
432 * if there are any. Append the cookie bubbles to @{code item}. 450 * if there are any. Append the cookie bubbles to @{code item}.
433 * @param {CookieListItem} item The cookie list item to create items in. 451 * @param {CookieListItem} item The cookie list item to create items in.
434 */ 452 */
435 createItems: function(item) { 453 createItems: function(item) {
436 if (this.children.length > 0) { 454 if (this.children.length > 0) {
(...skipping 12 matching lines...) Expand all
449 case 'app_cache': 467 case 'app_cache':
450 text = localStrings.getString('cookie_app_cache'); 468 text = localStrings.getString('cookie_app_cache');
451 break; 469 break;
452 case 'indexed_db': 470 case 'indexed_db':
453 text = localStrings.getString('cookie_indexed_db'); 471 text = localStrings.getString('cookie_indexed_db');
454 break; 472 break;
455 case 'file_system': 473 case 'file_system':
456 text = localStrings.getString('cookie_file_system'); 474 text = localStrings.getString('cookie_file_system');
457 break; 475 break;
458 } 476 }
477 if (!text)
478 return;
459 var div = item.ownerDocument.createElement('div'); 479 var div = item.ownerDocument.createElement('div');
460 div.className = 'cookie-item'; 480 div.className = 'cookie-item';
461 // Help out screen readers and such: this is a clickable thing. 481 // Help out screen readers and such: this is a clickable thing.
462 div.setAttribute('role', 'button'); 482 div.setAttribute('role', 'button');
463 div.textContent = text; 483 div.textContent = text;
464 var index = item.appendItem(this, div); 484 var index = item.appendItem(this, div);
465 div.onclick = function() { 485 div.onclick = function() {
466 if (item.selectedIndex == index) 486 if (item.selectedIndex == index)
467 item.selectedIndex = -1; 487 item.selectedIndex = -1;
468 else 488 else
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 parent.clear(); 841 parent.clear();
822 this.addByParent_(parent, 0, children); 842 this.addByParent_(parent, 0, children);
823 parent.endBatchUpdates(); 843 parent.endBatchUpdates();
824 }, 844 },
825 }; 845 };
826 846
827 return { 847 return {
828 CookiesList: CookiesList 848 CookiesList: CookiesList
829 }; 849 };
830 }); 850 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698