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

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
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_vector.h"
12 #include "chrome/installer/util/browser_distribution.h" 16 #include "chrome/installer/util/browser_distribution.h"
17 #include "chrome/installer/util/product.h"
18
19 #if defined(OS_WIN)
20 #include <windows.h>
tommi (sloooow) - chröme 2011/01/21 21:45:17 I'm assuming you can't move this to the top due to
grt (UTC plus 2) 2011/01/24 16:07:02 Right. My understanding is that platform-specific
21 #endif
22
23 class CommandLine;
24 class Version;
13 25
14 namespace installer { 26 namespace installer {
15 27
28 class ChannelInfo;
16 class InstallationState; 29 class InstallationState;
17 class MasterPreferences; 30 class MasterPreferences;
18 31
32 class ProductState;
33
34 typedef std::vector<Product*> Products;
35
19 // Encapsulates the state of the current installation operation. Only valid 36 // Encapsulates the state of the current installation operation. Only valid
20 // for installs and upgrades (not for uninstalls or non-install commands) 37 // for installs and upgrades (not for uninstalls or non-install commands).
38 // TODO(grt): Rename to InstallerEngine/Conductor or somesuch?
21 class InstallerState { 39 class InstallerState {
22 public: 40 public:
41 enum Level {
42 UNKNOWN_LEVEL,
43 USER_LEVEL,
44 SYSTEM_LEVEL
45 };
46
47 enum PackageType {
48 UNKNOWN_PACKAGE_TYPE,
49 SINGLE_PACKAGE,
50 MULTI_PACKAGE
51 };
52
23 enum Operation { 53 enum Operation {
24 UNINITIALIZED, 54 UNINITIALIZED,
25 SINGLE_INSTALL_OR_UPDATE, 55 SINGLE_INSTALL_OR_UPDATE,
26 MULTI_INSTALL, 56 MULTI_INSTALL,
27 MULTI_UPDATE, 57 MULTI_UPDATE,
58 UNINSTALL
28 }; 59 };
29 60
61 // Constructs an uninitialized instance; see Initialize().
30 InstallerState(); 62 InstallerState();
31 63
32 // Initializes |this| based on the current operation. 64 // Constructs an initialized but empty instance.
33 void Initialize(const MasterPreferences& prefs, 65 explicit InstallerState(Level level);
66
67 // Initializes this object based on the current operation.
68 void Initialize(const CommandLine& command_line,
69 const MasterPreferences& prefs,
34 const InstallationState& machine_state); 70 const InstallationState& machine_state);
35 71
36 // true if system-level, false if user-level. 72 // Resets the collection of products and their associated state.
37 bool system_install() const { return system_install_; } 73 void ResetProducts();
74
75 // Returns the product that was added. Ownership is not passed to the caller.
76 Product* AddProductFromState(BrowserDistribution::Type type,
77 const ProductState& state);
78
79 // Removes |product| from the set of products to be operated on. The object
80 // pointed to by |product| is freed. Returns false if |product| is not
81 // present in the set.
82 bool RemoveProduct(const Product* product);
83
84 Level level() const { return level_; }
85
86 PackageType package_type() const { return package_type_; }
87
88 // TODO(grt): Eradicate the bool in favor of the enum.
89 bool system_install() const { return level_ == SYSTEM_LEVEL; }
90
91 // TODO(grt): Eradicate the bool in favor of the enum.
92 bool multi_install() const { return package_type_ == MULTI_PACKAGE; }
93
94 // The full path to the place where the operand resides.
95 const FilePath& target_path() const { return target_path_; }
96
97 // True if the "msi" preference is set or if a product with the "msi" state
98 // flag is set is to be operated on.
99 bool msi() const { return msi_; }
100
101 // True if the --verbose-logging command-line flag is set or if the
102 // verbose_logging master preferences option is true.
103 bool verbose_logging() const { return verbose_logging_; }
104
105 #if defined(OS_WIN)
106 HKEY root_key() const { return root_key_; }
107 #endif
38 108
39 Operation operation() const { return operation_; } 109 Operation operation() const { return operation_; }
40 110
41 // The ClientState key by which we interact with Google Update. 111 // The ClientState key by which we interact with Google Update.
42 const std::wstring& state_key() const { return state_key_; } 112 const std::wstring& state_key() const { return state_key_; }
43 113
114 // Returns the BrowserDistribution instance corresponding to the binaries for
115 // this run if we're operating on a multi-package product.
116 BrowserDistribution* multi_package_binaries_distribution() const {
117 DCHECK(package_type_ == MULTI_PACKAGE);
118 DCHECK(multi_package_distribution_ != NULL);
119 return multi_package_distribution_;
120 }
121
122 const Products& products() const { return products_.get(); }
123
124 // Returns the product of the desired type, or NULL if none found.
125 const Product* FindProduct(BrowserDistribution::Type distribution_type) const;
126
127 // Returns the currently installed version in |target_path|, or NULL if no
128 // products are installed. Ownership is passed to the caller.
129 Version* GetCurrentVersion(const InstallationState& machine_state) const;
130
131 // Returns the path to the installer under Chrome version folder
132 // (for example <target_path>\Google\Chrome\Application\<Version>\Installer)
133 FilePath GetInstallerDirectory(const Version& version) const;
134
135 void RemoveOldVersionDirectories(const Version& latest_version) const;
robertshield 2011/01/21 16:58:56 Please add comment.
grt (UTC plus 2) 2011/01/24 16:07:02 Done.
136
137 // Adds to |com_dll_list| the list of COM DLLs that are to be registered
138 // and/or unregistered. The list may be empty.
139 void AddComDllList(std::vector<FilePath>* com_dll_list) const;
140
141 bool SetChannelFlags(bool set, ChannelInfo* channel_info) const;
142
44 protected: 143 protected:
144 const Product& AddProductFromPreferences(
145 BrowserDistribution::Type distribution_type,
146 const MasterPreferences& prefs,
147 const InstallationState& machine_state);
45 bool IsMultiInstallUpdate(const MasterPreferences& prefs, 148 bool IsMultiInstallUpdate(const MasterPreferences& prefs,
46 const InstallationState& machine_state); 149 const InstallationState& machine_state);
47 150
48 Operation operation_; 151 Operation operation_;
152 FilePath target_path_;
49 std::wstring state_key_; 153 std::wstring state_key_;
50 bool system_install_; 154 ScopedVector<Product> products_;
155 BrowserDistribution* multi_package_distribution_;
156 Level level_;
157 PackageType package_type_;
158 #if defined(OS_WIN)
159 HKEY root_key_;
160 #endif
161 bool msi_;
162 bool verbose_logging_;
51 163
52 private: 164 private:
53 DISALLOW_COPY_AND_ASSIGN(InstallerState); 165 DISALLOW_COPY_AND_ASSIGN(InstallerState);
54 }; // class InstallerState 166 }; // class InstallerState
55 167
56 } // namespace installer 168 } // namespace installer
57 169
58 #endif // CHROME_INSTALLER_UTIL_INSTALLER_STATE_H_ 170 #endif // CHROME_INSTALLER_UTIL_INSTALLER_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698