Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
| 4 * Copyright (C) 2013 Samsung Electronics. All rights reserved. | 4 * Copyright (C) 2013 Samsung Electronics. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * | 9 * |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 this._domStorageTreeElements = new Map(); | 107 this._domStorageTreeElements = new Map(); |
| 108 /** @type {!Object.<string, !Resources.CookieItemsView>} */ | 108 /** @type {!Object.<string, !Resources.CookieItemsView>} */ |
| 109 this._cookieViews = {}; | 109 this._cookieViews = {}; |
| 110 /** @type {!Object.<string, boolean>} */ | 110 /** @type {!Object.<string, boolean>} */ |
| 111 this._domains = {}; | 111 this._domains = {}; |
| 112 | 112 |
| 113 this.panelSidebarElement().addEventListener('mousemove', this._onmousemove.b ind(this), false); | 113 this.panelSidebarElement().addEventListener('mousemove', this._onmousemove.b ind(this), false); |
| 114 this.panelSidebarElement().addEventListener('mouseleave', this._onmouseleave .bind(this), false); | 114 this.panelSidebarElement().addEventListener('mouseleave', this._onmouseleave .bind(this), false); |
| 115 | 115 |
| 116 SDK.targetManager.observeTargets(this); | 116 SDK.targetManager.observeTargets(this); |
| 117 SDK.targetManager.addEventListener( | |
| 118 SDK.TargetManager.Events.MainFrameNavigated, | |
| 119 event => this._manifestTreeElement.loadManifest(event.data.target())); | |
|
pfeldman
2017/02/07 02:11:44
You only want to load manifest if the view is visi
eostroukhov
2017/02/07 19:16:51
Done.
| |
| 120 | |
| 121 var mainTarget = SDK.targetManager.mainTarget(); | |
|
pfeldman
2017/02/07 02:11:44
ditto
eostroukhov
2017/02/07 19:16:51
Done.
| |
| 122 if (mainTarget) | |
| 123 this._manifestTreeElement.loadManifest(mainTarget); | |
| 117 } | 124 } |
| 118 | 125 |
| 119 /** | 126 /** |
| 120 * @return {!Resources.ResourcesPanel} | 127 * @return {!Resources.ResourcesPanel} |
| 121 */ | 128 */ |
| 122 static _instance() { | 129 static _instance() { |
| 123 return /** @type {!Resources.ResourcesPanel} */ (self.runtime.sharedInstance (Resources.ResourcesPanel)); | 130 return /** @type {!Resources.ResourcesPanel} */ (self.runtime.sharedInstance (Resources.ResourcesPanel)); |
| 124 } | 131 } |
| 125 | 132 |
| 126 /** | 133 /** |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 633 this._innerShowView(view); | 640 this._innerShowView(view); |
| 634 } | 641 } |
| 635 | 642 |
| 636 showCategoryView(categoryName) { | 643 showCategoryView(categoryName) { |
| 637 if (!this._categoryView) | 644 if (!this._categoryView) |
| 638 this._categoryView = new Resources.StorageCategoryView(); | 645 this._categoryView = new Resources.StorageCategoryView(); |
| 639 this._categoryView.setText(categoryName); | 646 this._categoryView.setText(categoryName); |
| 640 this._innerShowView(this._categoryView); | 647 this._innerShowView(this._categoryView); |
| 641 } | 648 } |
| 642 | 649 |
| 650 /** | |
| 651 * @param {!UI.Widget} view | |
| 652 */ | |
| 643 _innerShowView(view) { | 653 _innerShowView(view) { |
| 644 if (this.visibleView === view) | 654 if (this.visibleView === view) |
| 645 return; | 655 return; |
| 646 | 656 |
| 647 if (this.visibleView) | 657 if (this.visibleView) |
| 648 this.visibleView.detach(); | 658 this.visibleView.detach(); |
| 649 | 659 |
| 650 view.show(this.storageViews); | 660 view.show(this.storageViews); |
| 651 this.visibleView = view; | 661 this.visibleView = view; |
| 652 | 662 |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1421 */ | 1431 */ |
| 1422 onselect(selectedByUser) { | 1432 onselect(selectedByUser) { |
| 1423 super.onselect(selectedByUser); | 1433 super.onselect(selectedByUser); |
| 1424 if (!this._view) | 1434 if (!this._view) |
| 1425 this._view = new Resources.ServiceWorkersView(); | 1435 this._view = new Resources.ServiceWorkersView(); |
| 1426 this._storagePanel._innerShowView(this._view); | 1436 this._storagePanel._innerShowView(this._view); |
| 1427 return false; | 1437 return false; |
| 1428 } | 1438 } |
| 1429 }; | 1439 }; |
| 1430 | 1440 |
| 1431 /** | |
| 1432 * @unrestricted | |
| 1433 */ | |
| 1434 Resources.AppManifestTreeElement = class extends Resources.BaseStorageTreeElemen t { | 1441 Resources.AppManifestTreeElement = class extends Resources.BaseStorageTreeElemen t { |
| 1435 /** | 1442 /** |
| 1436 * @param {!Resources.ResourcesPanel} storagePanel | 1443 * @param {!Resources.ResourcesPanel} storagePanel |
| 1437 */ | 1444 */ |
| 1438 constructor(storagePanel) { | 1445 constructor(storagePanel) { |
| 1439 super(storagePanel, Common.UIString('Manifest'), false); | 1446 super(storagePanel, Common.UIString('Manifest'), false); |
| 1447 /** @type {?Resources.AppManifestView} */ | |
| 1448 this._view = null; | |
| 1449 /** @type {string} */ | |
| 1450 this._manifestUrl = ''; | |
| 1451 /** @type {?string} */ | |
| 1452 this._manifestData = null; | |
| 1453 /** @type {!Array<!Protocol.Page.AppManifestError>} */ | |
| 1454 this._manifestFetchErrors = []; | |
| 1455 this.selectable = false; | |
| 1456 | |
| 1440 var icon = UI.Icon.create('mediumicon-manifest', 'resource-tree-item'); | 1457 var icon = UI.Icon.create('mediumicon-manifest', 'resource-tree-item'); |
| 1441 this.setLeadingIcons([icon]); | 1458 this.setLeadingIcons([icon]); |
| 1442 } | 1459 } |
| 1443 | 1460 |
| 1444 /** | 1461 /** |
| 1445 * @return {string} | 1462 * @return {string} |
| 1446 */ | 1463 */ |
| 1447 get itemURL() { | 1464 get itemURL() { |
| 1448 return 'manifest://'; | 1465 return 'manifest://'; |
| 1449 } | 1466 } |
| 1450 | 1467 |
| 1451 /** | 1468 /** |
| 1452 * @override | 1469 * @override |
| 1470 * @param {boolean=} selectedByUser | |
| 1453 * @return {boolean} | 1471 * @return {boolean} |
| 1454 */ | 1472 */ |
| 1455 onselect(selectedByUser) { | 1473 onselect(selectedByUser) { |
| 1474 if (!this.selectable) | |
| 1475 return false; | |
| 1456 super.onselect(selectedByUser); | 1476 super.onselect(selectedByUser); |
| 1457 if (!this._view) | 1477 if (!this._view) { |
| 1458 this._view = new Resources.AppManifestView(); | 1478 this._view = new Resources.AppManifestView(); |
| 1479 this._view.renderManifest(this._manifestUrl, this._manifestData, this._man ifestFetchErrors); | |
| 1480 } | |
| 1459 this._storagePanel._innerShowView(this._view); | 1481 this._storagePanel._innerShowView(this._view); |
| 1460 return false; | 1482 return false; |
| 1461 } | 1483 } |
| 1484 | |
| 1485 /** | |
| 1486 * @param {!SDK.Target} target | |
| 1487 */ | |
| 1488 loadManifest(target) { | |
| 1489 SDK.ResourceTreeModel.fromTarget(target).fetchAppManifest(this._onManifestFe tched.bind(this)); | |
| 1490 } | |
| 1491 | |
| 1492 /** | |
| 1493 * @param {string} url | |
| 1494 * @param {?string} data | |
| 1495 * @param {!Array<!Protocol.Page.AppManifestError>} errors | |
| 1496 */ | |
| 1497 _onManifestFetched(url, data, errors) { | |
| 1498 this._manifestUrl = url; | |
| 1499 this._manifestData = data; | |
| 1500 this._manifestFetchErrors = errors; | |
| 1501 | |
| 1502 this._setEnabled(!!data || !!errors.length); | |
| 1503 | |
| 1504 if (this._view) | |
| 1505 this._view.renderManifest(url, data, errors); | |
| 1506 } | |
| 1507 | |
| 1508 /** | |
| 1509 * @param {boolean} enabled | |
| 1510 */ | |
| 1511 _setEnabled(enabled) { | |
| 1512 this.selectable = enabled; | |
| 1513 this.listItemElement.classList.toggle('resource-sidebar-item-disabled', !ena bled); | |
| 1514 } | |
| 1462 }; | 1515 }; |
| 1463 | 1516 |
| 1464 /** | 1517 /** |
| 1465 * @unrestricted | 1518 * @unrestricted |
| 1466 */ | 1519 */ |
| 1467 Resources.ClearStorageTreeElement = class extends Resources.BaseStorageTreeEleme nt { | 1520 Resources.ClearStorageTreeElement = class extends Resources.BaseStorageTreeEleme nt { |
| 1468 /** | 1521 /** |
| 1469 * @param {!Resources.ResourcesPanel} storagePanel | 1522 * @param {!Resources.ResourcesPanel} storagePanel |
| 1470 */ | 1523 */ |
| 1471 constructor(storagePanel) { | 1524 constructor(storagePanel) { |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2092 | 2145 |
| 2093 this.element.classList.add('storage-view'); | 2146 this.element.classList.add('storage-view'); |
| 2094 this._emptyWidget = new UI.EmptyWidget(''); | 2147 this._emptyWidget = new UI.EmptyWidget(''); |
| 2095 this._emptyWidget.show(this.element); | 2148 this._emptyWidget.show(this.element); |
| 2096 } | 2149 } |
| 2097 | 2150 |
| 2098 setText(text) { | 2151 setText(text) { |
| 2099 this._emptyWidget.text = text; | 2152 this._emptyWidget.text = text; |
| 2100 } | 2153 } |
| 2101 }; | 2154 }; |
| OLD | NEW |