| OLD | NEW |
| 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 #include "chrome/installer/util/product.h" | 5 #include "chrome/installer/util/product.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 const MasterPreferences& prefs = MasterPreferences::ForCurrentProcess(); | 120 const MasterPreferences& prefs = MasterPreferences::ForCurrentProcess(); |
| 121 | 121 |
| 122 bool is_msi = false; | 122 bool is_msi = false; |
| 123 prefs.GetBool(installer::master_preferences::kMsi, &is_msi); | 123 prefs.GetBool(installer::master_preferences::kMsi, &is_msi); |
| 124 | 124 |
| 125 if (!is_msi) { | 125 if (!is_msi) { |
| 126 // We didn't find it in the preferences, try looking in the registry. | 126 // We didn't find it in the preferences, try looking in the registry. |
| 127 HKEY reg_root = system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 127 HKEY reg_root = system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
| 128 RegKey key; | 128 RegKey key; |
| 129 if (key.Open(reg_root, distribution_->GetStateKey().c_str(), KEY_READ)) { | 129 LONG result = key.Open(reg_root, distribution_->GetStateKey().c_str(), |
| 130 DWORD msi_value; | 130 KEY_READ); |
| 131 if (key.ReadValueDW(google_update::kRegMSIField, &msi_value) && | 131 if (result == ERROR_SUCCESS) { |
| 132 msi_value != 0) { | 132 DWORD msi_value = 0; |
| 133 msi_ = true; | 133 result = key.ReadValueDW(google_update::kRegMSIField, &msi_value); |
| 134 } | 134 msi_ = msi_value != 0; |
| 135 } | 135 } |
| 136 } else { | 136 } else { |
| 137 msi_ = true; | 137 msi_ = true; |
| 138 } | 138 } |
| 139 cache_state_ |= MSI_STATE; | 139 cache_state_ |= MSI_STATE; |
| 140 } | 140 } |
| 141 | 141 |
| 142 return msi_; | 142 return msi_; |
| 143 } | 143 } |
| 144 | 144 |
| 145 bool Product::SetMsiMarker(bool set) const { | 145 bool Product::SetMsiMarker(bool set) const { |
| 146 bool success = false; | |
| 147 HKEY reg_root = system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 146 HKEY reg_root = system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
| 148 RegKey client_state_key; | 147 RegKey client_state_key; |
| 149 if (client_state_key.Open(reg_root, distribution_->GetStateKey().c_str(), | 148 LONG result = client_state_key.Open(reg_root, |
| 150 KEY_READ | KEY_WRITE)) { | 149 distribution_->GetStateKey().c_str(), KEY_READ | KEY_WRITE); |
| 151 DWORD msi_value = set ? 1 : 0; | 150 if (result == ERROR_SUCCESS) { |
| 152 if (client_state_key.WriteValue(google_update::kRegMSIField, msi_value)) { | 151 result = client_state_key.WriteValue(google_update::kRegMSIField, |
| 153 success = true; | 152 set ? 1 : 0); |
| 154 } else { | |
| 155 LOG(ERROR) << "Could not write MSI value to client state key."; | |
| 156 } | |
| 157 } else { | |
| 158 LOG(ERROR) << "SetMsiMarker: Could not open client state key!"; | |
| 159 } | 153 } |
| 160 | 154 |
| 161 return success; | 155 LOG_IF(ERROR, result != ERROR_SUCCESS) << "Failed to Open or Write MSI value" |
| 156 "to client state key. error: " << result; |
| 157 |
| 158 return (result == ERROR_SUCCESS); |
| 162 } | 159 } |
| 163 | 160 |
| 164 bool Product::ShouldCreateUninstallEntry() const { | 161 bool Product::ShouldCreateUninstallEntry() const { |
| 165 if (IsMsi()) { | 162 if (IsMsi()) { |
| 166 // MSI installations will manage their own uninstall shortcuts. | 163 // MSI installations will manage their own uninstall shortcuts. |
| 167 return false; | 164 return false; |
| 168 } | 165 } |
| 169 | 166 |
| 170 return distribution_->ShouldCreateUninstallEntry(); | 167 return distribution_->ShouldCreateUninstallEntry(); |
| 171 } | 168 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 if (!distribution) { | 241 if (!distribution) { |
| 245 NOTREACHED(); | 242 NOTREACHED(); |
| 246 return false; | 243 return false; |
| 247 } | 244 } |
| 248 | 245 |
| 249 return AddDistribution(distribution); | 246 return AddDistribution(distribution); |
| 250 } | 247 } |
| 251 | 248 |
| 252 } // namespace installer | 249 } // namespace installer |
| 253 | 250 |
| OLD | NEW |