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 #include "chrome/installer/setup/installer_state.h" | 5 #include "chrome/installer/setup/installer_state.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 root_key_ = NULL; | 105 root_key_ = NULL; |
106 break; | 106 break; |
107 } | 107 } |
108 } | 108 } |
109 | 109 |
110 // Evaluates a product's eligibility for participation in this operation. | 110 // Evaluates a product's eligibility for participation in this operation. |
111 // We never expect these checks to fail, hence they all terminate the process in | 111 // We never expect these checks to fail, hence they all terminate the process in |
112 // debug builds. See the log messages for details. | 112 // debug builds. See the log messages for details. |
113 bool InstallerState::CanAddProduct(const base::FilePath* product_dir) const { | 113 bool InstallerState::CanAddProduct(const base::FilePath* product_dir) const { |
114 if (product_) { | 114 if (product_) { |
115 LOG(DFATAL) << "Cannot process more than one single-install product."; | 115 LOG(DFATAL) << "Cannot process more than one product."; |
116 return false; | 116 return false; |
117 } | 117 } |
118 return true; | 118 return true; |
119 } | 119 } |
120 | 120 |
121 // Adds |product|, installed in |product_dir| to this object's collection. If | 121 // Adds |product|, installed in |product_dir| to this object's collection. If |
122 // |product_dir| is NULL, the product's default install location is used. | 122 // |product_dir| is NULL, the product's default install location is used. |
123 // Returns NULL if |product| is incompatible with this object. Otherwise, | 123 // Returns NULL if |product| is incompatible with this object. Otherwise, |
124 // returns a pointer to the product (ownership is held by this object). | 124 // returns a pointer to the product (ownership is held by this object). |
125 Product* InstallerState::AddProductInDirectory( | 125 Product* InstallerState::AddProductInDirectory( |
126 const base::FilePath* product_dir, | 126 const base::FilePath* product_dir, |
127 std::unique_ptr<Product> product) { | 127 std::unique_ptr<Product> product) { |
128 DCHECK(product); | 128 DCHECK(product); |
129 const Product& the_product = *product; | 129 const Product& the_product = *product; |
130 DCHECK(!the_product.HasOption(kOptionMultiInstall)); | |
131 | 130 |
132 if (!CanAddProduct(product_dir)) | 131 if (!CanAddProduct(product_dir)) |
133 return nullptr; | 132 return nullptr; |
134 | 133 |
135 if (target_path_.empty()) { | 134 if (target_path_.empty()) { |
136 target_path_ = product_dir ? *product_dir : GetChromeInstallPath( | 135 target_path_ = product_dir ? *product_dir : GetChromeInstallPath( |
137 system_install(), | 136 system_install(), |
138 the_product.distribution()); | 137 the_product.distribution()); |
139 } | 138 } |
140 | 139 |
(...skipping 10 matching lines...) Expand all Loading... |
151 | 150 |
152 // Adds a product constructed on the basis of |prefs|, setting this object's msi | 151 // Adds a product constructed on the basis of |prefs|, setting this object's msi |
153 // flag if the product is represented in |machine_state| and is msi-installed. | 152 // flag if the product is represented in |machine_state| and is msi-installed. |
154 // Returns the product that was added, or NULL if |state| is incompatible with | 153 // Returns the product that was added, or NULL if |state| is incompatible with |
155 // this object. Ownership is not passed to the caller. | 154 // this object. Ownership is not passed to the caller. |
156 Product* InstallerState::AddProductFromPreferences( | 155 Product* InstallerState::AddProductFromPreferences( |
157 const MasterPreferences& prefs, | 156 const MasterPreferences& prefs, |
158 const InstallationState& machine_state) { | 157 const InstallationState& machine_state) { |
159 std::unique_ptr<Product> product_ptr( | 158 std::unique_ptr<Product> product_ptr( |
160 new Product(BrowserDistribution::GetDistribution())); | 159 new Product(BrowserDistribution::GetDistribution())); |
161 product_ptr->InitializeFromPreferences(prefs); | |
162 | 160 |
163 Product* product = AddProductInDirectory(nullptr, std::move(product_ptr)); | 161 Product* product = AddProductInDirectory(nullptr, std::move(product_ptr)); |
164 | 162 |
165 if (product != NULL && !msi_) { | 163 if (product != NULL && !msi_) { |
166 const ProductState* product_state = | 164 const ProductState* product_state = |
167 machine_state.GetProductState(system_install()); | 165 machine_state.GetProductState(system_install()); |
168 if (product_state != NULL) | 166 if (product_state != NULL) |
169 msi_ = product_state->is_msi(); | 167 msi_ = product_state->is_msi(); |
170 } | 168 } |
171 | 169 |
172 return product; | 170 return product; |
173 } | 171 } |
174 | 172 |
175 Product* InstallerState::AddProductFromState( | 173 Product* InstallerState::AddProductFromState( |
176 const ProductState& state) { | 174 const ProductState& state) { |
177 std::unique_ptr<Product> product_ptr( | 175 std::unique_ptr<Product> product_ptr( |
178 new Product(BrowserDistribution::GetDistribution())); | 176 new Product(BrowserDistribution::GetDistribution())); |
179 product_ptr->InitializeFromUninstallCommand(state.uninstall_command()); | |
180 | 177 |
181 // Strip off <version>/Installer/setup.exe; see GetInstallerDirectory(). | 178 // Strip off <version>/Installer/setup.exe; see GetInstallerDirectory(). |
182 base::FilePath product_dir = | 179 base::FilePath product_dir = |
183 state.GetSetupPath().DirName().DirName().DirName(); | 180 state.GetSetupPath().DirName().DirName().DirName(); |
184 | 181 |
185 Product* product = | 182 Product* product = |
186 AddProductInDirectory(&product_dir, std::move(product_ptr)); | 183 AddProductInDirectory(&product_dir, std::move(product_ptr)); |
187 | 184 |
188 if (product != NULL) | 185 if (product != NULL) |
189 msi_ |= state.is_msi(); | 186 msi_ |= state.is_msi(); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 #endif | 320 #endif |
324 } | 321 } |
325 install_list->Do(); | 322 install_list->Do(); |
326 } | 323 } |
327 | 324 |
328 bool InstallerState::RequiresActiveSetup() const { | 325 bool InstallerState::RequiresActiveSetup() const { |
329 return system_install(); | 326 return system_install(); |
330 } | 327 } |
331 | 328 |
332 } // namespace installer | 329 } // namespace installer |
OLD | NEW |