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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/resources/AppManifestView.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 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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 /**
5 * @implements {SDK.TargetManager.Observer}
6 * @unrestricted
7 */
8 Resources.AppManifestView = class extends UI.VBox { 4 Resources.AppManifestView = class extends UI.VBox {
9 constructor() { 5 constructor() {
10 super(true); 6 super(true);
11 this.registerRequiredCSS('resources/appManifestView.css'); 7 this.registerRequiredCSS('resources/appManifestView.css');
12 8
13 this._reportView = new UI.ReportView(Common.UIString('App Manifest')); 9 this._reportView = new UI.ReportView(Common.UIString('App Manifest'));
14 this._reportView.show(this.contentElement); 10 this._reportView.show(this.contentElement);
15 11
16 this._errorsSection = this._reportView.appendSection(Common.UIString('Errors and warnings')); 12 this._errorsSection = this._reportView.appendSection(Common.UIString('Errors and warnings'));
17 this._identitySection = this._reportView.appendSection(Common.UIString('Iden tity')); 13 this._identitySection = this._reportView.appendSection(Common.UIString('Iden tity'));
(...skipping 15 matching lines...) Expand all
33 var themeColorField = this._presentationSection.appendField(Common.UIString( 'Theme color')); 29 var themeColorField = this._presentationSection.appendField(Common.UIString( 'Theme color'));
34 this._themeColorSwatch = InlineEditor.ColorSwatch.create(); 30 this._themeColorSwatch = InlineEditor.ColorSwatch.create();
35 themeColorField.appendChild(this._themeColorSwatch); 31 themeColorField.appendChild(this._themeColorSwatch);
36 32
37 var backgroundColorField = this._presentationSection.appendField(Common.UISt ring('Background color')); 33 var backgroundColorField = this._presentationSection.appendField(Common.UISt ring('Background color'));
38 this._backgroundColorSwatch = InlineEditor.ColorSwatch.create(); 34 this._backgroundColorSwatch = InlineEditor.ColorSwatch.create();
39 backgroundColorField.appendChild(this._backgroundColorSwatch); 35 backgroundColorField.appendChild(this._backgroundColorSwatch);
40 36
41 this._orientationField = this._presentationSection.appendField(Common.UIStri ng('Orientation')); 37 this._orientationField = this._presentationSection.appendField(Common.UIStri ng('Orientation'));
42 this._displayField = this._presentationSection.appendField(Common.UIString(' Display')); 38 this._displayField = this._presentationSection.appendField(Common.UIString(' Display'));
43
44 SDK.targetManager.observeTargets(this, SDK.Target.Capability.DOM);
45 } 39 }
46 40
47 /** 41 /**
48 * @override
49 * @param {!SDK.Target} target
50 */
51 targetAdded(target) {
52 if (this._resourceTreeModel)
53 return;
54 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(target);
55 if (!resourceTreeModel)
56 return;
57 this._resourceTreeModel = resourceTreeModel;
58 this._updateManifest();
59 resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.MainFrameNav igated, this._updateManifest, this);
60 }
61
62 /**
63 * @override
64 * @param {!SDK.Target} target
65 */
66 targetRemoved(target) {
67 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(target);
68 if (!this._resourceTreeModel || this._resourceTreeModel !== resourceTreeMode l)
69 return;
70 resourceTreeModel.removeEventListener(SDK.ResourceTreeModel.Events.MainFrame Navigated, this._updateManifest, this);
71 delete this._resourceTreeModel;
72 }
73
74 _updateManifest() {
75 this._resourceTreeModel.fetchAppManifest(this._renderManifest.bind(this));
76 }
77
78 /**
79 * @param {string} url 42 * @param {string} url
80 * @param {?string} data 43 * @param {?string} data
81 * @param {!Array<!Protocol.Page.AppManifestError>} errors 44 * @param {!Array<!Protocol.Page.AppManifestError>} errors
82 */ 45 */
83 _renderManifest(url, data, errors) { 46 renderManifest(url, data, errors) {
84 this._reportView.setURL(Components.Linkifier.linkifyURL(url)); 47 // This needs to run after the Linkifier listener processes target added eve nt
48 setTimeout(() => this._reportView.setURL(Components.Linkifier.linkifyURL(url )));
pfeldman 2017/02/07 00:25:35 That's a bad assumption to make.
eostroukhov 2017/02/07 01:40:38 I do not see a cleaner option atm. Note - this is
85 this._errorsSection.clearContent(); 49 this._errorsSection.clearContent();
86 this._errorsSection.element.classList.toggle('hidden', !errors.length); 50 this._errorsSection.element.classList.toggle('hidden', !errors.length);
87 for (var error of errors) { 51 for (var error of errors) {
88 this._errorsSection.appendRow().appendChild( 52 this._errorsSection.appendRow().appendChild(
89 UI.createLabel(error.message, error.critical ? 'smallicon-error' : 'sm allicon-warning')); 53 UI.createLabel(error.message, error.critical ? 'smallicon-error' : 'sm allicon-warning'));
90 } 54 }
91 55
92 if (!data) 56 if (!data)
93 data = '{}'; 57 data = '{}';
94 58
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 * @param {!Common.Event} event 104 * @param {!Common.Event} event
141 */ 105 */
142 _addToHomescreen(event) { 106 _addToHomescreen(event) {
143 var target = SDK.targetManager.mainTarget(); 107 var target = SDK.targetManager.mainTarget();
144 if (target && target.hasBrowserCapability()) { 108 if (target && target.hasBrowserCapability()) {
145 target.pageAgent().requestAppBanner(); 109 target.pageAgent().requestAppBanner();
146 Common.console.show(); 110 Common.console.show();
147 } 111 }
148 } 112 }
149 }; 113 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698