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

Side by Side Diff: chrome/installer/util/installer_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
« no previous file with comments | « chrome/installer/util/installation_state.cc ('k') | chrome/installer/util/installer_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_INSTALLER_STATE_H_ 5 #ifndef CHROME_INSTALLER_UTIL_INSTALLER_STATE_H_
6 #define CHROME_INSTALLER_UTIL_INSTALLER_STATE_H_ 6 #define CHROME_INSTALLER_UTIL_INSTALLER_STATE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector>
10 11
11 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/file_path.h"
14 #include "base/logging.h"
15 #include "base/scoped_ptr.h"
16 #include "base/scoped_vector.h"
12 #include "chrome/installer/util/browser_distribution.h" 17 #include "chrome/installer/util/browser_distribution.h"
18 #include "chrome/installer/util/product.h"
19
20 #if defined(OS_WIN)
21 #include <windows.h> // NOLINT
22 #endif
23
24 class CommandLine;
25 class Version;
13 26
14 namespace installer { 27 namespace installer {
15 28
29 class ChannelInfo;
16 class InstallationState; 30 class InstallationState;
17 class MasterPreferences; 31 class MasterPreferences;
18 32
33 class ProductState;
34
35 typedef std::vector<Product*> Products;
36
19 // Encapsulates the state of the current installation operation. Only valid 37 // Encapsulates the state of the current installation operation. Only valid
20 // for installs and upgrades (not for uninstalls or non-install commands) 38 // for installs and upgrades (not for uninstalls or non-install commands).
39 // TODO(grt): Rename to InstallerEngine/Conductor or somesuch?
21 class InstallerState { 40 class InstallerState {
22 public: 41 public:
42 enum Level {
43 UNKNOWN_LEVEL,
44 USER_LEVEL,
45 SYSTEM_LEVEL
46 };
47
48 enum PackageType {
49 UNKNOWN_PACKAGE_TYPE,
50 SINGLE_PACKAGE,
51 MULTI_PACKAGE
52 };
53
23 enum Operation { 54 enum Operation {
24 UNINITIALIZED, 55 UNINITIALIZED,
25 SINGLE_INSTALL_OR_UPDATE, 56 SINGLE_INSTALL_OR_UPDATE,
26 MULTI_INSTALL, 57 MULTI_INSTALL,
27 MULTI_UPDATE, 58 MULTI_UPDATE,
59 UNINSTALL
28 }; 60 };
29 61
62 // Constructs an uninitialized instance; see Initialize().
30 InstallerState(); 63 InstallerState();
31 64
32 // Initializes |this| based on the current operation. 65 // Constructs an initialized but empty instance.
33 void Initialize(const MasterPreferences& prefs, 66 explicit InstallerState(Level level);
67
68 // Initializes this object based on the current operation.
69 void Initialize(const CommandLine& command_line,
70 const MasterPreferences& prefs,
34 const InstallationState& machine_state); 71 const InstallationState& machine_state);
35 72
36 // true if system-level, false if user-level. 73 // Adds a product constructed on the basis of |state|, setting this object's
37 bool system_install() const { return system_install_; } 74 // msi flag if |state| is msi-installed. Returns the product that was added,
75 // or NULL if |state| is incompatible with this object. Ownership is not
76 // passed to the caller.
77 Product* AddProductFromState(BrowserDistribution::Type type,
78 const ProductState& state);
38 79
80 // Returns the product that was added, or NULL if |product| is incompatible
81 // with this object. Ownership of |product| is taken by this object, while
82 // ownership of the return value is not passed to the caller.
83 Product* AddProduct(scoped_ptr<Product>* product);
84
85 // Removes |product| from the set of products to be operated on. The object
86 // pointed to by |product| is freed. Returns false if |product| is not
87 // present in the set.
88 bool RemoveProduct(const Product* product);
89
90 // The level (user or system) of this operation.
91 Level level() const { return level_; }
92
93 // The package type (single or multi) of this operation.
94 PackageType package_type() const { return package_type_; }
95
96 // An identifier of this operation.
39 Operation operation() const { return operation_; } 97 Operation operation() const { return operation_; }
40 98
99 // A convenience method returning level() == SYSTEM_LEVEL.
100 // TODO(grt): Eradicate the bool in favor of the enum.
101 bool system_install() const { return level_ == SYSTEM_LEVEL; }
tommi (sloooow) - chröme 2011/01/25 14:24:35 I saw you added a DCHECK for is_multi_install() to
grt (UTC plus 2) 2011/01/25 16:39:45 Done.
102
103 // A convenience method returning package_type() == MULTI_PACKAGE.
104 // TODO(grt): Eradicate the bool in favor of the enum.
105 bool is_multi_install() const;
106
107 // The full path to the place where the operand resides.
108 const FilePath& target_path() const { return target_path_; }
109
110 // True if the "msi" preference is set or if a product with the "msi" state
111 // flag is set is to be operated on.
112 bool is_msi() const { return msi_; }
113
114 // True if the --verbose-logging command-line flag is set or if the
115 // verbose_logging master preferences option is true.
116 bool verbose_logging() const { return verbose_logging_; }
117
118 #if defined(OS_WIN)
119 HKEY root_key() const { return root_key_; }
120 #endif
121
41 // The ClientState key by which we interact with Google Update. 122 // The ClientState key by which we interact with Google Update.
42 const std::wstring& state_key() const { return state_key_; } 123 const std::wstring& state_key() const { return state_key_; }
43 124
125 // Returns the BrowserDistribution instance corresponding to the binaries for
126 // this run if we're operating on a multi-package product.
127 BrowserDistribution* multi_package_binaries_distribution() const {
128 DCHECK(package_type_ == MULTI_PACKAGE);
129 DCHECK(multi_package_distribution_ != NULL);
130 return multi_package_distribution_;
131 }
132
133 const Products& products() const { return products_.get(); }
134
135 // Returns the product of the desired type, or NULL if none found.
136 const Product* FindProduct(BrowserDistribution::Type distribution_type) const;
137
138 // Returns the currently installed version in |target_path|, or NULL if no
139 // products are installed. Ownership is passed to the caller.
140 Version* GetCurrentVersion(const InstallationState& machine_state) const;
141
142 // Returns the path to the installer under Chrome version folder
143 // (for example <target_path>\Google\Chrome\Application\<Version>\Installer)
144 FilePath GetInstallerDirectory(const Version& version) const;
145
146 // Try to delete all directories whose versions are lower than
147 // |latest_version|.
148 void RemoveOldVersionDirectories(const Version& latest_version) const;
149
150 // Adds to |com_dll_list| the list of COM DLLs that are to be registered
151 // and/or unregistered. The list may be empty.
152 void AddComDllList(std::vector<FilePath>* com_dll_list) const;
153
154 bool SetChannelFlags(bool set, ChannelInfo* channel_info) const;
155
44 protected: 156 protected:
157 FilePath GetDefaultProductInstallPath(BrowserDistribution* dist) const;
158 bool CanAddProduct(const Product& product, const FilePath* product_dir) const;
159 Product* AddProductInDirectory(const FilePath* product_dir,
160 scoped_ptr<Product>* product);
161 Product* AddProductFromPreferences(
162 BrowserDistribution::Type distribution_type,
163 const MasterPreferences& prefs,
164 const InstallationState& machine_state);
45 bool IsMultiInstallUpdate(const MasterPreferences& prefs, 165 bool IsMultiInstallUpdate(const MasterPreferences& prefs,
46 const InstallationState& machine_state); 166 const InstallationState& machine_state);
47 167
168 // Sets this object's level and updates the root_key_ accordingly.
169 void set_level(Level level);
170
171 // Sets this object's package type and updates the multi_package_distribution_
172 // accordingly.
173 void set_package_type(PackageType type);
174
48 Operation operation_; 175 Operation operation_;
176 FilePath target_path_;
49 std::wstring state_key_; 177 std::wstring state_key_;
50 bool system_install_; 178 ScopedVector<Product> products_;
179 BrowserDistribution* multi_package_distribution_;
180 Level level_;
181 PackageType package_type_;
182 #if defined(OS_WIN)
183 HKEY root_key_;
184 #endif
185 bool msi_;
186 bool verbose_logging_;
51 187
52 private: 188 private:
53 DISALLOW_COPY_AND_ASSIGN(InstallerState); 189 DISALLOW_COPY_AND_ASSIGN(InstallerState);
54 }; // class InstallerState 190 }; // class InstallerState
55 191
56 } // namespace installer 192 } // namespace installer
57 193
58 #endif // CHROME_INSTALLER_UTIL_INSTALLER_STATE_H_ 194 #endif // CHROME_INSTALLER_UTIL_INSTALLER_STATE_H_
OLDNEW
« no previous file with comments | « chrome/installer/util/installation_state.cc ('k') | chrome/installer/util/installer_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698