summaryrefslogtreecommitdiffstats
path: root/chrome/installer/util
diff options
context:
space:
mode:
authormsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-27 17:27:50 +0000
committermsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-27 17:27:50 +0000
commitdc84cd67030349253c5ee2cdb48071cfa9234740 (patch)
tree79ce670831efbe459e0e44b8e59aa1dc2c9df631 /chrome/installer/util
parent219c128326fa47015cdd0880590d18a8d3a3f2b8 (diff)
downloadchromium_src-dc84cd67030349253c5ee2cdb48071cfa9234740.zip
chromium_src-dc84cd67030349253c5ee2cdb48071cfa9234740.tar.gz
chromium_src-dc84cd67030349253c5ee2cdb48071cfa9234740.tar.bz2
Revert 87035 - Properly detect the current version when migrating single to multi. Previously, we were missing the current version, which could have led to:
- failing to set "opv" on in-use update - failing to unregister Chrome Frame COM DLLs - returning INSTALL_FAILED instead of SAME_VERSION_REPAIR_FAILED - returning FIRST_INSTALL_SUCCESS instead of INSTALL_REPAIRED, IN_USE_UPDATED, or NEW_VERSION_UPDATED - leaving behind old version directories - failing to check for duplicates on same version repair BUG=none TEST=install single chrome. run mini_installer.exe with --multi-install --chrome to migrate to multi-install. make sure the installer result code is correct as above. Review URL: http://codereview.chromium.org/6976049 TBR=grt@chromium.org Review URL: http://codereview.chromium.org/7085003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87038 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/util')
-rw-r--r--chrome/installer/util/fake_installation_state.h59
-rw-r--r--chrome/installer/util/fake_product_state.h36
-rw-r--r--chrome/installer/util/installer_state.cc30
-rw-r--r--chrome/installer/util/installer_state_unittest.cc26
4 files changed, 3 insertions, 148 deletions
diff --git a/chrome/installer/util/fake_installation_state.h b/chrome/installer/util/fake_installation_state.h
deleted file mode 100644
index fc91a42..0000000
--- a/chrome/installer/util/fake_installation_state.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_INSTALLER_UTIL_FAKE_INSTALLATION_STATE_H_
-#define CHROME_INSTALLER_UTIL_FAKE_INSTALLATION_STATE_H_
-#pragma once
-
-#include "base/file_path.h"
-#include "base/version.h"
-#include "chrome/installer/util/fake_product_state.h"
-#include "chrome/installer/util/helper.h"
-#include "chrome/installer/util/installation_state.h"
-#include "chrome/installer/util/util_constants.h"
-
-namespace installer {
-
-// An InstallationState helper for use by unit tests.
-class FakeInstallationState : public InstallationState {
- public:
- // Takes ownership of |version|.
- void AddChrome(bool system_install, bool multi_install, Version* version) {
- FakeProductState chrome_state;
- chrome_state.set_version(version);
- chrome_state.set_multi_install(multi_install);
- FilePath setup_exe(
- GetChromeInstallPath(system_install,
- BrowserDistribution::GetSpecificDistribution(
- BrowserDistribution::CHROME_BROWSER)));
- setup_exe = setup_exe
- .AppendASCII(version->GetString())
- .Append(kInstallerDir)
- .Append(kSetupExe);
- chrome_state.SetUninstallProgram(setup_exe);
- chrome_state.AddUninstallSwitch(switches::kUninstall);
- if (multi_install) {
- chrome_state.AddUninstallSwitch(switches::kMultiInstall);
- chrome_state.AddUninstallSwitch(switches::kChrome);
- }
- SetProductState(system_install, BrowserDistribution::CHROME_BROWSER,
- chrome_state);
- }
-
- void SetProductState(bool system_install,
- BrowserDistribution::Type type,
- const ProductState& product_state) {
- ProductState& target = GetProducts(system_install)[IndexFromDistType(type)];
- target.CopyFrom(product_state);
- }
-
- protected:
- ProductState* GetProducts(bool system_install) {
- return system_install ? system_products_ : user_products_;
- }
-};
-
-} // namespace installer
-
-#endif // CHROME_INSTALLER_UTIL_FAKE_INSTALLATION_STATE_H_
diff --git a/chrome/installer/util/fake_product_state.h b/chrome/installer/util/fake_product_state.h
deleted file mode 100644
index 03fa1a4..0000000
--- a/chrome/installer/util/fake_product_state.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_INSTALLER_UTIL_FAKE_PRODUCT_STATE_H_
-#define CHROME_INSTALLER_UTIL_FAKE_PRODUCT_STATE_H_
-#pragma once
-
-#include <string>
-#include "chrome/installer/util/installation_state.h"
-
-namespace installer {
-
-// A ProductState helper for use by unit tests.
-class FakeProductState : public ProductState {
- public:
- // Takes ownership of |version|.
- void set_version(Version* version) { version_.reset(version); }
- void set_multi_install(bool multi) { multi_install_ = multi; }
- void set_brand(const std::wstring& brand) { brand_ = brand; }
- void set_usagestats(DWORD usagestats) {
- has_usagestats_ = true;
- usagestats_ = usagestats;
- }
- void clear_usagestats() { has_usagestats_ = false; }
- void SetUninstallProgram(const FilePath& setup_exe) {
- uninstall_command_ = CommandLine(setup_exe);
- }
- void AddUninstallSwitch(const std::string& option) {
- uninstall_command_.AppendSwitch(option);
- }
-};
-
-} // namespace installer
-
-#endif // CHROME_INSTALLER_UTIL_FAKE_PRODUCT_STATE_H_
diff --git a/chrome/installer/util/installer_state.cc b/chrome/installer/util/installer_state.cc
index 42e8e10..ff8a6b7 100644
--- a/chrome/installer/util/installer_state.cc
+++ b/chrome/installer/util/installer_state.cc
@@ -364,33 +364,9 @@ Version* InstallerState::GetCurrentVersion(
const InstallationState& machine_state) const {
DCHECK(!products_.empty());
scoped_ptr<Version> current_version;
- // If we're doing a multi-install, the current version may be either an
- // existing multi or an existing single product that is being migrated
- // in place (i.e., Chrome). In the latter case, there is no existing
- // CHROME_BINARIES installation so we need to search for the product.
- BrowserDistribution::Type prod_type;
- if (package_type_ == MULTI_PACKAGE) {
- prod_type = BrowserDistribution::CHROME_BINARIES;
- if (machine_state.GetProductState(level_ == SYSTEM_LEVEL,
- prod_type) == NULL) {
- // Search for a product on which we're operating that is installed in our
- // target directory.
- Products::const_iterator end = products().end();
- for (Products::const_iterator scan = products().begin(); scan != end;
- ++scan) {
- BrowserDistribution::Type product_type =
- (*scan)->distribution()->GetType();
- const ProductState* state =
- machine_state.GetProductState(level_ == SYSTEM_LEVEL, product_type);
- if (state != NULL && target_path_.IsParent(state->GetSetupPath())) {
- prod_type = product_type;
- break;
- }
- }
- }
- } else {
- prod_type = products_[0]->distribution()->GetType();
- }
+ const BrowserDistribution::Type prod_type = (package_type_ == MULTI_PACKAGE) ?
+ BrowserDistribution::CHROME_BINARIES :
+ products_[0]->distribution()->GetType();
const ProductState* product_state =
machine_state.GetProductState(level_ == SYSTEM_LEVEL, prod_type);
diff --git a/chrome/installer/util/installer_state_unittest.cc b/chrome/installer/util/installer_state_unittest.cc
index 7edb9b8..c35fac4 100644
--- a/chrome/installer/util/installer_state_unittest.cc
+++ b/chrome/installer/util/installer_state_unittest.cc
@@ -17,9 +17,6 @@
#include "base/version.h"
#include "base/win/registry.h"
#include "base/win/scoped_handle.h"
-#include "chrome/common/chrome_constants.h"
-#include "chrome/installer/util/fake_installation_state.h"
-#include "chrome/installer/util/fake_product_state.h"
#include "chrome/installer/util/google_update_constants.h"
#include "chrome/installer/util/helper.h"
#include "chrome/installer/util/installation_state.h"
@@ -434,26 +431,3 @@ TEST_F(InstallerStateTest, InstallerResult) {
}
TempRegKeyOverride::DeleteAllTempKeys();
}
-
-// Test GetCurrentVersion when migrating single Chrome to multi
-TEST_F(InstallerStateTest, GetCurrentVersionMigrateChrome) {
- using installer::FakeInstallationState;
-
- const bool system_install = false;
- FakeInstallationState machine_state;
-
- // Pretend that this version of single-install Chrome is already installed.
- machine_state.AddChrome(system_install, false,
- Version::GetVersionFromString(chrome::kChromeVersion));
-
- // Now we're invoked to install multi Chrome.
- CommandLine cmd_line(
- CommandLine::FromString(L"setup.exe --multi-install --chrome"));
- MasterPreferences prefs(cmd_line);
- InstallerState installer_state;
- installer_state.Initialize(cmd_line, prefs, machine_state);
-
- // Is the Chrome version picked up?
- scoped_ptr<Version> version(installer_state.GetCurrentVersion(machine_state));
- EXPECT_TRUE(version.get() != NULL);
-}