| 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._reportView = new UI.ReportView(Common.UIString('App Manifest')); | 13 this._reportView = new UI.ReportView(Common.UIString('App Manifest')); |
| 14 this._reportView.show(this.contentElement); | 14 this._reportView.show(this.contentElement); |
| 15 | 15 |
| 16 this._errorsSection = this._reportView.appendSection(Common.UIString('Errors
and warnings')); | 16 this._errorsSection = this._reportView.appendSection(Common.UIString('Errors
and warnings')); |
| 17 this._identitySection = this._reportView.appendSection(Common.UIString('Iden
tity')); | 17 this._identitySection = this._reportView.appendSection(Common.UIString('Iden
tity')); |
| 18 var toolbar = this._identitySection.createToolbar(); | 18 var toolbar = this._identitySection.createToolbar(); |
| 19 toolbar.renderAsLinks(); | 19 toolbar.renderAsLinks(); |
| 20 var addToHomeScreen = | 20 var addToHomeScreen = |
| 21 new UI.ToolbarButton(Common.UIString('Add to homescreen'), undefined, Co
mmon.UIString('Add to homescreen')); | 21 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); | 22 addToHomeScreen.addEventListener(UI.ToolbarButton.Events.Click, this._addToH
omescreen, this); |
| 23 toolbar.appendToolbarItem(addToHomeScreen); | 23 toolbar.appendToolbarItem(addToHomeScreen); |
| 24 | 24 |
| 25 this._manifestlessSection = this._reportView.appendSection(Common.UIString('
No manifest detected')); |
| 26 var p = createElement('p'); |
| 27 p.textContent = 'A web manifest allows you to control how your app behaves w
hen launched and displayed to the user. '; |
| 28 p.appendChild(UI.createExternalLink('https://developers.google.com/web/progr
essive-web-apps/?utm_source=devtools', |
| 29 Common.UIString('Read more on developers.google.com'))); |
| 30 this._manifestlessSection.element.appendChild(p); |
| 31 this._manifestlessSection.element.classList.add('hidden'); |
| 32 |
| 25 this._presentationSection = this._reportView.appendSection(Common.UIString('
Presentation')); | 33 this._presentationSection = this._reportView.appendSection(Common.UIString('
Presentation')); |
| 26 this._iconsSection = this._reportView.appendSection(Common.UIString('Icons')
); | 34 this._iconsSection = this._reportView.appendSection(Common.UIString('Icons')
); |
| 27 | 35 |
| 28 this._nameField = this._identitySection.appendField(Common.UIString('Name'))
; | 36 this._nameField = this._identitySection.appendField(Common.UIString('Name'))
; |
| 29 this._shortNameField = this._identitySection.appendField(Common.UIString('Sh
ort name')); | 37 this._shortNameField = this._identitySection.appendField(Common.UIString('Sh
ort name')); |
| 30 | 38 |
| 31 this._startURLField = this._presentationSection.appendField(Common.UIString(
'Start URL')); | 39 this._startURLField = this._presentationSection.appendField(Common.UIString(
'Start URL')); |
| 32 | 40 |
| 33 var themeColorField = this._presentationSection.appendField(Common.UIString(
'Theme color')); | 41 var themeColorField = this._presentationSection.appendField(Common.UIString(
'Theme color')); |
| 34 this._themeColorSwatch = InlineEditor.ColorSwatch.create(); | 42 this._themeColorSwatch = InlineEditor.ColorSwatch.create(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 */ | 90 */ |
| 83 _renderManifest(url, data, errors) { | 91 _renderManifest(url, data, errors) { |
| 84 this._reportView.setURL(Components.Linkifier.linkifyURL(url)); | 92 this._reportView.setURL(Components.Linkifier.linkifyURL(url)); |
| 85 this._errorsSection.clearContent(); | 93 this._errorsSection.clearContent(); |
| 86 this._errorsSection.element.classList.toggle('hidden', !errors.length); | 94 this._errorsSection.element.classList.toggle('hidden', !errors.length); |
| 87 for (var error of errors) { | 95 for (var error of errors) { |
| 88 this._errorsSection.appendRow().appendChild( | 96 this._errorsSection.appendRow().appendChild( |
| 89 UI.createLabel(error.message, error.critical ? 'smallicon-error' : 'sm
allicon-warning')); | 97 UI.createLabel(error.message, error.critical ? 'smallicon-error' : 'sm
allicon-warning')); |
| 90 } | 98 } |
| 91 | 99 |
| 92 if (!data) | 100 var manifestDataFound = !!data; |
| 93 data = '{}'; | 101 this._manifestlessSection.element.classList.toggle('hidden', manifestDataFou
nd); |
| 102 this._presentationSection.element.classList.toggle('hidden', !manifestDataFo
und); |
| 103 this._iconsSection.element.classList.toggle('hidden', !manifestDataFound); |
| 104 this._identitySection.element.classList.toggle('hidden', !manifestDataFound)
; |
| 105 if (!data) return; |
| 94 | 106 |
| 95 var parsedManifest = JSON.parse(data); | 107 var parsedManifest = JSON.parse(data); |
| 96 this._nameField.textContent = stringProperty('name'); | 108 this._nameField.textContent = stringProperty('name'); |
| 97 this._shortNameField.textContent = stringProperty('short_name'); | 109 this._shortNameField.textContent = stringProperty('short_name'); |
| 98 this._startURLField.removeChildren(); | 110 this._startURLField.removeChildren(); |
| 99 var startURL = stringProperty('start_url'); | 111 var startURL = stringProperty('start_url'); |
| 100 if (startURL) { | 112 if (startURL) { |
| 101 this._startURLField.appendChild(Components.Linkifier.linkifyURL( | 113 this._startURLField.appendChild(Components.Linkifier.linkifyURL( |
| 102 /** @type {string} */ (Common.ParsedURL.completeURL(url, startURL)), s
tartURL)); | 114 /** @type {string} */ (Common.ParsedURL.completeURL(url, startURL)), s
tartURL)); |
| 103 } | 115 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 * @param {!Common.Event} event | 152 * @param {!Common.Event} event |
| 141 */ | 153 */ |
| 142 _addToHomescreen(event) { | 154 _addToHomescreen(event) { |
| 143 var target = SDK.targetManager.mainTarget(); | 155 var target = SDK.targetManager.mainTarget(); |
| 144 if (target && target.hasBrowserCapability()) { | 156 if (target && target.hasBrowserCapability()) { |
| 145 target.pageAgent().requestAppBanner(); | 157 target.pageAgent().requestAppBanner(); |
| 146 Common.console.show(); | 158 Common.console.show(); |
| 147 } | 159 } |
| 148 } | 160 } |
| 149 }; | 161 }; |
| OLD | NEW |