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.
7 * @implements {WebInspector.ToolbarItem.Provider}
9 WebInspector
.DeviceModeButtonProvider = function()
11 var button
= new WebInspector
.ToolbarButton(WebInspector
.UIString("Toggle device mode"), "emulation-toolbar-item");
12 button
.setAction("emulation.toggle-device-mode");
13 WebInspector
.overridesSupport
.addEventListener(WebInspector
.OverridesSupport
.Events
.EmulationStateChanged
, emulationEnabledChanged
);
14 WebInspector
.overridesSupport
.addEventListener(WebInspector
.OverridesSupport
.Events
.OverridesWarningUpdated
, updateWarning
);
16 emulationEnabledChanged();
19 function emulationEnabledChanged()
21 button
.setToggled(WebInspector
.overridesSupport
.emulationEnabled());
24 function updateWarning()
26 var message
= WebInspector
.overridesSupport
.warningMessage();
27 button
.setTitle(message
|| WebInspector
.UIString("Toggle device mode"));
28 button
.element
.classList
.toggle("warning", !!message
);
31 this._button
= button
;
34 WebInspector
.DeviceModeButtonProvider
.prototype = {
37 * @return {?WebInspector.ToolbarItem}
47 * @implements {WebInspector.ActionDelegate}
49 WebInspector
.ToggleDeviceModeActionDelegate = function()
53 WebInspector
.ToggleDeviceModeActionDelegate
.prototype = {
56 * @param {!WebInspector.Context} context
57 * @param {string} actionId
59 handleAction: function(context
, actionId
)
61 WebInspector
.overridesSupport
.setEmulationEnabled(!WebInspector
.overridesSupport
.emulationEnabled());