summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/env_var.cc10
-rw-r--r--base/env_var.h8
-rw-r--r--chrome/browser/net/url_fixer_upper.cc3
-rw-r--r--net/proxy/proxy_config_service_linux.cc3
-rw-r--r--remoting/host/simple_host_process.cc4
5 files changed, 24 insertions, 4 deletions
diff --git a/base/env_var.cc b/base/env_var.cc
index 086191e..d0eaa0c 100644
--- a/base/env_var.cc
+++ b/base/env_var.cc
@@ -87,6 +87,16 @@ class EnvVarGetterImpl : public base::EnvVarGetter {
namespace base {
+namespace env_vars {
+
+#if defined(OS_POSIX)
+// On Posix systems, this variable contains the location of the user's home
+// directory. (e.g, /home/username/).
+const char kHome[] = "HOME";
+#endif
+
+} // namespace env_vars
+
EnvVarGetter::~EnvVarGetter() {}
bool EnvVarGetter::HasEnv(const char* variable_name) {
diff --git a/base/env_var.h b/base/env_var.h
index f0fe81f..c0a45ca 100644
--- a/base/env_var.h
+++ b/base/env_var.h
@@ -11,6 +11,14 @@
namespace base {
+namespace env_vars {
+
+#if defined(OS_POSIX)
+extern const char kHome[];
+#endif
+
+} // namespace env_vars
+
// These are used to derive mocks for unittests.
class EnvVarGetter {
public:
diff --git a/chrome/browser/net/url_fixer_upper.cc b/chrome/browser/net/url_fixer_upper.cc
index 30cc67a..92b69db 100644
--- a/chrome/browser/net/url_fixer_upper.cc
+++ b/chrome/browser/net/url_fixer_upper.cc
@@ -6,6 +6,7 @@
#include <algorithm>
+#include "base/env_var.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/string_util.h"
@@ -120,7 +121,7 @@ static std::string FixupHomedir(const std::string& text) {
DCHECK(text.length() > 0 && text[0] == '~');
if (text.length() == 1 || text[1] == '/') {
- const char* home = getenv("HOME");
+ const char* home = getenv(base::env_vars::kHome);
if (URLFixerUpper::home_directory_override)
home = URLFixerUpper::home_directory_override;
// We'll probably break elsewhere if $HOME is undefined, but check here
diff --git a/net/proxy/proxy_config_service_linux.cc b/net/proxy/proxy_config_service_linux.cc
index eadedbf6..bd863bd 100644
--- a/net/proxy/proxy_config_service_linux.cc
+++ b/net/proxy/proxy_config_service_linux.cc
@@ -15,6 +15,7 @@
#include <map>
+#include "base/env_var.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/logging.h"
@@ -432,7 +433,7 @@ class GConfSettingGetterImplKDE
} else {
// $KDEHOME is unset. Try to figure out what to use. This seems to be
// the common case on most distributions.
- if (!env_var_getter->GetEnv("HOME", &home))
+ if (!env_var_getter->GetEnv(base::env_vars::kHome, &home))
// User has no $HOME? Give up. Later we'll report the failure.
return;
if (base::GetDesktopEnvironment(env_var_getter) ==
diff --git a/remoting/host/simple_host_process.cc b/remoting/host/simple_host_process.cc
index 035fa32..a83dfc8 100644
--- a/remoting/host/simple_host_process.cc
+++ b/remoting/host/simple_host_process.cc
@@ -20,6 +20,7 @@
#include "base/at_exit.h"
#include "base/command_line.h"
+#include "base/env_var.h"
#include "base/file_path.h"
#include "base/logging.h"
#include "base/nss_util.h"
@@ -49,7 +50,6 @@ const wchar_t kHomePath[] = L"HOMEPATH";
const wchar_t* GetEnvironmentVar(const wchar_t* x) { return _wgetenv(x); }
#else
const std::string kDefaultConfigPath = ".ChromotingConfig.json";
-const char kHomePath[] = "HOME";
static char* GetEnvironmentVar(const char* x) { return getenv(x); }
#endif
@@ -93,7 +93,7 @@ int main(int argc, char** argv) {
std::wstring path = GetEnvironmentVar(kHomeDrive);
path += GetEnvironmentVar(kHomePath);
#else
- std::string path = GetEnvironmentVar(kHomePath);
+ std::string path = GetEnvironmentVar(base::env_vars::kHome);
#endif
FilePath config_path(path);
config_path = config_path.Append(kDefaultConfigPath);