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

Unified Diff: Source/devtools/front_end/main/AdvancedApp.js

Issue 405803004: [DevTools] Move device mode button to AdvancedApp and add shortcut. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/devtools/front_end/main/App.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/main/AdvancedApp.js
diff --git a/Source/devtools/front_end/main/AdvancedApp.js b/Source/devtools/front_end/main/AdvancedApp.js
index 30aee9156f90f269dd764102d65748bb338a1027..1190f6cdc4a4dfcb943282402784d0f93771c93c 100644
--- a/Source/devtools/front_end/main/AdvancedApp.js
+++ b/Source/devtools/front_end/main/AdvancedApp.js
@@ -9,10 +9,38 @@
WebInspector.AdvancedApp = function()
{
WebInspector.App.call(this);
+ if (WebInspector.overridesSupport.responsiveDesignAvailable()) {
+ this._toggleEmulationButton = new WebInspector.StatusBarButton(WebInspector.UIString("Toggle device mode."), "emulation-status-bar-item");
+ this._toggleEmulationButton.toggled = WebInspector.overridesSupport.emulationEnabled();
+ this._toggleEmulationButton.addEventListener("click", this._toggleEmulationEnabled, this);
+ WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport.Events.EmulationStateChanged, this._emulationEnabledChanged, this);
+ WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport.Events.OverridesWarningUpdated, this._overridesWarningUpdated, this);
+ }
WebInspector.dockController.addEventListener(WebInspector.DockController.Events.BeforeDockSideChanged, this._openToolboxWindow, this);
};
WebInspector.AdvancedApp.prototype = {
+ _toggleEmulationEnabled: function()
+ {
+ WebInspector.overridesSupport.setEmulationEnabled(!this._toggleEmulationButton.toggled);
+ },
+
+ _emulationEnabledChanged: function()
+ {
+ this._toggleEmulationButton.toggled = WebInspector.overridesSupport.emulationEnabled();
+ if (!WebInspector.overridesSupport.responsiveDesignAvailable() && WebInspector.overridesSupport.emulationEnabled())
+ WebInspector.inspectorView.showViewInDrawer("emulation", true);
+ },
+
+ _overridesWarningUpdated: function()
+ {
+ if (!this._toggleEmulationButton)
+ return;
+ var message = WebInspector.overridesSupport.warningMessage();
+ this._toggleEmulationButton.title = message || WebInspector.UIString("Toggle device mode.");
+ this._toggleEmulationButton.element.classList.toggle("warning", !!message);
+ },
+
createRootView: function()
{
var rootView = new WebInspector.RootView();
@@ -38,6 +66,15 @@ WebInspector.AdvancedApp.prototype = {
},
/**
+ * @param {!WebInspector.Target} mainTarget
+ */
+ presentUI: function(mainTarget)
+ {
+ WebInspector.App.prototype.presentUI.call(this, mainTarget);
+ this._overridesWarningUpdated();
+ },
+
+ /**
* @param {!WebInspector.Event} event
*/
_openToolboxWindow: function(event)
@@ -188,3 +225,46 @@ WebInspector.Toolbox = function()
rootView.attachToBody();
advancedApp._toolboxLoaded(this);
}
+
+/**
+ * @constructor
+ * @implements {WebInspector.StatusBarButton.Provider}
+ */
+WebInspector.AdvancedApp.EmulationButtonProvider = function()
+{
+}
+
+WebInspector.AdvancedApp.EmulationButtonProvider.prototype = {
+ /**
+ * @return {?WebInspector.StatusBarButton}
+ */
+ button: function()
+ {
+ if (!(WebInspector.app instanceof WebInspector.AdvancedApp))
+ return null;
+ return WebInspector.app._toggleEmulationButton || null;
+ }
+}
+
+/**
+ * @constructor
+ * @implements {WebInspector.ActionDelegate}
+ */
+WebInspector.AdvancedApp.ToggleDeviceModeActionDelegate = function()
+{
+}
+
+WebInspector.AdvancedApp.ToggleDeviceModeActionDelegate.prototype = {
+ /**
+ * @return {boolean}
+ */
+ handleAction: function()
+ {
+ if (!WebInspector.overridesSupport.responsiveDesignAvailable())
+ return false;
+ if (!(WebInspector.app instanceof WebInspector.AdvancedApp))
+ return false;
+ WebInspector.app._toggleEmulationEnabled();
+ return true;
+ }
+}
« no previous file with comments | « no previous file | Source/devtools/front_end/main/App.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698