Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(985)

Side by Side Diff: chrome/installer/util/installation_state.h

Issue 6288009: More installer refactoring in the interest of fixing some bugs and cleaning t... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_INSTALLER_UTIL_INSTALLATION_STATE_H_ 5 #ifndef CHROME_INSTALLER_UTIL_INSTALLATION_STATE_H_
6 #define CHROME_INSTALLER_UTIL_INSTALLATION_STATE_H_ 6 #define CHROME_INSTALLER_UTIL_INSTALLATION_STATE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/command_line.h"
13 #include "base/file_path.h"
12 #include "base/scoped_ptr.h" 14 #include "base/scoped_ptr.h"
13 #include "chrome/installer/util/browser_distribution.h" 15 #include "chrome/installer/util/browser_distribution.h"
14 #include "chrome/installer/util/channel_info.h" 16 #include "chrome/installer/util/channel_info.h"
15 17
16 class Version; 18 class Version;
17 19
18 namespace installer { 20 namespace installer {
19 21
20 class InstallationState; 22 class InstallationState;
21 class MasterPreferences; 23 class MasterPreferences;
22 class PackageProperties;
23 24
25 // A representation of a product's state on the machine based on the contents
26 // of the Windows registry.
27 // TODO(grt): Pull this out into its own file.
24 class ProductState { 28 class ProductState {
25 public: 29 public:
26 ProductState(); 30 ProductState();
27 void Initialize(bool system_install,
28 const std::wstring& version_key,
29 const std::wstring& state_key);
30 31
32 // Returns true if the product is installed (i.e., the product's Clients key
33 // exists and has a "pv" value); false otherwise.
34 bool Initialize(bool system_install,
35 BrowserDistribution::Type type);
36 bool Initialize(bool system_install,
37 BrowserDistribution* distribution);
38
39 // Returns the product's channel info (i.e., the Google Update "ap" value).
31 const ChannelInfo& channel() const { return channel_; } 40 const ChannelInfo& channel() const { return channel_; }
32 ChannelInfo& channel() { return channel_; }
33 41
42 // Returns the path to the product's "setup.exe"; may be empty.
43 FilePath GetSetupPath() const;
44
45 // Returns the product's version. This method may only be called on an
46 // instance that has been initialized for an installed product.
34 const Version& version() const; 47 const Version& version() const;
35 // Takes ownership of |version|.
36 void set_version(Version* version) { version_.reset(version); }
37 48
38 void CopyFrom(const ProductState& other); 49 // Returns the current version of the product if a new version is awaiting
50 // update; may be NULL. Ownership of a returned value is not passed to the
51 // caller.
52 const Version* old_version() const { return old_version_.get(); }
53
54 // Returns the command to be used to update to the new version that is
55 // awaiting update; may be empty.
56 const std::wstring& rename_cmd() const { return rename_cmd_; }
57
58 // True if the "msi" value in the ClientState key is present and non-zero.
59 bool is_msi() const { return msi_; }
60
61 // The command to uninstall the product; may be empty.
62 const CommandLine& uninstall_command() const { return uninstall_command_; }
63
64 // True if |uninstall_command| contains --multi-install.
65 bool is_multi_install() const { return multi_install_; }
66
67 // Returns this object a la operator=().
68 ProductState& CopyFrom(const ProductState& other);
69
70 protected:
71 ChannelInfo channel_;
72 scoped_ptr<Version> version_;
73 scoped_ptr<Version> old_version_;
74 std::wstring rename_cmd_;
75 CommandLine uninstall_command_;
76 bool msi_;
77 bool multi_install_;
39 78
40 private: 79 private:
41 friend class InstallationState; 80 friend class InstallationState;
42 81
43 ChannelInfo channel_;
44 scoped_ptr<Version> version_;
45 DISALLOW_COPY_AND_ASSIGN(ProductState); 82 DISALLOW_COPY_AND_ASSIGN(ProductState);
46 }; // class ProductState 83 }; // class ProductState
47 84
48 // Encapsulates the state of all products on the system. 85 // Encapsulates the state of all products on the system.
86 // TODO(grt): Rename this to MachineState and put it in its own file.
49 class InstallationState { 87 class InstallationState {
50 public: 88 public:
51 InstallationState(); 89 InstallationState();
52 90
53 // Initializes |this| with the machine's current state. 91 // Initializes this object with the machine's current state.
54 void Initialize(const MasterPreferences& prefs); 92 void Initialize();
55
56 // Returns the state of the multi-installer package or NULL if no
57 // multi-install products are installed.
58 // Caller does NOT assume ownership of returned pointer.
59 const ProductState* GetMultiPackageState(bool system_install) const;
60 93
61 // Returns the state of a product or NULL if not installed. 94 // Returns the state of a product or NULL if not installed.
62 // Caller does NOT assume ownership of returned pointer. 95 // Caller does NOT assume ownership of returned pointer.
63 const ProductState* GetProductState(bool system_install, 96 const ProductState* GetProductState(bool system_install,
64 BrowserDistribution::Type type) const; 97 BrowserDistribution::Type type) const;
65 98
66 protected: 99 protected:
67 enum { 100 enum {
68 CHROME_BROWSER_INDEX, 101 CHROME_BROWSER_INDEX,
69 CHROME_FRAME_INDEX, 102 CHROME_FRAME_INDEX,
70 MULTI_PACKAGE_INDEX, 103 CHROME_BINARIES_INDEX,
71 NUM_PRODUCTS 104 NUM_PRODUCTS
72 }; 105 };
73 106
74 static int IndexFromDistType(BrowserDistribution::Type type); 107 static int IndexFromDistType(BrowserDistribution::Type type);
75 static void InitializeProduct(bool system_install,
76 BrowserDistribution* distribution,
77 ProductState* product);
78 static void InitializeMultiPackage(bool system_install,
79 PackageProperties& properties,
80 ProductState* product);
81 108
82 ProductState user_products_[NUM_PRODUCTS]; 109 ProductState user_products_[NUM_PRODUCTS];
83 ProductState system_products_[NUM_PRODUCTS]; 110 ProductState system_products_[NUM_PRODUCTS];
84 111
85 private: 112 private:
86 DISALLOW_COPY_AND_ASSIGN(InstallationState); 113 DISALLOW_COPY_AND_ASSIGN(InstallationState);
87 }; // class InstallationState 114 }; // class InstallationState
88 115
89 } // namespace installer 116 } // namespace installer
90 117
91 #endif // CHROME_INSTALLER_UTIL_INSTALLATION_STATE_H_ 118 #endif // CHROME_INSTALLER_UTIL_INSTALLATION_STATE_H_
OLDNEW
« no previous file with comments | « chrome/installer/util/install_util_unittest.cc ('k') | chrome/installer/util/installation_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698