OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "chrome/installer/util/app_commands.h" | 14 #include "chrome/installer/util/app_commands.h" |
15 #include "chrome/installer/util/browser_distribution.h" | |
16 #include "chrome/installer/util/channel_info.h" | 15 #include "chrome/installer/util/channel_info.h" |
17 | 16 |
18 namespace base { | 17 namespace base { |
19 class Version; | 18 class Version; |
20 namespace win { | |
21 class RegKey; | |
22 } | |
23 } | 19 } |
24 | 20 |
25 namespace installer { | 21 namespace installer { |
26 | 22 |
27 class InstallationState; | 23 class InstallationState; |
28 | 24 |
29 // A representation of a product's state on the machine based on the contents | 25 // A representation of Chrome's state on the machine based on the contents of |
30 // of the Windows registry. | 26 // the Windows registry. |
31 // TODO(grt): Pull this out into its own file. | 27 // TODO(grt): Pull this out into its own file. |
| 28 // TODO(grt): Evaluate whether this is still needed. If yes, rename to |
| 29 // ChromeState or somesuch. |
32 class ProductState { | 30 class ProductState { |
33 public: | 31 public: |
34 ProductState(); | 32 ProductState(); |
35 ~ProductState(); | 33 ~ProductState(); |
36 | 34 |
37 // Returns true if the product is installed (i.e., the product's Clients key | 35 // Returns true if the product is installed (i.e., the product's Clients key |
38 // exists and has a "pv" value); false otherwise. | 36 // exists and has a "pv" value); false otherwise. |
39 bool Initialize(bool system_install, | 37 bool Initialize(bool system_install); |
40 BrowserDistribution::Type type); | |
41 bool Initialize(bool system_install, | |
42 BrowserDistribution* distribution); | |
43 | 38 |
44 // Returns the product's channel info (i.e., the Google Update "ap" value). | 39 // Returns the product's channel info (i.e., the Google Update "ap" value). |
45 const ChannelInfo& channel() const { return channel_; } | 40 const ChannelInfo& channel() const { return channel_; } |
46 | 41 |
47 // Returns the path to the product's "setup.exe"; may be empty. | 42 // Returns the path to the product's "setup.exe"; may be empty. |
48 base::FilePath GetSetupPath() const; | 43 base::FilePath GetSetupPath() const; |
49 | 44 |
50 // Returns the product's version. This method may only be called on an | 45 // Returns the product's version. This method may only be called on an |
51 // instance that has been initialized for an installed product. | 46 // instance that has been initialized for an installed product. |
52 const base::Version& version() const; | 47 const base::Version& version() const; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // Returns the set of Google Update commands. | 89 // Returns the set of Google Update commands. |
95 const AppCommands& commands() const { return commands_; } | 90 const AppCommands& commands() const { return commands_; } |
96 | 91 |
97 // Returns this object a la operator=(). | 92 // Returns this object a la operator=(). |
98 ProductState& CopyFrom(const ProductState& other); | 93 ProductState& CopyFrom(const ProductState& other); |
99 | 94 |
100 // Clears the state of this object. | 95 // Clears the state of this object. |
101 void Clear(); | 96 void Clear(); |
102 | 97 |
103 protected: | 98 protected: |
104 static bool InitializeCommands(const base::win::RegKey& version_key, | |
105 AppCommands* commands); | |
106 | |
107 ChannelInfo channel_; | 99 ChannelInfo channel_; |
108 std::unique_ptr<base::Version> version_; | 100 std::unique_ptr<base::Version> version_; |
109 std::unique_ptr<base::Version> old_version_; | 101 std::unique_ptr<base::Version> old_version_; |
110 std::wstring brand_; | 102 std::wstring brand_; |
111 std::wstring rename_cmd_; | 103 std::wstring rename_cmd_; |
112 std::wstring oem_install_; | 104 std::wstring oem_install_; |
113 base::CommandLine uninstall_command_; | 105 base::CommandLine uninstall_command_; |
114 AppCommands commands_; | 106 AppCommands commands_; |
115 DWORD eula_accepted_; | 107 DWORD eula_accepted_; |
116 DWORD usagestats_; | 108 DWORD usagestats_; |
(...skipping 13 matching lines...) Expand all Loading... |
130 // TODO(grt): Rename this to MachineState and put it in its own file. | 122 // TODO(grt): Rename this to MachineState and put it in its own file. |
131 class InstallationState { | 123 class InstallationState { |
132 public: | 124 public: |
133 InstallationState(); | 125 InstallationState(); |
134 | 126 |
135 // Initializes this object with the machine's current state. | 127 // Initializes this object with the machine's current state. |
136 void Initialize(); | 128 void Initialize(); |
137 | 129 |
138 // Returns the state of a product or NULL if not installed. | 130 // Returns the state of a product or NULL if not installed. |
139 // Caller does NOT assume ownership of returned pointer. | 131 // Caller does NOT assume ownership of returned pointer. |
140 const ProductState* GetProductState(bool system_install, | 132 const ProductState* GetProductState(bool system_install) const; |
141 BrowserDistribution::Type type) const; | |
142 | 133 |
143 // Returns the state of a product, even one that has not yet been installed. | 134 // Returns the state of a product, even one that has not yet been installed. |
144 // This is useful during first install, when some but not all ProductState | 135 // This is useful during first install, when some but not all ProductState |
145 // information has been written by Omaha. Notably absent from the | 136 // information has been written by Omaha. Notably absent from the |
146 // ProductState returned here are the version numbers. Do NOT try to access | 137 // ProductState returned here are the version numbers. Do NOT try to access |
147 // the version numbers from a ProductState returned by this method. | 138 // the version numbers from a ProductState returned by this method. |
148 // Caller does NOT assume ownership of returned pointer. This method will | 139 // Caller does NOT assume ownership of returned pointer. This method will |
149 // never return NULL. | 140 // never return NULL. |
150 const ProductState* GetNonVersionedProductState( | 141 const ProductState* GetNonVersionedProductState(bool system_install) const; |
151 bool system_install, BrowserDistribution::Type type) const; | |
152 | 142 |
153 protected: | 143 protected: |
154 enum { | 144 ProductState user_chrome_; |
155 CHROME_BROWSER_INDEX, | 145 ProductState system_chrome_; |
156 CHROME_FRAME_INDEX, | |
157 CHROME_BINARIES_INDEX, | |
158 NUM_PRODUCTS | |
159 }; | |
160 | |
161 static int IndexFromDistType(BrowserDistribution::Type type); | |
162 | |
163 ProductState user_products_[NUM_PRODUCTS]; | |
164 ProductState system_products_[NUM_PRODUCTS]; | |
165 | 146 |
166 private: | 147 private: |
167 DISALLOW_COPY_AND_ASSIGN(InstallationState); | 148 DISALLOW_COPY_AND_ASSIGN(InstallationState); |
168 }; // class InstallationState | 149 }; // class InstallationState |
169 | 150 |
170 } // namespace installer | 151 } // namespace installer |
171 | 152 |
172 #endif // CHROME_INSTALLER_UTIL_INSTALLATION_STATE_H_ | 153 #endif // CHROME_INSTALLER_UTIL_INSTALLATION_STATE_H_ |
OLD | NEW |