| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 | 67 |
| 68 VLOG(2) << "It seems that the package is being updated."; | 68 VLOG(2) << "It seems that the package is being updated."; |
| 69 | 69 |
| 70 return true; | 70 return true; |
| 71 } | 71 } |
| 72 | 72 |
| 73 InstallerState::InstallerState() | 73 InstallerState::InstallerState() |
| 74 : operation_(UNINITIALIZED), | 74 : operation_(UNINITIALIZED), |
| 75 state_type_(BrowserDistribution::CHROME_BROWSER), |
| 75 multi_package_distribution_(NULL), | 76 multi_package_distribution_(NULL), |
| 76 level_(UNKNOWN_LEVEL), | 77 level_(UNKNOWN_LEVEL), |
| 77 package_type_(UNKNOWN_PACKAGE_TYPE), | 78 package_type_(UNKNOWN_PACKAGE_TYPE), |
| 78 state_type_(BrowserDistribution::CHROME_BROWSER), | |
| 79 root_key_(NULL), | 79 root_key_(NULL), |
| 80 msi_(false), | 80 msi_(false), |
| 81 verbose_logging_(false), | 81 verbose_logging_(false), |
| 82 ensure_google_update_present_(false) { | 82 ensure_google_update_present_(false) { |
| 83 } | 83 } |
| 84 | 84 |
| 85 InstallerState::InstallerState(Level level) | 85 InstallerState::InstallerState(Level level) |
| 86 : operation_(UNINITIALIZED), | 86 : operation_(UNINITIALIZED), |
| 87 state_type_(BrowserDistribution::CHROME_BROWSER), |
| 87 multi_package_distribution_(NULL), | 88 multi_package_distribution_(NULL), |
| 88 level_(UNKNOWN_LEVEL), | 89 level_(UNKNOWN_LEVEL), |
| 89 package_type_(UNKNOWN_PACKAGE_TYPE), | 90 package_type_(UNKNOWN_PACKAGE_TYPE), |
| 90 state_type_(BrowserDistribution::CHROME_BROWSER), | |
| 91 root_key_(NULL), | 91 root_key_(NULL), |
| 92 msi_(false), | 92 msi_(false), |
| 93 verbose_logging_(false), | 93 verbose_logging_(false), |
| 94 ensure_google_update_present_(false) { | 94 ensure_google_update_present_(false) { |
| 95 // Use set_level() so that root_key_ is updated properly. | 95 // Use set_level() so that root_key_ is updated properly. |
| 96 set_level(level); | 96 set_level(level); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void InstallerState::Initialize(const CommandLine& command_line, | 99 void InstallerState::Initialize(const CommandLine& command_line, |
| 100 const MasterPreferences& prefs, | 100 const MasterPreferences& prefs, |
| 101 const InstallationState& machine_state) { | 101 const InstallationState& machine_state) { |
| 102 Clear(); |
| 103 |
| 102 bool pref_bool; | 104 bool pref_bool; |
| 103 if (!prefs.GetBool(master_preferences::kSystemLevel, &pref_bool)) | 105 if (!prefs.GetBool(master_preferences::kSystemLevel, &pref_bool)) |
| 104 pref_bool = false; | 106 pref_bool = false; |
| 105 set_level(pref_bool ? SYSTEM_LEVEL : USER_LEVEL); | 107 set_level(pref_bool ? SYSTEM_LEVEL : USER_LEVEL); |
| 106 | 108 |
| 107 if (!prefs.GetBool(master_preferences::kVerboseLogging, &verbose_logging_)) | 109 if (!prefs.GetBool(master_preferences::kVerboseLogging, &verbose_logging_)) |
| 108 verbose_logging_ = false; | 110 verbose_logging_ = false; |
| 109 | 111 |
| 110 if (!prefs.GetBool(master_preferences::kMultiInstall, &pref_bool)) | 112 if (!prefs.GetBool(master_preferences::kMultiInstall, &pref_bool)) |
| 111 pref_bool = false; | 113 pref_bool = false; |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 | 611 |
| 610 // static | 612 // static |
| 611 bool InstallerState::IsFileInUse(const base::FilePath& file) { | 613 bool InstallerState::IsFileInUse(const base::FilePath& file) { |
| 612 // Call CreateFile with a share mode of 0 which should cause this to fail | 614 // Call CreateFile with a share mode of 0 which should cause this to fail |
| 613 // with ERROR_SHARING_VIOLATION if the file exists and is in-use. | 615 // with ERROR_SHARING_VIOLATION if the file exists and is in-use. |
| 614 return !base::win::ScopedHandle(CreateFile(file.value().c_str(), | 616 return !base::win::ScopedHandle(CreateFile(file.value().c_str(), |
| 615 GENERIC_WRITE, 0, NULL, | 617 GENERIC_WRITE, 0, NULL, |
| 616 OPEN_EXISTING, 0, 0)).IsValid(); | 618 OPEN_EXISTING, 0, 0)).IsValid(); |
| 617 } | 619 } |
| 618 | 620 |
| 621 void InstallerState::Clear() { |
| 622 operation_ = UNINITIALIZED; |
| 623 target_path_.clear(); |
| 624 state_key_.clear(); |
| 625 state_type_ = BrowserDistribution::CHROME_BROWSER; |
| 626 products_.clear(); |
| 627 multi_package_distribution_ = NULL; |
| 628 critical_update_version_ = base::Version(); |
| 629 level_ = UNKNOWN_LEVEL; |
| 630 package_type_ = UNKNOWN_PACKAGE_TYPE; |
| 631 root_key_ = NULL; |
| 632 msi_ = false; |
| 633 verbose_logging_ = false; |
| 634 ensure_google_update_present_ = false; |
| 635 } |
| 636 |
| 619 bool InstallerState::AnyExistsAndIsInUse( | 637 bool InstallerState::AnyExistsAndIsInUse( |
| 620 const InstallationState& machine_state, | 638 const InstallationState& machine_state, |
| 621 uint32 file_bits) const { | 639 uint32 file_bits) const { |
| 622 static const wchar_t* const kBinaryFileNames[] = { | 640 static const wchar_t* const kBinaryFileNames[] = { |
| 623 kChromeFrameDll, | 641 kChromeFrameDll, |
| 624 kChromeFrameHelperExe, | 642 kChromeFrameHelperExe, |
| 625 kChromeDll, | 643 kChromeDll, |
| 626 }; | 644 }; |
| 627 DCHECK_NE(file_bits, 0U); | 645 DCHECK_NE(file_bits, 0U); |
| 628 DCHECK_LT(file_bits, 1U << NUM_BINARIES); | 646 DCHECK_LT(file_bits, 1U << NUM_BINARIES); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 } | 844 } |
| 827 if (!install_list->Do()) | 845 if (!install_list->Do()) |
| 828 LOG(ERROR) << "Failed to record installer error information in registry."; | 846 LOG(ERROR) << "Failed to record installer error information in registry."; |
| 829 } | 847 } |
| 830 | 848 |
| 831 bool InstallerState::RequiresActiveSetup() const { | 849 bool InstallerState::RequiresActiveSetup() const { |
| 832 return system_install() && FindProduct(BrowserDistribution::CHROME_BROWSER); | 850 return system_install() && FindProduct(BrowserDistribution::CHROME_BROWSER); |
| 833 } | 851 } |
| 834 | 852 |
| 835 } // namespace installer | 853 } // namespace installer |
| OLD | NEW |