summaryrefslogtreecommitdiffstats
path: root/chrome/installer/util
diff options
context:
space:
mode:
authorshrikant <shrikant@chromium.org>2015-06-23 13:36:55 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-23 20:37:27 +0000
commitafc7d534cbde1d1da6f764cc3b4adce7147d9f59 (patch)
tree2c52d88ff328b70d7f6785d95d64ec9d36795ffc /chrome/installer/util
parent6becec22159c9ff9d670c5527cf1d49e97f47c61 (diff)
downloadchromium_src-afc7d534cbde1d1da6f764cc3b4adce7147d9f59.zip
chromium_src-afc7d534cbde1d1da6f764cc3b4adce7147d9f59.tar.gz
chromium_src-afc7d534cbde1d1da6f764cc3b4adce7147d9f59.tar.bz2
With this CL we store path to actual Program Files folder in an environment variable in order to avoid repetitive use of SHGetFolderPath API. Especially on Windows 10 along with AppContainer token, SHGetFolderPath seem to take different route, which causes renderer process to crash. With this patch if environment variable is already set then we won't call SHGetFolderPath. Current assumption is that browser's environment is passed to renderer as it is, so any variables set by browser process are passed to renderer in environment.
BUG=502416 Review URL: https://codereview.chromium.org/1193023002 Cr-Commit-Position: refs/heads/master@{#335735}
Diffstat (limited to 'chrome/installer/util')
-rw-r--r--chrome/installer/util/install_util.cc32
1 files changed, 23 insertions, 9 deletions
diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc
index f7dccea..4fc383a 100644
--- a/chrome/installer/util/install_util.cc
+++ b/chrome/installer/util/install_util.cc
@@ -14,6 +14,7 @@
#include <algorithm>
#include "base/command_line.h"
+#include "base/environment.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
@@ -366,18 +367,31 @@ void InstallUtil::UpdateInstallerStage(bool system_install,
}
bool InstallUtil::IsPerUserInstall(const base::FilePath& exe_path) {
- const int kProgramFilesKey =
+ scoped_ptr<base::Environment> env(base::Environment::Create());
+
+ static const char kEnvProgramFilesPath[] = "CHROME_PROBED_PROGRAM_FILES_PATH";
+ std::string env_program_files_path;
+ // Check environment variable to find program files path.
+ base::FilePath program_files_path;
+ if (env->GetVar(kEnvProgramFilesPath, &env_program_files_path) &&
+ !env_program_files_path.empty()) {
+ program_files_path =
+ base::FilePath(base::UTF8ToWide(env_program_files_path));
+ } else {
+ const int kProgramFilesKey =
#if defined(_WIN64)
- // TODO(wfh): Revise this when Chrome is/can be installed in the 64-bit
- // program files directory.
- base::DIR_PROGRAM_FILESX86;
+ // TODO(wfh): Revise this when Chrome is/can be installed in the 64-bit
+ // program files directory.
+ base::DIR_PROGRAM_FILESX86;
#else
- base::DIR_PROGRAM_FILES;
+ base::DIR_PROGRAM_FILES;
#endif
- base::FilePath program_files_path;
- if (!PathService::Get(kProgramFilesKey, &program_files_path)) {
- NOTREACHED();
- return true;
+ if (!PathService::Get(kProgramFilesKey, &program_files_path)) {
+ NOTREACHED();
+ return true;
+ }
+ env->SetVar(kEnvProgramFilesPath,
+ base::WideToUTF8(program_files_path.value()));
}
return !base::StartsWith(exe_path.value(), program_files_path.value(), false);
}