OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 Emulation.DeviceModeModel = class { | 8 Emulation.DeviceModeModel = class { |
9 /** | 9 /** |
10 * @param {function()} updateCallback | 10 * @param {function()} updateCallback |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 this._scaleSetting.get(), this._deviceScaleFactorSetting.get() || defa
ultDeviceScaleFactor, mobile, | 465 this._scaleSetting.get(), this._deviceScaleFactorSetting.get() || defa
ultDeviceScaleFactor, mobile, |
466 screenHeight >= screenWidth ? Protocol.Emulation.ScreenOrientationType
.PortraitPrimary : | 466 screenHeight >= screenWidth ? Protocol.Emulation.ScreenOrientationType
.PortraitPrimary : |
467 Protocol.Emulation.ScreenOrientationType
.LandscapePrimary, | 467 Protocol.Emulation.ScreenOrientationType
.LandscapePrimary, |
468 resetPageScaleFactor); | 468 resetPageScaleFactor); |
469 this._applyUserAgent(mobile ? Emulation.DeviceModeModel._defaultMobileUser
Agent : ''); | 469 this._applyUserAgent(mobile ? Emulation.DeviceModeModel._defaultMobileUser
Agent : ''); |
470 this._applyTouch( | 470 this._applyTouch( |
471 this._uaSetting.get() === Emulation.DeviceModeModel.UA.DesktopTouch || | 471 this._uaSetting.get() === Emulation.DeviceModeModel.UA.DesktopTouch || |
472 this._uaSetting.get() === Emulation.DeviceModeModel.UA.Mobile, | 472 this._uaSetting.get() === Emulation.DeviceModeModel.UA.Mobile, |
473 this._uaSetting.get() === Emulation.DeviceModeModel.UA.Mobile); | 473 this._uaSetting.get() === Emulation.DeviceModeModel.UA.Mobile); |
474 } | 474 } |
475 if (this._target) | 475 var overlayModel = this._target ? this._target.model(SDK.OverlayModel) : nul
l; |
476 this._target.renderingAgent().setShowViewportSizeOnResize(this._type === E
mulation.DeviceModeModel.Type.None); | 476 if (overlayModel) |
| 477 overlayModel.setShowViewportSizeOnResize(this._type === Emulation.DeviceMo
deModel.Type.None); |
477 this._updateCallback.call(null); | 478 this._updateCallback.call(null); |
478 } | 479 } |
479 | 480 |
480 /** | 481 /** |
481 * @param {number} screenWidth | 482 * @param {number} screenWidth |
482 * @param {number} screenHeight | 483 * @param {number} screenHeight |
483 * @param {!UI.Insets=} outline | 484 * @param {!UI.Insets=} outline |
484 * @param {!UI.Insets=} insets | 485 * @param {!UI.Insets=} insets |
485 * @return {number} | 486 * @return {number} |
486 */ | 487 */ |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 var screenCaptureModel = this._target ? this._target.model(SDK.ScreenCapture
Model) : null; | 630 var screenCaptureModel = this._target ? this._target.model(SDK.ScreenCapture
Model) : null; |
630 if (!screenCaptureModel) | 631 if (!screenCaptureModel) |
631 return null; | 632 return null; |
632 | 633 |
633 var metrics = await screenCaptureModel.fetchLayoutMetrics(); | 634 var metrics = await screenCaptureModel.fetchLayoutMetrics(); |
634 if (!metrics) | 635 if (!metrics) |
635 return null; | 636 return null; |
636 | 637 |
637 if (!this._emulatedPageSize) | 638 if (!this._emulatedPageSize) |
638 this._calculateAndEmulate(false); | 639 this._calculateAndEmulate(false); |
639 this._target.renderingAgent().setShowViewportSizeOnResize(false); | 640 var overlayModel = this._target ? this._target.model(SDK.OverlayModel) : nul
l; |
| 641 if (overlayModel) |
| 642 overlayModel.setShowViewportSizeOnResize(false); |
640 | 643 |
641 var pageSize = fullSize ? new UI.Size(metrics.contentWidth, metrics.contentH
eight) : this._emulatedPageSize; | 644 var pageSize = fullSize ? new UI.Size(metrics.contentWidth, metrics.contentH
eight) : this._emulatedPageSize; |
642 var promises = []; | 645 var promises = []; |
643 promises.push( | 646 promises.push( |
644 this._target.emulationAgent().setVisibleSize(Math.floor(pageSize.width),
Math.floor(pageSize.height))); | 647 this._target.emulationAgent().setVisibleSize(Math.floor(pageSize.width),
Math.floor(pageSize.height))); |
645 if (fullSize) { | 648 if (fullSize) { |
646 promises.push(this._target.emulationAgent().forceViewport(0, 0, 1)); | 649 promises.push(this._target.emulationAgent().forceViewport(0, 0, 1)); |
647 } else { | 650 } else { |
648 promises.push(this._target.emulationAgent().forceViewport( | 651 promises.push(this._target.emulationAgent().forceViewport( |
649 Math.floor(metrics.viewportX), Math.floor(metrics.viewportY), metrics.
viewportScale)); | 652 Math.floor(metrics.viewportX), Math.floor(metrics.viewportY), metrics.
viewportScale)); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 | 696 |
694 Emulation.DeviceModeModel.MinDeviceSize = 50; | 697 Emulation.DeviceModeModel.MinDeviceSize = 50; |
695 Emulation.DeviceModeModel.MaxDeviceSize = 9999; | 698 Emulation.DeviceModeModel.MaxDeviceSize = 9999; |
696 | 699 |
697 | 700 |
698 Emulation.DeviceModeModel._defaultMobileUserAgent = | 701 Emulation.DeviceModeModel._defaultMobileUserAgent = |
699 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (
KHTML, like Gecko) Chrome/%s Mobile Safari/537.36'; | 702 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (
KHTML, like Gecko) Chrome/%s Mobile Safari/537.36'; |
700 Emulation.DeviceModeModel._defaultMobileUserAgent = | 703 Emulation.DeviceModeModel._defaultMobileUserAgent = |
701 SDK.MultitargetNetworkManager.patchUserAgentWithChromeVersion(Emulation.Devi
ceModeModel._defaultMobileUserAgent); | 704 SDK.MultitargetNetworkManager.patchUserAgentWithChromeVersion(Emulation.Devi
ceModeModel._defaultMobileUserAgent); |
702 Emulation.DeviceModeModel.defaultMobileScaleFactor = 2; | 705 Emulation.DeviceModeModel.defaultMobileScaleFactor = 2; |
OLD | NEW |