| 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) { |
| 239 this.sizeChild.textContent = info.quota.totalUsage; |
| 240 } |
| 241 |
| 242 // TODO(tzik): remove the entry if list is empty |
| 243 // if (!list.length) { |
| 244 // REMOVE SELF |
| 245 // } |
| 246 |
| 235 if (this.expanded) | 247 if (this.expanded) |
| 236 this.updateItems_(); | 248 this.updateItems_(); |
| 237 }, | 249 }, |
| 238 | 250 |
| 239 /** | 251 /** |
| 240 * Updates the items section to reflect changes, animating to the new state. | 252 * Updates the items section to reflect changes, animating to the new state. |
| 241 * Removes existing contents and calls @{code CookieTreeNode.createItems}. | 253 * Removes existing contents and calls @{code CookieTreeNode.createItems}. |
| 242 * @private | 254 * @private |
| 243 */ | 255 */ |
| 244 updateItems_: function() { | 256 updateItems_: function() { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 else if (this.data.type == 'database') | 429 else if (this.data.type == 'database') |
| 418 info.database = true; | 430 info.database = true; |
| 419 else if (this.data.type == 'local_storage') | 431 else if (this.data.type == 'local_storage') |
| 420 info.localStorage = true; | 432 info.localStorage = true; |
| 421 else if (this.data.type == 'app_cache') | 433 else if (this.data.type == 'app_cache') |
| 422 info.appCache = true; | 434 info.appCache = true; |
| 423 else if (this.data.type == 'indexed_db') | 435 else if (this.data.type == 'indexed_db') |
| 424 info.indexedDb = true; | 436 info.indexedDb = true; |
| 425 else if (this.data.type == 'file_system') | 437 else if (this.data.type == 'file_system') |
| 426 info.fileSystem = true; | 438 info.fileSystem = true; |
| 439 else if (this.data.type == 'quota') |
| 440 info.quota = { |
| 441 totalUsage: this.data.totalUsage, |
| 442 temporaryUsage: this.data.temporaryUsage, |
| 443 persistentUsage: this.data.persistentUsage, |
| 444 persistentQuota: this.data.persistentQuota, |
| 445 }; |
| 427 } | 446 } |
| 428 }, | 447 }, |
| 429 | 448 |
| 430 /** | 449 /** |
| 431 * Create the cookie "bubbles" for this node, recursing into children | 450 * Create the cookie "bubbles" for this node, recursing into children |
| 432 * if there are any. Append the cookie bubbles to @{code item}. | 451 * if there are any. Append the cookie bubbles to @{code item}. |
| 433 * @param {CookieListItem} item The cookie list item to create items in. | 452 * @param {CookieListItem} item The cookie list item to create items in. |
| 434 */ | 453 */ |
| 435 createItems: function(item) { | 454 createItems: function(item) { |
| 436 if (this.children.length > 0) { | 455 if (this.children.length > 0) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 449 case 'app_cache': | 468 case 'app_cache': |
| 450 text = localStrings.getString('cookie_app_cache'); | 469 text = localStrings.getString('cookie_app_cache'); |
| 451 break; | 470 break; |
| 452 case 'indexed_db': | 471 case 'indexed_db': |
| 453 text = localStrings.getString('cookie_indexed_db'); | 472 text = localStrings.getString('cookie_indexed_db'); |
| 454 break; | 473 break; |
| 455 case 'file_system': | 474 case 'file_system': |
| 456 text = localStrings.getString('cookie_file_system'); | 475 text = localStrings.getString('cookie_file_system'); |
| 457 break; | 476 break; |
| 458 } | 477 } |
| 478 if (!text) |
| 479 return; |
| 459 var div = item.ownerDocument.createElement('div'); | 480 var div = item.ownerDocument.createElement('div'); |
| 460 div.className = 'cookie-item'; | 481 div.className = 'cookie-item'; |
| 461 // Help out screen readers and such: this is a clickable thing. | 482 // Help out screen readers and such: this is a clickable thing. |
| 462 div.setAttribute('role', 'button'); | 483 div.setAttribute('role', 'button'); |
| 463 div.textContent = text; | 484 div.textContent = text; |
| 464 var index = item.appendItem(this, div); | 485 var index = item.appendItem(this, div); |
| 465 div.onclick = function() { | 486 div.onclick = function() { |
| 466 if (item.selectedIndex == index) | 487 if (item.selectedIndex == index) |
| 467 item.selectedIndex = -1; | 488 item.selectedIndex = -1; |
| 468 else | 489 else |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 parent.clear(); | 842 parent.clear(); |
| 822 this.addByParent_(parent, 0, children); | 843 this.addByParent_(parent, 0, children); |
| 823 parent.endBatchUpdates(); | 844 parent.endBatchUpdates(); |
| 824 }, | 845 }, |
| 825 }; | 846 }; |
| 826 | 847 |
| 827 return { | 848 return { |
| 828 CookiesList: CookiesList | 849 CookiesList: CookiesList |
| 829 }; | 850 }; |
| 830 }); | 851 }); |
| OLD | NEW |