| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/env_var.h" | 5 #include "base/environment.h" |
| 6 | 6 |
| 7 #if defined(OS_POSIX) | 7 #if defined(OS_POSIX) |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 #elif defined(OS_WIN) | 9 #elif defined(OS_WIN) |
| 10 #include <windows.h> | 10 #include <windows.h> |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 | 14 |
| 15 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
| 16 #include "base/scoped_ptr.h" | 16 #include "base/scoped_ptr.h" |
| 17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 18 #endif | 18 #endif |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 class EnvVarGetterImpl : public base::EnvVarGetter { | 22 class EnvironmentImpl : public base::Environment { |
| 23 public: | 23 public: |
| 24 virtual bool GetEnv(const char* variable_name, std::string* result) { | 24 virtual bool GetEnv(const char* variable_name, std::string* result) { |
| 25 if (GetEnvImpl(variable_name, result)) | 25 if (GetEnvImpl(variable_name, result)) |
| 26 return true; | 26 return true; |
| 27 | 27 |
| 28 // Some commonly used variable names are uppercase while others | 28 // Some commonly used variable names are uppercase while others |
| 29 // are lowercase, which is inconsistent. Let's try to be helpful | 29 // are lowercase, which is inconsistent. Let's try to be helpful |
| 30 // and look for a variable name with the reverse case. | 30 // and look for a variable name with the reverse case. |
| 31 // I.e. HTTP_PROXY may be http_proxy for some users/systems. | 31 // I.e. HTTP_PROXY may be http_proxy for some users/systems. |
| 32 char first_char = variable_name[0]; | 32 char first_char = variable_name[0]; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 namespace env_vars { | 105 namespace env_vars { |
| 106 | 106 |
| 107 #if defined(OS_POSIX) | 107 #if defined(OS_POSIX) |
| 108 // On Posix systems, this variable contains the location of the user's home | 108 // On Posix systems, this variable contains the location of the user's home |
| 109 // directory. (e.g, /home/username/). | 109 // directory. (e.g, /home/username/). |
| 110 const char kHome[] = "HOME"; | 110 const char kHome[] = "HOME"; |
| 111 #endif | 111 #endif |
| 112 | 112 |
| 113 } // namespace env_vars | 113 } // namespace env_vars |
| 114 | 114 |
| 115 EnvVarGetter::~EnvVarGetter() {} | 115 Environment::~Environment() {} |
| 116 | 116 |
| 117 // static | 117 // static |
| 118 EnvVarGetter* EnvVarGetter::Create() { | 118 Environment* Environment::Create() { |
| 119 return new EnvVarGetterImpl(); | 119 return new EnvironmentImpl(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 bool EnvVarGetter::HasEnv(const char* variable_name) { | 122 bool Environment::HasEnv(const char* variable_name) { |
| 123 return GetEnv(variable_name, NULL); | 123 return GetEnv(variable_name, NULL); |
| 124 } | 124 } |
| 125 | 125 |
| 126 } // namespace base | 126 } // namespace base |
| OLD | NEW |