| Index: chrome/installer/util/installation_state.h
|
| ===================================================================
|
| --- chrome/installer/util/installation_state.h (revision 72487)
|
| +++ chrome/installer/util/installation_state.h (working copy)
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2010 The Chromium Authors. All rights reserved.
|
| +// 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.
|
|
|
| @@ -9,6 +9,8 @@
|
| #include <string>
|
|
|
| #include "base/basictypes.h"
|
| +#include "base/command_line.h"
|
| +#include "base/file_path.h"
|
| #include "base/scoped_ptr.h"
|
| #include "chrome/installer/util/browser_distribution.h"
|
| #include "chrome/installer/util/channel_info.h"
|
| @@ -19,45 +21,76 @@
|
|
|
| class InstallationState;
|
| class MasterPreferences;
|
| -class PackageProperties;
|
|
|
| +// A representation of a product's state on the machine based on the contents
|
| +// of the Windows registry.
|
| +// TODO(grt): Pull this out into its own file.
|
| class ProductState {
|
| public:
|
| ProductState();
|
| - void Initialize(bool system_install,
|
| - const std::wstring& version_key,
|
| - const std::wstring& state_key);
|
|
|
| + // Returns true if the product is installed (i.e., the product's Clients key
|
| + // exists and has a "pv" value); false otherwise.
|
| + bool Initialize(bool system_install,
|
| + BrowserDistribution::Type type);
|
| + bool Initialize(bool system_install,
|
| + BrowserDistribution* distribution);
|
| +
|
| + // Returns the product's channel info (i.e., the Google Update "ap" value).
|
| const ChannelInfo& channel() const { return channel_; }
|
| - ChannelInfo& channel() { return channel_; }
|
|
|
| + // Returns the path to the product's "setup.exe"; may be empty.
|
| + FilePath GetSetupPath() const;
|
| +
|
| + // Returns the product's version. This method may only be called on an
|
| + // instance that has been initialized for an installed product.
|
| const Version& version() const;
|
| - // Takes ownership of |version|.
|
| - void set_version(Version* version) { version_.reset(version); }
|
|
|
| - void CopyFrom(const ProductState& other);
|
| + // Returns the current version of the product if a new version is awaiting
|
| + // update; may be NULL. Ownership of a returned value is not passed to the
|
| + // caller.
|
| + const Version* old_version() const { return old_version_.get(); }
|
|
|
| + // Returns the command to be used to update to the new version that is
|
| + // awaiting update; may be empty.
|
| + const std::wstring& rename_cmd() const { return rename_cmd_; }
|
| +
|
| + // True if the "msi" value in the ClientState key is present and non-zero.
|
| + bool is_msi() const { return msi_; }
|
| +
|
| + // The command to uninstall the product; may be empty.
|
| + const CommandLine& uninstall_command() const { return uninstall_command_; }
|
| +
|
| + // True if |uninstall_command| contains --multi-install.
|
| + bool is_multi_install() const { return multi_install_; }
|
| +
|
| + // Returns this object a la operator=().
|
| + ProductState& CopyFrom(const ProductState& other);
|
| +
|
| + protected:
|
| + ChannelInfo channel_;
|
| + scoped_ptr<Version> version_;
|
| + scoped_ptr<Version> old_version_;
|
| + std::wstring rename_cmd_;
|
| + CommandLine uninstall_command_;
|
| + bool msi_;
|
| + bool multi_install_;
|
| +
|
| private:
|
| friend class InstallationState;
|
|
|
| - ChannelInfo channel_;
|
| - scoped_ptr<Version> version_;
|
| DISALLOW_COPY_AND_ASSIGN(ProductState);
|
| }; // class ProductState
|
|
|
| // Encapsulates the state of all products on the system.
|
| +// TODO(grt): Rename this to MachineState and put it in its own file.
|
| class InstallationState {
|
| public:
|
| InstallationState();
|
|
|
| - // Initializes |this| with the machine's current state.
|
| - void Initialize(const MasterPreferences& prefs);
|
| + // Initializes this object with the machine's current state.
|
| + void Initialize();
|
|
|
| - // Returns the state of the multi-installer package or NULL if no
|
| - // multi-install products are installed.
|
| - // Caller does NOT assume ownership of returned pointer.
|
| - const ProductState* GetMultiPackageState(bool system_install) const;
|
| -
|
| // Returns the state of a product or NULL if not installed.
|
| // Caller does NOT assume ownership of returned pointer.
|
| const ProductState* GetProductState(bool system_install,
|
| @@ -67,17 +100,11 @@
|
| enum {
|
| CHROME_BROWSER_INDEX,
|
| CHROME_FRAME_INDEX,
|
| - MULTI_PACKAGE_INDEX,
|
| + CHROME_BINARIES_INDEX,
|
| NUM_PRODUCTS
|
| };
|
|
|
| static int IndexFromDistType(BrowserDistribution::Type type);
|
| - static void InitializeProduct(bool system_install,
|
| - BrowserDistribution* distribution,
|
| - ProductState* product);
|
| - static void InitializeMultiPackage(bool system_install,
|
| - PackageProperties& properties,
|
| - ProductState* product);
|
|
|
| ProductState user_products_[NUM_PRODUCTS];
|
| ProductState system_products_[NUM_PRODUCTS];
|
|
|