| 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 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @param {function()} updateCallback | 7 * @param {function()} updateCallback |
| 8 * @implements {WebInspector.TargetManager.Observer} | 8 * @implements {WebInspector.TargetManager.Observer} |
| 9 */ | 9 */ |
| 10 WebInspector.DeviceModeModel = function(updateCallback) | 10 WebInspector.DeviceModeModel = function(updateCallback) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 /** @type {?WebInspector.EmulatedDevice.Mode} */ | 55 /** @type {?WebInspector.EmulatedDevice.Mode} */ |
| 56 this._mode = null; | 56 this._mode = null; |
| 57 /** @type {number} */ | 57 /** @type {number} */ |
| 58 this._fitScale = 1; | 58 this._fitScale = 1; |
| 59 | 59 |
| 60 /** @type {?WebInspector.Target} */ | 60 /** @type {?WebInspector.Target} */ |
| 61 this._target = null; | 61 this._target = null; |
| 62 /** @type {?function()} */ | 62 /** @type {?function()} */ |
| 63 this._onTargetAvailable = null; | 63 this._onTargetAvailable = null; |
| 64 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Capabili
ty.Browser); | 64 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Capabili
ty.Browser); |
| 65 } | 65 }; |
| 66 | 66 |
| 67 /** @enum {string} */ | 67 /** @enum {string} */ |
| 68 WebInspector.DeviceModeModel.Type = { | 68 WebInspector.DeviceModeModel.Type = { |
| 69 None: "None", | 69 None: "None", |
| 70 Responsive: "Responsive", | 70 Responsive: "Responsive", |
| 71 Device: "Device" | 71 Device: "Device" |
| 72 } | 72 }; |
| 73 | 73 |
| 74 /** @enum {string} */ | 74 /** @enum {string} */ |
| 75 WebInspector.DeviceModeModel.UA = { | 75 WebInspector.DeviceModeModel.UA = { |
| 76 Mobile: WebInspector.UIString("Mobile"), | 76 Mobile: WebInspector.UIString("Mobile"), |
| 77 MobileNoTouch: WebInspector.UIString("Mobile (no touch)"), | 77 MobileNoTouch: WebInspector.UIString("Mobile (no touch)"), |
| 78 Desktop: WebInspector.UIString("Desktop"), | 78 Desktop: WebInspector.UIString("Desktop"), |
| 79 DesktopTouch: WebInspector.UIString("Desktop (touch)") | 79 DesktopTouch: WebInspector.UIString("Desktop (touch)") |
| 80 } | 80 }; |
| 81 | 81 |
| 82 WebInspector.DeviceModeModel.MinDeviceSize = 50; | 82 WebInspector.DeviceModeModel.MinDeviceSize = 50; |
| 83 WebInspector.DeviceModeModel.MaxDeviceSize = 9999; | 83 WebInspector.DeviceModeModel.MaxDeviceSize = 9999; |
| 84 | 84 |
| 85 /** | 85 /** |
| 86 * @param {string} value | 86 * @param {string} value |
| 87 * @return {boolean} | 87 * @return {boolean} |
| 88 */ | 88 */ |
| 89 WebInspector.DeviceModeModel.deviceSizeValidator = function(value) | 89 WebInspector.DeviceModeModel.deviceSizeValidator = function(value) |
| 90 { | 90 { |
| 91 if (/^[\d]+$/.test(value) && value >= WebInspector.DeviceModeModel.MinDevice
Size && value <= WebInspector.DeviceModeModel.MaxDeviceSize) | 91 if (/^[\d]+$/.test(value) && value >= WebInspector.DeviceModeModel.MinDevice
Size && value <= WebInspector.DeviceModeModel.MaxDeviceSize) |
| 92 return true; | 92 return true; |
| 93 return false; | 93 return false; |
| 94 } | 94 }; |
| 95 | 95 |
| 96 /** | 96 /** |
| 97 * @param {string} value | 97 * @param {string} value |
| 98 * @return {boolean} | 98 * @return {boolean} |
| 99 */ | 99 */ |
| 100 WebInspector.DeviceModeModel.deviceScaleFactorValidator = function(value) | 100 WebInspector.DeviceModeModel.deviceScaleFactorValidator = function(value) |
| 101 { | 101 { |
| 102 if (!value || (/^[\d]+(\.\d+)?|\.\d+$/.test(value) && value >= 0 && value <=
10)) | 102 if (!value || (/^[\d]+(\.\d+)?|\.\d+$/.test(value) && value >= 0 && value <=
10)) |
| 103 return true; | 103 return true; |
| 104 return false; | 104 return false; |
| 105 } | 105 }; |
| 106 | 106 |
| 107 WebInspector.DeviceModeModel._defaultMobileUserAgent = "Mozilla/5.0 (Linux; Andr
oid 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s
Mobile Safari/537.36"; | 107 WebInspector.DeviceModeModel._defaultMobileUserAgent = "Mozilla/5.0 (Linux; Andr
oid 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s
Mobile Safari/537.36"; |
| 108 WebInspector.DeviceModeModel._defaultMobileUserAgent = WebInspector.MultitargetN
etworkManager.patchUserAgentWithChromeVersion(WebInspector.DeviceModeModel._defa
ultMobileUserAgent); | 108 WebInspector.DeviceModeModel._defaultMobileUserAgent = WebInspector.MultitargetN
etworkManager.patchUserAgentWithChromeVersion(WebInspector.DeviceModeModel._defa
ultMobileUserAgent); |
| 109 WebInspector.DeviceModeModel.defaultMobileScaleFactor = 2; | 109 WebInspector.DeviceModeModel.defaultMobileScaleFactor = 2; |
| 110 | 110 |
| 111 WebInspector.DeviceModeModel.prototype = { | 111 WebInspector.DeviceModeModel.prototype = { |
| 112 /** | 112 /** |
| 113 * @param {!Size} availableSize | 113 * @param {!Size} availableSize |
| 114 * @param {!Size} preferredSize | 114 * @param {!Size} preferredSize |
| 115 */ | 115 */ |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 }, | 629 }, |
| 630 | 630 |
| 631 /** | 631 /** |
| 632 * @param {boolean} touchEnabled | 632 * @param {boolean} touchEnabled |
| 633 * @param {boolean} mobile | 633 * @param {boolean} mobile |
| 634 */ | 634 */ |
| 635 _applyTouch: function(touchEnabled, mobile) | 635 _applyTouch: function(touchEnabled, mobile) |
| 636 { | 636 { |
| 637 WebInspector.MultitargetTouchModel.instance().setTouchEnabled(touchEnabl
ed, mobile); | 637 WebInspector.MultitargetTouchModel.instance().setTouchEnabled(touchEnabl
ed, mobile); |
| 638 } | 638 } |
| 639 } | 639 }; |
| OLD | NEW |