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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/resources/ResourcesPanel.js

Issue 2679013004: [DevTools] Show an empty Manifest view if no manifest (Closed)
Patch Set: [DevTools] Disable "Manifest" if the site has none. Created 3 years, 10 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
OLDNEW
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(target); 152 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(target);
153 if (!resourceTreeModel) 153 if (!resourceTreeModel)
154 return; 154 return;
155 155
156 if (resourceTreeModel.cachedResourcesLoaded()) 156 if (resourceTreeModel.cachedResourcesLoaded())
157 this._initialize(); 157 this._initialize();
158 158
159 resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.CachedResour cesLoaded, this._initialize, this); 159 resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.CachedResour cesLoaded, this._initialize, this);
160 resourceTreeModel.addEventListener( 160 resourceTreeModel.addEventListener(
161 SDK.ResourceTreeModel.Events.WillLoadCachedResources, this._resetWithFra mes, this); 161 SDK.ResourceTreeModel.Events.WillLoadCachedResources, this._resetWithFra mes, this);
162
163 this._manifestTreeElement._startTracking(target);
pfeldman 2017/02/07 00:25:35 We only show manifest for the main target, see bel
eostroukhov 2017/02/07 01:40:38 Acknowledged.
162 } 164 }
163 165
164 /** 166 /**
165 * @override 167 * @override
166 * @param {!SDK.Target} target 168 * @param {!SDK.Target} target
167 */ 169 */
168 targetRemoved(target) { 170 targetRemoved(target) {
169 if (target !== this._target) 171 if (target !== this._target)
170 return; 172 return;
171 delete this._target; 173 delete this._target;
172 174 this._manifestTreeElement._stopTracking(target);
173 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(target); 175 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(target);
174 if (resourceTreeModel) { 176 if (resourceTreeModel) {
175 resourceTreeModel.removeEventListener(SDK.ResourceTreeModel.Events.CachedR esourcesLoaded, this._initialize, this); 177 resourceTreeModel.removeEventListener(SDK.ResourceTreeModel.Events.CachedR esourcesLoaded, this._initialize, this);
176 resourceTreeModel.removeEventListener( 178 resourceTreeModel.removeEventListener(
177 SDK.ResourceTreeModel.Events.WillLoadCachedResources, this._resetWithF rames, this); 179 SDK.ResourceTreeModel.Events.WillLoadCachedResources, this._resetWithF rames, this);
178 } 180 }
179 this._databaseModel.off(Resources.DatabaseModel.DatabaseAddedEvent, this._da tabaseAdded, this); 181 this._databaseModel.off(Resources.DatabaseModel.DatabaseAddedEvent, this._da tabaseAdded, this);
180 this._databaseModel.off(Resources.DatabaseModel.DatabasesRemovedEvent, this. _resetWebSQL, this); 182 this._databaseModel.off(Resources.DatabaseModel.DatabasesRemovedEvent, this. _resetWebSQL, this);
181 183
182 this._resetWithFrames(); 184 this._resetWithFrames();
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 this._innerShowView(view); 635 this._innerShowView(view);
634 } 636 }
635 637
636 showCategoryView(categoryName) { 638 showCategoryView(categoryName) {
637 if (!this._categoryView) 639 if (!this._categoryView)
638 this._categoryView = new Resources.StorageCategoryView(); 640 this._categoryView = new Resources.StorageCategoryView();
639 this._categoryView.setText(categoryName); 641 this._categoryView.setText(categoryName);
640 this._innerShowView(this._categoryView); 642 this._innerShowView(this._categoryView);
641 } 643 }
642 644
645 /**
646 * @param {!UI.Widget} view
647 */
643 _innerShowView(view) { 648 _innerShowView(view) {
644 if (this.visibleView === view) 649 if (this.visibleView === view)
645 return; 650 return;
646 651
647 if (this.visibleView) 652 if (this.visibleView)
648 this.visibleView.detach(); 653 this.visibleView.detach();
649 654
650 view.show(this.storageViews); 655 view.show(this.storageViews);
651 this.visibleView = view; 656 this.visibleView = view;
652 657
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1421 */ 1426 */
1422 onselect(selectedByUser) { 1427 onselect(selectedByUser) {
1423 super.onselect(selectedByUser); 1428 super.onselect(selectedByUser);
1424 if (!this._view) 1429 if (!this._view)
1425 this._view = new Resources.ServiceWorkersView(); 1430 this._view = new Resources.ServiceWorkersView();
1426 this._storagePanel._innerShowView(this._view); 1431 this._storagePanel._innerShowView(this._view);
1427 return false; 1432 return false;
1428 } 1433 }
1429 }; 1434 };
1430 1435
1431 /**
1432 * @unrestricted
1433 */
1434 Resources.AppManifestTreeElement = class extends Resources.BaseStorageTreeElemen t { 1436 Resources.AppManifestTreeElement = class extends Resources.BaseStorageTreeElemen t {
1435 /** 1437 /**
1436 * @param {!Resources.ResourcesPanel} storagePanel 1438 * @param {!Resources.ResourcesPanel} storagePanel
1437 */ 1439 */
1438 constructor(storagePanel) { 1440 constructor(storagePanel) {
1439 super(storagePanel, Common.UIString('Manifest'), false); 1441 super(storagePanel, Common.UIString('Manifest'), false);
1442 /** @type {?Resources.AppManifestView} */
1443 this._view = null;
1444 /** @type {?SDK.ResourceTreeModel} */
1445 this._resourceTreeModel = null;
1446 /** @type {string} */
1447 this._manifestUrl = '';
1448 /** @type {?string} */
1449 this._manifestData = null;
1450 /** @type {!Array<!Protocol.Page.AppManifestError>} */
1451 this._manifestFetchErrors = [];
1452 this.selectable = false;
1453
1440 var icon = UI.Icon.create('mediumicon-manifest', 'resource-tree-item'); 1454 var icon = UI.Icon.create('mediumicon-manifest', 'resource-tree-item');
1441 this.setLeadingIcons([icon]); 1455 this.setLeadingIcons([icon]);
1442 } 1456 }
1443 1457
1444 /** 1458 /**
1445 * @return {string} 1459 * @return {string}
1446 */ 1460 */
1447 get itemURL() { 1461 get itemURL() {
1448 return 'manifest://'; 1462 return 'manifest://';
1449 } 1463 }
1450 1464
1451 /** 1465 /**
1452 * @override 1466 * @override
1467 * @param {boolean=} selectedByUser
1453 * @return {boolean} 1468 * @return {boolean}
1454 */ 1469 */
1455 onselect(selectedByUser) { 1470 onselect(selectedByUser) {
1471 if (!this.selectable)
1472 return false;
1456 super.onselect(selectedByUser); 1473 super.onselect(selectedByUser);
1457 if (!this._view) 1474 if (!this._view) {
1458 this._view = new Resources.AppManifestView(); 1475 this._view = new Resources.AppManifestView();
1476 this._view.renderManifest(this._manifestUrl, this._manifestData, this._man ifestFetchErrors);
1477 }
1459 this._storagePanel._innerShowView(this._view); 1478 this._storagePanel._innerShowView(this._view);
1460 return false; 1479 return false;
1461 } 1480 }
1481
1482 /**
1483 * @param {!SDK.Target} target
1484 */
1485 _startTracking(target) {
1486 if (this._resourceTreeModel)
1487 return;
1488 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(target);
1489 if (!resourceTreeModel)
1490 return;
1491 this._resourceTreeModel = resourceTreeModel;
1492 this._updateManifest();
1493 resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.MainFrameNav igated, this._updateManifest, this);
pfeldman 2017/02/07 00:25:35 You should instead set this listener on the target
eostroukhov 2017/02/07 01:40:38 Done. Thanks for reminding me!
1494 }
1495
1496 /**
1497 * @param {!SDK.Target} target
1498 */
1499 _stopTracking(target) {
1500 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(target);
1501 if (!this._resourceTreeModel || this._resourceTreeModel !== resourceTreeMode l)
1502 return;
1503 resourceTreeModel.removeEventListener(SDK.ResourceTreeModel.Events.MainFrame Navigated, this._updateManifest, this);
1504 delete this._resourceTreeModel;
1505 this._onManifestFetched('', null, []);
1506 }
1507
1508 _updateManifest() {
1509 this._resourceTreeModel.fetchAppManifest(this._onManifestFetched.bind(this)) ;
1510 }
1511
1512 /**
1513 * @param {string} url
1514 * @param {?string} data
1515 * @param {!Array<!Protocol.Page.AppManifestError>} errors
1516 */
1517 _onManifestFetched(url, data, errors) {
1518 this._manifestUrl = url;
1519 this._manifestData = data;
1520 this._manifestFetchErrors = errors;
1521
1522 this._setEnabled(!!data || !!errors.length);
1523
1524 if (this._view)
1525 this._view.renderManifest(url, data, errors);
1526 }
1527
1528 /**
1529 * @param {boolean} enabled
1530 */
1531 _setEnabled(enabled) {
1532 this.selectable = enabled;
1533 this.listItemElement.classList.toggle('resource-sidebar-item-disabled', !ena bled);
1534 if (!enabled && this._storagePanel.visibleView === this._view)
1535 this._storagePanel.closeVisibleView();
pfeldman 2017/02/07 00:25:35 You might end up resetting the view upon navigatio
eostroukhov 2017/02/07 01:40:38 I think it is ok to let the user see "broken" pane
1536 }
1462 }; 1537 };
1463 1538
1464 /** 1539 /**
1465 * @unrestricted 1540 * @unrestricted
1466 */ 1541 */
1467 Resources.ClearStorageTreeElement = class extends Resources.BaseStorageTreeEleme nt { 1542 Resources.ClearStorageTreeElement = class extends Resources.BaseStorageTreeEleme nt {
1468 /** 1543 /**
1469 * @param {!Resources.ResourcesPanel} storagePanel 1544 * @param {!Resources.ResourcesPanel} storagePanel
1470 */ 1545 */
1471 constructor(storagePanel) { 1546 constructor(storagePanel) {
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
2092 2167
2093 this.element.classList.add('storage-view'); 2168 this.element.classList.add('storage-view');
2094 this._emptyWidget = new UI.EmptyWidget(''); 2169 this._emptyWidget = new UI.EmptyWidget('');
2095 this._emptyWidget.show(this.element); 2170 this._emptyWidget.show(this.element);
2096 } 2171 }
2097 2172
2098 setText(text) { 2173 setText(text) {
2099 this._emptyWidget.text = text; 2174 this._emptyWidget.text = text;
2100 } 2175 }
2101 }; 2176 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698