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

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

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month 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 WebInspector.DeviceModeToolbar = class { 7 Emulation.DeviceModeToolbar = class {
8 /** 8 /**
9 * @param {!WebInspector.DeviceModeModel} model 9 * @param {!Emulation.DeviceModeModel} model
10 * @param {!WebInspector.Setting} showMediaInspectorSetting 10 * @param {!Common.Setting} showMediaInspectorSetting
11 * @param {!WebInspector.Setting} showRulersSetting 11 * @param {!Common.Setting} showRulersSetting
12 */ 12 */
13 constructor(model, showMediaInspectorSetting, showRulersSetting) { 13 constructor(model, showMediaInspectorSetting, showRulersSetting) {
14 this._model = model; 14 this._model = model;
15 this._showMediaInspectorSetting = showMediaInspectorSetting; 15 this._showMediaInspectorSetting = showMediaInspectorSetting;
16 this._showRulersSetting = showRulersSetting; 16 this._showRulersSetting = showRulersSetting;
17 17
18 this._deviceOutlineSetting = this._model.deviceOutlineSetting(); 18 this._deviceOutlineSetting = this._model.deviceOutlineSetting();
19 this._showDeviceScaleFactorSetting = WebInspector.settings.createSetting('em ulation.showDeviceScaleFactor', false); 19 this._showDeviceScaleFactorSetting = Common.settings.createSetting('emulatio n.showDeviceScaleFactor', false);
20 this._showDeviceScaleFactorSetting.addChangeListener(this._updateDeviceScale FactorVisibility, this); 20 this._showDeviceScaleFactorSetting.addChangeListener(this._updateDeviceScale FactorVisibility, this);
21 21
22 this._showUserAgentTypeSetting = WebInspector.settings.createSetting('emulat ion.showUserAgentType', false); 22 this._showUserAgentTypeSetting = Common.settings.createSetting('emulation.sh owUserAgentType', false);
23 this._showUserAgentTypeSetting.addChangeListener(this._updateUserAgentTypeVi sibility, this); 23 this._showUserAgentTypeSetting.addChangeListener(this._updateUserAgentTypeVi sibility, this);
24 24
25 this._showNetworkConditionsSetting = WebInspector.settings.createSetting('em ulation.showNetworkConditions', false); 25 this._showNetworkConditionsSetting = Common.settings.createSetting('emulatio n.showNetworkConditions', false);
26 this._showNetworkConditionsSetting.addChangeListener(this._updateNetworkCond itionsVisibility, this); 26 this._showNetworkConditionsSetting.addChangeListener(this._updateNetworkCond itionsVisibility, this);
27 27
28 /** @type {!Map<!WebInspector.EmulatedDevice, !WebInspector.EmulatedDevice.M ode>} */ 28 /** @type {!Map<!Emulation.EmulatedDevice, !Emulation.EmulatedDevice.Mode>} */
29 this._lastMode = new Map(); 29 this._lastMode = new Map();
30 30
31 /** @type {!Map<!WebInspector.EmulatedDevice, number>} */ 31 /** @type {!Map<!Emulation.EmulatedDevice, number>} */
32 this._lastScale = new Map(); 32 this._lastScale = new Map();
33 33
34 this._element = createElementWithClass('div', 'device-mode-toolbar'); 34 this._element = createElementWithClass('div', 'device-mode-toolbar');
35 35
36 var leftContainer = this._element.createChild('div', 'device-mode-toolbar-sp acer'); 36 var leftContainer = this._element.createChild('div', 'device-mode-toolbar-sp acer');
37 leftContainer.createChild('div', 'device-mode-toolbar-spacer'); 37 leftContainer.createChild('div', 'device-mode-toolbar-spacer');
38 var leftToolbar = new WebInspector.Toolbar('', leftContainer); 38 var leftToolbar = new UI.Toolbar('', leftContainer);
39 leftToolbar.makeWrappable(); 39 leftToolbar.makeWrappable();
40 this._fillLeftToolbar(leftToolbar); 40 this._fillLeftToolbar(leftToolbar);
41 41
42 var mainToolbar = new WebInspector.Toolbar('', this._element); 42 var mainToolbar = new UI.Toolbar('', this._element);
43 mainToolbar.makeWrappable(); 43 mainToolbar.makeWrappable();
44 this._fillMainToolbar(mainToolbar); 44 this._fillMainToolbar(mainToolbar);
45 45
46 var rightContainer = this._element.createChild('div', 'device-mode-toolbar-s pacer'); 46 var rightContainer = this._element.createChild('div', 'device-mode-toolbar-s pacer');
47 var rightToolbar = new WebInspector.Toolbar('device-mode-toolbar-fixed-size' , rightContainer); 47 var rightToolbar = new UI.Toolbar('device-mode-toolbar-fixed-size', rightCon tainer);
48 rightToolbar.makeWrappable(); 48 rightToolbar.makeWrappable();
49 this._fillRightToolbar(rightToolbar); 49 this._fillRightToolbar(rightToolbar);
50 var modeToolbar = new WebInspector.Toolbar('device-mode-toolbar-fixed-size', rightContainer); 50 var modeToolbar = new UI.Toolbar('device-mode-toolbar-fixed-size', rightCont ainer);
51 modeToolbar.makeWrappable(); 51 modeToolbar.makeWrappable();
52 this._fillModeToolbar(modeToolbar); 52 this._fillModeToolbar(modeToolbar);
53 rightContainer.createChild('div', 'device-mode-toolbar-spacer'); 53 rightContainer.createChild('div', 'device-mode-toolbar-spacer');
54 var optionsToolbar = new WebInspector.Toolbar('', rightContainer); 54 var optionsToolbar = new UI.Toolbar('', rightContainer);
55 optionsToolbar.makeWrappable(true); 55 optionsToolbar.makeWrappable(true);
56 this._fillOptionsToolbar(optionsToolbar); 56 this._fillOptionsToolbar(optionsToolbar);
57 57
58 this._emulatedDevicesList = WebInspector.EmulatedDevicesList.instance(); 58 this._emulatedDevicesList = Emulation.EmulatedDevicesList.instance();
59 this._emulatedDevicesList.addEventListener( 59 this._emulatedDevicesList.addEventListener(
60 WebInspector.EmulatedDevicesList.Events.CustomDevicesUpdated, this._devi ceListChanged, this); 60 Emulation.EmulatedDevicesList.Events.CustomDevicesUpdated, this._deviceL istChanged, this);
61 this._emulatedDevicesList.addEventListener( 61 this._emulatedDevicesList.addEventListener(
62 WebInspector.EmulatedDevicesList.Events.StandardDevicesUpdated, this._de viceListChanged, this); 62 Emulation.EmulatedDevicesList.Events.StandardDevicesUpdated, this._devic eListChanged, this);
63 63
64 this._persistenceSetting = 64 this._persistenceSetting =
65 WebInspector.settings.createSetting('emulation.deviceModeValue', {device : '', orientation: '', mode: ''}); 65 Common.settings.createSetting('emulation.deviceModeValue', {device: '', orientation: '', mode: ''});
66 } 66 }
67 67
68 /** 68 /**
69 * @param {!WebInspector.Toolbar} toolbar 69 * @param {!UI.Toolbar} toolbar
70 */ 70 */
71 _fillLeftToolbar(toolbar) { 71 _fillLeftToolbar(toolbar) {
72 toolbar.appendToolbarItem( 72 toolbar.appendToolbarItem(
73 this._wrapToolbarItem(createElementWithClass('div', 'device-mode-empty-t oolbar-element'))); 73 this._wrapToolbarItem(createElementWithClass('div', 'device-mode-empty-t oolbar-element')));
74 this._deviceSelectItem = new WebInspector.ToolbarMenuButton(this._appendDevi ceMenuItems.bind(this)); 74 this._deviceSelectItem = new UI.ToolbarMenuButton(this._appendDeviceMenuItem s.bind(this));
75 this._deviceSelectItem.setGlyph(''); 75 this._deviceSelectItem.setGlyph('');
76 this._deviceSelectItem.turnIntoSelect(95); 76 this._deviceSelectItem.turnIntoSelect(95);
77 toolbar.appendToolbarItem(this._deviceSelectItem); 77 toolbar.appendToolbarItem(this._deviceSelectItem);
78 } 78 }
79 79
80 /** 80 /**
81 * @param {!WebInspector.Toolbar} toolbar 81 * @param {!UI.Toolbar} toolbar
82 */ 82 */
83 _fillMainToolbar(toolbar) { 83 _fillMainToolbar(toolbar) {
84 var widthInput = createElementWithClass('input', 'device-mode-size-input'); 84 var widthInput = createElementWithClass('input', 'device-mode-size-input');
85 widthInput.maxLength = 4; 85 widthInput.maxLength = 4;
86 widthInput.type = 'text'; 86 widthInput.type = 'text';
87 widthInput.title = WebInspector.UIString('Width'); 87 widthInput.title = Common.UIString('Width');
88 this._updateWidthInput = WebInspector.bindInput( 88 this._updateWidthInput = UI.bindInput(
89 widthInput, this._applyWidth.bind(this), WebInspector.DeviceModeModel.de viceSizeValidator, true); 89 widthInput, this._applyWidth.bind(this), Emulation.DeviceModeModel.devic eSizeValidator, true);
90 this._widthInput = widthInput; 90 this._widthInput = widthInput;
91 this._widthItem = this._wrapToolbarItem(widthInput); 91 this._widthItem = this._wrapToolbarItem(widthInput);
92 toolbar.appendToolbarItem(this._widthItem); 92 toolbar.appendToolbarItem(this._widthItem);
93 93
94 var xElement = createElementWithClass('div', 'device-mode-x'); 94 var xElement = createElementWithClass('div', 'device-mode-x');
95 xElement.textContent = '\u00D7'; 95 xElement.textContent = '\u00D7';
96 this._xItem = this._wrapToolbarItem(xElement); 96 this._xItem = this._wrapToolbarItem(xElement);
97 toolbar.appendToolbarItem(this._xItem); 97 toolbar.appendToolbarItem(this._xItem);
98 98
99 var heightInput = createElementWithClass('input', 'device-mode-size-input'); 99 var heightInput = createElementWithClass('input', 'device-mode-size-input');
100 heightInput.maxLength = 4; 100 heightInput.maxLength = 4;
101 heightInput.type = 'text'; 101 heightInput.type = 'text';
102 heightInput.title = WebInspector.UIString('Height (leave empty for full)'); 102 heightInput.title = Common.UIString('Height (leave empty for full)');
103 this._updateHeightInput = WebInspector.bindInput(heightInput, this._applyHei ght.bind(this), validateHeight, true); 103 this._updateHeightInput = UI.bindInput(heightInput, this._applyHeight.bind(t his), validateHeight, true);
104 this._heightInput = heightInput; 104 this._heightInput = heightInput;
105 this._heightItem = this._wrapToolbarItem(heightInput); 105 this._heightItem = this._wrapToolbarItem(heightInput);
106 toolbar.appendToolbarItem(this._heightItem); 106 toolbar.appendToolbarItem(this._heightItem);
107 107
108 /** 108 /**
109 * @param {string} value 109 * @param {string} value
110 * @return {boolean} 110 * @return {boolean}
111 */ 111 */
112 function validateHeight(value) { 112 function validateHeight(value) {
113 return !value || WebInspector.DeviceModeModel.deviceSizeValidator(value); 113 return !value || Emulation.DeviceModeModel.deviceSizeValidator(value);
114 } 114 }
115 } 115 }
116 116
117 /** 117 /**
118 * @param {string} value 118 * @param {string} value
119 */ 119 */
120 _applyWidth(value) { 120 _applyWidth(value) {
121 var width = value ? Number(value) : 0; 121 var width = value ? Number(value) : 0;
122 this._model.setWidthAndScaleToFit(width); 122 this._model.setWidthAndScaleToFit(width);
123 } 123 }
124 124
125 /** 125 /**
126 * @param {string} value 126 * @param {string} value
127 */ 127 */
128 _applyHeight(value) { 128 _applyHeight(value) {
129 var height = value ? Number(value) : 0; 129 var height = value ? Number(value) : 0;
130 this._model.setHeightAndScaleToFit(height); 130 this._model.setHeightAndScaleToFit(height);
131 } 131 }
132 132
133 /** 133 /**
134 * @param {!WebInspector.Toolbar} toolbar 134 * @param {!UI.Toolbar} toolbar
135 */ 135 */
136 _fillRightToolbar(toolbar) { 136 _fillRightToolbar(toolbar) {
137 toolbar.appendToolbarItem( 137 toolbar.appendToolbarItem(
138 this._wrapToolbarItem(createElementWithClass('div', 'device-mode-empty-t oolbar-element'))); 138 this._wrapToolbarItem(createElementWithClass('div', 'device-mode-empty-t oolbar-element')));
139 this._scaleItem = new WebInspector.ToolbarMenuButton(this._appendScaleMenuIt ems.bind(this)); 139 this._scaleItem = new UI.ToolbarMenuButton(this._appendScaleMenuItems.bind(t his));
140 this._scaleItem.setTitle(WebInspector.UIString('Zoom')); 140 this._scaleItem.setTitle(Common.UIString('Zoom'));
141 this._scaleItem.setGlyph(''); 141 this._scaleItem.setGlyph('');
142 this._scaleItem.turnIntoSelect(); 142 this._scaleItem.turnIntoSelect();
143 toolbar.appendToolbarItem(this._scaleItem); 143 toolbar.appendToolbarItem(this._scaleItem);
144 144
145 toolbar.appendToolbarItem( 145 toolbar.appendToolbarItem(
146 this._wrapToolbarItem(createElementWithClass('div', 'device-mode-empty-t oolbar-element'))); 146 this._wrapToolbarItem(createElementWithClass('div', 'device-mode-empty-t oolbar-element')));
147 this._deviceScaleItem = new WebInspector.ToolbarMenuButton(this._appendDevic eScaleMenuItems.bind(this)); 147 this._deviceScaleItem = new UI.ToolbarMenuButton(this._appendDeviceScaleMenu Items.bind(this));
148 this._deviceScaleItem.setVisible(this._showDeviceScaleFactorSetting.get()); 148 this._deviceScaleItem.setVisible(this._showDeviceScaleFactorSetting.get());
149 this._deviceScaleItem.setTitle(WebInspector.UIString('Device pixel ratio')); 149 this._deviceScaleItem.setTitle(Common.UIString('Device pixel ratio'));
150 this._deviceScaleItem.setGlyph(''); 150 this._deviceScaleItem.setGlyph('');
151 this._deviceScaleItem.turnIntoSelect(); 151 this._deviceScaleItem.turnIntoSelect();
152 this._deviceScaleItem.element.style.padding = '0 5px'; 152 this._deviceScaleItem.element.style.padding = '0 5px';
153 toolbar.appendToolbarItem(this._deviceScaleItem); 153 toolbar.appendToolbarItem(this._deviceScaleItem);
154 154
155 toolbar.appendToolbarItem( 155 toolbar.appendToolbarItem(
156 this._wrapToolbarItem(createElementWithClass('div', 'device-mode-empty-t oolbar-element'))); 156 this._wrapToolbarItem(createElementWithClass('div', 'device-mode-empty-t oolbar-element')));
157 this._uaItem = new WebInspector.ToolbarMenuButton(this._appendUserAgentMenuI tems.bind(this)); 157 this._uaItem = new UI.ToolbarMenuButton(this._appendUserAgentMenuItems.bind( this));
158 this._uaItem.setVisible(this._showUserAgentTypeSetting.get()); 158 this._uaItem.setVisible(this._showUserAgentTypeSetting.get());
159 this._uaItem.setTitle(WebInspector.UIString('Device type')); 159 this._uaItem.setTitle(Common.UIString('Device type'));
160 this._uaItem.setGlyph(''); 160 this._uaItem.setGlyph('');
161 this._uaItem.turnIntoSelect(); 161 this._uaItem.turnIntoSelect();
162 this._uaItem.element.style.padding = '0 5px'; 162 this._uaItem.element.style.padding = '0 5px';
163 toolbar.appendToolbarItem(this._uaItem); 163 toolbar.appendToolbarItem(this._uaItem);
164 } 164 }
165 165
166 /** 166 /**
167 * @param {!WebInspector.Toolbar} toolbar 167 * @param {!UI.Toolbar} toolbar
168 */ 168 */
169 _fillModeToolbar(toolbar) { 169 _fillModeToolbar(toolbar) {
170 toolbar.appendToolbarItem( 170 toolbar.appendToolbarItem(
171 this._wrapToolbarItem(createElementWithClass('div', 'device-mode-empty-t oolbar-element'))); 171 this._wrapToolbarItem(createElementWithClass('div', 'device-mode-empty-t oolbar-element')));
172 this._modeButton = new WebInspector.ToolbarButton('', 'largeicon-rotate-scre en'); 172 this._modeButton = new UI.ToolbarButton('', 'largeicon-rotate-screen');
173 this._modeButton.addEventListener('click', this._modeMenuClicked, this); 173 this._modeButton.addEventListener('click', this._modeMenuClicked, this);
174 toolbar.appendToolbarItem(this._modeButton); 174 toolbar.appendToolbarItem(this._modeButton);
175 } 175 }
176 176
177 /** 177 /**
178 * @param {!WebInspector.Toolbar} toolbar 178 * @param {!UI.Toolbar} toolbar
179 */ 179 */
180 _fillOptionsToolbar(toolbar) { 180 _fillOptionsToolbar(toolbar) {
181 this._networkConditionsItem = WebInspector.NetworkConditionsSelector.createT oolbarMenuButton(); 181 this._networkConditionsItem = Components.NetworkConditionsSelector.createToo lbarMenuButton();
182 this._networkConditionsItem.setVisible(this._showNetworkConditionsSetting.ge t()); 182 this._networkConditionsItem.setVisible(this._showNetworkConditionsSetting.ge t());
183 this._networkConditionsItem.setTitle(WebInspector.UIString('Network throttli ng')); 183 this._networkConditionsItem.setTitle(Common.UIString('Network throttling'));
184 this._networkConditionsItem.element.style.padding = '0 5px'; 184 this._networkConditionsItem.element.style.padding = '0 5px';
185 this._networkConditionsItem.element.style.maxWidth = '140px'; 185 this._networkConditionsItem.element.style.maxWidth = '140px';
186 toolbar.appendToolbarItem(this._networkConditionsItem); 186 toolbar.appendToolbarItem(this._networkConditionsItem);
187 187
188 var moreOptionsButton = new WebInspector.ToolbarMenuButton(this._appendOptio nsMenuItems.bind(this)); 188 var moreOptionsButton = new UI.ToolbarMenuButton(this._appendOptionsMenuItem s.bind(this));
189 moreOptionsButton.setTitle(WebInspector.UIString('More options')); 189 moreOptionsButton.setTitle(Common.UIString('More options'));
190 toolbar.appendToolbarItem(moreOptionsButton); 190 toolbar.appendToolbarItem(moreOptionsButton);
191 191
192 toolbar.appendToolbarItem( 192 toolbar.appendToolbarItem(
193 this._wrapToolbarItem(createElementWithClass('div', 'device-mode-empty-t oolbar-element'))); 193 this._wrapToolbarItem(createElementWithClass('div', 'device-mode-empty-t oolbar-element')));
194 } 194 }
195 195
196 /** 196 /**
197 * @param {!WebInspector.ContextMenu} contextMenu 197 * @param {!UI.ContextMenu} contextMenu
198 */ 198 */
199 _appendScaleMenuItems(contextMenu) { 199 _appendScaleMenuItems(contextMenu) {
200 if (this._model.type() === WebInspector.DeviceModeModel.Type.Device) { 200 if (this._model.type() === Emulation.DeviceModeModel.Type.Device) {
201 contextMenu.appendItem( 201 contextMenu.appendItem(
202 WebInspector.UIString('Fit to window (%.0f%%)', this._model.fitScale() * 100), 202 Common.UIString('Fit to window (%.0f%%)', this._model.fitScale() * 100 ),
203 this._onScaleMenuChanged.bind(this, this._model.fitScale()), false); 203 this._onScaleMenuChanged.bind(this, this._model.fitScale()), false);
204 contextMenu.appendSeparator(); 204 contextMenu.appendSeparator();
205 } 205 }
206 var boundAppendScaleItem = appendScaleItem.bind(this); 206 var boundAppendScaleItem = appendScaleItem.bind(this);
207 boundAppendScaleItem(WebInspector.UIString('50%'), 0.5); 207 boundAppendScaleItem(Common.UIString('50%'), 0.5);
208 boundAppendScaleItem(WebInspector.UIString('75%'), 0.75); 208 boundAppendScaleItem(Common.UIString('75%'), 0.75);
209 boundAppendScaleItem(WebInspector.UIString('100%'), 1); 209 boundAppendScaleItem(Common.UIString('100%'), 1);
210 boundAppendScaleItem(WebInspector.UIString('125%'), 1.25); 210 boundAppendScaleItem(Common.UIString('125%'), 1.25);
211 boundAppendScaleItem(WebInspector.UIString('150%'), 1.5); 211 boundAppendScaleItem(Common.UIString('150%'), 1.5);
212 212
213 /** 213 /**
214 * @param {string} title 214 * @param {string} title
215 * @param {number} value 215 * @param {number} value
216 * @this {!WebInspector.DeviceModeToolbar} 216 * @this {!Emulation.DeviceModeToolbar}
217 */ 217 */
218 function appendScaleItem(title, value) { 218 function appendScaleItem(title, value) {
219 contextMenu.appendCheckboxItem( 219 contextMenu.appendCheckboxItem(
220 title, this._onScaleMenuChanged.bind(this, value), this._model.scaleSe tting().get() === value, false); 220 title, this._onScaleMenuChanged.bind(this, value), this._model.scaleSe tting().get() === value, false);
221 } 221 }
222 } 222 }
223 223
224 /** 224 /**
225 * @param {number} value 225 * @param {number} value
226 */ 226 */
227 _onScaleMenuChanged(value) { 227 _onScaleMenuChanged(value) {
228 var device = this._model.device(); 228 var device = this._model.device();
229 if (device) 229 if (device)
230 this._lastScale.set(device, value); 230 this._lastScale.set(device, value);
231 this._model.scaleSetting().set(value); 231 this._model.scaleSetting().set(value);
232 } 232 }
233 233
234 /** 234 /**
235 * @param {!WebInspector.ContextMenu} contextMenu 235 * @param {!UI.ContextMenu} contextMenu
236 */ 236 */
237 _appendDeviceScaleMenuItems(contextMenu) { 237 _appendDeviceScaleMenuItems(contextMenu) {
238 var deviceScaleFactorSetting = this._model.deviceScaleFactorSetting(); 238 var deviceScaleFactorSetting = this._model.deviceScaleFactorSetting();
239 var defaultValue = this._model.uaSetting().get() === WebInspector.DeviceMode Model.UA.Mobile || 239 var defaultValue = this._model.uaSetting().get() === Emulation.DeviceModeMod el.UA.Mobile ||
240 this._model.uaSetting().get() === WebInspector.DeviceModeModel.UA.Mo bileNoTouch ? 240 this._model.uaSetting().get() === Emulation.DeviceModeModel.UA.Mobil eNoTouch ?
241 WebInspector.DeviceModeModel.defaultMobileScaleFactor : 241 Emulation.DeviceModeModel.defaultMobileScaleFactor :
242 window.devicePixelRatio; 242 window.devicePixelRatio;
243 appendDeviceScaleFactorItem(WebInspector.UIString('Default: %.1f', defaultVa lue), 0); 243 appendDeviceScaleFactorItem(Common.UIString('Default: %.1f', defaultValue), 0);
244 contextMenu.appendSeparator(); 244 contextMenu.appendSeparator();
245 appendDeviceScaleFactorItem(WebInspector.UIString('1'), 1); 245 appendDeviceScaleFactorItem(Common.UIString('1'), 1);
246 appendDeviceScaleFactorItem(WebInspector.UIString('2'), 2); 246 appendDeviceScaleFactorItem(Common.UIString('2'), 2);
247 appendDeviceScaleFactorItem(WebInspector.UIString('3'), 3); 247 appendDeviceScaleFactorItem(Common.UIString('3'), 3);
248 248
249 /** 249 /**
250 * @param {string} title 250 * @param {string} title
251 * @param {number} value 251 * @param {number} value
252 */ 252 */
253 function appendDeviceScaleFactorItem(title, value) { 253 function appendDeviceScaleFactorItem(title, value) {
254 contextMenu.appendCheckboxItem( 254 contextMenu.appendCheckboxItem(
255 title, deviceScaleFactorSetting.set.bind(deviceScaleFactorSetting, val ue), 255 title, deviceScaleFactorSetting.set.bind(deviceScaleFactorSetting, val ue),
256 deviceScaleFactorSetting.get() === value); 256 deviceScaleFactorSetting.get() === value);
257 } 257 }
258 } 258 }
259 259
260 /** 260 /**
261 * @param {!WebInspector.ContextMenu} contextMenu 261 * @param {!UI.ContextMenu} contextMenu
262 */ 262 */
263 _appendUserAgentMenuItems(contextMenu) { 263 _appendUserAgentMenuItems(contextMenu) {
264 var uaSetting = this._model.uaSetting(); 264 var uaSetting = this._model.uaSetting();
265 appendUAItem(WebInspector.DeviceModeModel.UA.Mobile, WebInspector.DeviceMode Model.UA.Mobile); 265 appendUAItem(Emulation.DeviceModeModel.UA.Mobile, Emulation.DeviceModeModel. UA.Mobile);
266 appendUAItem(WebInspector.DeviceModeModel.UA.MobileNoTouch, WebInspector.Dev iceModeModel.UA.MobileNoTouch); 266 appendUAItem(Emulation.DeviceModeModel.UA.MobileNoTouch, Emulation.DeviceMod eModel.UA.MobileNoTouch);
267 appendUAItem(WebInspector.DeviceModeModel.UA.Desktop, WebInspector.DeviceMod eModel.UA.Desktop); 267 appendUAItem(Emulation.DeviceModeModel.UA.Desktop, Emulation.DeviceModeModel .UA.Desktop);
268 appendUAItem(WebInspector.DeviceModeModel.UA.DesktopTouch, WebInspector.Devi ceModeModel.UA.DesktopTouch); 268 appendUAItem(Emulation.DeviceModeModel.UA.DesktopTouch, Emulation.DeviceMode Model.UA.DesktopTouch);
269 269
270 /** 270 /**
271 * @param {string} title 271 * @param {string} title
272 * @param {!WebInspector.DeviceModeModel.UA} value 272 * @param {!Emulation.DeviceModeModel.UA} value
273 */ 273 */
274 function appendUAItem(title, value) { 274 function appendUAItem(title, value) {
275 contextMenu.appendCheckboxItem(title, uaSetting.set.bind(uaSetting, value) , uaSetting.get() === value); 275 contextMenu.appendCheckboxItem(title, uaSetting.set.bind(uaSetting, value) , uaSetting.get() === value);
276 } 276 }
277 } 277 }
278 278
279 /** 279 /**
280 * @param {!WebInspector.ContextMenu} contextMenu 280 * @param {!UI.ContextMenu} contextMenu
281 */ 281 */
282 _appendOptionsMenuItems(contextMenu) { 282 _appendOptionsMenuItems(contextMenu) {
283 var model = this._model; 283 var model = this._model;
284 appendToggleItem( 284 appendToggleItem(
285 this._deviceOutlineSetting, WebInspector.UIString('Hide device frame'), 285 this._deviceOutlineSetting, Common.UIString('Hide device frame'),
286 WebInspector.UIString('Show device frame'), model.type() !== WebInspecto r.DeviceModeModel.Type.Device); 286 Common.UIString('Show device frame'), model.type() !== Emulation.DeviceM odeModel.Type.Device);
287 appendToggleItem( 287 appendToggleItem(
288 this._showMediaInspectorSetting, WebInspector.UIString('Hide media queri es'), 288 this._showMediaInspectorSetting, Common.UIString('Hide media queries'),
289 WebInspector.UIString('Show media queries')); 289 Common.UIString('Show media queries'));
290 appendToggleItem( 290 appendToggleItem(
291 this._showRulersSetting, WebInspector.UIString('Hide rulers'), WebInspec tor.UIString('Show rulers')); 291 this._showRulersSetting, Common.UIString('Hide rulers'), Common.UIString ('Show rulers'));
292 contextMenu.appendSeparator(); 292 contextMenu.appendSeparator();
293 appendToggleItem( 293 appendToggleItem(
294 this._showDeviceScaleFactorSetting, WebInspector.UIString('Remove device pixel ratio'), 294 this._showDeviceScaleFactorSetting, Common.UIString('Remove device pixel ratio'),
295 WebInspector.UIString('Add device pixel ratio')); 295 Common.UIString('Add device pixel ratio'));
296 appendToggleItem( 296 appendToggleItem(
297 this._showUserAgentTypeSetting, WebInspector.UIString('Remove device typ e'), 297 this._showUserAgentTypeSetting, Common.UIString('Remove device type'),
298 WebInspector.UIString('Add device type')); 298 Common.UIString('Add device type'));
299 appendToggleItem( 299 appendToggleItem(
300 this._showNetworkConditionsSetting, WebInspector.UIString('Remove networ k throttling'), 300 this._showNetworkConditionsSetting, Common.UIString('Remove network thro ttling'),
301 WebInspector.UIString('Add network throttling')); 301 Common.UIString('Add network throttling'));
302 contextMenu.appendSeparator(); 302 contextMenu.appendSeparator();
303 contextMenu.appendItemsAtLocation('deviceModeMenu'); 303 contextMenu.appendItemsAtLocation('deviceModeMenu');
304 contextMenu.appendSeparator(); 304 contextMenu.appendSeparator();
305 contextMenu.appendItem(WebInspector.UIString('Reset to defaults'), this._res et.bind(this)); 305 contextMenu.appendItem(Common.UIString('Reset to defaults'), this._reset.bin d(this));
306 306
307 /** 307 /**
308 * @param {!WebInspector.Setting} setting 308 * @param {!Common.Setting} setting
309 * @param {string} title1 309 * @param {string} title1
310 * @param {string} title2 310 * @param {string} title2
311 * @param {boolean=} disabled 311 * @param {boolean=} disabled
312 */ 312 */
313 function appendToggleItem(setting, title1, title2, disabled) { 313 function appendToggleItem(setting, title1, title2, disabled) {
314 if (typeof disabled === 'undefined') 314 if (typeof disabled === 'undefined')
315 disabled = model.type() === WebInspector.DeviceModeModel.Type.None; 315 disabled = model.type() === Emulation.DeviceModeModel.Type.None;
316 contextMenu.appendItem(setting.get() ? title1 : title2, setting.set.bind(s etting, !setting.get()), disabled); 316 contextMenu.appendItem(setting.get() ? title1 : title2, setting.set.bind(s etting, !setting.get()), disabled);
317 } 317 }
318 } 318 }
319 319
320 _reset() { 320 _reset() {
321 this._deviceOutlineSetting.set(false); 321 this._deviceOutlineSetting.set(false);
322 this._showDeviceScaleFactorSetting.set(false); 322 this._showDeviceScaleFactorSetting.set(false);
323 this._showUserAgentTypeSetting.set(false); 323 this._showUserAgentTypeSetting.set(false);
324 this._showMediaInspectorSetting.set(false); 324 this._showMediaInspectorSetting.set(false);
325 this._showRulersSetting.set(false); 325 this._showRulersSetting.set(false);
326 this._showNetworkConditionsSetting.set(false); 326 this._showNetworkConditionsSetting.set(false);
327 this._model.reset(); 327 this._model.reset();
328 } 328 }
329 329
330 /** 330 /**
331 * @param {!Element} element 331 * @param {!Element} element
332 * @return {!WebInspector.ToolbarItem} 332 * @return {!UI.ToolbarItem}
333 */ 333 */
334 _wrapToolbarItem(element) { 334 _wrapToolbarItem(element) {
335 var container = createElement('div'); 335 var container = createElement('div');
336 var shadowRoot = WebInspector.createShadowRootWithCoreStyles(container, 'emu lation/deviceModeToolbar.css'); 336 var shadowRoot = UI.createShadowRootWithCoreStyles(container, 'emulation/dev iceModeToolbar.css');
337 shadowRoot.appendChild(element); 337 shadowRoot.appendChild(element);
338 return new WebInspector.ToolbarItem(container); 338 return new UI.ToolbarItem(container);
339 } 339 }
340 340
341 /** 341 /**
342 * @param {!WebInspector.EmulatedDevice} device 342 * @param {!Emulation.EmulatedDevice} device
343 */ 343 */
344 _emulateDevice(device) { 344 _emulateDevice(device) {
345 this._model.emulate( 345 this._model.emulate(
346 WebInspector.DeviceModeModel.Type.Device, device, this._lastMode.get(dev ice) || device.modes[0], 346 Emulation.DeviceModeModel.Type.Device, device, this._lastMode.get(device ) || device.modes[0],
347 this._lastScale.get(device)); 347 this._lastScale.get(device));
348 } 348 }
349 349
350 _switchToResponsive() { 350 _switchToResponsive() {
351 this._model.emulate(WebInspector.DeviceModeModel.Type.Responsive, null, null ); 351 this._model.emulate(Emulation.DeviceModeModel.Type.Responsive, null, null);
352 } 352 }
353 353
354 /** 354 /**
355 * @param {!Array<!WebInspector.EmulatedDevice>} devices 355 * @param {!Array<!Emulation.EmulatedDevice>} devices
356 * @return {!Array<!WebInspector.EmulatedDevice>} 356 * @return {!Array<!Emulation.EmulatedDevice>}
357 */ 357 */
358 _filterDevices(devices) { 358 _filterDevices(devices) {
359 devices = devices.filter(function(d) { 359 devices = devices.filter(function(d) {
360 return d.show(); 360 return d.show();
361 }); 361 });
362 devices.sort(WebInspector.EmulatedDevice.deviceComparator); 362 devices.sort(Emulation.EmulatedDevice.deviceComparator);
363 return devices; 363 return devices;
364 } 364 }
365 365
366 /** 366 /**
367 * @return {!Array<!WebInspector.EmulatedDevice>} 367 * @return {!Array<!Emulation.EmulatedDevice>}
368 */ 368 */
369 _standardDevices() { 369 _standardDevices() {
370 return this._filterDevices(this._emulatedDevicesList.standard()); 370 return this._filterDevices(this._emulatedDevicesList.standard());
371 } 371 }
372 372
373 /** 373 /**
374 * @return {!Array<!WebInspector.EmulatedDevice>} 374 * @return {!Array<!Emulation.EmulatedDevice>}
375 */ 375 */
376 _customDevices() { 376 _customDevices() {
377 return this._filterDevices(this._emulatedDevicesList.custom()); 377 return this._filterDevices(this._emulatedDevicesList.custom());
378 } 378 }
379 379
380 /** 380 /**
381 * @return {!Array<!WebInspector.EmulatedDevice>} 381 * @return {!Array<!Emulation.EmulatedDevice>}
382 */ 382 */
383 _allDevices() { 383 _allDevices() {
384 return this._standardDevices().concat(this._customDevices()); 384 return this._standardDevices().concat(this._customDevices());
385 } 385 }
386 386
387 /** 387 /**
388 * @param {!WebInspector.ContextMenu} contextMenu 388 * @param {!UI.ContextMenu} contextMenu
389 */ 389 */
390 _appendDeviceMenuItems(contextMenu) { 390 _appendDeviceMenuItems(contextMenu) {
391 contextMenu.appendCheckboxItem( 391 contextMenu.appendCheckboxItem(
392 WebInspector.UIString('Responsive'), this._switchToResponsive.bind(this) , 392 Common.UIString('Responsive'), this._switchToResponsive.bind(this),
393 this._model.type() === WebInspector.DeviceModeModel.Type.Responsive, fal se); 393 this._model.type() === Emulation.DeviceModeModel.Type.Responsive, false) ;
394 appendGroup.call(this, this._standardDevices()); 394 appendGroup.call(this, this._standardDevices());
395 appendGroup.call(this, this._customDevices()); 395 appendGroup.call(this, this._customDevices());
396 contextMenu.appendSeparator(); 396 contextMenu.appendSeparator();
397 contextMenu.appendItem( 397 contextMenu.appendItem(
398 WebInspector.UIString('Edit\u2026'), 398 Common.UIString('Edit\u2026'),
399 this._emulatedDevicesList.revealCustomSetting.bind(this._emulatedDevices List), false); 399 this._emulatedDevicesList.revealCustomSetting.bind(this._emulatedDevices List), false);
400 400
401 /** 401 /**
402 * @param {!Array<!WebInspector.EmulatedDevice>} devices 402 * @param {!Array<!Emulation.EmulatedDevice>} devices
403 * @this {WebInspector.DeviceModeToolbar} 403 * @this {Emulation.DeviceModeToolbar}
404 */ 404 */
405 function appendGroup(devices) { 405 function appendGroup(devices) {
406 if (!devices.length) 406 if (!devices.length)
407 return; 407 return;
408 contextMenu.appendSeparator(); 408 contextMenu.appendSeparator();
409 for (var device of devices) 409 for (var device of devices)
410 contextMenu.appendCheckboxItem( 410 contextMenu.appendCheckboxItem(
411 device.title, this._emulateDevice.bind(this, device), this._model.de vice() === device, false); 411 device.title, this._emulateDevice.bind(this, device), this._model.de vice() === device, false);
412 } 412 }
413 } 413 }
414 414
415 /** 415 /**
416 * @this {WebInspector.DeviceModeToolbar} 416 * @this {Emulation.DeviceModeToolbar}
417 */ 417 */
418 _deviceListChanged() { 418 _deviceListChanged() {
419 var device = this._model.device(); 419 var device = this._model.device();
420 if (!device) 420 if (!device)
421 return; 421 return;
422 422
423 var devices = this._allDevices(); 423 var devices = this._allDevices();
424 if (devices.indexOf(device) === -1) { 424 if (devices.indexOf(device) === -1) {
425 if (devices.length) 425 if (devices.length)
426 this._emulateDevice(devices[0]); 426 this._emulateDevice(devices[0]);
427 else 427 else
428 this._model.emulate(WebInspector.DeviceModeModel.Type.Responsive, null, null); 428 this._model.emulate(Emulation.DeviceModeModel.Type.Responsive, null, nul l);
429 } 429 }
430 } 430 }
431 431
432 _updateDeviceScaleFactorVisibility() { 432 _updateDeviceScaleFactorVisibility() {
433 this._deviceScaleItem.setVisible(this._showDeviceScaleFactorSetting.get()); 433 this._deviceScaleItem.setVisible(this._showDeviceScaleFactorSetting.get());
434 } 434 }
435 435
436 _updateUserAgentTypeVisibility() { 436 _updateUserAgentTypeVisibility() {
437 this._uaItem.setVisible(this._showUserAgentTypeSetting.get()); 437 this._uaItem.setVisible(this._showUserAgentTypeSetting.get());
438 } 438 }
439 439
440 _updateNetworkConditionsVisibility() { 440 _updateNetworkConditionsVisibility() {
441 this._networkConditionsItem.setVisible(this._showNetworkConditionsSetting.ge t()); 441 this._networkConditionsItem.setVisible(this._showNetworkConditionsSetting.ge t());
442 } 442 }
443 443
444 /** 444 /**
445 * @param {!WebInspector.Event} event 445 * @param {!Common.Event} event
446 */ 446 */
447 _modeMenuClicked(event) { 447 _modeMenuClicked(event) {
448 var device = this._model.device(); 448 var device = this._model.device();
449 var model = this._model; 449 var model = this._model;
450 450
451 if (device.modes.length === 2 && device.modes[0].orientation !== device.mode s[1].orientation) { 451 if (device.modes.length === 2 && device.modes[0].orientation !== device.mode s[1].orientation) {
452 model.emulate(model.type(), model.device(), model.mode() === device.modes[ 0] ? device.modes[1] : device.modes[0]); 452 model.emulate(model.type(), model.device(), model.mode() === device.modes[ 0] ? device.modes[1] : device.modes[0]);
453 return; 453 return;
454 } 454 }
455 455
456 var contextMenu = new WebInspector.ContextMenu( 456 var contextMenu = new UI.ContextMenu(
457 /** @type {!Event} */ (event.data), false, event.target.element.totalOff setLeft(), 457 /** @type {!Event} */ (event.data), false, event.target.element.totalOff setLeft(),
458 event.target.element.totalOffsetTop() + event.target.element.offsetHeigh t); 458 event.target.element.totalOffsetTop() + event.target.element.offsetHeigh t);
459 addOrientation(WebInspector.EmulatedDevice.Vertical, WebInspector.UIString(' Portrait')); 459 addOrientation(Emulation.EmulatedDevice.Vertical, Common.UIString('Portrait' ));
460 addOrientation(WebInspector.EmulatedDevice.Horizontal, WebInspector.UIString ('Landscape')); 460 addOrientation(Emulation.EmulatedDevice.Horizontal, Common.UIString('Landsca pe'));
461 contextMenu.show(); 461 contextMenu.show();
462 462
463 /** 463 /**
464 * @param {string} orientation 464 * @param {string} orientation
465 * @param {string} title 465 * @param {string} title
466 */ 466 */
467 function addOrientation(orientation, title) { 467 function addOrientation(orientation, title) {
468 var modes = device.modesForOrientation(orientation); 468 var modes = device.modesForOrientation(orientation);
469 if (!modes.length) 469 if (!modes.length)
470 return; 470 return;
471 if (modes.length === 1) { 471 if (modes.length === 1) {
472 addMode(modes[0], title); 472 addMode(modes[0], title);
473 } else { 473 } else {
474 for (var index = 0; index < modes.length; index++) 474 for (var index = 0; index < modes.length; index++)
475 addMode(modes[index], title + ' \u2013 ' + modes[index].title); 475 addMode(modes[index], title + ' \u2013 ' + modes[index].title);
476 } 476 }
477 } 477 }
478 478
479 /** 479 /**
480 * @param {!WebInspector.EmulatedDevice.Mode} mode 480 * @param {!Emulation.EmulatedDevice.Mode} mode
481 * @param {string} title 481 * @param {string} title
482 */ 482 */
483 function addMode(mode, title) { 483 function addMode(mode, title) {
484 contextMenu.appendCheckboxItem(title, applyMode.bind(null, mode), model.mo de() === mode, false); 484 contextMenu.appendCheckboxItem(title, applyMode.bind(null, mode), model.mo de() === mode, false);
485 } 485 }
486 486
487 /** 487 /**
488 * @param {!WebInspector.EmulatedDevice.Mode} mode 488 * @param {!Emulation.EmulatedDevice.Mode} mode
489 */ 489 */
490 function applyMode(mode) { 490 function applyMode(mode) {
491 model.emulate(model.type(), model.device(), mode); 491 model.emulate(model.type(), model.device(), mode);
492 } 492 }
493 } 493 }
494 494
495 /** 495 /**
496 * @return {!Element} 496 * @return {!Element}
497 */ 497 */
498 element() { 498 element() {
499 return this._element; 499 return this._element;
500 } 500 }
501 501
502 update() { 502 update() {
503 if (this._model.type() !== this._cachedModelType) { 503 if (this._model.type() !== this._cachedModelType) {
504 this._cachedModelType = this._model.type(); 504 this._cachedModelType = this._model.type();
505 this._widthInput.disabled = this._model.type() !== WebInspector.DeviceMode Model.Type.Responsive; 505 this._widthInput.disabled = this._model.type() !== Emulation.DeviceModeMod el.Type.Responsive;
506 this._heightInput.disabled = this._model.type() !== WebInspector.DeviceMod eModel.Type.Responsive; 506 this._heightInput.disabled = this._model.type() !== Emulation.DeviceModeMo del.Type.Responsive;
507 this._deviceScaleItem.setEnabled(this._model.type() === WebInspector.Devic eModeModel.Type.Responsive); 507 this._deviceScaleItem.setEnabled(this._model.type() === Emulation.DeviceMo deModel.Type.Responsive);
508 this._uaItem.setEnabled(this._model.type() === WebInspector.DeviceModeMode l.Type.Responsive); 508 this._uaItem.setEnabled(this._model.type() === Emulation.DeviceModeModel.T ype.Responsive);
509 } 509 }
510 510
511 var size = this._model.appliedDeviceSize(); 511 var size = this._model.appliedDeviceSize();
512 this._updateHeightInput( 512 this._updateHeightInput(
513 this._model.type() === WebInspector.DeviceModeModel.Type.Responsive && t his._model.isFullHeight() ? 513 this._model.type() === Emulation.DeviceModeModel.Type.Responsive && this ._model.isFullHeight() ?
514 '' : 514 '' :
515 String(size.height)); 515 String(size.height));
516 this._updateWidthInput(String(size.width)); 516 this._updateWidthInput(String(size.width));
517 this._heightInput.placeholder = size.height; 517 this._heightInput.placeholder = size.height;
518 518
519 if (this._model.scale() !== this._cachedScale) { 519 if (this._model.scale() !== this._cachedScale) {
520 this._scaleItem.setText(WebInspector.UIString('%.0f%%', this._model.scale( ) * 100)); 520 this._scaleItem.setText(Common.UIString('%.0f%%', this._model.scale() * 10 0));
521 this._cachedScale = this._model.scale(); 521 this._cachedScale = this._model.scale();
522 } 522 }
523 523
524 var deviceScale = this._model.appliedDeviceScaleFactor(); 524 var deviceScale = this._model.appliedDeviceScaleFactor();
525 if (deviceScale !== this._cachedDeviceScale) { 525 if (deviceScale !== this._cachedDeviceScale) {
526 this._deviceScaleItem.setText(WebInspector.UIString('DPR: %.1f', deviceSca le)); 526 this._deviceScaleItem.setText(Common.UIString('DPR: %.1f', deviceScale));
527 this._cachedDeviceScale = deviceScale; 527 this._cachedDeviceScale = deviceScale;
528 } 528 }
529 529
530 var uaType = this._model.appliedUserAgentType(); 530 var uaType = this._model.appliedUserAgentType();
531 if (uaType !== this._cachedUaType) { 531 if (uaType !== this._cachedUaType) {
532 this._uaItem.setText(uaType); 532 this._uaItem.setText(uaType);
533 this._cachedUaType = uaType; 533 this._cachedUaType = uaType;
534 } 534 }
535 535
536 var deviceItemTitle = WebInspector.UIString('None'); 536 var deviceItemTitle = Common.UIString('None');
537 if (this._model.type() === WebInspector.DeviceModeModel.Type.Responsive) 537 if (this._model.type() === Emulation.DeviceModeModel.Type.Responsive)
538 deviceItemTitle = WebInspector.UIString('Responsive'); 538 deviceItemTitle = Common.UIString('Responsive');
539 if (this._model.type() === WebInspector.DeviceModeModel.Type.Device) 539 if (this._model.type() === Emulation.DeviceModeModel.Type.Device)
540 deviceItemTitle = this._model.device().title; 540 deviceItemTitle = this._model.device().title;
541 this._deviceSelectItem.setText(deviceItemTitle); 541 this._deviceSelectItem.setText(deviceItemTitle);
542 542
543 if (this._model.device() !== this._cachedModelDevice) { 543 if (this._model.device() !== this._cachedModelDevice) {
544 var device = this._model.device(); 544 var device = this._model.device();
545 this._modeButton.setVisible(!!device); 545 this._modeButton.setVisible(!!device);
546 if (device) { 546 if (device) {
547 var modeCount = device ? device.modes.length : 0; 547 var modeCount = device ? device.modes.length : 0;
548 this._modeButton.setEnabled(modeCount >= 2); 548 this._modeButton.setEnabled(modeCount >= 2);
549 this._modeButton.setTitle( 549 this._modeButton.setTitle(
550 modeCount === 2 ? WebInspector.UIString('Rotate') : WebInspector.UIS tring('Screen options')); 550 modeCount === 2 ? Common.UIString('Rotate') : Common.UIString('Scree n options'));
551 } 551 }
552 this._cachedModelDevice = device; 552 this._cachedModelDevice = device;
553 } 553 }
554 554
555 if (this._model.type() === WebInspector.DeviceModeModel.Type.Device) 555 if (this._model.type() === Emulation.DeviceModeModel.Type.Device)
556 this._lastMode.set( 556 this._lastMode.set(
557 /** @type {!WebInspector.EmulatedDevice} */ (this._model.device()), 557 /** @type {!Emulation.EmulatedDevice} */ (this._model.device()),
558 /** @type {!WebInspector.EmulatedDevice.Mode} */ (this._model.mode())) ; 558 /** @type {!Emulation.EmulatedDevice.Mode} */ (this._model.mode()));
559 559
560 if (this._model.mode() !== this._cachedModelMode && this._model.type() !== W ebInspector.DeviceModeModel.Type.None) { 560 if (this._model.mode() !== this._cachedModelMode && this._model.type() !== E mulation.DeviceModeModel.Type.None) {
561 this._cachedModelMode = this._model.mode(); 561 this._cachedModelMode = this._model.mode();
562 var value = this._persistenceSetting.get(); 562 var value = this._persistenceSetting.get();
563 if (this._model.device()) { 563 if (this._model.device()) {
564 value.device = this._model.device().title; 564 value.device = this._model.device().title;
565 value.orientation = this._model.mode() ? this._model.mode().orientation : ''; 565 value.orientation = this._model.mode() ? this._model.mode().orientation : '';
566 value.mode = this._model.mode() ? this._model.mode().title : ''; 566 value.mode = this._model.mode() ? this._model.mode().title : '';
567 } else { 567 } else {
568 value.device = ''; 568 value.device = '';
569 value.orientation = ''; 569 value.orientation = '';
570 value.mode = ''; 570 value.mode = '';
571 } 571 }
572 this._persistenceSetting.set(value); 572 this._persistenceSetting.set(value);
573 } 573 }
574 } 574 }
575 575
576 restore() { 576 restore() {
577 for (var device of this._allDevices()) { 577 for (var device of this._allDevices()) {
578 if (device.title === this._persistenceSetting.get().device) { 578 if (device.title === this._persistenceSetting.get().device) {
579 for (var mode of device.modes) { 579 for (var mode of device.modes) {
580 if (mode.orientation === this._persistenceSetting.get().orientation && 580 if (mode.orientation === this._persistenceSetting.get().orientation &&
581 mode.title === this._persistenceSetting.get().mode) { 581 mode.title === this._persistenceSetting.get().mode) {
582 this._lastMode.set(device, mode); 582 this._lastMode.set(device, mode);
583 this._emulateDevice(device); 583 this._emulateDevice(device);
584 return; 584 return;
585 } 585 }
586 } 586 }
587 } 587 }
588 } 588 }
589 589
590 this._model.emulate(WebInspector.DeviceModeModel.Type.Responsive, null, null ); 590 this._model.emulate(Emulation.DeviceModeModel.Type.Responsive, null, null);
591 } 591 }
592 }; 592 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698