diff options
author | grt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-05 03:13:33 +0000 |
---|---|---|
committer | grt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-05 03:13:33 +0000 |
commit | a6ea126034ade23d94df94e2b105538152f6d86e (patch) | |
tree | 24b3059668f27f4a2e29fca025f77eefe14987a5 /chrome/installer/util/installer_state.cc | |
parent | 269bb3a69e402a893bc8d01a99347c7ef6a5a38a (diff) | |
download | chromium_src-a6ea126034ade23d94df94e2b105538152f6d86e.zip chromium_src-a6ea126034ade23d94df94e2b105538152f6d86e.tar.gz chromium_src-a6ea126034ade23d94df94e2b105538152f6d86e.tar.bz2 |
- WriteInstallerResult is now back in InstallUtil and only writes the result where it is needed
- WriteInstallerResult is no longer called on uninstall (Google Update doesn't check it on uninstall)
- Introduced the poorly named InstallationState (state of the system based on registry inspection) and InstallerState (state of the current operation) classes
- Product::GetInstalledVersion and Product::IsInstalled are gone; use InstallationState instead
- A few cleanups to make the code comply with the style guide
- UpdateDiffInstallStatus has been renamed to UpdateInstallStatus
- Chromium builds noop in UpdateInstallStatus (this was always the case for the browser, but now also is for GCF and the multi-installer package).
- The -multifail suffixes is now added to/removed from the Google Update "ap" value by UpdateInstallStatus on the basis of multi-install success/failure.
- Added code to update the Google Update "ap" value based on the set up products/options installed
- ChannelInfo is now an ordered list of modifiers and suffixes. We're careful to keep -full at the end since that was an operating assumption previously.
- ActivePackageProperties is a typedef to either the Chrome or Chromium PackageProperties class
TEST=Some existing unit tests updated; more new unit tests to follow.
BUG=61609
Review URL: http://codereview.chromium.org/5988007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70483 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/util/installer_state.cc')
-rw-r--r-- | chrome/installer/util/installer_state.cc | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/chrome/installer/util/installer_state.cc b/chrome/installer/util/installer_state.cc new file mode 100644 index 0000000..fd396da --- /dev/null +++ b/chrome/installer/util/installer_state.cc @@ -0,0 +1,93 @@ +// Copyright (c) 2010 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. + +#include "chrome/installer/util/installer_state.h" + +#include "base/logging.h" +#include "chrome/installer/util/installation_state.h" +#include "chrome/installer/util/master_preferences.h" +#include "chrome/installer/util/master_preferences_constants.h" +#include "chrome/installer/util/package_properties.h" + +namespace installer { + +bool InstallerState::IsMultiInstallUpdate(const MasterPreferences& prefs, + const InstallationState& machine_state) { + // First, is the package present? + const ProductState* package = + machine_state.GetMultiPackageState(system_install_); + if (package == NULL) { + // The multi-install package has not been installed, so it certainly isn't + // being updated. + return false; + } + + BrowserDistribution::Type types[2]; + size_t num_types = 0; + if (prefs.install_chrome()) + types[num_types++] = BrowserDistribution::CHROME_BROWSER; + if (prefs.install_chrome_frame()) + types[num_types++] = BrowserDistribution::CHROME_FRAME; + + for (const BrowserDistribution::Type* scan = &types[0], + *end = &types[num_types]; scan != end; ++scan) { + const ProductState* product = + machine_state.GetProductState(system_install_, *scan); + if (product == NULL) { + VLOG(2) << "It seems that distribution type " << *scan + << " is being installed for the first time."; + return false; + } + if (!product->channel().Equals(package->channel())) { + VLOG(2) << "It seems that distribution type " << *scan + << " is being over installed."; + return false; + } + } + + VLOG(2) << "It seems that the package is being updated."; + + return true; +} + +InstallerState::InstallerState() : operation_(UNINITIALIZED) { +} + +void InstallerState::Initialize(const MasterPreferences& prefs, + const InstallationState& machine_state) { + if (!prefs.GetBool(installer::master_preferences::kSystemLevel, + &system_install_)) + system_install_ = false; + + BrowserDistribution* operand = NULL; + + if (!prefs.is_multi_install()) { + // For a single-install, the current browser dist is the operand. + operand = BrowserDistribution::GetDistribution(); + operation_ = SINGLE_INSTALL_OR_UPDATE; + } else if (IsMultiInstallUpdate(prefs, machine_state)) { + // Updates driven by Google Update take place under the multi-installer's + // app guid. + installer::ActivePackageProperties package_properties; + operation_ = MULTI_UPDATE; + state_key_ = package_properties.GetStateKey(); + } else { + // Initial and over installs will always take place under one of the + // product app guids. Chrome Frame's will be used if only Chrome Frame + // is being installed. In all other cases, Chrome's is used. + operand = BrowserDistribution::GetSpecificDistribution( + prefs.install_chrome() ? + BrowserDistribution::CHROME_BROWSER : + BrowserDistribution::CHROME_FRAME, + prefs); + operation_ = MULTI_INSTALL; + } + + if (operand != NULL) { + install_operand_ = operand->GetType(); + state_key_ = operand->GetStateKey(); + } +} + +} // namespace installer |