summaryrefslogtreecommitdiffstats
path: root/chrome/installer/util/installation_state.cc
diff options
context:
space:
mode:
authorgrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-25 16:44:37 +0000
committergrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-25 16:44:37 +0000
commitf0260d27d34e40f2e619fb7a16dcd7f9d63fc683 (patch)
tree7e7c9e83bbd2f67b4bbbe11d076c7cc70abd8855 /chrome/installer/util/installation_state.cc
parentce7937429f63f3d966346fcd973d720f268cd888 (diff)
downloadchromium_src-f0260d27d34e40f2e619fb7a16dcd7f9d63fc683.zip
chromium_src-f0260d27d34e40f2e619fb7a16dcd7f9d63fc683.tar.gz
chromium_src-f0260d27d34e40f2e619fb7a16dcd7f9d63fc683.tar.bz2
More installer refactoring in the interest of fixing some bugs and cleaning things up:
- Introduced ProductOperations: an interface implemented for each product that takes care of product-specific functions. Each Product owns an instance and delegates certain operations to it. - Removed the use of MasterPreferences by BrowserDistribution so that the former isn't needed outside of the installer. - Replaced PackageProperties with a new BrowserDistribution type (CHROME_BINARIES) - Plumbed the concept of InstallerState more thoroughly through installer - Removed ProductPackageMapping and Package - Moved more registry read ops into ProductState - Validation of products to be installed is now done in CheckPreInstallConditions - Ignore --chrome-frame --ready-mode if chrome is also being installed/updated and a SxS GCF is found (chrome is updated). - Migrates existing single-install Chrome to multi-install where appropriate. - Fixes update to Chrome's uninstallation arguments when Chrome Frame is uninstalled. - Removed dead code from install.cc. - Added code to update products' "ap" values when ready-mode is accepted. - Skip post-install things such as launching the browser when Chrome was implicitly added to the install/upgrade process by virtue of being part of a multi-install. BUG=61609 TEST=run the installer, see it work. existing tests in installer_util_unittests have been updated; new tests are included for ProductState, ChannelInfo, etc. Review URL: http://codereview.chromium.org/6288009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72497 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/util/installation_state.cc')
-rw-r--r--chrome/installer/util/installation_state.cc140
1 files changed, 86 insertions, 54 deletions
diff --git a/chrome/installer/util/installation_state.cc b/chrome/installer/util/installation_state.cc
index c0ab82d..f766195 100644
--- a/chrome/installer/util/installation_state.cc
+++ b/chrome/installer/util/installation_state.cc
@@ -9,33 +9,82 @@
#include "base/version.h"
#include "base/win/registry.h"
#include "chrome/installer/util/google_update_constants.h"
-#include "chrome/installer/util/package_properties.h"
+#include "chrome/installer/util/install_util.h"
namespace installer {
-ProductState::ProductState() {
+ProductState::ProductState()
+ : uninstall_command_(CommandLine::NO_PROGRAM),
+ msi_(false),
+ multi_install_(false) {
}
-void ProductState::Initialize(bool system_install,
- const std::wstring& version_key,
- const std::wstring& state_key) {
+bool ProductState::Initialize(bool system_install,
+ BrowserDistribution::Type type) {
+ return Initialize(system_install,
+ BrowserDistribution::GetSpecificDistribution(type));
+}
+
+bool ProductState::Initialize(bool system_install,
+ BrowserDistribution* distribution) {
+ const std::wstring version_key(distribution->GetVersionKey());
+ const std::wstring state_key(distribution->GetStateKey());
const HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
base::win::RegKey key(root_key, version_key.c_str(), KEY_QUERY_VALUE);
std::wstring version_str;
- if (key.ReadValue(google_update::kRegVersionField, &version_str)
- == ERROR_SUCCESS) {
+ if (key.ReadValue(google_update::kRegVersionField,
+ &version_str) == ERROR_SUCCESS) {
version_.reset(Version::GetVersionFromString(WideToASCII(version_str)));
if (version_.get() != NULL) {
- // The product is installed. Check for the channel value (absent if not
- // installed/managed by Google Update).
- if ((key.Open(root_key, state_key.c_str(), KEY_QUERY_VALUE) !=
- ERROR_SUCCESS) || !channel_.Initialize(key)) {
- channel_.set_value(std::wstring());
+ // The product is installed.
+ if (key.ReadValue(google_update::kRegOldVersionField,
+ &version_str) == ERROR_SUCCESS) {
+ old_version_.reset(
+ Version::GetVersionFromString(WideToASCII(version_str)));
+ } else {
+ old_version_.reset();
+ }
+ if (key.ReadValue(google_update::kRegRenameCmdField,
+ &rename_cmd_) != ERROR_SUCCESS)
+ rename_cmd_.clear();
+ // Read from the ClientState key.
+ channel_.set_value(std::wstring());
+ uninstall_command_ = CommandLine(CommandLine::NO_PROGRAM);
+ msi_ = false;
+ multi_install_ = false;
+ if (key.Open(root_key, state_key.c_str(),
+ KEY_QUERY_VALUE) == ERROR_SUCCESS) {
+ std::wstring setup_path;
+ std::wstring uninstall_arguments;
+ // "ap" will be absent if not managed by Google Update.
+ channel_.Initialize(key);
+ // "UninstallString" will be absent for the multi-installer package.
+ key.ReadValue(kUninstallStringField, &setup_path);
+ // "UninstallArguments" will be absent for the multi-installer package.
+ key.ReadValue(kUninstallArgumentsField, &uninstall_arguments);
+ InstallUtil::MakeUninstallCommand(setup_path, uninstall_arguments,
+ &uninstall_command_);
+ // "msi" may be absent, 0 or 1
+ DWORD dw_value = 0;
+ msi_ = (key.ReadValueDW(google_update::kRegMSIField,
+ &dw_value) == ERROR_SUCCESS) && (dw_value != 0);
+ // Multi-install is implied or is derived from the command-line.
+ if (distribution->GetType() == BrowserDistribution::CHROME_BINARIES) {
+ multi_install_ = true;
+ } else {
+ multi_install_ = uninstall_command_.HasSwitch(
+ switches::kMultiInstall);
+ }
}
}
} else {
version_.reset();
}
+ return version_.get() != NULL;
+}
+
+FilePath ProductState::GetSetupPath() const {
+ return uninstall_command_.GetProgram();
}
const Version& ProductState::version() const {
@@ -43,12 +92,17 @@ const Version& ProductState::version() const {
return *version_;
}
-void ProductState::CopyFrom(const ProductState& other) {
+ProductState& ProductState::CopyFrom(const ProductState& other) {
channel_.set_value(other.channel_.value());
- if (other.version_.get() == NULL)
- version_.reset();
- else
- version_.reset(other.version_->Clone());
+ version_.reset(other.version_.get() == NULL ? NULL : other.version_->Clone());
+ old_version_.reset(
+ other.old_version_.get() == NULL ? NULL : other.old_version_->Clone());
+ rename_cmd_ = other.rename_cmd_;
+ uninstall_command_ = other.uninstall_command_;
+ msi_ = other.msi_;
+ multi_install_ = other.multi_install_;
+
+ return *this;
}
InstallationState::InstallationState() {
@@ -60,53 +114,31 @@ int InstallationState::IndexFromDistType(BrowserDistribution::Type type) {
unexpected_chrome_browser_distribution_value_);
COMPILE_ASSERT(BrowserDistribution::CHROME_FRAME == CHROME_FRAME_INDEX,
unexpected_chrome_frame_distribution_value_);
+ COMPILE_ASSERT(BrowserDistribution::CHROME_BINARIES == CHROME_BINARIES_INDEX,
+ unexpected_chrome_frame_distribution_value_);
DCHECK(type == BrowserDistribution::CHROME_BROWSER ||
- type == BrowserDistribution::CHROME_FRAME);
+ type == BrowserDistribution::CHROME_FRAME ||
+ type == BrowserDistribution::CHROME_BINARIES);
return type;
}
-void InstallationState::Initialize(const MasterPreferences& prefs) {
+void InstallationState::Initialize() {
BrowserDistribution* distribution;
distribution = BrowserDistribution::GetSpecificDistribution(
- BrowserDistribution::CHROME_BROWSER, prefs);
- InitializeProduct(false, distribution, &user_products_[CHROME_BROWSER_INDEX]);
- InitializeProduct(true, distribution,
- &system_products_[CHROME_BROWSER_INDEX]);
+ BrowserDistribution::CHROME_BROWSER);
+ user_products_[CHROME_BROWSER_INDEX].Initialize(false, distribution);
+ system_products_[CHROME_BROWSER_INDEX].Initialize(true, distribution);
distribution = BrowserDistribution::GetSpecificDistribution(
- BrowserDistribution::CHROME_FRAME, prefs);
- InitializeProduct(false, distribution, &user_products_[CHROME_FRAME_INDEX]);
- InitializeProduct(true, distribution, &system_products_[CHROME_FRAME_INDEX]);
-
- ActivePackageProperties package_properties;
- InitializeMultiPackage(false, package_properties,
- &user_products_[MULTI_PACKAGE_INDEX]);
- InitializeMultiPackage(true, package_properties,
- &system_products_[MULTI_PACKAGE_INDEX]);
-}
+ BrowserDistribution::CHROME_FRAME);
+ user_products_[CHROME_FRAME_INDEX].Initialize(false, distribution);
+ system_products_[CHROME_FRAME_INDEX].Initialize(true, distribution);
-// static
-void InstallationState::InitializeProduct(bool system_install,
- BrowserDistribution* distribution,
- ProductState* product) {
- product->Initialize(system_install, distribution->GetVersionKey(),
- distribution->GetStateKey());
-}
-
-// static
-void InstallationState::InitializeMultiPackage(bool system_install,
- PackageProperties& properties,
- ProductState* product) {
- product->Initialize(system_install, properties.GetVersionKey(),
- properties.GetStateKey());
-}
-
-const ProductState* InstallationState::GetMultiPackageState(
- bool system_install) const {
- const ProductState& product_state =
- (system_install ? system_products_ : user_products_)[MULTI_PACKAGE_INDEX];
- return product_state.version_.get() == NULL ? NULL : &product_state;
+ distribution = BrowserDistribution::GetSpecificDistribution(
+ BrowserDistribution::CHROME_BINARIES);
+ user_products_[CHROME_BINARIES_INDEX].Initialize(false, distribution);
+ system_products_[CHROME_BINARIES_INDEX].Initialize(true, distribution);
}
const ProductState* InstallationState::GetProductState(