diff options
Diffstat (limited to 'chrome/installer/util/install_util.cc')
-rw-r--r-- | chrome/installer/util/install_util.cc | 105 |
1 files changed, 12 insertions, 93 deletions
diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc index 6c11f99..ae9c67d 100644 --- a/chrome/installer/util/install_util.cc +++ b/chrome/installer/util/install_util.cc @@ -73,21 +73,23 @@ bool InstallUtil::ExecuteExeAsAdmin(const CommandLine& cmd, DWORD* exit_code) { return true; } -std::wstring InstallUtil::GetChromeUninstallCmd(bool system_install) { +std::wstring InstallUtil::GetChromeUninstallCmd(bool system_install, + BrowserDistribution* dist) { + DCHECK(dist); HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; - BrowserDistribution* dist = BrowserDistribution::GetDistribution(); RegKey key(root, dist->GetUninstallRegPath().c_str(), KEY_READ); std::wstring uninstall_cmd; key.ReadValue(installer_util::kUninstallStringField, &uninstall_cmd); return uninstall_cmd; } -installer::Version* InstallUtil::GetChromeVersion(bool system_install) { +installer::Version* InstallUtil::GetChromeVersion(BrowserDistribution* dist, + bool system_install) { + DCHECK(dist); RegKey key; std::wstring version_str; HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; - BrowserDistribution* dist = BrowserDistribution::GetDistribution(); if (!key.Open(reg_root, dist->GetVersionKey().c_str(), KEY_READ) || !key.ReadValue(google_update::kRegVersionField, &version_str)) { VLOG(1) << "No existing Chrome install found."; @@ -111,34 +113,6 @@ bool InstallUtil::IsOSSupported() { (version == base::win::VERSION_XP && major >= 2); } -void InstallUtil::WriteInstallerResult(bool system_install, - installer_util::InstallStatus status, - int string_resource_id, - const std::wstring* const launch_cmd) { - HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; - BrowserDistribution* dist = BrowserDistribution::GetDistribution(); - std::wstring key = dist->GetStateKey(); - int installer_result = (dist->GetInstallReturnCode(status) == 0) ? 0 : 1; - scoped_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList()); - install_list->AddCreateRegKeyWorkItem(root, key); - install_list->AddSetRegValueWorkItem(root, key, L"InstallerResult", - installer_result, true); - install_list->AddSetRegValueWorkItem(root, key, L"InstallerError", - status, true); - if (string_resource_id != 0) { - std::wstring msg = installer_util::GetLocalizedString(string_resource_id); - install_list->AddSetRegValueWorkItem(root, key, L"InstallerResultUIString", - msg, true); - } - if (launch_cmd != NULL && !launch_cmd->empty()) { - install_list->AddSetRegValueWorkItem(root, key, - L"InstallerSuccessLaunchCmdLine", - *launch_cmd, true); - } - if (!install_list->Do()) - LOG(ERROR) << "Failed to record installer error information in registry."; -} - bool InstallUtil::IsPerUserInstall(const wchar_t* const exe_path) { wchar_t program_files_path[MAX_PATH] = {0}; if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL, @@ -155,7 +129,7 @@ bool InstallUtil::IsChromeFrameProcess() { return prefs.install_chrome_frame(); } -bool InstallUtil::IsChromeSxSProcess() { +bool CheckIsChromeSxSProcess() { CommandLine* command_line = CommandLine::ForCurrentProcess(); CHECK(command_line); @@ -173,64 +147,9 @@ bool InstallUtil::IsChromeSxSProcess() { chrome_sxs_dir); } -bool InstallUtil::IsMSIProcess(bool system_level) { - // Initialize the static msi flags. - static bool is_msi_ = false; - static bool msi_checked_ = false; - - if (!msi_checked_) { - msi_checked_ = true; - - const MasterPreferences& prefs = GetMasterPreferencesForCurrentProcess(); - - bool is_msi = false; - prefs.GetBool(installer_util::master_preferences::kMsi, &is_msi); - - if (!is_msi) { - // We didn't find it in the preferences, try looking in the registry. - HKEY reg_root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; - RegKey key; - DWORD msi_value; - - BrowserDistribution* dist = BrowserDistribution::GetDistribution(); - DCHECK(dist); - - bool success = false; - std::wstring reg_key(dist->GetStateKey()); - if (key.Open(reg_root, reg_key.c_str(), KEY_READ | KEY_WRITE)) { - if (key.ReadValueDW(google_update::kRegMSIField, &msi_value)) { - is_msi = (msi_value == 1); - } - } - } - - is_msi_ = is_msi; - } - - return is_msi_; -} - -bool InstallUtil::SetMSIMarker(bool system_level, bool set) { - BrowserDistribution* dist = BrowserDistribution::GetDistribution(); - DCHECK(dist); - std::wstring client_state_path(dist->GetStateKey()); - - bool success = false; - HKEY reg_root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; - RegKey client_state_key; - if (client_state_key.Open(reg_root, client_state_path.c_str(), - KEY_READ | KEY_WRITE)) { - DWORD msi_value = set ? 1 : 0; - if (client_state_key.WriteValue(google_update::kRegMSIField, msi_value)) { - success = true; - } else { - LOG(ERROR) << "Could not write msi value to client state key."; - } - } else { - LOG(ERROR) << "Could not open client state key!"; - } - - return success; +bool InstallUtil::IsChromeSxSProcess() { + static bool sxs = CheckIsChromeSxSProcess(); + return sxs; } bool InstallUtil::BuildDLLRegistrationList(const std::wstring& install_path, @@ -257,8 +176,8 @@ bool InstallUtil::DeleteRegistryKey(RegKey& root_key, const std::wstring& key_path) { VLOG(1) << "Deleting registry key " << key_path; if (!root_key.DeleteKey(key_path.c_str()) && - ::GetLastError() != ERROR_MOD_NOT_FOUND) { - LOG(ERROR) << "Failed to delete registry key: " << key_path; + ::GetLastError() != ERROR_FILE_NOT_FOUND) { + PLOG(ERROR) << "Failed to delete registry key: " << key_path; return false; } return true; |