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 <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 <string> | 10 #include <string> |
11 | 11 |
12 #include "base/at_exit.h" | 12 #include "base/at_exit.h" |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
16 #include "base/file_version_info.h" | |
16 #include "base/path_service.h" | 17 #include "base/path_service.h" |
17 #include "base/process_util.h" | 18 #include "base/process_util.h" |
18 #include "base/scoped_handle_win.h" | 19 #include "base/scoped_handle_win.h" |
19 #include "base/string_number_conversions.h" | 20 #include "base/string_number_conversions.h" |
20 #include "base/string_util.h" | 21 #include "base/string_util.h" |
21 #include "base/utf_string_conversions.h" | 22 #include "base/utf_string_conversions.h" |
22 #include "base/values.h" | 23 #include "base/values.h" |
24 #include "base/win_util.h" | |
23 #include "base/win/windows_version.h" | 25 #include "base/win/windows_version.h" |
26 #include "breakpad/src/client/windows/handler/exception_handler.h" | |
24 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
25 #include "chrome/installer/setup/install.h" | 28 #include "chrome/installer/setup/install.h" |
26 #include "chrome/installer/setup/setup_constants.h" | 29 #include "chrome/installer/setup/setup_constants.h" |
27 #include "chrome/installer/setup/setup_util.h" | 30 #include "chrome/installer/setup/setup_util.h" |
28 #include "chrome/installer/setup/uninstall.h" | 31 #include "chrome/installer/setup/uninstall.h" |
29 #include "chrome/installer/util/browser_distribution.h" | 32 #include "chrome/installer/util/browser_distribution.h" |
30 #include "chrome/installer/util/delete_after_reboot_helper.h" | 33 #include "chrome/installer/util/delete_after_reboot_helper.h" |
31 #include "chrome/installer/util/delete_tree_work_item.h" | 34 #include "chrome/installer/util/delete_tree_work_item.h" |
32 #include "chrome/installer/util/google_update_settings.h" | 35 #include "chrome/installer/util/google_update_settings.h" |
33 #include "chrome/installer/util/google_update_constants.h" | 36 #include "chrome/installer/util/google_update_constants.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
45 | 48 |
46 #include "installer_util_strings.h" // NOLINT | 49 #include "installer_util_strings.h" // NOLINT |
47 | 50 |
48 using installer::Product; | 51 using installer::Product; |
49 using installer::ProductPackageMapping; | 52 using installer::ProductPackageMapping; |
50 using installer::Products; | 53 using installer::Products; |
51 using installer::Package; | 54 using installer::Package; |
52 using installer::Packages; | 55 using installer::Packages; |
53 using installer::MasterPreferences; | 56 using installer::MasterPreferences; |
54 | 57 |
58 const wchar_t kChromePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices"; | |
59 const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\"; | |
60 const wchar_t kSystemPrincipalSid[] = L"S-1-5-18"; | |
61 | |
62 const MINIDUMP_TYPE kLargerDumpType = static_cast<MINIDUMP_TYPE>( | |
63 MiniDumpWithProcessThreadData | // Get PEB and TEB. | |
64 MiniDumpWithUnloadedModules | // Get unloaded modules when available. | |
65 MiniDumpWithIndirectlyReferencedMemory); // Get memory referenced by stack. | |
66 | |
55 namespace { | 67 namespace { |
56 | 68 |
57 // This method unpacks and uncompresses the given archive file. For Chrome | 69 // This method unpacks and uncompresses the given archive file. For Chrome |
58 // install we are creating a uncompressed archive that contains all the files | 70 // install we are creating a uncompressed archive that contains all the files |
59 // needed for the installer. This uncompressed archive is later compressed. | 71 // needed for the installer. This uncompressed archive is later compressed. |
60 // | 72 // |
61 // This method first uncompresses archive specified by parameter "archive" | 73 // This method first uncompresses archive specified by parameter "archive" |
62 // and assumes that it will result in an uncompressed full archive file | 74 // and assumes that it will result in an uncompressed full archive file |
63 // (chrome.7z) or uncompressed archive patch file (chrome_patch.diff). If it | 75 // (chrome.7z) or uncompressed archive patch file (chrome_patch.diff). If it |
64 // is patch file, it is applied to the old archive file that should be | 76 // is patch file, it is applied to the old archive file that should be |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
695 VLOG(1) << "Install distribution: Chrome"; | 707 VLOG(1) << "Install distribution: Chrome"; |
696 installations->AddDistribution(BrowserDistribution::CHROME_BROWSER, prefs); | 708 installations->AddDistribution(BrowserDistribution::CHROME_BROWSER, prefs); |
697 } | 709 } |
698 | 710 |
699 if (prefs.install_chrome_frame()) { | 711 if (prefs.install_chrome_frame()) { |
700 VLOG(1) << "Install distribution: Chrome Frame"; | 712 VLOG(1) << "Install distribution: Chrome Frame"; |
701 installations->AddDistribution(BrowserDistribution::CHROME_FRAME, prefs); | 713 installations->AddDistribution(BrowserDistribution::CHROME_FRAME, prefs); |
702 } | 714 } |
703 } | 715 } |
704 | 716 |
717 // Returns the Custom information for the client identified by the exe path | |
718 // passed in. This information is used for crash reporting. | |
719 google_breakpad::CustomClientInfo* GetCustomInfo(const wchar_t* exe_path) { | |
720 std::wstring product; | |
721 std::wstring version; | |
722 scoped_ptr<FileVersionInfo> | |
723 version_info(FileVersionInfo::CreateFileVersionInfo(FilePath(exe_path))); | |
724 if (version_info.get()) { | |
725 version = version_info->product_version(); | |
726 product = version_info->product_short_name(); | |
727 } | |
728 | |
729 if (version.empty()) | |
730 version = L"0.1.0.0"; | |
731 | |
732 if (product.empty()) | |
733 product = L"Chrome installer"; | |
robertshield
2010/12/22 19:02:00
microscopic nit: "Chrome Installer" here and on li
ananta
2010/12/22 19:13:01
Done.
| |
734 | |
735 static google_breakpad::CustomInfoEntry ver_entry(L"ver", version.c_str()); | |
736 static google_breakpad::CustomInfoEntry prod_entry(L"prod", product.c_str()); | |
737 static google_breakpad::CustomInfoEntry plat_entry(L"plat", L"Win32"); | |
738 static google_breakpad::CustomInfoEntry type_entry(L"ptype", | |
739 L"Chrome installer"); | |
740 static google_breakpad::CustomInfoEntry entries[] = { | |
741 ver_entry, prod_entry, plat_entry, type_entry }; | |
742 static google_breakpad::CustomClientInfo custom_info = { | |
743 entries, arraysize(entries) }; | |
744 return &custom_info; | |
745 } | |
746 | |
747 // Initialize crash reporting for this process. This involves connecting to | |
748 // breakpad, etc. | |
749 google_breakpad::ExceptionHandler* InitializeCrashReporting( | |
750 bool system_install) { | |
751 // Only report crashes if the user allows it. | |
752 if (!GoogleUpdateSettings::GetCollectStatsConsent()) | |
753 return NULL; | |
754 | |
755 // Get the alternate dump directory. We use the temp path. | |
756 FilePath temp_directory; | |
757 if (!file_util::GetTempDir(&temp_directory) || temp_directory.empty()) | |
758 return NULL; | |
759 | |
760 wchar_t exe_path[MAX_PATH * 2] = {0}; | |
761 GetModuleFileName(NULL, exe_path, arraysize(exe_path)); | |
762 | |
763 // Build the pipe name. It can be either: | |
764 // System-wide install: "NamedPipe\GoogleCrashServices\S-1-5-18" | |
765 // Per-user install: "NamedPipe\GoogleCrashServices\<user SID>" | |
766 std::wstring user_sid = kSystemPrincipalSid; | |
767 | |
768 if (system_install) { | |
769 user_sid = kSystemPrincipalSid; | |
robertshield
2010/12/22 19:02:00
Don't need this line since the user_sid is initial
ananta
2010/12/22 19:13:01
Done.
| |
770 } else { | |
771 if (!win_util::GetUserSidString(&user_sid)) { | |
772 return NULL; | |
773 } | |
774 } | |
775 | |
776 std::wstring pipe_name = kGoogleUpdatePipeName; | |
777 pipe_name += user_sid; | |
778 | |
779 google_breakpad::ExceptionHandler* breakpad = | |
780 new google_breakpad::ExceptionHandler( | |
781 temp_directory.ToWStringHack(), NULL, NULL, NULL, | |
782 google_breakpad::ExceptionHandler::HANDLER_ALL, kLargerDumpType, | |
783 pipe_name.c_str(), GetCustomInfo(exe_path)); | |
784 return breakpad; | |
785 } | |
786 | |
705 } // namespace | 787 } // namespace |
706 | 788 |
707 int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance, | 789 int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance, |
708 wchar_t* command_line, int show_command) { | 790 wchar_t* command_line, int show_command) { |
709 // The exit manager is in charge of calling the dtors of singletons. | 791 // The exit manager is in charge of calling the dtors of singletons. |
710 base::AtExitManager exit_manager; | 792 base::AtExitManager exit_manager; |
711 CommandLine::Init(0, NULL); | 793 CommandLine::Init(0, NULL); |
712 | 794 |
713 const MasterPreferences& prefs = | 795 const MasterPreferences& prefs = |
714 installer::MasterPreferences::ForCurrentProcess(); | 796 installer::MasterPreferences::ForCurrentProcess(); |
715 installer::InitInstallerLogging(prefs); | 797 installer::InitInstallerLogging(prefs); |
716 | 798 |
717 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); | 799 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); |
718 VLOG(1) << "Command Line: " << cmd_line.command_line_string(); | 800 VLOG(1) << "Command Line: " << cmd_line.command_line_string(); |
719 | 801 |
720 VLOG(1) << "multi install is " << prefs.is_multi_install(); | 802 VLOG(1) << "multi install is " << prefs.is_multi_install(); |
721 bool system_install = false; | 803 bool system_install = false; |
722 prefs.GetBool(installer::master_preferences::kSystemLevel, &system_install); | 804 prefs.GetBool(installer::master_preferences::kSystemLevel, &system_install); |
723 VLOG(1) << "system install is " << system_install; | 805 VLOG(1) << "system install is " << system_install; |
724 | 806 |
807 google_breakpad::scoped_ptr<google_breakpad::ExceptionHandler> breakpad( | |
808 InitializeCrashReporting(system_install)); | |
809 | |
725 ProductPackageMapping installations(prefs.is_multi_install(), system_install); | 810 ProductPackageMapping installations(prefs.is_multi_install(), system_install); |
726 PopulateInstallations(prefs, &installations); | 811 PopulateInstallations(prefs, &installations); |
727 | 812 |
728 // Check to make sure current system is WinXP or later. If not, log | 813 // Check to make sure current system is WinXP or later. If not, log |
729 // error message and get out. | 814 // error message and get out. |
730 if (!InstallUtil::IsOSSupported()) { | 815 if (!InstallUtil::IsOSSupported()) { |
731 LOG(ERROR) << "Chrome only supports Windows XP or later."; | 816 LOG(ERROR) << "Chrome only supports Windows XP or later."; |
732 installations.packages()[0]->WriteInstallerResult( | 817 installations.packages()[0]->WriteInstallerResult( |
733 installer::OS_NOT_SUPPORTED, IDS_INSTALL_OS_NOT_SUPPORTED_BASE, NULL); | 818 installer::OS_NOT_SUPPORTED, IDS_INSTALL_OS_NOT_SUPPORTED_BASE, NULL); |
734 return installer::OS_NOT_SUPPORTED; | 819 return installer::OS_NOT_SUPPORTED; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
831 // to pass through, since this is only returned on uninstall which is | 916 // to pass through, since this is only returned on uninstall which is |
832 // never invoked directly by Google Update. | 917 // never invoked directly by Google Update. |
833 return_code = InstallUtil::GetInstallReturnCode(install_status); | 918 return_code = InstallUtil::GetInstallReturnCode(install_status); |
834 } | 919 } |
835 } | 920 } |
836 | 921 |
837 VLOG(1) << "Installation complete, returning: " << return_code; | 922 VLOG(1) << "Installation complete, returning: " << return_code; |
838 | 923 |
839 return return_code; | 924 return return_code; |
840 } | 925 } |
OLD | NEW |