summaryrefslogtreecommitdiffstats
path: root/chrome/installer/util
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/installer/util')
-rw-r--r--chrome/installer/util/install_util.cc22
-rwxr-xr-xchrome/installer/util/install_util.h7
2 files changed, 29 insertions, 0 deletions
diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc
index a372070..bec4af8 100644
--- a/chrome/installer/util/install_util.cc
+++ b/chrome/installer/util/install_util.cc
@@ -7,12 +7,15 @@
#include "install_util.h"
+#include <algorithm>
#include <shellapi.h>
+#include <shlobj.h>
#include "base/logging.h"
#include "base/registry.h"
#include "base/string_util.h"
#include "base/win_util.h"
+
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/google_update_constants.h"
#include "chrome/installer/util/l10n_string_util.h"
@@ -109,3 +112,22 @@ void InstallUtil::WriteInstallerResult(bool system_install,
if (!install_list->Do())
LOG(ERROR) << "Failed to record installer error information in registry.";
}
+
+bool InstallUtil::IsPerUserInstall(const wchar_t* const exe_path) {
+ std::wstring exe_path_copy = exe_path;
+
+ wchar_t program_files_path[MAX_PATH] = {0};
+ if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL,
+ SHGFP_TYPE_CURRENT, program_files_path))) {
+ std::wstring program_files_path_copy = program_files_path;
+
+ if (std::equal(program_files_path_copy.begin(),
+ program_files_path_copy.end(), exe_path_copy.begin(),
+ CaseInsensitiveCompare<wchar_t>())) {
+ return false;
+ }
+ } else {
+ NOTREACHED();
+ }
+ return true;
+} \ No newline at end of file
diff --git a/chrome/installer/util/install_util.h b/chrome/installer/util/install_util.h
index 95c4bf9..ee6e2ff 100755
--- a/chrome/installer/util/install_util.h
+++ b/chrome/installer/util/install_util.h
@@ -10,6 +10,7 @@
#define CHROME_INSTALLER_UTIL_INSTALL_UTIL_H__
#include <string>
+#include <tchar.h>
#include <windows.h>
#include "base/basictypes.h"
@@ -46,6 +47,12 @@ class InstallUtil {
installer_util::InstallStatus status,
int string_resource_id,
const std::wstring* const launch_cmd);
+
+ // Returns true if this installation path is per user, otherwise returns
+ // false (per machine install, meaning: the exe_path contains path to
+ // Program Files).
+ static bool IsPerUserInstall(const wchar_t* const exe_path);
+
private:
DISALLOW_EVIL_CONSTRUCTORS(InstallUtil);
};