summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-04 02:51:41 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-04 02:51:41 +0000
commit87c8ad5f0e992629d8abcf52d57410c85eb7fc88 (patch)
tree8a55786b25bd152809ba2b4fbbc41579bfb15518 /net
parentb53945dbc78bef7f47c93928c6a2f23f0c6c0624 (diff)
downloadchromium_src-87c8ad5f0e992629d8abcf52d57410c85eb7fc88.zip
chromium_src-87c8ad5f0e992629d8abcf52d57410c85eb7fc88.tar.gz
chromium_src-87c8ad5f0e992629d8abcf52d57410c85eb7fc88.tar.bz2
linux: obey proxy environment variables in preference to gconf
This fixes a tiny bug, where we were consulting gnome's settings based on whether the DESKTOP_SESSION *wasn't* gnome. TEST=Covered by new unit test. Review URL: http://codereview.chromium.org/100318 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15184 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/proxy/proxy_config_service_linux.cc2
-rw-r--r--net/proxy/proxy_config_service_linux_unittest.cc24
2 files changed, 25 insertions, 1 deletions
diff --git a/net/proxy/proxy_config_service_linux.cc b/net/proxy/proxy_config_service_linux.cc
index f864ed2..0d6f067 100644
--- a/net/proxy/proxy_config_service_linux.cc
+++ b/net/proxy/proxy_config_service_linux.cc
@@ -515,7 +515,7 @@ int ProxyConfigServiceLinux::GetProxyConfig(ProxyConfig* config) {
bool ok = false;
if (env_var_getter_->Getenv("GNOME_DESKTOP_SESSION_ID", &dummy)
|| (env_var_getter_->Getenv("DESKTOP_SESSION", &desktop_session)
- && desktop_session.compare("gnome"))) {
+ && desktop_session.compare("gnome") == 0)) {
// Get settings from gconf.
//
// I (sdoyon) would have liked to prioritize environment variables
diff --git a/net/proxy/proxy_config_service_linux_unittest.cc b/net/proxy/proxy_config_service_linux_unittest.cc
index ae2b1f7..9ff2813 100644
--- a/net/proxy/proxy_config_service_linux_unittest.cc
+++ b/net/proxy/proxy_config_service_linux_unittest.cc
@@ -733,4 +733,28 @@ TEST(ProxyConfigServiceLinuxTest, BasicEnvTest) {
}
}
+// Verify that we fall back on consulting the environment when
+// GNOME-specific environment variables aren't available.
+TEST(ProxyConfigServiceLinuxTest, FallbackOnEnv) {
+ MockEnvironmentVariableGetter* env_getter =
+ new MockEnvironmentVariableGetter;
+ MockGConfSettingGetter* gconf_getter = new MockGConfSettingGetter;
+ ProxyConfigServiceLinux service(env_getter, gconf_getter);
+
+ // Imagine we're:
+ // 1) Running a non-GNOME desktop session:
+ env_getter->values.DESKTOP_SESSION = "default";
+ // 2) Have settings in gconf.
+ gconf_getter->values.mode = "auto";
+ gconf_getter->values.autoconfig_url = "http://incorrect/wpad.dat";
+ // 3) But we have a proxy-specifying environment variable set:
+ env_getter->values.auto_proxy = "http://correct/wpad.dat";
+
+ ProxyConfig config;
+ service.GetProxyConfig(&config);
+
+ // Then we expect the environment variable to win.
+ EXPECT_EQ(GURL(env_getter->values.auto_proxy), config.pac_url);
+}
+
} // namespace net