15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// found in the LICENSE file. 45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#ifndef CHROME_INSTALLER_UTIL_INSTALLER_STATE_H_ 65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define CHROME_INSTALLER_UTIL_INSTALLER_STATE_H_ 75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include <set> 95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include <string> 105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include <vector> 115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "base/basictypes.h" 135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "base/files/file_path.h" 145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "base/logging.h" 155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "base/memory/scoped_ptr.h" 165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "base/memory/scoped_vector.h" 175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "base/version.h" 185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "chrome/installer/util/browser_distribution.h" 195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "chrome/installer/util/product.h" 205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "chrome/installer/util/util_constants.h" 215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#if defined(OS_WIN) 235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include <windows.h> // NOLINT 245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#endif 255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)namespace base { 2753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)class CommandLine; 285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 2993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 30df95704c49daea886ddad70775bda23618d6274dBen Murdochnamespace installer { 3153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) 3253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)class ChannelInfo; 3353e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)class InstallationState; 3453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)class MasterPreferences; 3502772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch 3653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)class ProductState; 3753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) 3853e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)typedef std::vector<Product*> Products; 391e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) 4053e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)// Encapsulates the state of the current installation operation. Only valid 415267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)// for installs and upgrades (not for uninstalls or non-install commands). 4253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)// This class interprets the command-line arguments and master preferences and 4353e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)// determines the operations to be performed. For example, the Chrome Binaries 4453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)// are automatically added if required in multi-install mode. 4553e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)// TODO(erikwright): This is now used a fair bit during uninstall, and 4653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)// InstallerState::Initialize() contains a lot of code for uninstall. The class 4753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)// comment should probably be updated. 481e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)// TODO(grt): Rename to InstallerEngine/Conductor or somesuch? 4953e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)class InstallerState { 5053e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) public: 5153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) enum Level { 5253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) UNKNOWN_LEVEL, 5353e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) USER_LEVEL, 5453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) SYSTEM_LEVEL 551e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) }; 5693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 5793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) enum PackageType { 585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) UNKNOWN_PACKAGE_TYPE, 595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SINGLE_PACKAGE, 605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) MULTI_PACKAGE 615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) }; 625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) enum Operation { 645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) UNINITIALIZED, 655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SINGLE_INSTALL_OR_UPDATE, 665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) MULTI_INSTALL, 675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) MULTI_UPDATE, 68fff8884795cb540f87cf6e6d67b629519b00eb8bBen Murdoch UNINSTALL 695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) }; 705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Constructs an uninitialized instance; see Initialize(). 725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) InstallerState(); 735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Constructs an initialized but empty instance. 755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) explicit InstallerState(Level level); 7653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) 775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Initializes this object based on the current operation. 785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) void Initialize(const base::CommandLine& command_line, 795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const MasterPreferences& prefs, 805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const InstallationState& machine_state); 815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Adds a product constructed on the basis of |state|, setting this object's 835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // msi flag if |state| is msi-installed. Returns the product that was added, 8453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) // or NULL if |state| is incompatible with this object. Ownership is not 855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // passed to the caller. 865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Product* AddProductFromState(BrowserDistribution::Type type, 875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const ProductState& state); 885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Returns the product that was added, or NULL if |product| is incompatible 905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // with this object. Ownership of |product| is taken by this object, while 915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // ownership of the return value is not passed to the caller. 925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Product* AddProduct(scoped_ptr<Product>* product); 935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Removes |product| from the set of products to be operated on. The object 955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // pointed to by |product| is freed. Returns false if |product| is not 965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // present in the set. 97fff8884795cb540f87cf6e6d67b629519b00eb8bBen Murdoch bool RemoveProduct(const Product* product); 985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // The level (user or system) of this operation. 1005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Level level() const { return level_; } 1015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // The package type (single or multi) of this operation. 1035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) PackageType package_type() const { return package_type_; } 1045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // An identifier of this operation. 1065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Operation operation() const { return operation_; } 1075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 10853e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) // A convenience method returning level() == SYSTEM_LEVEL. 1095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // TODO(grt): Eradicate the bool in favor of the enum. 1105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool system_install() const; 1115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // A convenience method returning package_type() == MULTI_PACKAGE. 1135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // TODO(grt): Eradicate the bool in favor of the enum. 1145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool is_multi_install() const; 1155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // A convenient method returning the presence of the 1175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // --ensure-google-update-present switch. 1185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool ensure_google_update_present() const { 1195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return ensure_google_update_present_; 1205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 1215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // The full path to the place where the operand resides. 1235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const base::FilePath& target_path() const { return target_path_; } 1245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // True if the "msi" preference is set or if a product with the "msi" state 1265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // flag is set is to be operated on. 1275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool is_msi() const { return msi_; } 1285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // True if the --verbose-logging command-line flag is set or if the 1305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // verbose_logging master preferences option is true. 1315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool verbose_logging() const { return verbose_logging_; } 1325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#if defined(OS_WIN) 1345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) HKEY root_key() const { return root_key_; } 1355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#endif 1365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // The ClientState key by which we interact with Google Update. 1385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const std::wstring& state_key() const { return state_key_; } 1395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Convenience method to return the type of the BrowserDistribution associated 1415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // with the ClientState key we will be interacting with. 1425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) BrowserDistribution::Type state_type() const { return state_type_; } 1435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Returns the BrowserDistribution instance corresponding to the binaries for 1455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // this run if we're operating on a multi-package product. 1465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) BrowserDistribution* multi_package_binaries_distribution() const { 1475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) DCHECK(package_type_ == MULTI_PACKAGE); 1485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) DCHECK(multi_package_distribution_ != NULL); 1495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return multi_package_distribution_; 1505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 1515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 15202772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch const Products& products() const { return products_.get(); } 1535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Returns the product of the desired type, or NULL if none found. 1555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const Product* FindProduct(BrowserDistribution::Type distribution_type) const; 1565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Returns the currently installed version in |target_path|, or NULL if no 1585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // products are installed. Ownership is passed to the caller. 1595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::Version* GetCurrentVersion( 1605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const InstallationState& machine_state) const; 1615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Returns the critical update version if all of the following are true: 1635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // * --critical-update-version=CUV was specified on the command-line. 1645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // * current_version == NULL or current_version < CUV. 1655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // * new_version >= CUV. 1665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Otherwise, returns an invalid version. 16753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) base::Version DetermineCriticalVersion( 1685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const base::Version* current_version, 1695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const base::Version& new_version) const; 1705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Returns whether or not there is currently a Chrome Frame instance running. 172fff8884795cb540f87cf6e6d67b629519b00eb8bBen Murdoch // Note that there isn't a mechanism to lock Chrome Frame in place, so Chrome 173fff8884795cb540f87cf6e6d67b629519b00eb8bBen Murdoch // Frame may either exit or start up after this is called. 174fff8884795cb540f87cf6e6d67b629519b00eb8bBen Murdoch bool IsChromeFrameRunning(const InstallationState& machine_state) const; 175fff8884795cb540f87cf6e6d67b629519b00eb8bBen Murdoch 176fff8884795cb540f87cf6e6d67b629519b00eb8bBen Murdoch // Returns true if any of the binaries from a multi-install Chrome Frame that 177fff8884795cb540f87cf6e6d67b629519b00eb8bBen Murdoch // has been migrated to single-install are still in use. 178fff8884795cb540f87cf6e6d67b629519b00eb8bBen Murdoch bool AreBinariesInUse(const InstallationState& machine_state) const; 1795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Returns the path to the installer under Chrome version folder 1815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // (for example <target_path>\Google\Chrome\Application\<Version>\Installer) 182df95704c49daea886ddad70775bda23618d6274dBen Murdoch base::FilePath GetInstallerDirectory(const base::Version& version) const; 1835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Try to delete all directories under |temp_path| whose versions are less 185df95704c49daea886ddad70775bda23618d6274dBen Murdoch // than |new_version| and not equal to |existing_version|. |existing_version| 1865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // may be NULL. 1875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) void RemoveOldVersionDirectories(const base::Version& new_version, 188e1f1df5f01594c0e62e751e4b46e779b85c2faa5Torne (Richard Coles) base::Version* existing_version, 1895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const base::FilePath& temp_path) const; 1905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Adds to |com_dll_list| the list of COM DLLs that are to be registered 1925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // and/or unregistered. The list may be empty. 1935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) void AddComDllList(std::vector<base::FilePath>* com_dll_list) const; 1945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool SetChannelFlags(bool set, ChannelInfo* channel_info) const; 1965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 197df95704c49daea886ddad70775bda23618d6274dBen Murdoch // See InstallUtil::UpdateInstallerStage. 1985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) void UpdateStage(installer::InstallerStage stage) const; 1995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2008abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) // For a MULTI_INSTALL or MULTI_UPDATE operation, updates the Google Update 2018abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) // "ap" values for all products being operated on. 2028abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) void UpdateChannels() const; 2038abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) 2048abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) // Sets installer result information in the registry for consumption by Google 2058abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) // Update. The InstallerResult value is set to 0 (SUCCESS) or 1 2068abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) // (FAILED_CUSTOM_ERROR) depending on whether |status| maps to success or not. 2078abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) // |status| itself is written to the InstallerError value. 2085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // |string_resource_id|, if non-zero, identifies a localized string written to 2095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // the InstallerResultUIString value. |launch_cmd|, if non-NULL and 2105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // non-empty, is written to the InstallerSuccessLaunchCmdLine value. 2115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) void WriteInstallerResult(InstallStatus status, 2125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) int string_resource_id, 2135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const std::wstring* launch_cmd) const; 214df95704c49daea886ddad70775bda23618d6274dBen Murdoch 215df95704c49daea886ddad70775bda23618d6274dBen Murdoch // Returns true if this install needs to register an Active Setup command. 2165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool RequiresActiveSetup() const; 2175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) protected: 2195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Bits for the |file_bits| argument of AnyExistsAndIsInUse. 220926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) enum { 2215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) CHROME_DLL = 1 << 0, 222926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) CHROME_FRAME_DLL = 1 << 1, 2235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) CHROME_FRAME_HELPER_DLL = 1 << 2, 2245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) CHROME_FRAME_HELPER_EXE = 1 << 3, 2255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) NUM_BINARIES = 4 2265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) }; 227e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles) 2285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Returns true if |file| exists and cannot be opened for exclusive write 2295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // access. 2305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) static bool IsFileInUse(const base::FilePath& file); 2315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2325267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Clears the instance to an uninitialized state. 2335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) void Clear(); 2345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Returns true if any file corresponding to a bit in |file_bits| (from the 2365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // enum above) for the currently installed version exists and is in use. 2375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool AnyExistsAndIsInUse(const InstallationState& machine_state, 2385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) uint32 file_bits) const; 2395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::FilePath GetDefaultProductInstallPath(BrowserDistribution* dist) const; 24053e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) bool CanAddProduct(const Product& product, 24153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) const base::FilePath* product_dir) const; 24253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) Product* AddProductInDirectory(const base::FilePath* product_dir, 24353e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) scoped_ptr<Product>* product); 24453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) Product* AddProductFromPreferences( 24553e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) BrowserDistribution::Type distribution_type, 24653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) const MasterPreferences& prefs, 24753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) const InstallationState& machine_state); 24853e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) bool IsMultiInstallUpdate(const MasterPreferences& prefs, 24953e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) const InstallationState& machine_state); 25053e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) 25153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) // Enumerates all files named one of 25253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) // [chrome.exe, old_chrome.exe, new_chrome.exe] in target_path_ and 25353e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) // returns their version numbers in a set. 25453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) void GetExistingExeVersions(std::set<std::string>* existing_versions) const; 25553e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) 25653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) // Sets this object's level and updates the root_key_ accordingly. 25753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) void set_level(Level level); 25853e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) 25953e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) // Sets this object's package type and updates the multi_package_distribution_ 26053e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) // accordingly. 26153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) void set_package_type(PackageType type); 26253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) 26353e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) Operation operation_; 26453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) base::FilePath target_path_; 26553e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) std::wstring state_key_; 26653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) BrowserDistribution::Type state_type_; 26753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) ScopedVector<Product> products_; 26853e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) BrowserDistribution* multi_package_distribution_; 26953e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) base::Version critical_update_version_; 27053e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) Level level_; 27153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) PackageType package_type_; 27253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#if defined(OS_WIN) 27353e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) HKEY root_key_; 27453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#endif 27553e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) bool msi_; 27653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) bool verbose_logging_; 27753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) bool ensure_google_update_present_; 27853e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) 27953e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) private: 28053e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(InstallerState); 28153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)}; // class InstallerState 28253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) 28353e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)} // namespace installer 28453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) 28553e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#endif // CHROME_INSTALLER_UTIL_INSTALLER_STATE_H_ 28653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)