diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-08 03:56:17 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-08 03:56:17 +0000 |
commit | 6c817557ed5fa92658cfc0616fe72a71643491f9 (patch) | |
tree | beb3ef6cdc6aaa5e5737b64d23bd62cca0787a1c | |
parent | 33d396b083d7096f7c44ea76fd4a6765dec75d87 (diff) | |
download | chromium_src-6c817557ed5fa92658cfc0616fe72a71643491f9.zip chromium_src-6c817557ed5fa92658cfc0616fe72a71643491f9.tar.gz chromium_src-6c817557ed5fa92658cfc0616fe72a71643491f9.tar.bz2 |
base: Get rid of the deprecated SysInfo::GetEnvVar.
Use the new EnvVarGetter::GetEnv instead.
BUG=None
TEST=trybots
Review URL: http://codereview.chromium.org/2876045
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51829 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/sys_info.h | 5 | ||||
-rw-r--r-- | base/sys_info_posix.cc | 11 | ||||
-rw-r--r-- | base/sys_info_unittest.cc | 5 | ||||
-rw-r--r-- | base/sys_info_win.cc | 11 | ||||
-rw-r--r-- | chrome/browser/browser_init.cc | 9 | ||||
-rw-r--r-- | courgette/encoded_program.cc | 12 |
6 files changed, 14 insertions, 39 deletions
diff --git a/base/sys_info.h b/base/sys_info.h index cefce13..1bb4eca 100644 --- a/base/sys_info.h +++ b/base/sys_info.h @@ -30,11 +30,6 @@ class SysInfo { // or -1 on failure. static int64 AmountOfFreeDiskSpace(const FilePath& path); - // Return the value of the given environment variable - // or an empty string if not defined. - // DEPRECATED in favor of EnvVarGetter in base/env_var.h. - static std::wstring GetEnvVar(const wchar_t* var); - // Returns the name of the host operating system. static std::string OperatingSystemName(); diff --git a/base/sys_info_posix.cc b/base/sys_info_posix.cc index f2d75d2..3f487e5 100644 --- a/base/sys_info_posix.cc +++ b/base/sys_info_posix.cc @@ -47,17 +47,6 @@ int64 SysInfo::AmountOfFreeDiskSpace(const FilePath& path) { } // static -std::wstring SysInfo::GetEnvVar(const wchar_t* var) { - std::string var_utf8 = WideToUTF8(std::wstring(var)); - char* value = getenv(var_utf8.c_str()); - if (!value) { - return std::wstring(); - } else { - return UTF8ToWide(value); - } -} - -// static std::string SysInfo::OperatingSystemName() { utsname info; if (uname(&info) < 0) { diff --git a/base/sys_info_unittest.cc b/base/sys_info_unittest.cc index 79f172d..3e51890 100644 --- a/base/sys_info_unittest.cc +++ b/base/sys_info_unittest.cc @@ -28,11 +28,6 @@ TEST_F(SysInfoTest, AmountOfFreeDiskSpace) { << tmp_path.value(); } -TEST_F(SysInfoTest, GetEnvVar) { - // Every setup should have non-empty PATH... - EXPECT_NE(base::SysInfo::GetEnvVar(L"PATH"), L""); -} - #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) TEST_F(SysInfoTest, OperatingSystemVersionNumbers) { int32 os_major_version = -1; diff --git a/base/sys_info_win.cc b/base/sys_info_win.cc index 35a7878..ed4d2fb 100644 --- a/base/sys_info_win.cc +++ b/base/sys_info_win.cc @@ -48,17 +48,6 @@ int64 SysInfo::AmountOfFreeDiskSpace(const FilePath& path) { } // static -std::wstring SysInfo::GetEnvVar(const wchar_t* var) { - DWORD value_length = GetEnvironmentVariable(var, NULL, 0); - if (value_length == 0) { - return L""; - } - scoped_array<wchar_t> value(new wchar_t[value_length]); - GetEnvironmentVariable(var, value.get(), value_length); - return std::wstring(value.get()); -} - -// static std::string SysInfo::OperatingSystemName() { return "Windows NT"; } diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc index b1fc8dd..d75b0e2 100644 --- a/chrome/browser/browser_init.cc +++ b/chrome/browser/browser_init.cc @@ -8,9 +8,10 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" +#include "base/env_var.h" #include "base/event_recorder.h" #include "base/path_service.h" -#include "base/sys_info.h" +#include "base/scoped_ptr.h" #include "chrome/browser/automation/automation_provider.h" #include "chrome/browser/automation/chrome_frame_automation_provider.h" #include "chrome/browser/browser_list.h" @@ -307,9 +308,11 @@ LaunchMode GetLaunchShortcutKind() { // The windows quick launch path is not localized. if (shortcut.find(L"\\Quick Launch\\") != std::wstring::npos) return LM_SHORTCUT_QUICKLAUNCH; - std::wstring appdata_path = base::SysInfo::GetEnvVar(L"USERPROFILE"); + scoped_ptr<base::EnvVarGetter> env(base::EnvVarGetter::Create()); + std::string appdata_path; + env->GetEnv("USERPROFILE", &appdata_path); if (!appdata_path.empty() && - shortcut.find(appdata_path) != std::wstring::npos) + shortcut.find(ASCIIToWide(appdata_path)) != std::wstring::npos) return LM_SHORTCUT_DESKTOP; return LM_SHORTCUT_UNKNOWN; } diff --git a/courgette/encoded_program.cc b/courgette/encoded_program.cc index 1265312..71bd65a 100644 --- a/courgette/encoded_program.cc +++ b/courgette/encoded_program.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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. @@ -9,8 +9,10 @@ #include <string> #include <vector> +#include "base/env_var.h" #include "base/logging.h" -#include "base/sys_info.h" +#include "base/scoped_ptr.h" +#include "base/string_util.h" #include "courgette/courgette.h" #include "courgette/streams.h" @@ -264,9 +266,11 @@ enum FieldSelect { static FieldSelect GetFieldSelect() { #if 1 // TODO(sra): Use better configuration. - std::wstring s = base::SysInfo::GetEnvVar(L"A_FIELDS"); + scoped_ptr<base::EnvVarGetter> env(base::EnvVarGetter::Create()); + std::string s; + env->GetEnv("A_FIELDS", &s); if (!s.empty()) { - return static_cast<FieldSelect>(wcstoul(s.c_str(), 0, 0)); + return static_cast<FieldSelect>(wcstoul(ASCIIToWide(s).c_str(), 0, 0)); } #endif return static_cast<FieldSelect>(~0); |