| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 } |
| 241 |
| 235 if (this.expanded) | 242 if (this.expanded) |
| 236 this.updateItems_(); | 243 this.updateItems_(); |
| 237 }, | 244 }, |
| 238 | 245 |
| 239 /** | 246 /** |
| 240 * Updates the items section to reflect changes, animating to the new state. | 247 * Updates the items section to reflect changes, animating to the new state. |
| 241 * Removes existing contents and calls @{code CookieTreeNode.createItems}. | 248 * Removes existing contents and calls @{code CookieTreeNode.createItems}. |
| 242 * @private | 249 * @private |
| 243 */ | 250 */ |
| 244 updateItems_: function() { | 251 updateItems_: function() { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 /** | 412 /** |
| 406 * Summarize the information in this node and update @{code info}. | 413 * Summarize the information in this node and update @{code info}. |
| 407 * This will recurse into child nodes to summarize all descendants. | 414 * This will recurse into child nodes to summarize all descendants. |
| 408 * @param {Object} info The info object from @{code updateOrigin}. | 415 * @param {Object} info The info object from @{code updateOrigin}. |
| 409 */ | 416 */ |
| 410 collectSummaryInfo: function(info) { | 417 collectSummaryInfo: function(info) { |
| 411 if (this.children.length > 0) { | 418 if (this.children.length > 0) { |
| 412 for (var i = 0; i < this.children.length; ++i) | 419 for (var i = 0; i < this.children.length; ++i) |
| 413 this.children[i].collectSummaryInfo(info); | 420 this.children[i].collectSummaryInfo(info); |
| 414 } else if (this.data && !this.data.hasChildren) { | 421 } else if (this.data && !this.data.hasChildren) { |
| 415 if (this.data.type == 'cookie') | 422 if (this.data.type == 'cookie') { |
| 416 info.cookies++; | 423 info.cookies++; |
| 417 else if (this.data.type == 'database') | 424 } else if (this.data.type == 'database') { |
| 418 info.database = true; | 425 info.database = true; |
| 419 else if (this.data.type == 'local_storage') | 426 } else if (this.data.type == 'local_storage') { |
| 420 info.localStorage = true; | 427 info.localStorage = true; |
| 421 else if (this.data.type == 'app_cache') | 428 } else if (this.data.type == 'app_cache') { |
| 422 info.appCache = true; | 429 info.appCache = true; |
| 423 else if (this.data.type == 'indexed_db') | 430 } else if (this.data.type == 'indexed_db') { |
| 424 info.indexedDb = true; | 431 info.indexedDb = true; |
| 425 else if (this.data.type == 'file_system') | 432 } else if (this.data.type == 'file_system') { |
| 426 info.fileSystem = true; | 433 info.fileSystem = true; |
| 434 } else if (this.data.type == 'quota') { |
| 435 info.quota = this.data; |
| 436 } |
| 427 } | 437 } |
| 428 }, | 438 }, |
| 429 | 439 |
| 430 /** | 440 /** |
| 431 * Create the cookie "bubbles" for this node, recursing into children | 441 * Create the cookie "bubbles" for this node, recursing into children |
| 432 * if there are any. Append the cookie bubbles to @{code item}. | 442 * if there are any. Append the cookie bubbles to @{code item}. |
| 433 * @param {CookieListItem} item The cookie list item to create items in. | 443 * @param {CookieListItem} item The cookie list item to create items in. |
| 434 */ | 444 */ |
| 435 createItems: function(item) { | 445 createItems: function(item) { |
| 436 if (this.children.length > 0) { | 446 if (this.children.length > 0) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 449 case 'app_cache': | 459 case 'app_cache': |
| 450 text = localStrings.getString('cookie_app_cache'); | 460 text = localStrings.getString('cookie_app_cache'); |
| 451 break; | 461 break; |
| 452 case 'indexed_db': | 462 case 'indexed_db': |
| 453 text = localStrings.getString('cookie_indexed_db'); | 463 text = localStrings.getString('cookie_indexed_db'); |
| 454 break; | 464 break; |
| 455 case 'file_system': | 465 case 'file_system': |
| 456 text = localStrings.getString('cookie_file_system'); | 466 text = localStrings.getString('cookie_file_system'); |
| 457 break; | 467 break; |
| 458 } | 468 } |
| 469 if (!text) |
| 470 return; |
| 459 var div = item.ownerDocument.createElement('div'); | 471 var div = item.ownerDocument.createElement('div'); |
| 460 div.className = 'cookie-item'; | 472 div.className = 'cookie-item'; |
| 461 // Help out screen readers and such: this is a clickable thing. | 473 // Help out screen readers and such: this is a clickable thing. |
| 462 div.setAttribute('role', 'button'); | 474 div.setAttribute('role', 'button'); |
| 463 div.textContent = text; | 475 div.textContent = text; |
| 464 var index = item.appendItem(this, div); | 476 var index = item.appendItem(this, div); |
| 465 div.onclick = function() { | 477 div.onclick = function() { |
| 466 if (item.selectedIndex == index) | 478 if (item.selectedIndex == index) |
| 467 item.selectedIndex = -1; | 479 item.selectedIndex = -1; |
| 468 else | 480 else |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 parent.clear(); | 833 parent.clear(); |
| 822 this.addByParent_(parent, 0, children); | 834 this.addByParent_(parent, 0, children); |
| 823 parent.endBatchUpdates(); | 835 parent.endBatchUpdates(); |
| 824 }, | 836 }, |
| 825 }; | 837 }; |
| 826 | 838 |
| 827 return { | 839 return { |
| 828 CookiesList: CookiesList | 840 CookiesList: CookiesList |
| 829 }; | 841 }; |
| 830 }); | 842 }); |
| OLD | NEW |