diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-28 13:42:46 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-28 13:42:46 +0000 |
commit | 8586ba6c1120dd5fb58175b792f001d9f6468e06 (patch) | |
tree | 3e745293b1cb1dbcffcf7b21647ad133ccee2725 /chrome/installer/util/install_util.cc | |
parent | 7285f6ea8ca1e82f215c9c4d0cea09579cc45510 (diff) | |
download | chromium_src-8586ba6c1120dd5fb58175b792f001d9f6468e06.zip chromium_src-8586ba6c1120dd5fb58175b792f001d9f6468e06.tar.gz chromium_src-8586ba6c1120dd5fb58175b792f001d9f6468e06.tar.bz2 |
Additional changes to support Chrome / CF installation wrapped in an MSI:
Disables start menu uninstall shortcuts.
Tweaks quoting of uninstall command to follow msi ca rules.
Adds a ClientState registry entry to flag that this installation is managed by an MSI.
Set said registry flag on first MSI install.
BUG=19370
TEST=Install with generated MSI, upgrade, uninstall.
Review URL: http://codereview.chromium.org/1525042
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45802 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/util/install_util.cc')
-rw-r--r-- | chrome/installer/util/install_util.cc | 82 |
1 files changed, 71 insertions, 11 deletions
diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc index a3f32d1..6d87869 100644 --- a/chrome/installer/util/install_util.cc +++ b/chrome/installer/util/install_util.cc @@ -136,14 +136,20 @@ bool InstallUtil::IsChromeFrameProcess() { DCHECK(command_line) << "IsChromeFrameProcess() called before ComamandLine::Init()"; - // Also assume this to be a ChromeFrame process if we are running inside - // the Chrome Frame DLL. FilePath module_path; PathService::Get(base::FILE_MODULE, &module_path); std::wstring module_name(module_path.BaseName().value()); - return command_line->HasSwitch(installer_util::switches::kChromeFrame) || - module_name == installer_util::kChromeFrameDll; + scoped_ptr<DictionaryValue> prefs(installer_util::GetInstallPreferences( + *command_line)); + DCHECK(prefs.get()); + bool is_cf = false; + installer_util::GetDistroBooleanPreference(prefs.get(), + installer_util::master_preferences::kChromeFrame, &is_cf); + + // Also assume this to be a ChromeFrame process if we are running inside + // the Chrome Frame DLL. + return is_cf || module_name == installer_util::kChromeFrameDll; } bool InstallUtil::IsChromeSxSProcess() { @@ -164,18 +170,72 @@ bool InstallUtil::IsChromeSxSProcess() { chrome_sxs_dir); } -bool InstallUtil::IsMSIProcess() { +bool InstallUtil::IsMSIProcess(bool system_level) { + // Initialize the static msi flags. + static bool is_msi_ = false; + static bool msi_checked_ = false; + CommandLine* command_line = CommandLine::ForCurrentProcess(); CHECK(command_line); - scoped_ptr<DictionaryValue> prefs(installer_util::GetInstallPreferences( - *command_line)); - bool value = false; - return (installer_util::GetDistroBooleanPreference(prefs.get(), - installer_util::master_preferences::kMsi, &value) && - value); + if (!msi_checked_) { + msi_checked_ = true; + + scoped_ptr<DictionaryValue> prefs(installer_util::GetInstallPreferences( + *command_line)); + DCHECK(prefs.get()); + bool is_msi = false; + installer_util::GetDistroBooleanPreference(prefs.get(), + 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::BuildDLLRegistrationList(const std::wstring& install_path, const wchar_t** const dll_names, int dll_names_count, |