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 <windows.h> | 5 #include <windows.h> |
6 #include <msi.h> | 6 #include <msi.h> |
7 #include <shellapi.h> | 7 #include <shellapi.h> |
8 #include <shlobj.h> | 8 #include <shlobj.h> |
9 | 9 |
10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
14 #include "base/file_version_info.h" | 14 #include "base/file_version_info.h" |
15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
16 #include "base/process_util.h" | 16 #include "base/process_util.h" |
17 #include "base/scoped_temp_dir.h" | 17 #include "base/scoped_temp_dir.h" |
18 #include "base/string16.h" | 18 #include "base/string16.h" |
19 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
21 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
22 #include "base/values.h" | 22 #include "base/values.h" |
23 #include "base/win/registry.h" | 23 #include "base/win/registry.h" |
| 24 #include "base/win/scoped_com_initializer.h" |
24 #include "base/win/scoped_comptr.h" | 25 #include "base/win/scoped_comptr.h" |
25 #include "base/win/scoped_handle.h" | 26 #include "base/win/scoped_handle.h" |
26 #include "base/win/win_util.h" | 27 #include "base/win/win_util.h" |
27 #include "base/win/windows_version.h" | 28 #include "base/win/windows_version.h" |
28 #include "breakpad/src/client/windows/handler/exception_handler.h" | 29 #include "breakpad/src/client/windows/handler/exception_handler.h" |
29 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
30 #include "chrome/installer/setup/chrome_frame_quick_enable.h" | 31 #include "chrome/installer/setup/chrome_frame_quick_enable.h" |
31 #include "chrome/installer/setup/chrome_frame_ready_mode.h" | 32 #include "chrome/installer/setup/chrome_frame_ready_mode.h" |
32 #include "chrome/installer/setup/install.h" | 33 #include "chrome/installer/setup/install.h" |
33 #include "chrome/installer/setup/install_worker.h" | 34 #include "chrome/installer/setup/install_worker.h" |
(...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1310 LOG(ERROR) << "Unable to get shutdown privileges."; | 1311 LOG(ERROR) << "Unable to get shutdown privileges."; |
1311 return false; | 1312 return false; |
1312 } | 1313 } |
1313 | 1314 |
1314 // Popup a dialog that will prompt to reboot using the default system message. | 1315 // Popup a dialog that will prompt to reboot using the default system message. |
1315 // TODO(robertshield): Add a localized, more specific string to the prompt. | 1316 // TODO(robertshield): Add a localized, more specific string to the prompt. |
1316 RestartDialog(NULL, NULL, EWX_REBOOT | EWX_FORCEIFHUNG); | 1317 RestartDialog(NULL, NULL, EWX_REBOOT | EWX_FORCEIFHUNG); |
1317 return true; | 1318 return true; |
1318 } | 1319 } |
1319 | 1320 |
1320 // Class to manage COM initialization and uninitialization | |
1321 class AutoCom { | |
1322 public: | |
1323 AutoCom() : initialized_(false) { } | |
1324 ~AutoCom() { | |
1325 if (initialized_) CoUninitialize(); | |
1326 } | |
1327 bool Init(bool system_install) { | |
1328 if (CoInitializeEx(NULL, COINIT_APARTMENTTHREADED) != S_OK) { | |
1329 LOG(ERROR) << "COM initialization failed."; | |
1330 return false; | |
1331 } | |
1332 initialized_ = true; | |
1333 return true; | |
1334 } | |
1335 | |
1336 private: | |
1337 bool initialized_; | |
1338 }; | |
1339 | |
1340 // Returns the Custom information for the client identified by the exe path | 1321 // Returns the Custom information for the client identified by the exe path |
1341 // passed in. This information is used for crash reporting. | 1322 // passed in. This information is used for crash reporting. |
1342 google_breakpad::CustomClientInfo* GetCustomInfo(const wchar_t* exe_path) { | 1323 google_breakpad::CustomClientInfo* GetCustomInfo(const wchar_t* exe_path) { |
1343 string16 product; | 1324 string16 product; |
1344 string16 version; | 1325 string16 version; |
1345 scoped_ptr<FileVersionInfo> version_info( | 1326 scoped_ptr<FileVersionInfo> version_info( |
1346 FileVersionInfo::CreateFileVersionInfo(FilePath(exe_path))); | 1327 FileVersionInfo::CreateFileVersionInfo(FilePath(exe_path))); |
1347 if (version_info.get()) { | 1328 if (version_info.get()) { |
1348 version = version_info->product_version(); | 1329 version = version_info->product_version(); |
1349 product = version_info->product_short_name(); | 1330 product = version_info->product_short_name(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1437 // Check to make sure current system is WinXP or later. If not, log | 1418 // Check to make sure current system is WinXP or later. If not, log |
1438 // error message and get out. | 1419 // error message and get out. |
1439 if (!InstallUtil::IsOSSupported()) { | 1420 if (!InstallUtil::IsOSSupported()) { |
1440 LOG(ERROR) << "Chrome only supports Windows XP or later."; | 1421 LOG(ERROR) << "Chrome only supports Windows XP or later."; |
1441 installer_state.WriteInstallerResult( | 1422 installer_state.WriteInstallerResult( |
1442 installer::OS_NOT_SUPPORTED, IDS_INSTALL_OS_NOT_SUPPORTED_BASE, NULL); | 1423 installer::OS_NOT_SUPPORTED, IDS_INSTALL_OS_NOT_SUPPORTED_BASE, NULL); |
1443 return installer::OS_NOT_SUPPORTED; | 1424 return installer::OS_NOT_SUPPORTED; |
1444 } | 1425 } |
1445 | 1426 |
1446 // Initialize COM for use later. | 1427 // Initialize COM for use later. |
1447 AutoCom auto_com; | 1428 base::win::ScopedCOMInitializer com_initializer; |
1448 if (!auto_com.Init(system_install)) { | 1429 if (!com_initializer.succeeded()) { |
1449 installer_state.WriteInstallerResult( | 1430 installer_state.WriteInstallerResult( |
1450 installer::OS_ERROR, IDS_INSTALL_OS_ERROR_BASE, NULL); | 1431 installer::OS_ERROR, IDS_INSTALL_OS_ERROR_BASE, NULL); |
1451 return installer::OS_ERROR; | 1432 return installer::OS_ERROR; |
1452 } | 1433 } |
1453 | 1434 |
1454 // Some command line options don't work with SxS install/uninstall | 1435 // Some command line options don't work with SxS install/uninstall |
1455 if (InstallUtil::IsChromeSxSProcess()) { | 1436 if (InstallUtil::IsChromeSxSProcess()) { |
1456 if (system_install || | 1437 if (system_install || |
1457 prefs.is_multi_install() || | 1438 prefs.is_multi_install() || |
1458 cmd_line.HasSwitch(installer::switches::kForceUninstall) || | 1439 cmd_line.HasSwitch(installer::switches::kForceUninstall) || |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1551 if (!(installer_state.is_msi() && is_uninstall)) | 1532 if (!(installer_state.is_msi() && is_uninstall)) |
1552 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT | 1533 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT |
1553 // to pass through, since this is only returned on uninstall which is | 1534 // to pass through, since this is only returned on uninstall which is |
1554 // never invoked directly by Google Update. | 1535 // never invoked directly by Google Update. |
1555 return_code = InstallUtil::GetInstallReturnCode(install_status); | 1536 return_code = InstallUtil::GetInstallReturnCode(install_status); |
1556 | 1537 |
1557 VLOG(1) << "Installation complete, returning: " << return_code; | 1538 VLOG(1) << "Installation complete, returning: " << return_code; |
1558 | 1539 |
1559 return return_code; | 1540 return return_code; |
1560 } | 1541 } |
OLD | NEW |