Chromium Code Reviews| 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 /** | 5 /** |
| 6 * @unrestricted | 6 * @unrestricted |
| 7 */ | 7 */ |
| 8 Audits2.Audits2Panel = class extends UI.PanelWithSidebar { | 8 Audits2.Audits2Panel = class extends UI.PanelWithSidebar { |
| 9 constructor() { | 9 constructor() { |
| 10 super('audits2'); | 10 super('audits2'); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 * @return {!Element} | 135 * @return {!Element} |
| 136 */ | 136 */ |
| 137 _createStatusView(launcherUIElement) { | 137 _createStatusView(launcherUIElement) { |
| 138 var statusView = launcherUIElement.createChild('div', 'audits2-status vbox h idden'); | 138 var statusView = launcherUIElement.createChild('div', 'audits2-status vbox h idden'); |
| 139 this._statusIcon = statusView.createChild('div', 'icon'); | 139 this._statusIcon = statusView.createChild('div', 'icon'); |
| 140 this._statusElement = statusView.createChild('div'); | 140 this._statusElement = statusView.createChild('div'); |
| 141 this._updateStatus(Common.UIString('Loading...')); | 141 this._updateStatus(Common.UIString('Loading...')); |
| 142 return statusView; | 142 return statusView; |
| 143 } | 143 } |
| 144 | 144 |
| 145 /** | |
| 146 * @return {!Promise<undefined>} | |
| 147 */ | |
| 148 _updateInspectedURL() { | |
| 149 var mainTarget = SDK.targetManager.mainTarget(); | |
| 150 var runtimeModel = mainTarget.model(SDK.RuntimeModel); | |
| 151 var executionContext = runtimeModel && runtimeModel.defaultExecutionContext( ); | |
| 152 this._inspectedURL = mainTarget.inspectedURL(); | |
| 153 if (!executionContext) | |
| 154 return Promise.resolve(); | |
| 155 | |
| 156 return new Promise(resolve => { | |
| 157 executionContext.evaluate('window.location.href', 'audits', false, false, true, false, false, (object, err) => { | |
| 158 if (!err && object) | |
| 159 this._inspectedURL = object.value; | |
|
dgozman
2017/05/22 20:48:14
object.release();
| |
| 160 resolve(); | |
| 161 }); | |
| 162 }); | |
| 163 } | |
| 164 | |
| 145 _start() { | 165 _start() { |
| 146 var emulationModel = self.singleton(Emulation.DeviceModeModel); | 166 var emulationModel = self.singleton(Emulation.DeviceModeModel); |
| 147 this._emulationEnabledBefore = emulationModel.enabledSetting().get(); | 167 this._emulationEnabledBefore = emulationModel.enabledSetting().get(); |
| 148 this._emulationOutlineEnabledBefore = emulationModel.deviceOutlineSetting(). get(); | 168 this._emulationOutlineEnabledBefore = emulationModel.deviceOutlineSetting(). get(); |
| 149 emulationModel.enabledSetting().set(true); | 169 emulationModel.enabledSetting().set(true); |
| 150 emulationModel.deviceOutlineSetting().set(true); | 170 emulationModel.deviceOutlineSetting().set(true); |
| 151 emulationModel.toolbarControlsEnabledSetting().set(false); | 171 emulationModel.toolbarControlsEnabledSetting().set(false); |
| 152 | 172 |
| 153 for (var device of Emulation.EmulatedDevicesList.instance().standard()) { | 173 for (var device of Emulation.EmulatedDevicesList.instance().standard()) { |
| 154 if (device.title === 'Nexus 5X') | 174 if (device.title === 'Nexus 5X') |
| 155 emulationModel.emulate(Emulation.DeviceModeModel.Type.Device, device, de vice.modes[0], 1); | 175 emulationModel.emulate(Emulation.DeviceModeModel.Type.Device, device, de vice.modes[0], 1); |
| 156 } | 176 } |
| 157 this._dialog.setCloseOnEscape(false); | 177 this._dialog.setCloseOnEscape(false); |
| 158 this._inspectedURL = SDK.targetManager.mainTarget().inspectedURL(); | |
| 159 | 178 |
| 160 var categoryIDs = []; | 179 var categoryIDs = []; |
| 161 for (var preset of Audits2.Audits2Panel.Presets) { | 180 for (var preset of Audits2.Audits2Panel.Presets) { |
| 162 if (preset.setting.get()) | 181 if (preset.setting.get()) |
| 163 categoryIDs.push(preset.configID); | 182 categoryIDs.push(preset.configID); |
| 164 } | 183 } |
| 165 | 184 |
| 166 return Promise.resolve() | 185 return Promise.resolve() |
| 186 .then(_ => this._updateInspectedURL()) | |
| 167 .then(_ => this._protocolService.attach()) | 187 .then(_ => this._protocolService.attach()) |
| 168 .then(_ => { | 188 .then(_ => { |
| 169 this._auditRunning = true; | 189 this._auditRunning = true; |
| 170 this._updateButton(); | 190 this._updateButton(); |
| 171 this._updateStatus(Common.UIString('Loading\u2026')); | 191 this._updateStatus(Common.UIString('Loading\u2026')); |
| 172 }) | 192 }) |
| 173 .then(_ => this._protocolService.startLighthouse(this._inspectedURL, cat egoryIDs)) | 193 .then(_ => this._protocolService.startLighthouse(this._inspectedURL, cat egoryIDs)) |
| 174 .then(lighthouseResult => { | 194 .then(lighthouseResult => { |
| 175 if (lighthouseResult && lighthouseResult.fatal) { | 195 if (lighthouseResult && lighthouseResult.fatal) { |
| 176 const error = new Error(lighthouseResult.message); | 196 const error = new Error(lighthouseResult.message); |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 657 return; | 677 return; |
| 658 | 678 |
| 659 var element = Components.DOMPresentationUtils.linkifyNodeReference(node, undefined, detailsItem.snippet); | 679 var element = Components.DOMPresentationUtils.linkifyNodeReference(node, undefined, detailsItem.snippet); |
| 660 origElement.title = ''; | 680 origElement.title = ''; |
| 661 origElement.textContent = ''; | 681 origElement.textContent = ''; |
| 662 origElement.appendChild(element); | 682 origElement.appendChild(element); |
| 663 }); | 683 }); |
| 664 }); | 684 }); |
| 665 } | 685 } |
| 666 }; | 686 }; |
| OLD | NEW |