summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/nix/xdg_util.cc14
-rw-r--r--base/nix/xdg_util.h6
-rw-r--r--chrome/common/auto_start_linux.cc9
-rw-r--r--chrome/common/chrome_paths_linux.cc31
-rw-r--r--content/shell/shell_browser_context.cc16
5 files changed, 43 insertions, 33 deletions
diff --git a/base/nix/xdg_util.cc b/base/nix/xdg_util.cc
index 7d26344..08d4eee 100644
--- a/base/nix/xdg_util.cc
+++ b/base/nix/xdg_util.cc
@@ -11,9 +11,19 @@
#include "base/file_util.h"
#include "base/third_party/xdg_user_dirs/xdg_user_dir_lookup.h"
+namespace {
+
+// The KDE session version environment variable used in KDE 4.
+const char kKDE4SessionEnvVar[] = "KDE_SESSION_VERSION";
+
+} // namespace
+
namespace base {
namespace nix {
+const char kDotConfigDir[] = ".config";
+const char kXdgConfigHomeEnvVar[] = "XDG_CONFIG_HOME";
+
FilePath GetXDGDirectory(Environment* env, const char* env_name,
const char* fallback_dir) {
FilePath path;
@@ -46,7 +56,7 @@ DesktopEnvironment GetDesktopEnvironment(Environment* env) {
return DESKTOP_ENVIRONMENT_KDE4;
} else if (desktop_session == "kde") {
// This may mean KDE4 on newer systems, so we have to check.
- if (env->HasVar("KDE_SESSION_VERSION"))
+ if (env->HasVar(kKDE4SessionEnvVar))
return DESKTOP_ENVIRONMENT_KDE4;
return DESKTOP_ENVIRONMENT_KDE3;
} else if (desktop_session.find("xfce") != std::string::npos ||
@@ -60,7 +70,7 @@ DesktopEnvironment GetDesktopEnvironment(Environment* env) {
if (env->HasVar("GNOME_DESKTOP_SESSION_ID")) {
return DESKTOP_ENVIRONMENT_GNOME;
} else if (env->HasVar("KDE_FULL_SESSION")) {
- if (env->HasVar("KDE_SESSION_VERSION"))
+ if (env->HasVar(kKDE4SessionEnvVar))
return DESKTOP_ENVIRONMENT_KDE4;
return DESKTOP_ENVIRONMENT_KDE3;
}
diff --git a/base/nix/xdg_util.h b/base/nix/xdg_util.h
index cb8072ce..1e0c5f3 100644
--- a/base/nix/xdg_util.h
+++ b/base/nix/xdg_util.h
@@ -27,6 +27,12 @@ class Environment;
namespace nix {
+// The default XDG config directory name.
+BASE_EXPORT extern const char kDotConfigDir[];
+
+// The XDG config directory environment variable.
+BASE_EXPORT extern const char kXdgConfigHomeEnvVar[];
+
// Utility function for getting XDG directories.
// |env_name| is the name of an environment variable that we want to use to get
// a directory path. |fallback_dir| is the directory relative to $HOME that we
diff --git a/chrome/common/auto_start_linux.cc b/chrome/common/auto_start_linux.cc
index 099cb5e..6041f0e 100644
--- a/chrome/common/auto_start_linux.cc
+++ b/chrome/common/auto_start_linux.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -14,12 +14,11 @@
namespace {
const FilePath::CharType kAutostart[] = "autostart";
-const FilePath::CharType kConfig[] = ".config";
-const char kXdgConfigHome[] = "XDG_CONFIG_HOME";
FilePath GetAutostartDirectory(base::Environment* environment) {
- FilePath result =
- base::nix::GetXDGDirectory(environment, kXdgConfigHome, kConfig);
+ FilePath result = base::nix::GetXDGDirectory(environment,
+ base::nix::kXdgConfigHomeEnvVar,
+ base::nix::kDotConfigDir);
result = result.Append(kAutostart);
return result;
}
diff --git a/chrome/common/chrome_paths_linux.cc b/chrome/common/chrome_paths_linux.cc
index 6f3bd9c..b6bcc54 100644
--- a/chrome/common/chrome_paths_linux.cc
+++ b/chrome/common/chrome_paths_linux.cc
@@ -12,15 +12,18 @@
namespace {
-const char kDotConfigDir[] = ".config";
const char kDownloadsDir[] = "Downloads";
const char kPicturesDir[] = "Pictures";
-const char kXdgConfigHomeEnvVar[] = "XDG_CONFIG_HOME";
} // namespace
namespace chrome {
+using base::nix::GetXDGDirectory;
+using base::nix::GetXDGUserDirectory;
+using base::nix::kDotConfigDir;
+using base::nix::kXdgConfigHomeEnvVar;
+
// See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
// for a spec on where config files go. The net effect for most
// systems is we use ~/.config/chromium/ for Chromium and
@@ -28,9 +31,9 @@ namespace chrome {
// (This also helps us sidestep issues with other apps grabbing ~/.chromium .)
bool GetDefaultUserDataDirectory(FilePath* result) {
scoped_ptr<base::Environment> env(base::Environment::Create());
- FilePath config_dir(base::nix::GetXDGDirectory(env.get(),
- kXdgConfigHomeEnvVar,
- kDotConfigDir));
+ FilePath config_dir(GetXDGDirectory(env.get(),
+ kXdgConfigHomeEnvVar,
+ kDotConfigDir));
#if defined(GOOGLE_CHROME_BUILD)
*result = config_dir.Append("google-chrome");
#else
@@ -56,9 +59,9 @@ void GetUserCacheDirectory(const FilePath& profile_dir, FilePath* result) {
FilePath cache_dir;
if (!PathService::Get(base::DIR_CACHE, &cache_dir))
return;
- FilePath config_dir(base::nix::GetXDGDirectory(env.get(),
- kXdgConfigHomeEnvVar,
- kDotConfigDir));
+ FilePath config_dir(GetXDGDirectory(env.get(),
+ kXdgConfigHomeEnvVar,
+ kDotConfigDir));
if (!config_dir.AppendRelativePath(profile_dir, &cache_dir))
return;
@@ -68,9 +71,9 @@ void GetUserCacheDirectory(const FilePath& profile_dir, FilePath* result) {
bool GetChromeFrameUserDataDirectory(FilePath* result) {
scoped_ptr<base::Environment> env(base::Environment::Create());
- FilePath config_dir(base::nix::GetXDGDirectory(env.get(),
- kXdgConfigHomeEnvVar,
- kDotConfigDir));
+ FilePath config_dir(GetXDGDirectory(env.get(),
+ kXdgConfigHomeEnvVar,
+ kDotConfigDir));
#if defined(GOOGLE_CHROME_BUILD)
*result = config_dir.Append("google-chrome-frame");
#else
@@ -80,7 +83,7 @@ bool GetChromeFrameUserDataDirectory(FilePath* result) {
}
bool GetUserDocumentsDirectory(FilePath* result) {
- *result = base::nix::GetXDGUserDirectory("DOCUMENTS", "Documents");
+ *result = GetXDGUserDirectory("DOCUMENTS", "Documents");
return true;
}
@@ -98,7 +101,7 @@ bool GetUserDownloadsDirectory(FilePath* result) {
// We respect the user's preferred pictures location, unless it is
// ~ or their desktop directory, in which case we default to ~/Pictures.
bool GetUserPicturesDirectory(FilePath* result) {
- *result = base::nix::GetXDGUserDirectory("PICTURES", kPicturesDir);
+ *result = GetXDGUserDirectory("PICTURES", kPicturesDir);
FilePath home = file_util::GetHomeDir();
if (*result != home) {
@@ -114,7 +117,7 @@ bool GetUserPicturesDirectory(FilePath* result) {
}
bool GetUserDesktop(FilePath* result) {
- *result = base::nix::GetXDGUserDirectory("DESKTOP", "Desktop");
+ *result = GetXDGUserDirectory("DESKTOP", "Desktop");
return true;
}
diff --git a/content/shell/shell_browser_context.cc b/content/shell/shell_browser_context.cc
index 3af52d4..fe91531 100644
--- a/content/shell/shell_browser_context.cc
+++ b/content/shell/shell_browser_context.cc
@@ -29,15 +29,6 @@ using content::BrowserThread;
namespace content {
-namespace {
-
-#if defined(OS_LINUX)
-const char kDotConfigDir[] = ".config";
-const char kXdgConfigHomeEnvVar[] = "XDG_CONFIG_HOME";
-#endif
-
-} // namespace
-
ShellBrowserContext::ShellBrowserContext() {
InitWhileIOAllowed();
}
@@ -60,9 +51,10 @@ void ShellBrowserContext::InitWhileIOAllowed() {
path_ = path_.Append(std::wstring(L"content_shell"));
#elif defined(OS_LINUX)
scoped_ptr<base::Environment> env(base::Environment::Create());
- FilePath config_dir(base::nix::GetXDGDirectory(env.get(),
- kXdgConfigHomeEnvVar,
- kDotConfigDir));
+ FilePath config_dir(
+ base::nix::GetXDGDirectory(env.get(),
+ base::nix::kXdgConfigHomeEnvVar,
+ base::nix::kDotConfigDir));
path_ = config_dir.Append("content_shell");
#elif defined(OS_MACOSX)
CHECK(PathService::Get(base::DIR_APP_DATA, &path_));