| OLD | NEW |
| 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 /** | 4 /** |
| 5 * @implements {SDK.TargetManager.Observer} | 5 * @implements {SDK.TargetManager.Observer} |
| 6 * @unrestricted | 6 * @unrestricted |
| 7 */ | 7 */ |
| 8 Resources.AppManifestView = class extends UI.VBox { | 8 Resources.AppManifestView = class extends UI.VBox { |
| 9 constructor() { | 9 constructor() { |
| 10 super(true); | 10 super(true); |
| 11 this.registerRequiredCSS('resources/appManifestView.css'); | 11 this.registerRequiredCSS('resources/appManifestView.css'); |
| 12 | 12 |
| 13 this._emptyView = new UI.EmptyWidget(Common.UIString('No web app manifest'))
; |
| 14 |
| 15 this._emptyView.show(this.contentElement); |
| 16 this._emptyView.hideWidget(); |
| 17 |
| 13 this._reportView = new UI.ReportView(Common.UIString('App Manifest')); | 18 this._reportView = new UI.ReportView(Common.UIString('App Manifest')); |
| 14 this._reportView.show(this.contentElement); | 19 this._reportView.show(this.contentElement); |
| 20 this._reportView.hideWidget(); |
| 15 | 21 |
| 16 this._errorsSection = this._reportView.appendSection(Common.UIString('Errors
and warnings')); | 22 this._errorsSection = this._reportView.appendSection(Common.UIString('Errors
and warnings')); |
| 17 this._identitySection = this._reportView.appendSection(Common.UIString('Iden
tity')); | 23 this._identitySection = this._reportView.appendSection(Common.UIString('Iden
tity')); |
| 18 var toolbar = this._identitySection.createToolbar(); | 24 var toolbar = this._identitySection.createToolbar(); |
| 19 toolbar.renderAsLinks(); | 25 toolbar.renderAsLinks(); |
| 20 var addToHomeScreen = | 26 var addToHomeScreen = |
| 21 new UI.ToolbarButton(Common.UIString('Add to homescreen'), undefined, Co
mmon.UIString('Add to homescreen')); | 27 new UI.ToolbarButton(Common.UIString('Add to homescreen'), undefined, Co
mmon.UIString('Add to homescreen')); |
| 22 addToHomeScreen.addEventListener(UI.ToolbarButton.Events.Click, this._addToH
omescreen, this); | 28 addToHomeScreen.addEventListener(UI.ToolbarButton.Events.Click, this._addToH
omescreen, this); |
| 23 toolbar.appendToolbarItem(addToHomeScreen); | 29 toolbar.appendToolbarItem(addToHomeScreen); |
| 24 | 30 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 _updateManifest() { | 80 _updateManifest() { |
| 75 this._resourceTreeModel.fetchAppManifest(this._renderManifest.bind(this)); | 81 this._resourceTreeModel.fetchAppManifest(this._renderManifest.bind(this)); |
| 76 } | 82 } |
| 77 | 83 |
| 78 /** | 84 /** |
| 79 * @param {string} url | 85 * @param {string} url |
| 80 * @param {?string} data | 86 * @param {?string} data |
| 81 * @param {!Array<!Protocol.Page.AppManifestError>} errors | 87 * @param {!Array<!Protocol.Page.AppManifestError>} errors |
| 82 */ | 88 */ |
| 83 _renderManifest(url, data, errors) { | 89 _renderManifest(url, data, errors) { |
| 90 if (!data && !errors.length) { |
| 91 this._emptyView.showWidget(); |
| 92 this._reportView.hideWidget(); |
| 93 return; |
| 94 } |
| 95 this._emptyView.hideWidget(); |
| 96 this._reportView.showWidget(); |
| 97 |
| 84 this._reportView.setURL(Components.Linkifier.linkifyURL(url)); | 98 this._reportView.setURL(Components.Linkifier.linkifyURL(url)); |
| 85 this._errorsSection.clearContent(); | 99 this._errorsSection.clearContent(); |
| 86 this._errorsSection.element.classList.toggle('hidden', !errors.length); | 100 this._errorsSection.element.classList.toggle('hidden', !errors.length); |
| 87 for (var error of errors) { | 101 for (var error of errors) { |
| 88 this._errorsSection.appendRow().appendChild( | 102 this._errorsSection.appendRow().appendChild( |
| 89 UI.createLabel(error.message, error.critical ? 'smallicon-error' : 'sm
allicon-warning')); | 103 UI.createLabel(error.message, error.critical ? 'smallicon-error' : 'sm
allicon-warning')); |
| 90 } | 104 } |
| 91 | 105 |
| 92 if (!data) | 106 if (!data) |
| 93 data = '{}'; | 107 data = '{}'; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 * @param {!Common.Event} event | 154 * @param {!Common.Event} event |
| 141 */ | 155 */ |
| 142 _addToHomescreen(event) { | 156 _addToHomescreen(event) { |
| 143 var target = SDK.targetManager.mainTarget(); | 157 var target = SDK.targetManager.mainTarget(); |
| 144 if (target && target.hasBrowserCapability()) { | 158 if (target && target.hasBrowserCapability()) { |
| 145 target.pageAgent().requestAppBanner(); | 159 target.pageAgent().requestAppBanner(); |
| 146 Common.console.show(); | 160 Common.console.show(); |
| 147 } | 161 } |
| 148 } | 162 } |
| 149 }; | 163 }; |
| OLD | NEW |