Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / devtools / front_end / emulation / DeviceModeButton.js
blobec6f8db6902bc6bc12b058f75eb37ec8e779cb32
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.
5 /**
6 * @constructor
7 * @implements {WebInspector.ToolbarItem.Provider}
8 */
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();
17 updateWarning();
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 = {
35 /**
36 * @override
37 * @return {?WebInspector.ToolbarItem}
39 item: function()
41 return this._button;
45 /**
46 * @constructor
47 * @implements {WebInspector.ActionDelegate}
49 WebInspector.ToggleDeviceModeActionDelegate = function()
53 WebInspector.ToggleDeviceModeActionDelegate.prototype = {
54 /**
55 * @override
56 * @param {!WebInspector.Context} context
57 * @param {string} actionId
59 handleAction: function(context, actionId)
61 WebInspector.overridesSupport.setEmulationEnabled(!WebInspector.overridesSupport.emulationEnabled());