Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/EmulationModel.js

Issue 2844383003: [DevTools] Move the rest of emulation to EmulationModel (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeView.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 SDK.EmulationModel = class extends SDK.SDKModel { 5 SDK.EmulationModel = class extends SDK.SDKModel {
6 /** 6 /**
7 * @param {!SDK.Target} target 7 * @param {!SDK.Target} target
8 */ 8 */
9 constructor(target) { 9 constructor(target) {
10 super(target); 10 super(target);
(...skipping 18 matching lines...) Expand all
29 } 29 }
30 30
31 /** 31 /**
32 * @return {boolean} 32 * @return {boolean}
33 */ 33 */
34 supportsDeviceEmulation() { 34 supportsDeviceEmulation() {
35 return this.target().hasAllCapabilities(SDK.Target.Capability.DeviceEmulatio n); 35 return this.target().hasAllCapabilities(SDK.Target.Capability.DeviceEmulatio n);
36 } 36 }
37 37
38 /** 38 /**
39 * @return {!Promise}
40 */
41 resetPageScaleFactor() {
42 return this._emulationAgent.resetPageScaleFactor();
43 }
44
45 /**
46 * @param {?Protocol.PageAgent.SetDeviceMetricsOverrideRequest} metrics
47 * @return {!Promise}
48 */
49 emulateDevice(metrics) {
50 if (metrics)
51 return this._emulationAgent.invoke_setDeviceMetricsOverride(metrics);
52 else
53 return this._emulationAgent.clearDeviceMetricsOverride();
54 }
55
56 /**
57 * @param {number} width
58 * @param {number} height
59 * @return {!Promise}
60 */
61 setVisibleSize(width, height) {
62 return this._emulationAgent.setVisibleSize(width, height);
63 }
64
65 /**
66 * @param {{x: number, y: number, scale: number}|null} viewport
67 * @return {!Promise}
68 */
69 forceViewport(viewport) {
70 if (viewport)
71 return this._emulationAgent.forceViewport(viewport.x, viewport.y, viewport .scale);
72 else
73 return this._emulationAgent.resetViewport();
74 }
75
76 /**
77 * @return {?SDK.OverlayModel}
78 */
79 overlayModel() {
80 return this._overlayModel;
81 }
82
83 /**
39 * @param {?SDK.EmulationModel.Geolocation} geolocation 84 * @param {?SDK.EmulationModel.Geolocation} geolocation
40 */ 85 */
41 emulateGeolocation(geolocation) { 86 emulateGeolocation(geolocation) {
42 if (!geolocation) { 87 if (!geolocation) {
43 this._emulationAgent.clearGeolocationOverride(); 88 this._emulationAgent.clearGeolocationOverride();
44 return; 89 return;
45 } 90 }
46 91
47 if (geolocation.error) { 92 if (geolocation.error) {
48 this._emulationAgent.setGeolocationOverride(); 93 this._emulationAgent.setGeolocationOverride();
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 return /^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value); 324 return /^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value);
280 } 325 }
281 326
282 /** 327 /**
283 * @return {string} 328 * @return {string}
284 */ 329 */
285 toSetting() { 330 toSetting() {
286 return JSON.stringify(this); 331 return JSON.stringify(this);
287 } 332 }
288 }; 333 };
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeView.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698