Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: Source/devtools/front_end/emulation/DeviceModeButton.js

Issue 1205083002: [DevTools] Show warning on device mode button when network throttling is enabled. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698