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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeWrapper.js

Issue 2837463002: DevTools: allow capturing screenshots from command menu. (Closed)
Patch Set: clean Created 3 years, 8 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
OLDNEW
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 * @return {boolean} 28 * @param {boolean=} fullSize
dgozman 2017/04/21 20:40:54 Keep the annotation.
pfeldman 2017/04/21 20:51:35 Done.
29 */ 29 */
30 _captureScreenshot() { 30 _captureScreenshot(fullSize) {
31 if (!this._deviceModeView) 31 if (!this._deviceModeView)
32 return false; 32 this._deviceModeView = new Emulation.DeviceModeView();
33 this._deviceModeView.captureScreenshot(); 33 this._deviceModeView.setNonEmulatedAvailableSize(this._inspectedPagePlacehol der.element);
34 if (fullSize)
35 this._deviceModeView.captureFullSizeScreenshot();
36 else
37 this._deviceModeView.captureScreenshot();
34 return true; 38 return true;
35 } 39 }
36 40
37 /**
38 * @return {boolean}
39 */
40 _captureFullSizeScreenshot() {
41 if (!this._deviceModeView)
42 return false;
43 this._deviceModeView.captureFullSizeScreenshot();
44 return true;
45 }
46
47 /** 41 /**
48 * @param {boolean} force 42 * @param {boolean} force
49 */ 43 */
50 _update(force) { 44 _update(force) {
51 this._toggleDeviceModeAction.setToggled(this._showDeviceModeSetting.get()); 45 this._toggleDeviceModeAction.setToggled(this._showDeviceModeSetting.get());
52 if (!force) { 46 if (!force) {
53 var showing = this._deviceModeView && this._deviceModeView.isShowing(); 47 var showing = this._deviceModeView && this._deviceModeView.isShowing();
54 if (this._showDeviceModeSetting.get() === showing) 48 if (this._showDeviceModeSetting.get() === showing)
55 return; 49 return;
56 } 50 }
(...skipping 27 matching lines...) Expand all
84 * @param {string} actionId 78 * @param {string} actionId
85 * @return {boolean} 79 * @return {boolean}
86 */ 80 */
87 handleAction(context, actionId) { 81 handleAction(context, actionId) {
88 if (Emulation.DeviceModeView._wrapperInstance) { 82 if (Emulation.DeviceModeView._wrapperInstance) {
89 switch (actionId) { 83 switch (actionId) {
90 case 'emulation.capture-screenshot': 84 case 'emulation.capture-screenshot':
91 return Emulation.DeviceModeView._wrapperInstance._captureScreenshot(); 85 return Emulation.DeviceModeView._wrapperInstance._captureScreenshot();
92 86
93 case 'emulation.capture-full-height-screenshot': 87 case 'emulation.capture-full-height-screenshot':
94 return Emulation.DeviceModeView._wrapperInstance._captureFullSizeScree nshot(); 88 return Emulation.DeviceModeView._wrapperInstance._captureScreenshot(tr ue);
95 89
96 case 'emulation.toggle-device-mode': 90 case 'emulation.toggle-device-mode':
97 Emulation.DeviceModeView._wrapperInstance._toggleDeviceMode(); 91 Emulation.DeviceModeView._wrapperInstance._toggleDeviceMode();
98 return true; 92 return true;
99 } 93 }
100 } 94 }
101 return false; 95 return false;
102 } 96 }
103 }; 97 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698