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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/installer/util/installer_state.h
===================================================================
--- chrome/installer/util/installer_state.h (revision 71802)
+++ chrome/installer/util/installer_state.h (working copy)
@@ -7,47 +7,159 @@
#pragma once
#include <string>
+#include <vector>
#include "base/basictypes.h"
+#include "base/file_path.h"
+#include "base/logging.h"
+#include "base/scoped_vector.h"
#include "chrome/installer/util/browser_distribution.h"
+#include "chrome/installer/util/product.h"
+#if defined(OS_WIN)
+#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
+#endif
+
+class CommandLine;
+class Version;
+
namespace installer {
+class ChannelInfo;
class InstallationState;
class MasterPreferences;
+class ProductState;
+
+typedef std::vector<Product*> Products;
+
// Encapsulates the state of the current installation operation. Only valid
-// for installs and upgrades (not for uninstalls or non-install commands)
+// for installs and upgrades (not for uninstalls or non-install commands).
+// TODO(grt): Rename to InstallerEngine/Conductor or somesuch?
class InstallerState {
public:
+ enum Level {
+ UNKNOWN_LEVEL,
+ USER_LEVEL,
+ SYSTEM_LEVEL
+ };
+
+ enum PackageType {
+ UNKNOWN_PACKAGE_TYPE,
+ SINGLE_PACKAGE,
+ MULTI_PACKAGE
+ };
+
enum Operation {
UNINITIALIZED,
SINGLE_INSTALL_OR_UPDATE,
MULTI_INSTALL,
MULTI_UPDATE,
+ UNINSTALL
};
+ // Constructs an uninitialized instance; see Initialize().
InstallerState();
- // Initializes |this| based on the current operation.
- void Initialize(const MasterPreferences& prefs,
+ // Constructs an initialized but empty instance.
+ explicit InstallerState(Level level);
+
+ // Initializes this object based on the current operation.
+ void Initialize(const CommandLine& command_line,
+ const MasterPreferences& prefs,
const InstallationState& machine_state);
- // true if system-level, false if user-level.
- bool system_install() const { return system_install_; }
+ // Resets the collection of products and their associated state.
+ void ResetProducts();
+ // Returns the product that was added. Ownership is not passed to the caller.
+ Product* AddProductFromState(BrowserDistribution::Type type,
+ const ProductState& state);
+
+ // Removes |product| from the set of products to be operated on. The object
+ // pointed to by |product| is freed. Returns false if |product| is not
+ // present in the set.
+ bool RemoveProduct(const Product* product);
+
+ Level level() const { return level_; }
+
+ PackageType package_type() const { return package_type_; }
+
+ // TODO(grt): Eradicate the bool in favor of the enum.
+ bool system_install() const { return level_ == SYSTEM_LEVEL; }
+
+ // TODO(grt): Eradicate the bool in favor of the enum.
+ bool multi_install() const { return package_type_ == MULTI_PACKAGE; }
+
+ // The full path to the place where the operand resides.
+ const FilePath& target_path() const { return target_path_; }
+
+ // True if the "msi" preference is set or if a product with the "msi" state
+ // flag is set is to be operated on.
+ bool msi() const { return msi_; }
+
+ // True if the --verbose-logging command-line flag is set or if the
+ // verbose_logging master preferences option is true.
+ bool verbose_logging() const { return verbose_logging_; }
+
+#if defined(OS_WIN)
+ HKEY root_key() const { return root_key_; }
+#endif
+
Operation operation() const { return operation_; }
// The ClientState key by which we interact with Google Update.
const std::wstring& state_key() const { return state_key_; }
+ // Returns the BrowserDistribution instance corresponding to the binaries for
+ // this run if we're operating on a multi-package product.
+ BrowserDistribution* multi_package_binaries_distribution() const {
+ DCHECK(package_type_ == MULTI_PACKAGE);
+ DCHECK(multi_package_distribution_ != NULL);
+ return multi_package_distribution_;
+ }
+
+ const Products& products() const { return products_.get(); }
+
+ // Returns the product of the desired type, or NULL if none found.
+ const Product* FindProduct(BrowserDistribution::Type distribution_type) const;
+
+ // Returns the currently installed version in |target_path|, or NULL if no
+ // products are installed. Ownership is passed to the caller.
+ Version* GetCurrentVersion(const InstallationState& machine_state) const;
+
+ // Returns the path to the installer under Chrome version folder
+ // (for example <target_path>\Google\Chrome\Application\<Version>\Installer)
+ FilePath GetInstallerDirectory(const Version& version) const;
+
+ 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.
+
+ // Adds to |com_dll_list| the list of COM DLLs that are to be registered
+ // and/or unregistered. The list may be empty.
+ void AddComDllList(std::vector<FilePath>* com_dll_list) const;
+
+ bool SetChannelFlags(bool set, ChannelInfo* channel_info) const;
+
protected:
+ const Product& AddProductFromPreferences(
+ BrowserDistribution::Type distribution_type,
+ const MasterPreferences& prefs,
+ const InstallationState& machine_state);
bool IsMultiInstallUpdate(const MasterPreferences& prefs,
const InstallationState& machine_state);
Operation operation_;
+ FilePath target_path_;
std::wstring state_key_;
- bool system_install_;
+ ScopedVector<Product> products_;
+ BrowserDistribution* multi_package_distribution_;
+ Level level_;
+ PackageType package_type_;
+#if defined(OS_WIN)
+ HKEY root_key_;
+#endif
+ bool msi_;
+ bool verbose_logging_;
private:
DISALLOW_COPY_AND_ASSIGN(InstallerState);

Powered by Google App Engine
This is Rietveld 408576698