Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Unified Diff: chrome/app/client_util.cc

Issue 3135036: Use Environment::GetVar instead of the obscure EnvQueryStr function. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: another fix Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/app/client_util.cc
diff --git a/chrome/app/client_util.cc b/chrome/app/client_util.cc
index 61d8c40cff6749d58080eebe12234552957fa9c0..2cdc978b27edf38e40751218691c3b2b9f3818b6 100644
--- a/chrome/app/client_util.cc
+++ b/chrome/app/client_util.cc
@@ -77,17 +77,6 @@ std::wstring GetExecutablePath() {
return exe_path.append(L"\\");
}
-// Not generic, we only handle strings up to 128 chars.
-bool EnvQueryStr(const wchar_t* key_name, std::wstring* value) {
- wchar_t out[128];
- DWORD count = sizeof(out)/sizeof(out[0]);
- DWORD rv = ::GetEnvironmentVariableW(key_name, out, count);
- if ((rv == 0) || (rv >= count))
- return false;
- *value = out;
- return true;
-}
-
// Expects that |dir| has a trailing backslash. |dir| is modified so it
// contains the full path that was tried. Caller must check for the return
// value not being null to dermine if this path contains a valid dll.
@@ -206,10 +195,15 @@ HMODULE MainDllLoader::Load(std::wstring* version, std::wstring* file) {
if (dll)
return dll;
- if (!EnvQueryStr(
- BrowserDistribution::GetDistribution()->GetEnvVersionKey().c_str(),
- version)) {
+ scoped_ptr<base::Environment> env(base::Environment::Create());
+
+ std::string version_value;
+ if (!env->GetVar(WideToUTF8(
+ BrowserDistribution::GetDistribution()->GetEnvVersionKey()).c_str(),
+ &version_value)) {
std::wstring reg_path(GetRegistryPath());
+
+ *version = UTF8ToWide(version_value);
// Look into the registry to find the latest version.
if (!GetVersion(dir.c_str(), reg_path.c_str(), version))
return NULL;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698