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

Unified Diff: base/base_paths_win.cc

Issue 986373006: Add DIR_PROGRAM_FILES6432 to PathService to return "Program Files" on both 64-bit and 32-bit platfo… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 5 years, 9 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
Index: base/base_paths_win.cc
diff --git a/base/base_paths_win.cc b/base/base_paths_win.cc
index 5bef3106aaf010f8f50029a1a580a1d3bd20865a..7e6b1c5aa77322a5e8ebd2829f45a58006a83cac 100644
--- a/base/base_paths_win.cc
+++ b/base/base_paths_win.cc
@@ -6,8 +6,10 @@
#include <shlobj.h>
#include "base/base_paths.h"
+#include "base/environment.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
+#include "base/strings/utf_string_conversions.h"
#include "base/win/scoped_co_mem.h"
#include "base/win/windows_version.h"
@@ -26,6 +28,8 @@ bool PathProviderWin(int key, FilePath* result) {
// handling it.
wchar_t system_buffer[MAX_PATH];
system_buffer[0] = 0;
+ scoped_ptr<base::Environment> env(base::Environment::Create());
grt (UTC plus 2) 2015/03/12 13:34:44 move these down into a block in the base::DIR_PROG
Will Harris 2015/03/12 20:34:29 Done.
+ std::string programfiles_w6432;
FilePath cur;
switch (key) {
@@ -65,6 +69,21 @@ bool PathProviderWin(int key, FilePath* result) {
return false;
cur = FilePath(system_buffer);
break;
+ case base::DIR_PROGRAM_FILES6432:
+#if !defined(_WIN64)
+ // 32-bit process running in WOW64 sets ProgramW6432 environment variable.
grt (UTC plus 2) 2015/03/12 13:34:44 How about reducing the dependence on the variable
Will Harris 2015/03/12 20:34:29 Done.
+ // See https://msdn.microsoft.com/library/windows/desktop/aa384274.aspx
+ if (env->GetVar("ProgramW6432", &programfiles_w6432)) {
+ // GetVar returns UTF8 - convert back to Wide.
+ cur = FilePath(UTF8ToWide(programfiles_w6432));
+ break;
+ }
+#endif
+ if (FAILED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL,
+ SHGFP_TYPE_CURRENT, system_buffer)))
+ return false;
+ cur = FilePath(system_buffer);
+ break;
case base::DIR_IE_INTERNET_CACHE:
if (FAILED(SHGetFolderPath(NULL, CSIDL_INTERNET_CACHE, NULL,
SHGFP_TYPE_CURRENT, system_buffer)))

Powered by Google App Engine
This is Rietveld 408576698