| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 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 * @unrestricted | 5 * @unrestricted |
| 6 */ | 6 */ |
| 7 Emulation.DeviceModeWrapper = class extends UI.VBox { | 7 Emulation.DeviceModeWrapper = class extends UI.VBox { |
| 8 /** | 8 /** |
| 9 * @param {!Emulation.InspectedPagePlaceholder} inspectedPagePlaceholder | 9 * @param {!Emulation.InspectedPagePlaceholder} inspectedPagePlaceholder |
| 10 */ | 10 */ |
| 11 constructor(inspectedPagePlaceholder) { | 11 constructor(inspectedPagePlaceholder) { |
| 12 super(); | 12 super(); |
| 13 Emulation.DeviceModeView._wrapperInstance = this; | 13 Emulation.DeviceModeView._wrapperInstance = this; |
| 14 this._inspectedPagePlaceholder = inspectedPagePlaceholder; | 14 this._inspectedPagePlaceholder = inspectedPagePlaceholder; |
| 15 /** @type {?Emulation.DeviceModeView} */ | 15 /** @type {?Emulation.DeviceModeView} */ |
| 16 this._deviceModeView = null; | 16 this._deviceModeView = null; |
| 17 this._toggleDeviceModeAction = UI.actionRegistry.action('emulation.toggle-de
vice-mode'); | 17 this._toggleDeviceModeAction = UI.actionRegistry.action('emulation.toggle-de
vice-mode'); |
| 18 this._showDeviceModeSetting = Common.settings.createSetting('emulation.showD
eviceMode', false); | 18 this._showDeviceModeSetting = Common.settings.createSetting('emulation.showD
eviceMode', false); |
| 19 this._showDeviceModeSetting.addChangeListener(this._update.bind(this, false)
); | 19 this._showDeviceModeSetting.addChangeListener(this._update.bind(this, false)
); |
| 20 this._update(true); | 20 this._update(true); |
| 21 } | 21 } |
| 22 | 22 |
| 23 _toggleDeviceMode() { | 23 _toggleDeviceMode() { |
| 24 this._showDeviceModeSetting.set(!this._showDeviceModeSetting.get()); | 24 this._showDeviceModeSetting.set(!this._showDeviceModeSetting.get()); |
| 25 } | 25 } |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * @param {boolean=} fullSize |
| 28 * @return {boolean} | 29 * @return {boolean} |
| 29 */ | 30 */ |
| 30 _captureScreenshot() { | 31 _captureScreenshot(fullSize) { |
| 31 if (!this._deviceModeView) | 32 if (!this._deviceModeView) |
| 32 return false; | 33 this._deviceModeView = new Emulation.DeviceModeView(); |
| 33 this._deviceModeView.captureScreenshot(); | 34 this._deviceModeView.setNonEmulatedAvailableSize(this._inspectedPagePlacehol
der.element); |
| 35 if (fullSize) |
| 36 this._deviceModeView.captureFullSizeScreenshot(); |
| 37 else |
| 38 this._deviceModeView.captureScreenshot(); |
| 34 return true; | 39 return true; |
| 35 } | 40 } |
| 36 | 41 |
| 37 /** | |
| 38 * @return {boolean} | |
| 39 */ | |
| 40 _captureFullSizeScreenshot() { | |
| 41 if (!this._deviceModeView) | |
| 42 return false; | |
| 43 this._deviceModeView.captureFullSizeScreenshot(); | |
| 44 return true; | |
| 45 } | |
| 46 | |
| 47 /** | 42 /** |
| 48 * @param {boolean} force | 43 * @param {boolean} force |
| 49 */ | 44 */ |
| 50 _update(force) { | 45 _update(force) { |
| 51 this._toggleDeviceModeAction.setToggled(this._showDeviceModeSetting.get()); | 46 this._toggleDeviceModeAction.setToggled(this._showDeviceModeSetting.get()); |
| 52 if (!force) { | 47 if (!force) { |
| 53 var showing = this._deviceModeView && this._deviceModeView.isShowing(); | 48 var showing = this._deviceModeView && this._deviceModeView.isShowing(); |
| 54 if (this._showDeviceModeSetting.get() === showing) | 49 if (this._showDeviceModeSetting.get() === showing) |
| 55 return; | 50 return; |
| 56 } | 51 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 84 * @param {string} actionId | 79 * @param {string} actionId |
| 85 * @return {boolean} | 80 * @return {boolean} |
| 86 */ | 81 */ |
| 87 handleAction(context, actionId) { | 82 handleAction(context, actionId) { |
| 88 if (Emulation.DeviceModeView._wrapperInstance) { | 83 if (Emulation.DeviceModeView._wrapperInstance) { |
| 89 switch (actionId) { | 84 switch (actionId) { |
| 90 case 'emulation.capture-screenshot': | 85 case 'emulation.capture-screenshot': |
| 91 return Emulation.DeviceModeView._wrapperInstance._captureScreenshot(); | 86 return Emulation.DeviceModeView._wrapperInstance._captureScreenshot(); |
| 92 | 87 |
| 93 case 'emulation.capture-full-height-screenshot': | 88 case 'emulation.capture-full-height-screenshot': |
| 94 return Emulation.DeviceModeView._wrapperInstance._captureFullSizeScree
nshot(); | 89 return Emulation.DeviceModeView._wrapperInstance._captureScreenshot(tr
ue); |
| 95 | 90 |
| 96 case 'emulation.toggle-device-mode': | 91 case 'emulation.toggle-device-mode': |
| 97 Emulation.DeviceModeView._wrapperInstance._toggleDeviceMode(); | 92 Emulation.DeviceModeView._wrapperInstance._toggleDeviceMode(); |
| 98 return true; | 93 return true; |
| 99 } | 94 } |
| 100 } | 95 } |
| 101 return false; | 96 return false; |
| 102 } | 97 } |
| 103 }; | 98 }; |
| OLD | NEW |