OLD | NEW |
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 CookieListItem.prototype = { | 113 CookieListItem.prototype = { |
114 __proto__: DeletableItem.prototype, | 114 __proto__: DeletableItem.prototype, |
115 | 115 |
116 /** @inheritDoc */ | 116 /** @inheritDoc */ |
117 decorate: function() { | 117 decorate: function() { |
118 this.siteChild = this.ownerDocument.createElement('div'); | 118 this.siteChild = this.ownerDocument.createElement('div'); |
119 this.siteChild.className = 'cookie-site'; | 119 this.siteChild.className = 'cookie-site'; |
120 this.dataChild = this.ownerDocument.createElement('div'); | 120 this.dataChild = this.ownerDocument.createElement('div'); |
121 this.dataChild.className = 'cookie-data'; | 121 this.dataChild.className = 'cookie-data'; |
122 this.sizeChild = this.ownerDocument.createElement('div'); | |
123 this.sizeChild.className = 'cookie-size'; | |
124 this.itemsChild = this.ownerDocument.createElement('div'); | 122 this.itemsChild = this.ownerDocument.createElement('div'); |
125 this.itemsChild.className = 'cookie-items'; | 123 this.itemsChild.className = 'cookie-items'; |
126 this.infoChild = this.ownerDocument.createElement('div'); | 124 this.infoChild = this.ownerDocument.createElement('div'); |
127 this.infoChild.className = 'cookie-details'; | 125 this.infoChild.className = 'cookie-details'; |
128 this.infoChild.hidden = true; | 126 this.infoChild.hidden = true; |
129 var remove = this.ownerDocument.createElement('button'); | 127 var remove = this.ownerDocument.createElement('button'); |
130 remove.textContent = localStrings.getString('remove_cookie'); | 128 remove.textContent = localStrings.getString('remove_cookie'); |
131 remove.onclick = this.removeCookie_.bind(this); | 129 remove.onclick = this.removeCookie_.bind(this); |
132 this.infoChild.appendChild(remove); | 130 this.infoChild.appendChild(remove); |
133 var content = this.contentElement; | 131 var content = this.contentElement; |
134 content.appendChild(this.siteChild); | 132 content.appendChild(this.siteChild); |
135 content.appendChild(this.dataChild); | 133 content.appendChild(this.dataChild); |
136 content.appendChild(this.sizeChild); | |
137 content.appendChild(this.itemsChild); | 134 content.appendChild(this.itemsChild); |
138 this.itemsChild.appendChild(this.infoChild); | 135 this.itemsChild.appendChild(this.infoChild); |
139 if (this.origin && this.origin.data) { | 136 if (this.origin && this.origin.data) { |
140 this.siteChild.textContent = this.origin.data.title; | 137 this.siteChild.textContent = this.origin.data.title; |
141 this.siteChild.setAttribute('title', this.origin.data.title); | 138 this.siteChild.setAttribute('title', this.origin.data.title); |
142 } | 139 } |
143 this.itemList_ = []; | 140 this.itemList_ = []; |
144 }, | 141 }, |
145 | 142 |
146 /** @type {boolean} */ | 143 /** @type {boolean} */ |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 list.push(localStrings.getString('cookie_app_cache')); | 243 list.push(localStrings.getString('cookie_app_cache')); |
247 if (info.fileSystem) | 244 if (info.fileSystem) |
248 list.push(localStrings.getString('cookie_file_system')); | 245 list.push(localStrings.getString('cookie_file_system')); |
249 var text = ''; | 246 var text = ''; |
250 for (var i = 0; i < list.length; ++i) | 247 for (var i = 0; i < list.length; ++i) |
251 if (text.length > 0) | 248 if (text.length > 0) |
252 text += ', ' + list[i]; | 249 text += ', ' + list[i]; |
253 else | 250 else |
254 text = list[i]; | 251 text = list[i]; |
255 this.dataChild.textContent = text; | 252 this.dataChild.textContent = text; |
256 if (info.quota && info.quota.totalUsage) { | |
257 this.sizeChild.textContent = info.quota.totalUsage; | |
258 } | |
259 | |
260 if (this.expanded) | 253 if (this.expanded) |
261 this.updateItems_(); | 254 this.updateItems_(); |
262 }, | 255 }, |
263 | 256 |
264 /** | 257 /** |
265 * Updates the items section to reflect changes, animating to the new state. | 258 * Updates the items section to reflect changes, animating to the new state. |
266 * Removes existing contents and calls @{code CookieTreeNode.createItems}. | 259 * Removes existing contents and calls @{code CookieTreeNode.createItems}. |
267 * @private | 260 * @private |
268 */ | 261 */ |
269 updateItems_: function() { | 262 updateItems_: function() { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 /** | 423 /** |
431 * Summarize the information in this node and update @{code info}. | 424 * Summarize the information in this node and update @{code info}. |
432 * This will recurse into child nodes to summarize all descendants. | 425 * This will recurse into child nodes to summarize all descendants. |
433 * @param {Object} info The info object from @{code updateOrigin}. | 426 * @param {Object} info The info object from @{code updateOrigin}. |
434 */ | 427 */ |
435 collectSummaryInfo: function(info) { | 428 collectSummaryInfo: function(info) { |
436 if (this.children.length > 0) { | 429 if (this.children.length > 0) { |
437 for (var i = 0; i < this.children.length; ++i) | 430 for (var i = 0; i < this.children.length; ++i) |
438 this.children[i].collectSummaryInfo(info); | 431 this.children[i].collectSummaryInfo(info); |
439 } else if (this.data && !this.data.hasChildren) { | 432 } else if (this.data && !this.data.hasChildren) { |
440 if (this.data.type == 'cookie') { | 433 if (this.data.type == 'cookie') |
441 info.cookies++; | 434 info.cookies++; |
442 } else if (this.data.type == 'database') { | 435 else if (this.data.type == 'database') |
443 info.database = true; | 436 info.database = true; |
444 } else if (this.data.type == 'local_storage') { | 437 else if (this.data.type == 'local_storage') |
445 info.localStorage = true; | 438 info.localStorage = true; |
446 } else if (this.data.type == 'app_cache') { | 439 else if (this.data.type == 'app_cache') |
447 info.appCache = true; | 440 info.appCache = true; |
448 } else if (this.data.type == 'indexed_db') { | 441 else if (this.data.type == 'indexed_db') |
449 info.indexedDb = true; | 442 info.indexedDb = true; |
450 } else if (this.data.type == 'file_system') { | 443 else if (this.data.type == 'file_system') |
451 info.fileSystem = true; | 444 info.fileSystem = true; |
452 } else if (this.data.type == 'quota') { | |
453 info.quota = this.data; | |
454 } | |
455 } | 445 } |
456 }, | 446 }, |
457 | 447 |
458 /** | 448 /** |
459 * Create the cookie "bubbles" for this node, recursing into children | 449 * Create the cookie "bubbles" for this node, recursing into children |
460 * if there are any. Append the cookie bubbles to @{code item}. | 450 * if there are any. Append the cookie bubbles to @{code item}. |
461 * @param {CookieListItem} item The cookie list item to create items in. | 451 * @param {CookieListItem} item The cookie list item to create items in. |
462 */ | 452 */ |
463 createItems: function(item) { | 453 createItems: function(item) { |
464 if (this.children.length > 0) { | 454 if (this.children.length > 0) { |
(...skipping 12 matching lines...) Expand all Loading... |
477 case 'app_cache': | 467 case 'app_cache': |
478 text = localStrings.getString('cookie_app_cache'); | 468 text = localStrings.getString('cookie_app_cache'); |
479 break; | 469 break; |
480 case 'indexed_db': | 470 case 'indexed_db': |
481 text = localStrings.getString('cookie_indexed_db'); | 471 text = localStrings.getString('cookie_indexed_db'); |
482 break; | 472 break; |
483 case 'file_system': | 473 case 'file_system': |
484 text = localStrings.getString('cookie_file_system'); | 474 text = localStrings.getString('cookie_file_system'); |
485 break; | 475 break; |
486 } | 476 } |
487 if (!text) | |
488 return; | |
489 var div = item.ownerDocument.createElement('div'); | 477 var div = item.ownerDocument.createElement('div'); |
490 div.className = 'cookie-item'; | 478 div.className = 'cookie-item'; |
491 // Help out screen readers and such: this is a clickable thing. | 479 // Help out screen readers and such: this is a clickable thing. |
492 div.setAttribute('role', 'button'); | 480 div.setAttribute('role', 'button'); |
493 div.textContent = text; | 481 div.textContent = text; |
494 var index = item.appendItem(this, div); | 482 var index = item.appendItem(this, div); |
495 div.onclick = function() { | 483 div.onclick = function() { |
496 if (item.selectedIndex == index) | 484 if (item.selectedIndex == index) |
497 item.selectedIndex = -1; | 485 item.selectedIndex = -1; |
498 else | 486 else |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 parent.clear(); | 834 parent.clear(); |
847 this.addByParent_(parent, 0, children); | 835 this.addByParent_(parent, 0, children); |
848 parent.endBatchUpdates(); | 836 parent.endBatchUpdates(); |
849 }, | 837 }, |
850 }; | 838 }; |
851 | 839 |
852 return { | 840 return { |
853 CookiesList: CookiesList | 841 CookiesList: CookiesList |
854 }; | 842 }; |
855 }); | 843 }); |
OLD | NEW |