| 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/util/installer_state.h" | 5 #include "chrome/installer/util/installer_state.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 if (product_dir == NULL) | 278 if (product_dir == NULL) |
| 279 target_path_ = GetDefaultProductInstallPath(the_product.distribution()); | 279 target_path_ = GetDefaultProductInstallPath(the_product.distribution()); |
| 280 else | 280 else |
| 281 target_path_ = *product_dir; | 281 target_path_ = *product_dir; |
| 282 } | 282 } |
| 283 | 283 |
| 284 if (state_key_.empty()) | 284 if (state_key_.empty()) |
| 285 state_key_ = the_product.distribution()->GetStateKey(); | 285 state_key_ = the_product.distribution()->GetStateKey(); |
| 286 | 286 |
| 287 products_.push_back(product->release()); | 287 products_.push_back(product->release()); |
| 288 return products_[products_->size() - 1]; | 288 return products_[products_.size() - 1]; |
| 289 } | 289 } |
| 290 | 290 |
| 291 Product* InstallerState::AddProduct(scoped_ptr<Product>* product) { | 291 Product* InstallerState::AddProduct(scoped_ptr<Product>* product) { |
| 292 return AddProductInDirectory(NULL, product); | 292 return AddProductInDirectory(NULL, product); |
| 293 } | 293 } |
| 294 | 294 |
| 295 // Adds a product of type |distribution_type| constructed on the basis of | 295 // Adds a product of type |distribution_type| constructed on the basis of |
| 296 // |prefs|, setting this object's msi flag if the product is represented in | 296 // |prefs|, setting this object's msi flag if the product is represented in |
| 297 // |machine_state| and is msi-installed. Returns the product that was added, | 297 // |machine_state| and is msi-installed. Returns the product that was added, |
| 298 // or NULL if |state| is incompatible with this object. Ownership is not passed | 298 // or NULL if |state| is incompatible with this object. Ownership is not passed |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 | 343 |
| 344 bool InstallerState::is_multi_install() const { | 344 bool InstallerState::is_multi_install() const { |
| 345 DCHECK(package_type_ == SINGLE_PACKAGE || package_type_ == MULTI_PACKAGE); | 345 DCHECK(package_type_ == SINGLE_PACKAGE || package_type_ == MULTI_PACKAGE); |
| 346 return package_type_ != SINGLE_PACKAGE; | 346 return package_type_ != SINGLE_PACKAGE; |
| 347 } | 347 } |
| 348 | 348 |
| 349 bool InstallerState::RemoveProduct(const Product* product) { | 349 bool InstallerState::RemoveProduct(const Product* product) { |
| 350 ScopedVector<Product>::iterator it = | 350 ScopedVector<Product>::iterator it = |
| 351 std::find(products_.begin(), products_.end(), product); | 351 std::find(products_.begin(), products_.end(), product); |
| 352 if (it != products_.end()) { | 352 if (it != products_.end()) { |
| 353 products_->erase(it); | 353 products_.weak_erase(it); |
| 354 return true; | 354 return true; |
| 355 } | 355 } |
| 356 return false; | 356 return false; |
| 357 } | 357 } |
| 358 | 358 |
| 359 const Product* InstallerState::FindProduct( | 359 const Product* InstallerState::FindProduct( |
| 360 BrowserDistribution::Type distribution_type) const { | 360 BrowserDistribution::Type distribution_type) const { |
| 361 for (Products::const_iterator scan = products_.begin(), end = products_.end(); | 361 for (Products::const_iterator scan = products_.begin(), end = products_.end(); |
| 362 scan != end; ++scan) { | 362 scan != end; ++scan) { |
| 363 if ((*scan)->is_type(distribution_type)) | 363 if ((*scan)->is_type(distribution_type)) |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 if (is_multi_install()) { | 617 if (is_multi_install()) { |
| 618 InstallUtil::AddInstallerResultItems( | 618 InstallUtil::AddInstallerResultItems( |
| 619 system_install, multi_package_binaries_distribution()->GetStateKey(), | 619 system_install, multi_package_binaries_distribution()->GetStateKey(), |
| 620 status, string_resource_id, launch_cmd, install_list.get()); | 620 status, string_resource_id, launch_cmd, install_list.get()); |
| 621 } | 621 } |
| 622 if (!install_list->Do()) | 622 if (!install_list->Do()) |
| 623 LOG(ERROR) << "Failed to record installer error information in registry."; | 623 LOG(ERROR) << "Failed to record installer error information in registry."; |
| 624 } | 624 } |
| 625 | 625 |
| 626 } // namespace installer | 626 } // namespace installer |
| OLD | NEW |