| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.ToolbarItem.Provider} | 7 * @implements {WebInspector.ToolbarItem.Provider} |
| 8 */ | 8 */ |
| 9 WebInspector.DeviceModeButtonProvider = function() | 9 WebInspector.DeviceModeButtonProvider = function() |
| 10 { | 10 { |
| 11 var button = new WebInspector.ToolbarButton(WebInspector.UIString("Toggle de
vice mode"), "emulation-toolbar-item"); | 11 var button = new WebInspector.ToolbarButton(WebInspector.UIString("Toggle de
vice mode"), "emulation-toolbar-item"); |
| 12 button.addEventListener("click", toggleEmulationEnabled); | 12 button.addEventListener("click", toggleEmulationEnabled); |
| 13 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport
.Events.EmulationStateChanged, emulationEnabledChanged); | 13 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport
.Events.EmulationStateChanged, emulationEnabledChanged); |
| 14 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport
.Events.OverridesWarningUpdated, overridesWarningUpdated); | 14 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport
.Events.OverridesWarningUpdated, updateWarning); |
| 15 var networkConditionsSetting = WebInspector.moduleSetting("networkConditions
"); |
| 16 networkConditionsSetting.addChangeListener(updateWarning); |
| 17 |
| 15 emulationEnabledChanged(); | 18 emulationEnabledChanged(); |
| 16 overridesWarningUpdated(); | 19 updateWarning(); |
| 17 | 20 |
| 18 function toggleEmulationEnabled() | 21 function toggleEmulationEnabled() |
| 19 { | 22 { |
| 20 WebInspector.overridesSupport.setEmulationEnabled(!button.toggled()); | 23 WebInspector.overridesSupport.setEmulationEnabled(!button.toggled()); |
| 21 } | 24 } |
| 22 | 25 |
| 23 function emulationEnabledChanged() | 26 function emulationEnabledChanged() |
| 24 { | 27 { |
| 25 button.setToggled(WebInspector.overridesSupport.emulationEnabled()); | 28 button.setToggled(WebInspector.overridesSupport.emulationEnabled()); |
| 26 } | 29 } |
| 27 | 30 |
| 28 function overridesWarningUpdated() | 31 function updateWarning() |
| 29 { | 32 { |
| 30 var message = WebInspector.overridesSupport.warningMessage(); | 33 var message = WebInspector.overridesSupport.warningMessage(); |
| 34 if (!message && networkConditionsSetting.get().throughput >= 0) |
| 35 message = WebInspector.UIString("Network throttling is enabled"); |
| 31 button.setTitle(message || WebInspector.UIString("Toggle device mode")); | 36 button.setTitle(message || WebInspector.UIString("Toggle device mode")); |
| 32 button.element.classList.toggle("warning", !!message); | 37 button.element.classList.toggle("warning", !!message); |
| 33 } | 38 } |
| 34 | 39 |
| 35 this._button = button; | 40 this._button = button; |
| 36 } | 41 } |
| 37 | 42 |
| 38 WebInspector.DeviceModeButtonProvider.prototype = { | 43 WebInspector.DeviceModeButtonProvider.prototype = { |
| 39 /** | 44 /** |
| 40 * @override | 45 * @override |
| (...skipping 17 matching lines...) Expand all Loading... |
| 58 /** | 63 /** |
| 59 * @override | 64 * @override |
| 60 * @param {!WebInspector.Context} context | 65 * @param {!WebInspector.Context} context |
| 61 * @param {string} actionId | 66 * @param {string} actionId |
| 62 */ | 67 */ |
| 63 handleAction: function(context, actionId) | 68 handleAction: function(context, actionId) |
| 64 { | 69 { |
| 65 WebInspector.overridesSupport.setEmulationEnabled(!WebInspector.override
sSupport.emulationEnabled()); | 70 WebInspector.overridesSupport.setEmulationEnabled(!WebInspector.override
sSupport.emulationEnabled()); |
| 66 } | 71 } |
| 67 } | 72 } |
| OLD | NEW |