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

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

Issue 1641513003: [DevTools] Split DeviceModeView.js into view, toolbar and wrapper. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@device-mode-cleanup-remove-files
Patch Set: Created 4 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 /**
6 * @extends {WebInspector.VBox}
7 * @param {!WebInspector.InspectedPagePlaceholder} inspectedPagePlaceholder
8 * @constructor
9 */
10 WebInspector.DeviceModeWrapper = function(inspectedPagePlaceholder)
11 {
12 WebInspector.VBox.call(this);
13 WebInspector.DeviceModeView._wrapperInstance = this;
14 this._inspectedPagePlaceholder = inspectedPagePlaceholder;
15 /** @type {?WebInspector.DeviceModeView} */
16 this._deviceModeView = null;
17 this._toggleDeviceModeAction = WebInspector.actionRegistry.action("emulation .toggle-device-mode");
18 this._showDeviceModeSetting = WebInspector.settings.createSetting("emulation .showDeviceMode", false);
19 this._showDeviceModeSetting.addChangeListener(this._update.bind(this, false) );
20 this._update(true);
21 }
22
23 /** @type {!WebInspector.DeviceModeWrapper} */
24 WebInspector.DeviceModeView._wrapperInstance;
25
26 WebInspector.DeviceModeWrapper.prototype = {
27 _toggleDeviceMode: function()
28 {
29 this._showDeviceModeSetting.set(!this._showDeviceModeSetting.get());
30 },
31
32 /**
33 * @param {boolean} force
34 */
35 _update: function(force)
36 {
37 this._toggleDeviceModeAction.setToggled(this._showDeviceModeSetting.get( ));
38 if (!force) {
39 var showing = this._deviceModeView && this._deviceModeView.isShowing ();
40 if (this._showDeviceModeSetting.get() === showing)
41 return;
42 }
43
44 if (this._showDeviceModeSetting.get()) {
45 if (!this._deviceModeView)
46 this._deviceModeView = new WebInspector.DeviceModeView();
47 this._deviceModeView.show(this.element);
48 this._inspectedPagePlaceholder.clearMinimumSizeAndMargins();
49 this._inspectedPagePlaceholder.show(this._deviceModeView.element);
50 } else {
51 if (this._deviceModeView)
52 this._deviceModeView.detach();
53 this._inspectedPagePlaceholder.restoreMinimumSizeAndMargins();
54 this._inspectedPagePlaceholder.show(this.element);
55 }
56 },
57
58 __proto__: WebInspector.VBox.prototype
59 }
60
61 /**
62 * @constructor
63 * @implements {WebInspector.ActionDelegate}
64 */
65 WebInspector.DeviceModeWrapper.ActionDelegate = function()
66 {
67 }
68
69 WebInspector.DeviceModeWrapper.ActionDelegate.prototype = {
70 /**
71 * @override
72 * @param {!WebInspector.Context} context
73 * @param {string} actionId
74 * @return {boolean}
75 */
76 handleAction: function(context, actionId)
77 {
78 if (WebInspector.DeviceModeView._wrapperInstance) {
79 if (actionId === "emulation.toggle-device-mode") {
80 WebInspector.DeviceModeView._wrapperInstance._toggleDeviceMode() ;
81 return true;
82 }
83 if (actionId === "emulation.request-app-banner") {
84 var target = WebInspector.targetManager.mainTarget();
85 if (target && target.isPage())
86 target.pageAgent().requestAppBanner();
87 return true;
88 }
89 }
90 return false;
91 }
92 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698