| 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); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 _updateManifest() { | 74 _updateManifest() { |
| 75 this._resourceTreeModel.fetchAppManifest(this._renderManifest.bind(this)); | 75 this._resourceTreeModel.fetchAppManifest(this._renderManifest.bind(this)); |
| 76 } | 76 } |
| 77 | 77 |
| 78 /** | 78 /** |
| 79 * @param {string} url | 79 * @param {string} url |
| 80 * @param {?string} data | 80 * @param {?string} data |
| 81 * @param {!Array<!Protocol.Page.AppManifestError>} errors | 81 * @param {!Array<!Protocol.Page.AppManifestError>} errors |
| 82 */ | 82 */ |
| 83 _renderManifest(url, data, errors) { | 83 _renderManifest(url, data, errors) { |
| 84 this._reportView.setURL(Components.Linkifier.linkifyURLAsNode(url)); | 84 this._reportView.setURL(Components.Linkifier.linkifyURL(url)); |
| 85 this._errorsSection.clearContent(); | 85 this._errorsSection.clearContent(); |
| 86 this._errorsSection.element.classList.toggle('hidden', !errors.length); | 86 this._errorsSection.element.classList.toggle('hidden', !errors.length); |
| 87 for (var error of errors) { | 87 for (var error of errors) { |
| 88 this._errorsSection.appendRow().appendChild( | 88 this._errorsSection.appendRow().appendChild( |
| 89 createLabel(error.message, error.critical ? 'smallicon-error' : 'small
icon-warning')); | 89 createLabel(error.message, error.critical ? 'smallicon-error' : 'small
icon-warning')); |
| 90 } | 90 } |
| 91 | 91 |
| 92 if (!data) | 92 if (!data) |
| 93 data = '{}'; | 93 data = '{}'; |
| 94 | 94 |
| 95 var parsedManifest = JSON.parse(data); | 95 var parsedManifest = JSON.parse(data); |
| 96 this._nameField.textContent = stringProperty('name'); | 96 this._nameField.textContent = stringProperty('name'); |
| 97 this._shortNameField.textContent = stringProperty('short_name'); | 97 this._shortNameField.textContent = stringProperty('short_name'); |
| 98 this._startURLField.removeChildren(); | 98 this._startURLField.removeChildren(); |
| 99 var startURL = stringProperty('start_url'); | 99 var startURL = stringProperty('start_url'); |
| 100 if (startURL) { | 100 if (startURL) { |
| 101 this._startURLField.appendChild(Components.linkifyResourceAsNode( | 101 this._startURLField.appendChild(Components.Linkifier.linkifyURL( |
| 102 /** @type {string} */ (Common.ParsedURL.completeURL(url, startURL)), u
ndefined, undefined, undefined, | 102 /** @type {string} */ (Common.ParsedURL.completeURL(url, startURL)), s
tartURL)); |
| 103 undefined, startURL)); | |
| 104 } | 103 } |
| 105 | 104 |
| 106 this._themeColorSwatch.classList.toggle('hidden', !stringProperty('theme_col
or')); | 105 this._themeColorSwatch.classList.toggle('hidden', !stringProperty('theme_col
or')); |
| 107 var themeColor = Common.Color.parse(stringProperty('theme_color') || 'white'
) || Common.Color.parse('white'); | 106 var themeColor = Common.Color.parse(stringProperty('theme_color') || 'white'
) || Common.Color.parse('white'); |
| 108 this._themeColorSwatch.setColor(/** @type {!Common.Color} */ (themeColor)); | 107 this._themeColorSwatch.setColor(/** @type {!Common.Color} */ (themeColor)); |
| 109 this._backgroundColorSwatch.classList.toggle('hidden', !stringProperty('back
ground_color')); | 108 this._backgroundColorSwatch.classList.toggle('hidden', !stringProperty('back
ground_color')); |
| 110 var backgroundColor = | 109 var backgroundColor = |
| 111 Common.Color.parse(stringProperty('background_color') || 'white') || Com
mon.Color.parse('white'); | 110 Common.Color.parse(stringProperty('background_color') || 'white') || Com
mon.Color.parse('white'); |
| 112 this._backgroundColorSwatch.setColor(/** @type {!Common.Color} */ (backgroun
dColor)); | 111 this._backgroundColorSwatch.setColor(/** @type {!Common.Color} */ (backgroun
dColor)); |
| 113 | 112 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 138 } | 137 } |
| 139 | 138 |
| 140 _addToHomescreen() { | 139 _addToHomescreen() { |
| 141 var target = SDK.targetManager.mainTarget(); | 140 var target = SDK.targetManager.mainTarget(); |
| 142 if (target && target.hasBrowserCapability()) { | 141 if (target && target.hasBrowserCapability()) { |
| 143 target.pageAgent().requestAppBanner(); | 142 target.pageAgent().requestAppBanner(); |
| 144 Common.console.show(); | 143 Common.console.show(); |
| 145 } | 144 } |
| 146 } | 145 } |
| 147 }; | 146 }; |
| OLD | NEW |