| 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'))
; | 13 this._emptyView = new UI.EmptyWidget(Common.UIString('No manifest detected')
); |
| 14 var p = this._emptyView.appendParagraph(); |
| 15 var linkElement = UI.createExternalLink('https://developers.google.com/web/f
undamentals/engage-and-retain/web-app-manifest/?utm_source=devtools', |
| 16 Common.UIString('Read more about the web manifest')); |
| 17 p.appendChild(UI.formatLocalized('A web manifest allows you to control how y
our app behaves when launched and displayed to the user. %s', [linkElement])); |
| 14 | 18 |
| 15 this._emptyView.show(this.contentElement); | 19 this._emptyView.show(this.contentElement); |
| 16 this._emptyView.hideWidget(); | 20 this._emptyView.hideWidget(); |
| 17 | 21 |
| 18 this._reportView = new UI.ReportView(Common.UIString('App Manifest')); | 22 this._reportView = new UI.ReportView(Common.UIString('App Manifest')); |
| 19 this._reportView.show(this.contentElement); | 23 this._reportView.show(this.contentElement); |
| 20 this._reportView.hideWidget(); | 24 this._reportView.hideWidget(); |
| 21 | 25 |
| 22 this._errorsSection = this._reportView.appendSection(Common.UIString('Errors
and warnings')); | 26 this._errorsSection = this._reportView.appendSection(Common.UIString('Errors
and warnings')); |
| 23 this._identitySection = this._reportView.appendSection(Common.UIString('Iden
tity')); | 27 this._identitySection = this._reportView.appendSection(Common.UIString('Iden
tity')); |
| 24 var toolbar = this._identitySection.createToolbar(); | 28 var toolbar = this._identitySection.createToolbar(); |
| 25 toolbar.renderAsLinks(); | 29 toolbar.renderAsLinks(); |
| 26 var addToHomeScreen = | 30 var addToHomeScreen = |
| 27 new UI.ToolbarButton(Common.UIString('Add to homescreen'), undefined, Co
mmon.UIString('Add to homescreen')); | 31 new UI.ToolbarButton(Common.UIString('Add to homescreen'), undefined, Co
mmon.UIString('Add to homescreen')); |
| 28 addToHomeScreen.addEventListener(UI.ToolbarButton.Events.Click, this._addToH
omescreen, this); | 32 addToHomeScreen.addEventListener(UI.ToolbarButton.Events.Click, this._addToH
omescreen, this); |
| 29 toolbar.appendToolbarItem(addToHomeScreen); | 33 toolbar.appendToolbarItem(addToHomeScreen); |
| 30 | 34 |
| 31 this._manifestlessSection = this._reportView.appendSection(Common.UIString('
No manifest detected')); | |
| 32 var p = createElement('p'); | |
| 33 p.textContent = 'A web manifest allows you to control how your app behaves w
hen launched and displayed to the user. '; | |
| 34 p.appendChild(UI.createExternalLink('https://developers.google.com/web/progr
essive-web-apps/?utm_source=devtools', | |
| 35 Common.UIString('Read more on developers.google.com'))); | |
| 36 this._manifestlessSection.element.appendChild(p); | |
| 37 this._manifestlessSection.element.classList.add('hidden'); | |
| 38 | |
| 39 this._presentationSection = this._reportView.appendSection(Common.UIString('
Presentation')); | 35 this._presentationSection = this._reportView.appendSection(Common.UIString('
Presentation')); |
| 40 this._iconsSection = this._reportView.appendSection(Common.UIString('Icons')
); | 36 this._iconsSection = this._reportView.appendSection(Common.UIString('Icons')
); |
| 41 | 37 |
| 42 this._nameField = this._identitySection.appendField(Common.UIString('Name'))
; | 38 this._nameField = this._identitySection.appendField(Common.UIString('Name'))
; |
| 43 this._shortNameField = this._identitySection.appendField(Common.UIString('Sh
ort name')); | 39 this._shortNameField = this._identitySection.appendField(Common.UIString('Sh
ort name')); |
| 44 | 40 |
| 45 this._startURLField = this._presentationSection.appendField(Common.UIString(
'Start URL')); | 41 this._startURLField = this._presentationSection.appendField(Common.UIString(
'Start URL')); |
| 46 | 42 |
| 47 var themeColorField = this._presentationSection.appendField(Common.UIString(
'Theme color')); | 43 var themeColorField = this._presentationSection.appendField(Common.UIString(
'Theme color')); |
| 48 this._themeColorSwatch = InlineEditor.ColorSwatch.create(); | 44 this._themeColorSwatch = InlineEditor.ColorSwatch.create(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 this._reportView.showWidget(); | 100 this._reportView.showWidget(); |
| 105 | 101 |
| 106 this._reportView.setURL(Components.Linkifier.linkifyURL(url)); | 102 this._reportView.setURL(Components.Linkifier.linkifyURL(url)); |
| 107 this._errorsSection.clearContent(); | 103 this._errorsSection.clearContent(); |
| 108 this._errorsSection.element.classList.toggle('hidden', !errors.length); | 104 this._errorsSection.element.classList.toggle('hidden', !errors.length); |
| 109 for (var error of errors) { | 105 for (var error of errors) { |
| 110 this._errorsSection.appendRow().appendChild( | 106 this._errorsSection.appendRow().appendChild( |
| 111 UI.createLabel(error.message, error.critical ? 'smallicon-error' : 'sm
allicon-warning')); | 107 UI.createLabel(error.message, error.critical ? 'smallicon-error' : 'sm
allicon-warning')); |
| 112 } | 108 } |
| 113 | 109 |
| 114 var manifestDataFound = !!data; | 110 if (!data) |
| 115 this._manifestlessSection.element.classList.toggle('hidden', manifestDataFou
nd); | 111 return; |
| 116 this._presentationSection.element.classList.toggle('hidden', !manifestDataFo
und); | |
| 117 this._iconsSection.element.classList.toggle('hidden', !manifestDataFound); | |
| 118 this._identitySection.element.classList.toggle('hidden', !manifestDataFound)
; | |
| 119 if (!data) return; | |
| 120 | 112 |
| 121 var parsedManifest = JSON.parse(data); | 113 var parsedManifest = JSON.parse(data); |
| 122 this._nameField.textContent = stringProperty('name'); | 114 this._nameField.textContent = stringProperty('name'); |
| 123 this._shortNameField.textContent = stringProperty('short_name'); | 115 this._shortNameField.textContent = stringProperty('short_name'); |
| 124 this._startURLField.removeChildren(); | 116 this._startURLField.removeChildren(); |
| 125 var startURL = stringProperty('start_url'); | 117 var startURL = stringProperty('start_url'); |
| 126 if (startURL) { | 118 if (startURL) { |
| 127 this._startURLField.appendChild(Components.Linkifier.linkifyURL( | 119 this._startURLField.appendChild(Components.Linkifier.linkifyURL( |
| 128 /** @type {string} */ (Common.ParsedURL.completeURL(url, startURL)), s
tartURL)); | 120 /** @type {string} */ (Common.ParsedURL.completeURL(url, startURL)), s
tartURL)); |
| 129 } | 121 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 * @param {!Common.Event} event | 158 * @param {!Common.Event} event |
| 167 */ | 159 */ |
| 168 _addToHomescreen(event) { | 160 _addToHomescreen(event) { |
| 169 var target = SDK.targetManager.mainTarget(); | 161 var target = SDK.targetManager.mainTarget(); |
| 170 if (target && target.hasBrowserCapability()) { | 162 if (target && target.hasBrowserCapability()) { |
| 171 target.pageAgent().requestAppBanner(); | 163 target.pageAgent().requestAppBanner(); |
| 172 Common.console.show(); | 164 Common.console.show(); |
| 173 } | 165 } |
| 174 } | 166 } |
| 175 }; | 167 }; |
| OLD | NEW |