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

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) 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_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.
24 class ProductState { 27 class ProductState {
25 public: 28 public:
26 ProductState(); 29 ProductState();
27 void Initialize(bool system_install, 30 // Returns true if the product is installed (i.e., the product's Clients key
28 const std::wstring& version_key, 31 // exists and has a "pv" value); false otherwise.
29 const std::wstring& state_key); 32 bool Initialize(bool system_install,
33 BrowserDistribution::Type type);
34 bool Initialize(bool system_install,
35 BrowserDistribution* distribution);
30 36
31 const ChannelInfo& channel() const { return channel_; } 37 const ChannelInfo& channel() const { return channel_; }
32 ChannelInfo& channel() { return channel_; } 38 ChannelInfo& channel() { return channel_; }
33 39
40 FilePath GetSetupPath() const;
41
34 const Version& version() const; 42 const Version& version() const;
35 // Takes ownership of |version|. 43 // Takes ownership of |version|.
36 void set_version(Version* version) { version_.reset(version); } 44 void set_version(Version* version) { version_.reset(version); }
37 45
38 void CopyFrom(const ProductState& other); 46 // May be NULL. Ownership of a returned value is not passed to the caller.
47 const Version* old_version() const { return old_version_.get(); }
48 // Takes ownership of |version|.
49 void set_old_version(Version* version) { old_version_.reset(version); }
50
51 const std::wstring& rename_cmd() const { return rename_cmd_; }
52 void set_rename_cmd(const std::wstring& rename_cmd) {
53 rename_cmd_ = rename_cmd;
54 }
55
56 // True if the "msi" value in the ClientState key is present and non-zero.
57 bool msi() const { return msi_; }
58 void set_msi(bool set) { msi_ = set; }
robertshield 2011/01/21 16:58:56 Remove the public setters for this and other field
grt (UTC plus 2) 2011/01/24 16:07:02 Done.
59
60 const CommandLine& uninstall_command() const { return uninstall_command_; }
61
62 // True if |uninstall_command| contains --multi-install.
63 bool multi_install() const { return multi_install_; }
64
65 // Returns this object a la operator=().
66 ProductState& CopyFrom(const ProductState& other);
39 67
40 private: 68 private:
41 friend class InstallationState; 69 friend class InstallationState;
42 70
43 ChannelInfo channel_; 71 ChannelInfo channel_;
44 scoped_ptr<Version> version_; 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_;
45 DISALLOW_COPY_AND_ASSIGN(ProductState); 78 DISALLOW_COPY_AND_ASSIGN(ProductState);
46 }; // class ProductState 79 }; // class ProductState
47 80
48 // Encapsulates the state of all products on the system. 81 // Encapsulates the state of all products on the system.
49 class InstallationState { 82 class InstallationState {
50 public: 83 public:
51 InstallationState(); 84 InstallationState();
52 85
53 // Initializes |this| with the machine's current state. 86 // Initializes this object with the machine's current state.
54 void Initialize(const MasterPreferences& prefs); 87 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 88
61 // Returns the state of a product or NULL if not installed. 89 // Returns the state of a product or NULL if not installed.
62 // Caller does NOT assume ownership of returned pointer. 90 // Caller does NOT assume ownership of returned pointer.
63 const ProductState* GetProductState(bool system_install, 91 const ProductState* GetProductState(bool system_install,
64 BrowserDistribution::Type type) const; 92 BrowserDistribution::Type type) const;
65 93
66 protected: 94 protected:
67 enum { 95 enum {
68 CHROME_BROWSER_INDEX, 96 CHROME_BROWSER_INDEX,
69 CHROME_FRAME_INDEX, 97 CHROME_FRAME_INDEX,
70 MULTI_PACKAGE_INDEX, 98 CHROME_BINARIES_INDEX,
71 NUM_PRODUCTS 99 NUM_PRODUCTS
72 }; 100 };
73 101
74 static int IndexFromDistType(BrowserDistribution::Type type); 102 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 103
82 ProductState user_products_[NUM_PRODUCTS]; 104 ProductState user_products_[NUM_PRODUCTS];
83 ProductState system_products_[NUM_PRODUCTS]; 105 ProductState system_products_[NUM_PRODUCTS];
84 106
85 private: 107 private:
86 DISALLOW_COPY_AND_ASSIGN(InstallationState); 108 DISALLOW_COPY_AND_ASSIGN(InstallationState);
87 }; // class InstallationState 109 }; // class InstallationState
88 110
89 } // namespace installer 111 } // namespace installer
90 112
91 #endif // CHROME_INSTALLER_UTIL_INSTALLATION_STATE_H_ 113 #endif // CHROME_INSTALLER_UTIL_INSTALLATION_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698