summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-10 22:30:53 +0000
committermdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-10 22:30:53 +0000
commitfad9c8a5d8f6ae4d1272985b63131986189bbed6 (patch)
tree2be70a8d13a83af9c2e1312f48bd2c8749eae06e
parentdd14da8f2d18c8f9b6a6c0a9b2bb4e03da92c90c (diff)
downloadchromium_src-fad9c8a5d8f6ae4d1272985b63131986189bbed6.zip
chromium_src-fad9c8a5d8f6ae4d1272985b63131986189bbed6.tar.gz
chromium_src-fad9c8a5d8f6ae4d1272985b63131986189bbed6.tar.bz2
Linux: check the timestamps of .kde and .kde4 to figure out which to use for proxy configuration in KDE.
BUG=none TEST=under KDE4, if you have both .kde and .kde4, the one with a newer config directory within will be used Review URL: http://codereview.chromium.org/2729014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49459 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/proxy/proxy_config_service_linux.cc26
-rw-r--r--net/proxy/proxy_config_service_linux_unittest.cc18
2 files changed, 38 insertions, 6 deletions
diff --git a/net/proxy/proxy_config_service_linux.cc b/net/proxy/proxy_config_service_linux.cc
index ad17b36..cd7102b 100644
--- a/net/proxy/proxy_config_service_linux.cc
+++ b/net/proxy/proxy_config_service_linux.cc
@@ -433,21 +433,35 @@ class GConfSettingGetterImplKDE
kde_config_dir_ = KDEHomeToConfigPath(kde_path);
} else {
// Some distributions patch KDE4 to use .kde4 instead of .kde, so that
- // both can be installed side-by-side. They will probably continue to
- // use .kde4, even when they no longer provide KDE3, for backwards-
- // compatibility. So if there is a .kde4 directory, use that instead of
- // .kde for the proxy config.
+ // both can be installed side-by-side. Sadly they don't all do this, and
+ // they don't always do this: some distributions have started switching
+ // back as well. So if there is a .kde4 directory, check the timestamps
+ // of the config directories within and use the newest one.
// Note that we should currently be running in the UI thread, because in
// the gconf version, that is the only thread that can access the proxy
// settings (a gconf restriction). As noted below, the initial read of
// the proxy settings will be done in this thread anyway, so we check
// for .kde4 here in this thread as well.
+ FilePath kde3_path = FilePath(home).Append(".kde");
+ FilePath kde3_config = KDEHomeToConfigPath(kde3_path);
FilePath kde4_path = FilePath(home).Append(".kde4");
+ FilePath kde4_config = KDEHomeToConfigPath(kde4_path);
+ bool use_kde4 = false;
if (file_util::DirectoryExists(kde4_path)) {
+ file_util::FileInfo kde3_info;
+ file_util::FileInfo kde4_info;
+ if (file_util::GetFileInfo(kde4_config, &kde4_info)) {
+ if (file_util::GetFileInfo(kde3_config, &kde3_info)) {
+ use_kde4 = kde4_info.last_modified >= kde3_info.last_modified;
+ } else {
+ use_kde4 = true;
+ }
+ }
+ }
+ if (use_kde4) {
kde_config_dir_ = KDEHomeToConfigPath(kde4_path);
} else {
- FilePath kde_path = FilePath(home).Append(".kde");
- kde_config_dir_ = KDEHomeToConfigPath(kde_path);
+ kde_config_dir_ = KDEHomeToConfigPath(kde3_path);
}
}
}
diff --git a/net/proxy/proxy_config_service_linux_unittest.cc b/net/proxy/proxy_config_service_linux_unittest.cc
index fb1b016..5a09275 100644
--- a/net/proxy/proxy_config_service_linux_unittest.cc
+++ b/net/proxy/proxy_config_service_linux_unittest.cc
@@ -1309,6 +1309,7 @@ TEST_F(ProxyConfigServiceLinuxTest, KDEHomePicker) {
}
// Now create .kde4 and put a kioslaverc in the config directory.
+ // Note that its timestamp will be at least as new as the .kde one.
file_util::CreateDirectory(kde4_config_);
file_util::WriteFile(kioslaverc4_, slaverc4.c_str(), slaverc4.length());
CHECK(file_util::PathExists(kioslaverc4_));
@@ -1352,6 +1353,23 @@ TEST_F(ProxyConfigServiceLinuxTest, KDEHomePicker) {
EXPECT_TRUE(config.auto_detect());
EXPECT_EQ(GURL(), config.pac_url());
}
+
+ // Finally, make the .kde4 config directory older than the .kde directory
+ // and make sure we then use .kde instead of .kde4 since it's newer.
+ file_util::SetLastModifiedTime(kde4_config_, base::Time());
+
+ { SCOPED_TRACE("KDE4, very old .kde4 directory present, use .kde");
+ MockEnvVarGetter* env_getter = new MockEnvVarGetter;
+ env_getter->values.DESKTOP_SESSION = "kde4";
+ env_getter->values.HOME = user_home_.value().c_str();
+ SynchConfigGetter sync_config_getter(
+ new ProxyConfigServiceLinux(env_getter));
+ ProxyConfig config;
+ sync_config_getter.SetupAndInitialFetch();
+ sync_config_getter.SyncGetProxyConfig(&config);
+ EXPECT_TRUE(config.auto_detect());
+ EXPECT_EQ(GURL(), config.pac_url());
+ }
}
} // namespace net