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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/resources/ResourcesPanel.js
diff --git a/third_party/WebKit/Source/devtools/front_end/resources/ResourcesPanel.js b/third_party/WebKit/Source/devtools/front_end/resources/ResourcesPanel.js
index 948c20fa46b1c6f8250c1e88deab4409d3fe7085..79fc7658eeda58511a3f3921a89e86db51a922bc 100644
--- a/third_party/WebKit/Source/devtools/front_end/resources/ResourcesPanel.js
+++ b/third_party/WebKit/Source/devtools/front_end/resources/ResourcesPanel.js
@@ -159,6 +159,8 @@ Resources.ResourcesPanel = class extends UI.PanelWithSidebar {
resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.CachedResourcesLoaded, this._initialize, this);
resourceTreeModel.addEventListener(
SDK.ResourceTreeModel.Events.WillLoadCachedResources, this._resetWithFrames, this);
+
+ 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.
}
/**
@@ -169,7 +171,7 @@ Resources.ResourcesPanel = class extends UI.PanelWithSidebar {
if (target !== this._target)
return;
delete this._target;
-
+ this._manifestTreeElement._stopTracking(target);
var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(target);
if (resourceTreeModel) {
resourceTreeModel.removeEventListener(SDK.ResourceTreeModel.Events.CachedResourcesLoaded, this._initialize, this);
@@ -640,6 +642,9 @@ Resources.ResourcesPanel = class extends UI.PanelWithSidebar {
this._innerShowView(this._categoryView);
}
+ /**
+ * @param {!UI.Widget} view
+ */
_innerShowView(view) {
if (this.visibleView === view)
return;
@@ -1428,15 +1433,24 @@ Resources.ServiceWorkersTreeElement = class extends Resources.BaseStorageTreeEle
}
};
-/**
- * @unrestricted
- */
Resources.AppManifestTreeElement = class extends Resources.BaseStorageTreeElement {
/**
* @param {!Resources.ResourcesPanel} storagePanel
*/
constructor(storagePanel) {
super(storagePanel, Common.UIString('Manifest'), false);
+ /** @type {?Resources.AppManifestView} */
+ this._view = null;
+ /** @type {?SDK.ResourceTreeModel} */
+ this._resourceTreeModel = null;
+ /** @type {string} */
+ this._manifestUrl = '';
+ /** @type {?string} */
+ this._manifestData = null;
+ /** @type {!Array<!Protocol.Page.AppManifestError>} */
+ this._manifestFetchErrors = [];
+ this.selectable = false;
+
var icon = UI.Icon.create('mediumicon-manifest', 'resource-tree-item');
this.setLeadingIcons([icon]);
}
@@ -1450,15 +1464,76 @@ Resources.AppManifestTreeElement = class extends Resources.BaseStorageTreeElemen
/**
* @override
+ * @param {boolean=} selectedByUser
* @return {boolean}
*/
onselect(selectedByUser) {
+ if (!this.selectable)
+ return false;
super.onselect(selectedByUser);
- if (!this._view)
+ if (!this._view) {
this._view = new Resources.AppManifestView();
+ this._view.renderManifest(this._manifestUrl, this._manifestData, this._manifestFetchErrors);
+ }
this._storagePanel._innerShowView(this._view);
return false;
}
+
+ /**
+ * @param {!SDK.Target} target
+ */
+ _startTracking(target) {
+ if (this._resourceTreeModel)
+ return;
+ var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(target);
+ if (!resourceTreeModel)
+ return;
+ this._resourceTreeModel = resourceTreeModel;
+ this._updateManifest();
+ resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.MainFrameNavigated, 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!
+ }
+
+ /**
+ * @param {!SDK.Target} target
+ */
+ _stopTracking(target) {
+ var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(target);
+ if (!this._resourceTreeModel || this._resourceTreeModel !== resourceTreeModel)
+ return;
+ resourceTreeModel.removeEventListener(SDK.ResourceTreeModel.Events.MainFrameNavigated, this._updateManifest, this);
+ delete this._resourceTreeModel;
+ this._onManifestFetched('', null, []);
+ }
+
+ _updateManifest() {
+ this._resourceTreeModel.fetchAppManifest(this._onManifestFetched.bind(this));
+ }
+
+ /**
+ * @param {string} url
+ * @param {?string} data
+ * @param {!Array<!Protocol.Page.AppManifestError>} errors
+ */
+ _onManifestFetched(url, data, errors) {
+ this._manifestUrl = url;
+ this._manifestData = data;
+ this._manifestFetchErrors = errors;
+
+ this._setEnabled(!!data || !!errors.length);
+
+ if (this._view)
+ this._view.renderManifest(url, data, errors);
+ }
+
+ /**
+ * @param {boolean} enabled
+ */
+ _setEnabled(enabled) {
+ this.selectable = enabled;
+ this.listItemElement.classList.toggle('resource-sidebar-item-disabled', !enabled);
+ if (!enabled && this._storagePanel.visibleView === this._view)
+ 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
+ }
};
/**

Powered by Google App Engine
This is Rietveld 408576698