| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * @constructor | |
| 7 * @implements {WebInspector.ToolbarItem.Provider} | |
| 8 */ | |
| 9 WebInspector.DeviceModeButtonProvider = function() | |
| 10 { | |
| 11 var action = WebInspector.actionRegistry.action("emulation.toggle-device-mod
e"); | |
| 12 var button = WebInspector.Toolbar.createActionButton(action); | |
| 13 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport
.Events.EmulationStateChanged, emulationEnabledChanged); | |
| 14 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport
.Events.OverridesWarningUpdated, updateWarning); | |
| 15 | |
| 16 emulationEnabledChanged(); | |
| 17 updateWarning(); | |
| 18 | |
| 19 function emulationEnabledChanged() | |
| 20 { | |
| 21 action.setToggled(WebInspector.overridesSupport.emulationEnabled()); | |
| 22 } | |
| 23 | |
| 24 function updateWarning() | |
| 25 { | |
| 26 var message = WebInspector.overridesSupport.warningMessage(); | |
| 27 action.setTitle(message || WebInspector.UIString("Toggle device mode")); | |
| 28 button.element.classList.toggle("warning", !!message); | |
| 29 } | |
| 30 | |
| 31 this._button = button; | |
| 32 } | |
| 33 | |
| 34 WebInspector.DeviceModeButtonProvider.prototype = { | |
| 35 /** | |
| 36 * @override | |
| 37 * @return {?WebInspector.ToolbarItem} | |
| 38 */ | |
| 39 item: function() | |
| 40 { | |
| 41 return this._button; | |
| 42 } | |
| 43 } | |
| 44 | |
| 45 /** | |
| 46 * @constructor | |
| 47 * @implements {WebInspector.ActionDelegate} | |
| 48 */ | |
| 49 WebInspector.ToggleDeviceModeActionDelegate = function() | |
| 50 { | |
| 51 } | |
| 52 | |
| 53 WebInspector.ToggleDeviceModeActionDelegate.prototype = { | |
| 54 /** | |
| 55 * @override | |
| 56 * @param {!WebInspector.Context} context | |
| 57 * @param {string} actionId | |
| 58 * @return {boolean} | |
| 59 */ | |
| 60 handleAction: function(context, actionId) | |
| 61 { | |
| 62 WebInspector.overridesSupport.setEmulationEnabled(!WebInspector.override
sSupport.emulationEnabled()); | |
| 63 return true; | |
| 64 } | |
| 65 } | |
| OLD | NEW |