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 // See the corresponding header file for description of the functions in this | 5 // See the corresponding header file for description of the functions in this |
6 // file. | 6 // file. |
7 | 7 |
8 #include "chrome/installer/util/install_util.h" | 8 #include "chrome/installer/util/install_util.h" |
9 | 9 |
10 #include <shellapi.h> | 10 #include <shellapi.h> |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 } | 214 } |
215 return CommandLine(CommandLine::NO_PROGRAM); | 215 return CommandLine(CommandLine::NO_PROGRAM); |
216 } | 216 } |
217 | 217 |
218 void InstallUtil::GetChromeVersion(BrowserDistribution* dist, | 218 void InstallUtil::GetChromeVersion(BrowserDistribution* dist, |
219 bool system_install, | 219 bool system_install, |
220 Version* version) { | 220 Version* version) { |
221 DCHECK(dist); | 221 DCHECK(dist); |
222 RegKey key; | 222 RegKey key; |
223 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 223 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
224 LONG result = key.Open(reg_root, dist->GetVersionKey().c_str(), | 224 LONG result = key.Open(reg_root, |
225 KEY_QUERY_VALUE); | 225 dist->GetVersionKey().c_str(), |
| 226 KEY_QUERY_VALUE | KEY_WOW64_32KEY); |
226 | 227 |
227 base::string16 version_str; | 228 base::string16 version_str; |
228 if (result == ERROR_SUCCESS) | 229 if (result == ERROR_SUCCESS) |
229 result = key.ReadValue(google_update::kRegVersionField, &version_str); | 230 result = key.ReadValue(google_update::kRegVersionField, &version_str); |
230 | 231 |
231 *version = Version(); | 232 *version = Version(); |
232 if (result == ERROR_SUCCESS && !version_str.empty()) { | 233 if (result == ERROR_SUCCESS && !version_str.empty()) { |
233 VLOG(1) << "Existing " << dist->GetDisplayName() << " version found " | 234 VLOG(1) << "Existing " << dist->GetDisplayName() << " version found " |
234 << version_str; | 235 << version_str; |
235 *version = Version(base::UTF16ToASCII(version_str)); | 236 *version = Version(base::UTF16ToASCII(version_str)); |
236 } else { | 237 } else { |
237 DCHECK_EQ(ERROR_FILE_NOT_FOUND, result); | 238 DCHECK_EQ(ERROR_FILE_NOT_FOUND, result); |
238 VLOG(1) << "No existing " << dist->GetDisplayName() | 239 VLOG(1) << "No existing " << dist->GetDisplayName() |
239 << " install found."; | 240 << " install found."; |
240 } | 241 } |
241 } | 242 } |
242 | 243 |
243 void InstallUtil::GetCriticalUpdateVersion(BrowserDistribution* dist, | 244 void InstallUtil::GetCriticalUpdateVersion(BrowserDistribution* dist, |
244 bool system_install, | 245 bool system_install, |
245 Version* version) { | 246 Version* version) { |
246 DCHECK(dist); | 247 DCHECK(dist); |
247 RegKey key; | 248 RegKey key; |
248 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 249 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
249 LONG result = | 250 LONG result = key.Open(reg_root, |
250 key.Open(reg_root, dist->GetVersionKey().c_str(), KEY_QUERY_VALUE); | 251 dist->GetVersionKey().c_str(), |
| 252 KEY_QUERY_VALUE | KEY_WOW64_32KEY); |
251 | 253 |
252 base::string16 version_str; | 254 base::string16 version_str; |
253 if (result == ERROR_SUCCESS) | 255 if (result == ERROR_SUCCESS) |
254 result = key.ReadValue(google_update::kRegCriticalVersionField, | 256 result = key.ReadValue(google_update::kRegCriticalVersionField, |
255 &version_str); | 257 &version_str); |
256 | 258 |
257 *version = Version(); | 259 *version = Version(); |
258 if (result == ERROR_SUCCESS && !version_str.empty()) { | 260 if (result == ERROR_SUCCESS && !version_str.empty()) { |
259 VLOG(1) << "Critical Update version for " << dist->GetDisplayName() | 261 VLOG(1) << "Critical Update version for " << dist->GetDisplayName() |
260 << " found " << version_str; | 262 << " found " << version_str; |
(...skipping 18 matching lines...) Expand all Loading... |
279 void InstallUtil::AddInstallerResultItems( | 281 void InstallUtil::AddInstallerResultItems( |
280 bool system_install, | 282 bool system_install, |
281 const base::string16& state_key, | 283 const base::string16& state_key, |
282 installer::InstallStatus status, | 284 installer::InstallStatus status, |
283 int string_resource_id, | 285 int string_resource_id, |
284 const base::string16* const launch_cmd, | 286 const base::string16* const launch_cmd, |
285 WorkItemList* install_list) { | 287 WorkItemList* install_list) { |
286 DCHECK(install_list); | 288 DCHECK(install_list); |
287 const HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 289 const HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
288 DWORD installer_result = (GetInstallReturnCode(status) == 0) ? 0 : 1; | 290 DWORD installer_result = (GetInstallReturnCode(status) == 0) ? 0 : 1; |
289 install_list->AddCreateRegKeyWorkItem( | 291 install_list->AddCreateRegKeyWorkItem(root, state_key, KEY_WOW64_32KEY); |
290 root, state_key, WorkItem::kWow64Default); | |
291 install_list->AddSetRegValueWorkItem(root, | 292 install_list->AddSetRegValueWorkItem(root, |
292 state_key, | 293 state_key, |
293 WorkItem::kWow64Default, | 294 KEY_WOW64_32KEY, |
294 installer::kInstallerResult, | 295 installer::kInstallerResult, |
295 installer_result, | 296 installer_result, |
296 true); | 297 true); |
297 install_list->AddSetRegValueWorkItem(root, | 298 install_list->AddSetRegValueWorkItem(root, |
298 state_key, | 299 state_key, |
299 WorkItem::kWow64Default, | 300 KEY_WOW64_32KEY, |
300 installer::kInstallerError, | 301 installer::kInstallerError, |
301 static_cast<DWORD>(status), | 302 static_cast<DWORD>(status), |
302 true); | 303 true); |
303 if (string_resource_id != 0) { | 304 if (string_resource_id != 0) { |
304 base::string16 msg = installer::GetLocalizedString(string_resource_id); | 305 base::string16 msg = installer::GetLocalizedString(string_resource_id); |
305 install_list->AddSetRegValueWorkItem(root, | 306 install_list->AddSetRegValueWorkItem(root, |
306 state_key, | 307 state_key, |
307 WorkItem::kWow64Default, | 308 KEY_WOW64_32KEY, |
308 installer::kInstallerResultUIString, | 309 installer::kInstallerResultUIString, |
309 msg, | 310 msg, |
310 true); | 311 true); |
311 } | 312 } |
312 if (launch_cmd != NULL && !launch_cmd->empty()) { | 313 if (launch_cmd != NULL && !launch_cmd->empty()) { |
313 install_list->AddSetRegValueWorkItem( | 314 install_list->AddSetRegValueWorkItem( |
314 root, | 315 root, |
315 state_key, | 316 state_key, |
316 WorkItem::kWow64Default, | 317 KEY_WOW64_32KEY, |
317 installer::kInstallerSuccessLaunchCmdLine, | 318 installer::kInstallerSuccessLaunchCmdLine, |
318 *launch_cmd, | 319 *launch_cmd, |
319 true); | 320 true); |
320 } | 321 } |
321 } | 322 } |
322 | 323 |
323 void InstallUtil::UpdateInstallerStage(bool system_install, | 324 void InstallUtil::UpdateInstallerStage(bool system_install, |
324 const base::string16& state_key_path, | 325 const base::string16& state_key_path, |
325 installer::InstallerStage stage) { | 326 installer::InstallerStage stage) { |
326 DCHECK_LE(static_cast<installer::InstallerStage>(0), stage); | 327 DCHECK_LE(static_cast<installer::InstallerStage>(0), stage); |
327 DCHECK_GT(installer::NUM_STAGES, stage); | 328 DCHECK_GT(installer::NUM_STAGES, stage); |
328 const HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 329 const HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
329 RegKey state_key; | 330 RegKey state_key; |
330 LONG result = state_key.Open(root, state_key_path.c_str(), | 331 LONG result = |
331 KEY_QUERY_VALUE | KEY_SET_VALUE); | 332 state_key.Open(root, |
| 333 state_key_path.c_str(), |
| 334 KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_WOW64_32KEY); |
332 if (result == ERROR_SUCCESS) { | 335 if (result == ERROR_SUCCESS) { |
333 if (stage == installer::NO_STAGE) { | 336 if (stage == installer::NO_STAGE) { |
334 result = state_key.DeleteValue(installer::kInstallerExtraCode1); | 337 result = state_key.DeleteValue(installer::kInstallerExtraCode1); |
335 LOG_IF(ERROR, result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) | 338 LOG_IF(ERROR, result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) |
336 << "Failed deleting installer stage from " << state_key_path | 339 << "Failed deleting installer stage from " << state_key_path |
337 << "; result: " << result; | 340 << "; result: " << result; |
338 } else { | 341 } else { |
339 const DWORD extra_code_1 = static_cast<DWORD>(stage); | 342 const DWORD extra_code_1 = static_cast<DWORD>(stage); |
340 result = state_key.WriteValue(installer::kInstallerExtraCode1, | 343 result = state_key.WriteValue(installer::kInstallerExtraCode1, |
341 extra_code_1); | 344 extra_code_1); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 // Open the program and see if it references the expected file. | 640 // Open the program and see if it references the expected file. |
638 base::File file; | 641 base::File file; |
639 BY_HANDLE_FILE_INFORMATION info = {}; | 642 BY_HANDLE_FILE_INFORMATION info = {}; |
640 | 643 |
641 return (OpenForInfo(path, &file) && | 644 return (OpenForInfo(path, &file) && |
642 GetInfo(file, &info) && | 645 GetInfo(file, &info) && |
643 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && | 646 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && |
644 info.nFileIndexHigh == file_info_.nFileIndexHigh && | 647 info.nFileIndexHigh == file_info_.nFileIndexHigh && |
645 info.nFileIndexLow == file_info_.nFileIndexLow); | 648 info.nFileIndexLow == file_info_.nFileIndexLow); |
646 } | 649 } |
OLD | NEW |