Web Inspector: [Overrides] Do not persist the User Agent "master switch"
authorapavlov@chromium.org <apavlov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Oct 2012 11:55:53 +0000 (11:55 +0000)
committerapavlov@chromium.org <apavlov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Oct 2012 11:55:53 +0000 (11:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=100484

Reviewed by Yury Semikhatsky.

The User Agent override state is managed in the front-end, just like for other override-able parameters.

* inspector/InspectorResourceAgent.cpp:
(WebCore::InspectorResourceAgent::disable):
* inspector/front-end/NetworkManager.js:
(WebInspector.NetworkManager.get NetworkAgent):
(WebInspector.NetworkManager):
* inspector/front-end/SettingsScreen.js:
(WebInspector.UserAgentSettingsTab.prototype._createUserAgentSelectRowElement.set checkboxClicked):
(WebInspector.UserAgentSettingsTab.prototype._createUserAgentSelectRowElement):
* inspector/front-end/UserAgentSupport.js:
(WebInspector.UserAgentSupport):
(WebInspector.UserAgentSupport.prototype.toggleUserAgentOverride):
(WebInspector.UserAgentSupport.prototype._userAgentChanged):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@132623 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorResourceAgent.cpp
Source/WebCore/inspector/front-end/NetworkManager.js
Source/WebCore/inspector/front-end/SettingsScreen.js
Source/WebCore/inspector/front-end/UserAgentSupport.js

index d101ada..e2cbcdc 100644 (file)
@@ -1,3 +1,25 @@
+2012-10-26  Alexander Pavlov  <apavlov@chromium.org>
+
+        Web Inspector: [Overrides] Do not persist the User Agent "master switch"
+        https://bugs.webkit.org/show_bug.cgi?id=100484
+
+        Reviewed by Yury Semikhatsky.
+
+        The User Agent override state is managed in the front-end, just like for other override-able parameters.
+
+        * inspector/InspectorResourceAgent.cpp:
+        (WebCore::InspectorResourceAgent::disable):
+        * inspector/front-end/NetworkManager.js:
+        (WebInspector.NetworkManager.get NetworkAgent):
+        (WebInspector.NetworkManager):
+        * inspector/front-end/SettingsScreen.js:
+        (WebInspector.UserAgentSettingsTab.prototype._createUserAgentSelectRowElement.set checkboxClicked):
+        (WebInspector.UserAgentSettingsTab.prototype._createUserAgentSelectRowElement):
+        * inspector/front-end/UserAgentSupport.js:
+        (WebInspector.UserAgentSupport):
+        (WebInspector.UserAgentSupport.prototype.toggleUserAgentOverride):
+        (WebInspector.UserAgentSupport.prototype._userAgentChanged):
+
 2012-10-26  Takashi Sakamoto  <tasak@google.com>
 
         [Shadow]: removing styles in shadow dom subtree causes crash.
index 8d15b8e..5af0895 100644 (file)
@@ -570,6 +570,7 @@ void InspectorResourceAgent::enable()
 void InspectorResourceAgent::disable(ErrorString*)
 {
     m_state->setBoolean(ResourceAgentState::resourceAgentEnabled, false);
+    m_state->setString(ResourceAgentState::userAgentOverride, "");
     m_instrumentingAgents->setInspectorResourceAgent(0);
     m_resourcesData->clear();
 }
index 93cd1ba..ad01286 100644 (file)
@@ -42,10 +42,6 @@ WebInspector.NetworkManager = function()
     NetworkAgent.enable();
 
     WebInspector.settings.cacheDisabled.addChangeListener(this._cacheDisabledSettingChanged, this);
-
-    if (WebInspector.settings.userAgent.get())
-        this._userAgentSettingChanged();
-    WebInspector.settings.userAgent.addChangeListener(this._userAgentSettingChanged, this);
 }
 
 WebInspector.NetworkManager.EventTypes = {
@@ -112,11 +108,6 @@ WebInspector.NetworkManager.prototype = {
         NetworkAgent.setCacheDisabled(enabled);
     },
 
-    _userAgentSettingChanged: function()
-    {
-        NetworkAgent.setUserAgentOverride(WebInspector.settings.userAgent.get());
-    },
-
     __proto__: WebInspector.Object.prototype
 }
 
index c70e74d..db7e45e 100644 (file)
@@ -406,7 +406,7 @@ WebInspector.UserAgentSettingsTab.prototype = {
         var labelElement = p.createChild("label");
         var checkboxElement = labelElement.createChild("input");
         checkboxElement.type = "checkbox";
-        checkboxElement.checked = !!userAgent;
+        checkboxElement.checked = false;
         labelElement.appendChild(document.createTextNode(WebInspector.UIString("User Agent")));
         p.appendChild(this._createUserAgentSelectRowElement(checkboxElement));
         return p;
@@ -496,8 +496,8 @@ WebInspector.UserAgentSettingsTab.prototype = {
             } else {
                 this._selectElement.disabled = true;
                 this._otherUserAgentElement.disabled = true;
-                WebInspector.settings.userAgent.set("");
             }
+            WebInspector.userAgentSupport.toggleUserAgentOverride(checkboxElement.checked);
         }
         checkboxElement.addEventListener("click", checkboxClicked.bind(this), false);
 
index b3edc66..4859f65 100644 (file)
  */
 WebInspector.UserAgentSupport = function()
 {
+    this._userAgentOverrideEnabled = false;
     this._deviceMetricsOverrideEnabled = false;
     this._geolocationPositionOverrideEnabled = false;
     this._deviceOrientationOverrideEnabled = false;
 
+    WebInspector.settings.userAgent.addChangeListener(this._userAgentChanged, this);
     WebInspector.settings.deviceMetrics.addChangeListener(this._deviceMetricsChanged, this);
     WebInspector.settings.deviceFitWindow.addChangeListener(this._deviceMetricsChanged, this);
     WebInspector.settings.geolocationOverride.addChangeListener(this._geolocationPositionChanged, this);
@@ -307,6 +309,14 @@ WebInspector.UserAgentSupport.DeviceOrientation.clearDeviceOrientationOverride =
 }
 
 WebInspector.UserAgentSupport.prototype = {
+    toggleUserAgentOverride: function(enabled)
+    {
+        if (enabled === this._userAgentOverrideEnabled)
+            return;
+        this._userAgentOverrideEnabled = enabled;
+        this._userAgentChanged();
+    },
+
     toggleDeviceMetricsOverride: function(enabled)
     {
         if (enabled === this._deviceMetricsOverrideEnabled)
@@ -331,6 +341,11 @@ WebInspector.UserAgentSupport.prototype = {
         this._deviceOrientationChanged();
     },
 
+    _userAgentChanged: function()
+    {
+        NetworkAgent.setUserAgentOverride(this._userAgentOverrideEnabled ? WebInspector.settings.userAgent.get() : "");
+    },
+
     _deviceMetricsChanged: function()
     {
         var metrics = WebInspector.UserAgentSupport.DeviceMetrics.parseSetting(this._deviceMetricsOverrideEnabled ? WebInspector.settings.deviceMetrics.get() : "");