| 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.SDKModelObserver<!SDK.ResourceTreeModel>} | 5 * @implements {SDK.SDKModelObserver<!SDK.ResourceTreeModel>} |
| 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); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 */ | 88 */ |
| 89 _renderManifest(url, data, errors) { | 89 _renderManifest(url, data, errors) { |
| 90 if (!data && !errors.length) { | 90 if (!data && !errors.length) { |
| 91 this._emptyView.showWidget(); | 91 this._emptyView.showWidget(); |
| 92 this._reportView.hideWidget(); | 92 this._reportView.hideWidget(); |
| 93 return; | 93 return; |
| 94 } | 94 } |
| 95 this._emptyView.hideWidget(); | 95 this._emptyView.hideWidget(); |
| 96 this._reportView.showWidget(); | 96 this._reportView.showWidget(); |
| 97 | 97 |
| 98 this._reportView.setURL(Components.Linkifier.linkifyURL(url)); | 98 this._reportView.setURL(Components.Linkifier.linkifyURL({url: url})); |
| 99 this._errorsSection.clearContent(); | 99 this._errorsSection.clearContent(); |
| 100 this._errorsSection.element.classList.toggle('hidden', !errors.length); | 100 this._errorsSection.element.classList.toggle('hidden', !errors.length); |
| 101 for (var error of errors) { | 101 for (var error of errors) { |
| 102 this._errorsSection.appendRow().appendChild( | 102 this._errorsSection.appendRow().appendChild( |
| 103 UI.createLabel(error.message, error.critical ? 'smallicon-error' : 'sm
allicon-warning')); | 103 UI.createLabel(error.message, error.critical ? 'smallicon-error' : 'sm
allicon-warning')); |
| 104 } | 104 } |
| 105 | 105 |
| 106 if (!data) | 106 if (!data) |
| 107 return; | 107 return; |
| 108 | 108 |
| 109 if (data.charCodeAt(0) === 0xFEFF) | 109 if (data.charCodeAt(0) === 0xFEFF) |
| 110 data = data.slice(1); // Trim the BOM as per https://tools.ietf.org/html/
rfc7159#section-8.1. | 110 data = data.slice(1); // Trim the BOM as per https://tools.ietf.org/html/
rfc7159#section-8.1. |
| 111 | 111 |
| 112 var parsedManifest = JSON.parse(data); | 112 var parsedManifest = JSON.parse(data); |
| 113 this._nameField.textContent = stringProperty('name'); | 113 this._nameField.textContent = stringProperty('name'); |
| 114 this._shortNameField.textContent = stringProperty('short_name'); | 114 this._shortNameField.textContent = stringProperty('short_name'); |
| 115 this._startURLField.removeChildren(); | 115 this._startURLField.removeChildren(); |
| 116 var startURL = stringProperty('start_url'); | 116 var startURL = stringProperty('start_url'); |
| 117 if (startURL) { | 117 if (startURL) { |
| 118 this._startURLField.appendChild(Components.Linkifier.linkifyURL( | 118 var completeURL = /** @type {string} */ (Common.ParsedURL.completeURL(url,
startURL)); |
| 119 /** @type {string} */ (Common.ParsedURL.completeURL(url, startURL)), s
tartURL)); | 119 this._startURLField.appendChild(Components.Linkifier.linkifyURL({url: comp
leteURL, text: startURL})); |
| 120 } | 120 } |
| 121 | 121 |
| 122 this._themeColorSwatch.classList.toggle('hidden', !stringProperty('theme_col
or')); | 122 this._themeColorSwatch.classList.toggle('hidden', !stringProperty('theme_col
or')); |
| 123 var themeColor = Common.Color.parse(stringProperty('theme_color') || 'white'
) || Common.Color.parse('white'); | 123 var themeColor = Common.Color.parse(stringProperty('theme_color') || 'white'
) || Common.Color.parse('white'); |
| 124 this._themeColorSwatch.setColor(/** @type {!Common.Color} */ (themeColor)); | 124 this._themeColorSwatch.setColor(/** @type {!Common.Color} */ (themeColor)); |
| 125 this._backgroundColorSwatch.classList.toggle('hidden', !stringProperty('back
ground_color')); | 125 this._backgroundColorSwatch.classList.toggle('hidden', !stringProperty('back
ground_color')); |
| 126 var backgroundColor = | 126 var backgroundColor = |
| 127 Common.Color.parse(stringProperty('background_color') || 'white') || Com
mon.Color.parse('white'); | 127 Common.Color.parse(stringProperty('background_color') || 'white') || Com
mon.Color.parse('white'); |
| 128 this._backgroundColorSwatch.setColor(/** @type {!Common.Color} */ (backgroun
dColor)); | 128 this._backgroundColorSwatch.setColor(/** @type {!Common.Color} */ (backgroun
dColor)); |
| 129 | 129 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 157 * @param {!Common.Event} event | 157 * @param {!Common.Event} event |
| 158 */ | 158 */ |
| 159 _addToHomescreen(event) { | 159 _addToHomescreen(event) { |
| 160 var target = SDK.targetManager.mainTarget(); | 160 var target = SDK.targetManager.mainTarget(); |
| 161 if (target && target.hasBrowserCapability()) { | 161 if (target && target.hasBrowserCapability()) { |
| 162 target.pageAgent().requestAppBanner(); | 162 target.pageAgent().requestAppBanner(); |
| 163 Common.console.show(); | 163 Common.console.show(); |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 }; | 166 }; |
| OLD | NEW |