OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 * @extends {WebInspector.App} | 7 * @extends {WebInspector.App} |
8 */ | 8 */ |
9 WebInspector.AdvancedApp = function() | 9 WebInspector.AdvancedApp = function() |
10 { | 10 { |
11 WebInspector.App.call(this); | 11 WebInspector.App.call(this); |
| 12 if (WebInspector.overridesSupport.responsiveDesignAvailable()) { |
| 13 this._toggleEmulationButton = new WebInspector.StatusBarButton(WebInspec
tor.UIString("Toggle device mode."), "emulation-status-bar-item"); |
| 14 this._toggleEmulationButton.toggled = WebInspector.overridesSupport.emul
ationEnabled(); |
| 15 this._toggleEmulationButton.addEventListener("click", this._toggleEmulat
ionEnabled, this); |
| 16 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSup
port.Events.EmulationStateChanged, this._emulationEnabledChanged, this); |
| 17 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSup
port.Events.OverridesWarningUpdated, this._overridesWarningUpdated, this); |
| 18 } |
12 WebInspector.dockController.addEventListener(WebInspector.DockController.Eve
nts.BeforeDockSideChanged, this._openToolboxWindow, this); | 19 WebInspector.dockController.addEventListener(WebInspector.DockController.Eve
nts.BeforeDockSideChanged, this._openToolboxWindow, this); |
13 }; | 20 }; |
14 | 21 |
15 WebInspector.AdvancedApp.prototype = { | 22 WebInspector.AdvancedApp.prototype = { |
| 23 _toggleEmulationEnabled: function() |
| 24 { |
| 25 WebInspector.overridesSupport.setEmulationEnabled(!this._toggleEmulation
Button.toggled); |
| 26 }, |
| 27 |
| 28 _emulationEnabledChanged: function() |
| 29 { |
| 30 this._toggleEmulationButton.toggled = WebInspector.overridesSupport.emul
ationEnabled(); |
| 31 if (!WebInspector.overridesSupport.responsiveDesignAvailable() && WebIns
pector.overridesSupport.emulationEnabled()) |
| 32 WebInspector.inspectorView.showViewInDrawer("emulation", true); |
| 33 }, |
| 34 |
| 35 _overridesWarningUpdated: function() |
| 36 { |
| 37 if (!this._toggleEmulationButton) |
| 38 return; |
| 39 var message = WebInspector.overridesSupport.warningMessage(); |
| 40 this._toggleEmulationButton.title = message || WebInspector.UIString("To
ggle device mode."); |
| 41 this._toggleEmulationButton.element.classList.toggle("warning", !!messag
e); |
| 42 }, |
| 43 |
16 createRootView: function() | 44 createRootView: function() |
17 { | 45 { |
18 var rootView = new WebInspector.RootView(); | 46 var rootView = new WebInspector.RootView(); |
19 | 47 |
20 this._rootSplitView = new WebInspector.SplitView(false, true, "Inspector
View.splitViewState", 300, 300, true); | 48 this._rootSplitView = new WebInspector.SplitView(false, true, "Inspector
View.splitViewState", 300, 300, true); |
21 this._rootSplitView.show(rootView.element); | 49 this._rootSplitView.show(rootView.element); |
22 | 50 |
23 WebInspector.inspectorView.show(this._rootSplitView.sidebarElement()); | 51 WebInspector.inspectorView.show(this._rootSplitView.sidebarElement()); |
24 | 52 |
25 this._inspectedPagePlaceholder = new WebInspector.InspectedPagePlacehold
er(); | 53 this._inspectedPagePlaceholder = new WebInspector.InspectedPagePlacehold
er(); |
26 this._inspectedPagePlaceholder.addEventListener(WebInspector.InspectedPa
gePlaceholder.Events.Update, this._onSetInspectedPageBounds.bind(this, false), t
his); | 54 this._inspectedPagePlaceholder.addEventListener(WebInspector.InspectedPa
gePlaceholder.Events.Update, this._onSetInspectedPageBounds.bind(this, false), t
his); |
27 this._responsiveDesignView = new WebInspector.ResponsiveDesignView(this.
_inspectedPagePlaceholder); | 55 this._responsiveDesignView = new WebInspector.ResponsiveDesignView(this.
_inspectedPagePlaceholder); |
28 this._responsiveDesignView.show(this._rootSplitView.mainElement()); | 56 this._responsiveDesignView.show(this._rootSplitView.mainElement()); |
29 | 57 |
30 WebInspector.dockController.addEventListener(WebInspector.DockController
.Events.BeforeDockSideChanged, this._onBeforeDockSideChange, this); | 58 WebInspector.dockController.addEventListener(WebInspector.DockController
.Events.BeforeDockSideChanged, this._onBeforeDockSideChange, this); |
31 WebInspector.dockController.addEventListener(WebInspector.DockController
.Events.DockSideChanged, this._onDockSideChange, this); | 59 WebInspector.dockController.addEventListener(WebInspector.DockController
.Events.DockSideChanged, this._onDockSideChange, this); |
32 WebInspector.dockController.addEventListener(WebInspector.DockController
.Events.AfterDockSideChanged, this._onAfterDockSideChange, this); | 60 WebInspector.dockController.addEventListener(WebInspector.DockController
.Events.AfterDockSideChanged, this._onAfterDockSideChange, this); |
33 this._onDockSideChange(); | 61 this._onDockSideChange(); |
34 | 62 |
35 console.timeStamp("AdvancedApp.attachToBody"); | 63 console.timeStamp("AdvancedApp.attachToBody"); |
36 rootView.attachToBody(); | 64 rootView.attachToBody(); |
37 this._inspectedPagePlaceholder.update(); | 65 this._inspectedPagePlaceholder.update(); |
38 }, | 66 }, |
39 | 67 |
40 /** | 68 /** |
| 69 * @param {!WebInspector.Target} mainTarget |
| 70 */ |
| 71 presentUI: function(mainTarget) |
| 72 { |
| 73 WebInspector.App.prototype.presentUI.call(this, mainTarget); |
| 74 this._overridesWarningUpdated(); |
| 75 }, |
| 76 |
| 77 /** |
41 * @param {!WebInspector.Event} event | 78 * @param {!WebInspector.Event} event |
42 */ | 79 */ |
43 _openToolboxWindow: function(event) | 80 _openToolboxWindow: function(event) |
44 { | 81 { |
45 if (/** @type {string} */ (event.data.to) !== WebInspector.DockControlle
r.State.Undocked) | 82 if (/** @type {string} */ (event.data.to) !== WebInspector.DockControlle
r.State.Undocked) |
46 return; | 83 return; |
47 | 84 |
48 if (this._toolboxWindow) | 85 if (this._toolboxWindow) |
49 return; | 86 return; |
50 | 87 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 218 |
182 var advancedApp = /** @type {!WebInspector.AdvancedApp} */ (window.opener.We
bInspector.app); | 219 var advancedApp = /** @type {!WebInspector.AdvancedApp} */ (window.opener.We
bInspector.app); |
183 var rootView = new WebInspector.RootView(); | 220 var rootView = new WebInspector.RootView(); |
184 this._inspectedPagePlaceholder = new WebInspector.InspectedPagePlaceholder()
; | 221 this._inspectedPagePlaceholder = new WebInspector.InspectedPagePlaceholder()
; |
185 this._inspectedPagePlaceholder.addEventListener(WebInspector.InspectedPagePl
aceholder.Events.Update, advancedApp._onSetInspectedPageBounds.bind(advancedApp,
true)); | 222 this._inspectedPagePlaceholder.addEventListener(WebInspector.InspectedPagePl
aceholder.Events.Update, advancedApp._onSetInspectedPageBounds.bind(advancedApp,
true)); |
186 this._responsiveDesignView = new WebInspector.ResponsiveDesignView(this._ins
pectedPagePlaceholder); | 223 this._responsiveDesignView = new WebInspector.ResponsiveDesignView(this._ins
pectedPagePlaceholder); |
187 this._responsiveDesignView.show(rootView.element); | 224 this._responsiveDesignView.show(rootView.element); |
188 rootView.attachToBody(); | 225 rootView.attachToBody(); |
189 advancedApp._toolboxLoaded(this); | 226 advancedApp._toolboxLoaded(this); |
190 } | 227 } |
| 228 |
| 229 /** |
| 230 * @constructor |
| 231 * @implements {WebInspector.StatusBarButton.Provider} |
| 232 */ |
| 233 WebInspector.AdvancedApp.EmulationButtonProvider = function() |
| 234 { |
| 235 } |
| 236 |
| 237 WebInspector.AdvancedApp.EmulationButtonProvider.prototype = { |
| 238 /** |
| 239 * @return {?WebInspector.StatusBarButton} |
| 240 */ |
| 241 button: function() |
| 242 { |
| 243 if (!(WebInspector.app instanceof WebInspector.AdvancedApp)) |
| 244 return null; |
| 245 return WebInspector.app._toggleEmulationButton || null; |
| 246 } |
| 247 } |
| 248 |
| 249 /** |
| 250 * @constructor |
| 251 * @implements {WebInspector.ActionDelegate} |
| 252 */ |
| 253 WebInspector.AdvancedApp.ToggleDeviceModeActionDelegate = function() |
| 254 { |
| 255 } |
| 256 |
| 257 WebInspector.AdvancedApp.ToggleDeviceModeActionDelegate.prototype = { |
| 258 /** |
| 259 * @return {boolean} |
| 260 */ |
| 261 handleAction: function() |
| 262 { |
| 263 if (!WebInspector.overridesSupport.responsiveDesignAvailable()) |
| 264 return false; |
| 265 if (!(WebInspector.app instanceof WebInspector.AdvancedApp)) |
| 266 return false; |
| 267 WebInspector.app._toggleEmulationEnabled(); |
| 268 return true; |
| 269 } |
| 270 } |
OLD | NEW |