| 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 * @implements {WebInspector.Console.UIDelegate} | 7 * @implements {WebInspector.Console.UIDelegate} |
| 8 */ | 8 */ |
| 9 WebInspector.App = function() | 9 WebInspector.App = function() |
| 10 { | 10 { |
| 11 if (WebInspector.overridesSupport.responsiveDesignAvailable()) { | |
| 12 this._toggleEmulationButton = new WebInspector.StatusBarButton(WebInspec
tor.UIString("Toggle device mode."), "emulation-status-bar-item"); | |
| 13 this._toggleEmulationButton.toggled = WebInspector.overridesSupport.emul
ationEnabled(); | |
| 14 this._toggleEmulationButton.addEventListener("click", this._toggleEmulat
ionEnabled, this); | |
| 15 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSup
port.Events.EmulationStateChanged, this._emulationEnabledChanged, this); | |
| 16 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSup
port.Events.OverridesWarningUpdated, this._overridesWarningUpdated, this); | |
| 17 } | |
| 18 WebInspector.console.setUIDelegate(this); | 11 WebInspector.console.setUIDelegate(this); |
| 19 }; | 12 }; |
| 20 | 13 |
| 21 WebInspector.App.prototype = { | 14 WebInspector.App.prototype = { |
| 22 _toggleEmulationEnabled: function() | |
| 23 { | |
| 24 WebInspector.overridesSupport.setEmulationEnabled(!this._toggleEmulation
Button.toggled); | |
| 25 }, | |
| 26 | |
| 27 _emulationEnabledChanged: function() | |
| 28 { | |
| 29 this._toggleEmulationButton.toggled = WebInspector.overridesSupport.emul
ationEnabled(); | |
| 30 if (!WebInspector.overridesSupport.responsiveDesignAvailable() && WebIns
pector.overridesSupport.emulationEnabled()) | |
| 31 WebInspector.inspectorView.showViewInDrawer("emulation", true); | |
| 32 }, | |
| 33 | |
| 34 _overridesWarningUpdated: function() | |
| 35 { | |
| 36 if (!this._toggleEmulationButton) | |
| 37 return; | |
| 38 var message = WebInspector.overridesSupport.warningMessage(); | |
| 39 this._toggleEmulationButton.title = message || WebInspector.UIString("To
ggle device mode."); | |
| 40 this._toggleEmulationButton.element.classList.toggle("warning", !!messag
e); | |
| 41 }, | |
| 42 | |
| 43 createRootView: function() | 15 createRootView: function() |
| 44 { | 16 { |
| 45 }, | 17 }, |
| 46 | 18 |
| 47 /** | 19 /** |
| 48 * @param {!WebInspector.Target} mainTarget | 20 * @param {!WebInspector.Target} mainTarget |
| 49 */ | 21 */ |
| 50 presentUI: function(mainTarget) | 22 presentUI: function(mainTarget) |
| 51 { | 23 { |
| 52 WebInspector.inspectorView.showInitialPanel(); | 24 WebInspector.inspectorView.showInitialPanel(); |
| 53 | 25 |
| 54 WebInspector.overridesSupport.applyInitialOverrides(); | 26 WebInspector.overridesSupport.applyInitialOverrides(); |
| 55 if (!WebInspector.overridesSupport.responsiveDesignAvailable() && WebIns
pector.overridesSupport.emulationEnabled()) | 27 if (!WebInspector.overridesSupport.responsiveDesignAvailable() && WebIns
pector.overridesSupport.emulationEnabled()) |
| 56 WebInspector.inspectorView.showViewInDrawer("emulation", true); | 28 WebInspector.inspectorView.showViewInDrawer("emulation", true); |
| 57 this._overridesWarningUpdated(); | |
| 58 }, | 29 }, |
| 59 | 30 |
| 60 showConsole: function() | 31 showConsole: function() |
| 61 { | 32 { |
| 62 WebInspector.Revealer.reveal(WebInspector.console); | 33 WebInspector.Revealer.reveal(WebInspector.console); |
| 63 } | 34 } |
| 64 }; | 35 }; |
| 65 | 36 |
| 66 /** | 37 /** |
| 67 * @constructor | |
| 68 * @implements {WebInspector.StatusBarButton.Provider} | |
| 69 */ | |
| 70 WebInspector.App.EmulationButtonProvider = function() | |
| 71 { | |
| 72 } | |
| 73 | |
| 74 WebInspector.App.EmulationButtonProvider.prototype = { | |
| 75 /** | |
| 76 * @return {?WebInspector.StatusBarButton} | |
| 77 */ | |
| 78 button: function() | |
| 79 { | |
| 80 if (!(WebInspector.app instanceof WebInspector.App)) | |
| 81 return null; | |
| 82 return WebInspector.app._toggleEmulationButton || null; | |
| 83 } | |
| 84 } | |
| 85 | |
| 86 /** | |
| 87 * @type {!WebInspector.App} | 38 * @type {!WebInspector.App} |
| 88 */ | 39 */ |
| 89 WebInspector.app; | 40 WebInspector.app; |
| OLD | NEW |