Commit 5fa72daa authored by thestig@chromium.org's avatar thestig@chromium.org

Reverting 10555.

Review URL: http://codereview.chromium.org/28239

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10560 0039d316-1c4b-4281-b951-d872f2087c98
parent db8562c1
...@@ -5,53 +5,31 @@ ...@@ -5,53 +5,31 @@
#include "chrome/common/chrome_paths_internal.h" #include "chrome/common/chrome_paths_internal.h"
#include <glib.h> #include <glib.h>
#include <stdlib.h>
#include "base/file_path.h" #include "base/file_path.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/path_service.h"
#include "chrome/third_party/xdg_user_dirs/xdg_user_dir_lookup.h"
namespace { namespace {
FilePath GetHomeDir() {
const char *home_dir = getenv("HOME");
if (home_dir && home_dir[0])
return FilePath(home_dir);
home_dir = g_get_home_dir();
if (home_dir && home_dir[0])
return FilePath(home_dir);
FilePath rv;
if (PathService::Get(base::DIR_TEMP, &rv))
return rv;
/* last resort */
return FilePath("/tmp/");
}
// Wrapper around xdg_user_dir_lookup() from
// src/chrome/third_party/xdg-user-dirs
FilePath GetXDGUserDirectory(const char* env_name, const char* fallback_dir) {
char* xdg_dir = xdg_user_dir_lookup(env_name);
if (xdg_dir) {
FilePath rv(xdg_dir);
free(xdg_dir);
return rv;
}
return GetHomeDir().Append(fallback_dir);
}
// |env_name| is the name of an environment variable that we want to use to get // |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 // a directory path. |fallback_dir| is the directory relative to $HOME that we
// use if |env_name| cannot be found or is empty. |fallback_dir| may be NULL. // use if |env_name| cannot be found or is empty. |fallback_dir| may be NULL.
FilePath GetXDGDirectory(const char* env_name, const char* fallback_dir) { // TODO(thestig): Don't use g_getenv() here because most of the time XDG
const char* env_value = getenv(env_name); // environment variables won't actually be loaded.
if (env_value && env_value[0]) FilePath GetStandardDirectory(const char* env_name, const char* fallback_dir) {
return FilePath(env_value); FilePath rv;
return GetHomeDir().Append(fallback_dir); const char* env_value = g_getenv(env_name);
if (env_value && env_value[0]) {
rv = FilePath(env_value);
} else {
const char* home_dir = g_getenv("HOME");
if (!home_dir)
home_dir = g_get_home_dir();
rv = FilePath(home_dir);
if (fallback_dir)
rv = rv.Append(fallback_dir);
}
return rv;
} }
} // namespace } // namespace
...@@ -64,7 +42,7 @@ namespace chrome { ...@@ -64,7 +42,7 @@ namespace chrome {
// ~/.config/google-chrome/ for official builds. // ~/.config/google-chrome/ for official builds.
// (This also helps us sidestep issues with other apps grabbing ~/.chromium .) // (This also helps us sidestep issues with other apps grabbing ~/.chromium .)
bool GetDefaultUserDataDirectory(FilePath* result) { bool GetDefaultUserDataDirectory(FilePath* result) {
FilePath config_dir(GetXDGDirectory("XDG_CONFIG_HOME", ".config")); FilePath config_dir = GetStandardDirectory("XDG_CONFIG_HOME", ".config");
#if defined(GOOGLE_CHROME_BUILD) #if defined(GOOGLE_CHROME_BUILD)
*result = config_dir.Append("google-chrome"); *result = config_dir.Append("google-chrome");
#else #else
...@@ -74,12 +52,12 @@ bool GetDefaultUserDataDirectory(FilePath* result) { ...@@ -74,12 +52,12 @@ bool GetDefaultUserDataDirectory(FilePath* result) {
} }
bool GetUserDocumentsDirectory(FilePath* result) { bool GetUserDocumentsDirectory(FilePath* result) {
*result = GetXDGUserDirectory("DOCUMENTS", "Documents"); *result = GetStandardDirectory("XDG_DOCUMENTS_DIR", "Documents");
return true; return true;
} }
bool GetUserDesktop(FilePath* result) { bool GetUserDesktop(FilePath* result) {
*result = GetXDGUserDirectory("DESKTOP", "Desktop"); *result = GetStandardDirectory("XDG_DESKTOP_DIR", "Desktop");
return true; return true;
} }
......
...@@ -283,7 +283,6 @@ if env.Bit('windows'): ...@@ -283,7 +283,6 @@ if env.Bit('windows'):
if env.Bit('linux'): if env.Bit('linux'):
input_files.Append( input_files.Append(
'$CHROME_DIR/third_party/xdg_user_dirs/xdg_user_dir_lookup.cc',
'transport_dib_linux.cc', 'transport_dib_linux.cc',
'x11_util.cc' 'x11_util.cc'
) )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment