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

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

Issue 10709006: Show apps protecting local data in chrome://settings/cookies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 8 years, 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 */ var DeletableItemList = options.DeletableItemList; 6 /** @const */ var DeletableItemList = options.DeletableItemList;
7 /** @const */ var DeletableItem = options.DeletableItem; 7 /** @const */ var DeletableItem = options.DeletableItem;
8 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; 8 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel;
9 /** @const */ var ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; 9 /** @const */ var ListSingleSelectionModel = cr.ui.ListSingleSelectionModel;
10 10
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 this.itemsChild.style.height = itemsHeight + 'px'; 215 this.itemsChild.style.height = itemsHeight + 'px';
216 this.style.height = fixedHeight + 'px'; 216 this.style.height = fixedHeight + 'px';
217 }, 217 },
218 218
219 /** 219 /**
220 * Updates the origin summary to reflect changes in its items. 220 * Updates the origin summary to reflect changes in its items.
221 * Both CookieListItem and CookieTreeNode implement this API. 221 * Both CookieListItem and CookieTreeNode implement this API.
222 * This implementation scans the descendants to update the text. 222 * This implementation scans the descendants to update the text.
223 */ 223 */
224 updateOrigin: function() { 224 updateOrigin: function() {
225 var info = { 225 var info = {
Evan Stade 2012/07/10 07:53:08 surely the block of code between here and L271 des
Bernhard Bauer 2012/07/10 09:50:59 Done.
226 cookies: 0, 226 cookies: 0,
227 database: false, 227 database: false,
228 localStorage: false, 228 localStorage: false,
229 appCache: false, 229 appCache: false,
230 indexedDb: false, 230 indexedDb: false,
231 fileSystem: false, 231 fileSystem: false,
232 serverBoundCerts: 0, 232 serverBoundCerts: 0,
233 }; 233 };
234 if (this.origin) 234 if (this.origin)
235 this.origin.collectSummaryInfo(info); 235 this.origin.collectSummaryInfo(info);
(...skipping 12 matching lines...) Expand all
248 list.push(loadTimeData.getString('cookie_file_system')); 248 list.push(loadTimeData.getString('cookie_file_system'));
249 if (info.serverBoundCerts) 249 if (info.serverBoundCerts)
250 list.push(loadTimeData.getString('cookie_server_bound_cert')); 250 list.push(loadTimeData.getString('cookie_server_bound_cert'));
251 var text = ''; 251 var text = '';
252 for (var i = 0; i < list.length; ++i) 252 for (var i = 0; i < list.length; ++i)
253 if (text.length > 0) 253 if (text.length > 0)
254 text += ', ' + list[i]; 254 text += ', ' + list[i];
255 else 255 else
256 text = list[i]; 256 text = list[i];
257 this.dataChild.textContent = text; 257 this.dataChild.textContent = text;
258 var apps = info.protectedByApps;
259 if (apps) {
260 for (var key in apps) {
261 var img = this.dataChild.ownerDocument.createElement('img');
262 img.src = 'chrome://extension-icon/' + key + '/16/1';
263 img.title = loadTimeData.getString('label_protected_by_apps') +
Evan Stade 2012/07/10 07:53:08 perhaps this is part of the TODO to use a better a
Bernhard Bauer 2012/07/10 09:50:59 Indeed! For this CL I'm just going with the existi
264 ' ' + apps[key].name;
265 img.className = 'protecting-app';
266 this.dataChild.appendChild(img);
267 }
268 }
258 if (info.quota && info.quota.totalUsage) { 269 if (info.quota && info.quota.totalUsage) {
259 this.sizeChild.textContent = info.quota.totalUsage; 270 this.sizeChild.textContent = info.quota.totalUsage;
260 } 271 }
Evan Stade 2012/07/10 07:53:08 no curlies.
Bernhard Bauer 2012/07/10 09:50:59 Done.
261 272
262 if (this.expanded) 273 if (this.expanded)
263 this.updateItems_(); 274 this.updateItems_();
264 }, 275 },
265 276
266 /** 277 /**
267 * Updates the items section to reflect changes, animating to the new state. 278 * Updates the items section to reflect changes, animating to the new state.
268 * Removes existing contents and calls @{code CookieTreeNode.createItems}. 279 * Removes existing contents and calls @{code CookieTreeNode.createItems}.
269 * @private 280 * @private
270 */ 281 */
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 } else if (this.data.type == 'app_cache') { 459 } else if (this.data.type == 'app_cache') {
449 info.appCache = true; 460 info.appCache = true;
450 } else if (this.data.type == 'indexed_db') { 461 } else if (this.data.type == 'indexed_db') {
451 info.indexedDb = true; 462 info.indexedDb = true;
452 } else if (this.data.type == 'file_system') { 463 } else if (this.data.type == 'file_system') {
453 info.fileSystem = true; 464 info.fileSystem = true;
454 } else if (this.data.type == 'quota') { 465 } else if (this.data.type == 'quota') {
455 info.quota = this.data; 466 info.quota = this.data;
456 } else if (this.data.type == 'server_bound_cert') { 467 } else if (this.data.type == 'server_bound_cert') {
457 info.serverBoundCerts++; 468 info.serverBoundCerts++;
458 } 469 }
Evan Stade 2012/07/10 07:53:08 \n
Bernhard Bauer 2012/07/10 09:50:59 Done.
470 var apps = this.data.protectedByApps;
471 if (apps) {
472 if (!info.protectedByApps)
473 info.protectedByApps = {};
474 apps.forEach(function(appInfo) {
475 info.protectedByApps[appInfo.id] = appInfo;
476 });
477 }
459 } 478 }
460 }, 479 },
461 480
462 /** 481 /**
463 * Create the cookie "bubbles" for this node, recursing into children 482 * Create the cookie "bubbles" for this node, recursing into children
464 * if there are any. Append the cookie bubbles to @{code item}. 483 * if there are any. Append the cookie bubbles to @{code item}.
465 * @param {CookieListItem} item The cookie list item to create items in. 484 * @param {CookieListItem} item The cookie list item to create items in.
466 */ 485 */
467 createItems: function(item) { 486 createItems: function(item) {
468 if (this.children.length > 0) { 487 if (this.children.length > 0) {
Evan Stade 2012/07/10 07:53:08 ditto in this function, needs vertical spacing.
Bernhard Bauer 2012/07/10 09:50:59 Done. I also flattened the nested if's a bit.
469 for (var i = 0; i < this.children.length; ++i) 488 for (var i = 0; i < this.children.length; ++i)
470 this.children[i].createItems(item); 489 this.children[i].createItems(item);
471 } else if (this.data && !this.data.hasChildren) { 490 } else if (this.data && !this.data.hasChildren) {
472 var text = ''; 491 var text = '';
473 switch (this.data.type) { 492 switch (this.data.type) {
474 case 'cookie': 493 case 'cookie':
475 case 'database': 494 case 'database':
476 text = this.data.name; 495 text = this.data.name;
477 break; 496 break;
478 case 'local_storage': 497 case 'local_storage':
(...skipping 12 matching lines...) Expand all
491 text = loadTimeData.getString('cookie_server_bound_cert'); 510 text = loadTimeData.getString('cookie_server_bound_cert');
492 break; 511 break;
493 } 512 }
494 if (!text) 513 if (!text)
495 return; 514 return;
496 var div = item.ownerDocument.createElement('div'); 515 var div = item.ownerDocument.createElement('div');
497 div.className = 'cookie-item'; 516 div.className = 'cookie-item';
498 // Help out screen readers and such: this is a clickable thing. 517 // Help out screen readers and such: this is a clickable thing.
499 div.setAttribute('role', 'button'); 518 div.setAttribute('role', 'button');
500 div.textContent = text; 519 div.textContent = text;
520 var apps = this.data.protectedByApps;
521 if (apps) {
522 apps.forEach(function(appInfo) {
Evan Stade 2012/07/10 07:53:08 hmm, this function looks oddly familiar
Bernhard Bauer 2012/07/10 09:50:59 Extracted a function.
523 var img = div.ownerDocument.createElement('img');
524 img.src = 'chrome://extension-icon/' + appInfo.id + '/16/1';
525 img.title = loadTimeData.getString('label_protected_by_apps') +
526 ' ' + appInfo.name;
527 img.className = 'protecting-app';
528 div.appendChild(img);
529 });
530 }
501 var index = item.appendItem(this, div); 531 var index = item.appendItem(this, div);
502 div.onclick = function() { 532 div.onclick = function() {
503 if (item.selectedIndex == index) 533 if (item.selectedIndex == index)
504 item.selectedIndex = -1; 534 item.selectedIndex = -1;
505 else 535 else
506 item.selectedIndex = index; 536 item.selectedIndex = index;
507 }; 537 };
508 } 538 }
509 }, 539 },
510 540
511 /** 541 /**
512 * Set the detail text to be displayed to that of this cookie tree node. 542 * Set the detail text to be displayed to that of this cookie tree node.
513 * Uses preallocated DOM elements for each cookie node type from @{code 543 * Uses preallocated DOM elements for each cookie node type from @{code
514 * infoNodes}, and inserts the appropriate elements to @{code element}. 544 * infoNodes}, and inserts the appropriate elements to @{code element}.
515 * @param {Element} element The DOM element to insert elements to. 545 * @param {Element} element The DOM element to insert elements to.
516 * @param {Object.<string, {table: Element, info: Object.<string, 546 * @param {Object.<string, {table: Element, info: Object.<string,
517 * Element>}>} infoNodes The map from cookie node types to maps from 547 * Element>}>} infoNodes The map from cookie node types to maps from
518 * cookie attribute names to DOM elements to display cookie attribute 548 * cookie attribute names to DOM elements to display cookie attribute
519 * values, created by @{code CookiesList.decorate}. 549 * values, created by @{code CookiesList.decorate}.
520 */ 550 */
521 setDetailText: function(element, infoNodes) { 551 setDetailText: function(element, infoNodes) {
522 var table; 552 var table;
Evan Stade 2012/07/10 07:53:08 ditto in this function, needs vertical spacing.
Bernhard Bauer 2012/07/10 09:50:59 Done.
523 if (this.data && !this.data.hasChildren) { 553 if (this.data && !this.data.hasChildren) {
524 if (cookieInfo[this.data.type]) { 554 if (cookieInfo[this.data.type]) {
525 var info = cookieInfo[this.data.type]; 555 var info = cookieInfo[this.data.type];
526 var nodes = infoNodes[this.data.type].info; 556 var nodes = infoNodes[this.data.type].info;
527 for (var i = 0; i < info.length; ++i) { 557 for (var i = 0; i < info.length; ++i) {
528 var name = info[i][0]; 558 var name = info[i][0];
529 if (name != 'id' && this.data[name]) 559 if (name != 'id' && this.data[name])
530 nodes[name].textContent = this.data[name]; 560 nodes[name].textContent = this.data[name];
531 else 561 else
532 nodes[name].textContent = ''; 562 nodes[name].textContent = '';
(...skipping 11 matching lines...) Expand all
544 * The parent of this cookie tree node. 574 * The parent of this cookie tree node.
545 * @type {?CookieTreeNode|CookieListItem} 575 * @type {?CookieTreeNode|CookieListItem}
546 */ 576 */
547 get parent() { 577 get parent() {
548 // See below for an explanation of this special case. 578 // See below for an explanation of this special case.
549 if (typeof this.parent_ == 'number') 579 if (typeof this.parent_ == 'number')
550 return this.list_.getListItemByIndex(this.parent_); 580 return this.list_.getListItemByIndex(this.parent_);
551 return this.parent_; 581 return this.parent_;
552 }, 582 },
553 set parent(parent) { 583 set parent(parent) {
554 if (parent == this.parent) 584 if (parent == this.parent)
Evan Stade 2012/07/10 07:53:08 ditto in this function, needs vertical spacing.
Bernhard Bauer 2012/07/10 09:50:59 Done.
555 return; 585 return;
556 if (parent instanceof CookieListItem) { 586 if (parent instanceof CookieListItem) {
557 // If the parent is to be a CookieListItem, then we keep the reference 587 // If the parent is to be a CookieListItem, then we keep the reference
558 // to it by its containing list and list index, rather than directly. 588 // to it by its containing list and list index, rather than directly.
559 // This allows the list items to be garbage collected when they scroll 589 // This allows the list items to be garbage collected when they scroll
560 // out of view (except the expanded item, which we cache). This is 590 // out of view (except the expanded item, which we cache). This is
561 // transparent except in the setter and getter, where we handle it. 591 // transparent except in the setter and getter, where we handle it.
562 this.parent_ = parent.listIndex; 592 this.parent_ = parent.listIndex;
563 this.list_ = parent.list; 593 this.list_ = parent.list;
564 parent.addEventListener('listIndexChange', 594 parent.addEventListener('listIndexChange',
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 parent.clear(); 884 parent.clear();
855 this.addByParent_(parent, 0, children); 885 this.addByParent_(parent, 0, children);
856 parent.endBatchUpdates(); 886 parent.endBatchUpdates();
857 }, 887 },
858 }; 888 };
859 889
860 return { 890 return {
861 CookiesList: CookiesList 891 CookiesList: CookiesList
862 }; 892 };
863 }); 893 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698