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

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: 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..29b32652ab51d0b4c403d7837c90a0465ac4ea7d 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());
+ std::string programfiles_w6432;
cpu_(ooo_6.6-7.5) 2015/03/12 00:38:15 I think the construct of line 31 is on the expensi
Will Harris 2015/03/12 01:18:36 I checked and Environment is very lightweight, the
FilePath cur;
switch (key) {
@@ -65,6 +69,19 @@ bool PathProviderWin(int key, FilePath* result) {
return false;
cur = FilePath(system_buffer);
break;
+ case base::DIR_PROGRAM_FILES6432:
+#if defined(_WIN64)
+ if (FAILED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL,
+ SHGFP_TYPE_CURRENT, system_buffer)))
+ return false;
+ cur = FilePath(system_buffer);
+#else
+ if (!env->GetVar("ProgramW6432", &programfiles_w6432))
+ return false;
+ // GetVar returns UTF8 - convert back to Wide.
+ cur = FilePath(UTF8ToWide(programfiles_w6432));
+#endif
+ 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