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

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..d68e467072e035bf6a9f5fa8558edadb3d0146e5 100644
--- a/third_party/WebKit/Source/devtools/front_end/resources/ResourcesPanel.js
+++ b/third_party/WebKit/Source/devtools/front_end/resources/ResourcesPanel.js
@@ -114,6 +114,13 @@ Resources.ResourcesPanel = class extends UI.PanelWithSidebar {
this.panelSidebarElement().addEventListener('mouseleave', this._onmouseleave.bind(this), false);
SDK.targetManager.observeTargets(this);
+ SDK.targetManager.addEventListener(
+ SDK.TargetManager.Events.MainFrameNavigated,
+ 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.
+
+ var mainTarget = SDK.targetManager.mainTarget();
pfeldman 2017/02/07 02:11:44 ditto
eostroukhov 2017/02/07 19:16:51 Done.
+ if (mainTarget)
+ this._manifestTreeElement.loadManifest(mainTarget);
}
/**
@@ -640,6 +647,9 @@ Resources.ResourcesPanel = class extends UI.PanelWithSidebar {
this._innerShowView(this._categoryView);
}
+ /**
+ * @param {!UI.Widget} view
+ */
_innerShowView(view) {
if (this.visibleView === view)
return;
@@ -1428,15 +1438,22 @@ 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 {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 +1467,51 @@ 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
+ */
+ loadManifest(target) {
+ SDK.ResourceTreeModel.fromTarget(target).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);
+ }
};
/**

Powered by Google App Engine
This is Rietveld 408576698