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/setup/setup_main.h" | 5 #include "chrome/installer/setup/setup_main.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <msi.h> | 8 #include <msi.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #include <shlobj.h> | 10 #include <shlobj.h> |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 using installer::InstallerState; | 73 using installer::InstallerState; |
74 using installer::InstallationState; | 74 using installer::InstallationState; |
75 using installer::InstallationValidator; | 75 using installer::InstallationValidator; |
76 using installer::MasterPreferences; | 76 using installer::MasterPreferences; |
77 using installer::Product; | 77 using installer::Product; |
78 using installer::ProductState; | 78 using installer::ProductState; |
79 using installer::Products; | 79 using installer::Products; |
80 | 80 |
81 const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\"; | 81 const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\"; |
82 const wchar_t kSystemPrincipalSid[] = L"S-1-5-18"; | 82 const wchar_t kSystemPrincipalSid[] = L"S-1-5-18"; |
| 83 const wchar_t kDisplayVersion[] = L"DisplayVersion"; |
83 | 84 |
84 const MINIDUMP_TYPE kLargerDumpType = static_cast<MINIDUMP_TYPE>( | 85 const MINIDUMP_TYPE kLargerDumpType = static_cast<MINIDUMP_TYPE>( |
85 MiniDumpWithProcessThreadData | // Get PEB and TEB. | 86 MiniDumpWithProcessThreadData | // Get PEB and TEB. |
86 MiniDumpWithUnloadedModules | // Get unloaded modules when available. | 87 MiniDumpWithUnloadedModules | // Get unloaded modules when available. |
87 MiniDumpWithIndirectlyReferencedMemory); // Get memory referenced by stack. | 88 MiniDumpWithIndirectlyReferencedMemory); // Get memory referenced by stack. |
88 | 89 |
89 namespace { | 90 namespace { |
90 | 91 |
| 92 // Overwrite an existing DisplayVersion as written by the MSI installer |
| 93 // with the real version number of Chrome. |
| 94 LONG OverwriteDisplayVersion(const base::string16& path, |
| 95 const base::string16& value) { |
| 96 base::win::RegKey key; |
| 97 LONG result = 0; |
| 98 if ((result = key.Open(HKEY_LOCAL_MACHINE, path.c_str(), |
| 99 KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_WOW64_64KEY)) |
| 100 != ERROR_SUCCESS) { |
| 101 LOG(ERROR) << "Failed to set DisplayVersion: " << path << " not found"; |
| 102 return result; |
| 103 } |
| 104 if ((result = key.HasValue(kDisplayVersion)) != ERROR_SUCCESS) { |
| 105 LOG(ERROR) << "Failed to set DisplayVersion: " << kDisplayVersion |
| 106 << " not found under " << path; |
| 107 return result; |
| 108 } |
| 109 if ((result = key.WriteValue(kDisplayVersion, value.c_str())) |
| 110 != ERROR_SUCCESS) { |
| 111 LOG(ERROR) << "Failed to set DisplayVersion: " << kDisplayVersion |
| 112 << " could not be written under " << path; |
| 113 return result; |
| 114 } |
| 115 return ERROR_SUCCESS; |
| 116 } |
| 117 |
91 // Returns NULL if no compressed archive is available for processing, otherwise | 118 // Returns NULL if no compressed archive is available for processing, otherwise |
92 // returns a patch helper configured to uncompress and patch. | 119 // returns a patch helper configured to uncompress and patch. |
93 scoped_ptr<installer::ArchivePatchHelper> CreateChromeArchiveHelper( | 120 scoped_ptr<installer::ArchivePatchHelper> CreateChromeArchiveHelper( |
94 const base::FilePath& setup_exe, | 121 const base::FilePath& setup_exe, |
95 const base::CommandLine& command_line, | 122 const base::CommandLine& command_line, |
96 const installer::InstallerState& installer_state, | 123 const installer::InstallerState& installer_state, |
97 const base::FilePath& working_directory) { | 124 const base::FilePath& working_directory) { |
98 // A compressed archive is ordinarily given on the command line by the mini | 125 // A compressed archive is ordinarily given on the command line by the mini |
99 // installer. If one was not given, look for chrome.packed.7z next to the | 126 // installer. If one was not given, look for chrome.packed.7z next to the |
100 // running program. | 127 // running program. |
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 | 938 |
912 // This method processes any command line options that make setup.exe do | 939 // This method processes any command line options that make setup.exe do |
913 // various tasks other than installation (renaming chrome.exe, showing eula | 940 // various tasks other than installation (renaming chrome.exe, showing eula |
914 // among others). This function returns true if any such command line option | 941 // among others). This function returns true if any such command line option |
915 // has been found and processed (so setup.exe should exit at that point). | 942 // has been found and processed (so setup.exe should exit at that point). |
916 bool HandleNonInstallCmdLineOptions(const InstallationState& original_state, | 943 bool HandleNonInstallCmdLineOptions(const InstallationState& original_state, |
917 const base::FilePath& setup_exe, | 944 const base::FilePath& setup_exe, |
918 const base::CommandLine& cmd_line, | 945 const base::CommandLine& cmd_line, |
919 InstallerState* installer_state, | 946 InstallerState* installer_state, |
920 int* exit_code) { | 947 int* exit_code) { |
| 948 // This option is independent of all others so doesn't belong in the if/else |
| 949 // block below. |
| 950 if (cmd_line.HasSwitch(installer::switches::kDelay)) { |
| 951 const std::string delay_seconds_string( |
| 952 cmd_line.GetSwitchValueASCII(installer::switches::kDelay)); |
| 953 int delay_seconds; |
| 954 if (base::StringToInt(delay_seconds_string, &delay_seconds) && |
| 955 delay_seconds > 0) { |
| 956 ::Sleep(delay_seconds * 1000); |
| 957 } |
| 958 } |
| 959 |
921 // TODO(gab): Add a local |status| variable which each block below sets; | 960 // TODO(gab): Add a local |status| variable which each block below sets; |
922 // only determine the |exit_code| from |status| at the end (this will allow | 961 // only determine the |exit_code| from |status| at the end (this will allow |
923 // this method to validate that | 962 // this method to validate that |
924 // (!handled || status != installer::UNKNOWN_STATUS)). | 963 // (!handled || status != installer::UNKNOWN_STATUS)). |
925 bool handled = true; | 964 bool handled = true; |
926 // TODO(tommi): Split these checks up into functions and use a data driven | 965 // TODO(tommi): Split these checks up into functions and use a data driven |
927 // map of switch->function. | 966 // map of switch->function. |
928 if (cmd_line.HasSwitch(installer::switches::kUpdateSetupExe)) { | 967 if (cmd_line.HasSwitch(installer::switches::kUpdateSetupExe)) { |
929 installer::InstallStatus status = installer::SETUP_PATCH_FAILED; | 968 installer::InstallStatus status = installer::SETUP_PATCH_FAILED; |
930 // If --update-setup-exe command line option is given, we apply the given | 969 // If --update-setup-exe command line option is given, we apply the given |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1145 patch_file, | 1184 patch_file, |
1146 output_file); | 1185 output_file); |
1147 } else { | 1186 } else { |
1148 *exit_code = installer::PATCH_INVALID_ARGUMENTS; | 1187 *exit_code = installer::PATCH_INVALID_ARGUMENTS; |
1149 } | 1188 } |
1150 } else if (cmd_line.HasSwitch(installer::switches::kReenableAutoupdates)) { | 1189 } else if (cmd_line.HasSwitch(installer::switches::kReenableAutoupdates)) { |
1151 // setup.exe has been asked to attempt to reenable updates for Chrome. | 1190 // setup.exe has been asked to attempt to reenable updates for Chrome. |
1152 bool updates_enabled = GoogleUpdateSettings::ReenableAutoupdates(); | 1191 bool updates_enabled = GoogleUpdateSettings::ReenableAutoupdates(); |
1153 *exit_code = updates_enabled ? installer::REENABLE_UPDATES_SUCCEEDED : | 1192 *exit_code = updates_enabled ? installer::REENABLE_UPDATES_SUCCEEDED : |
1154 installer::REENABLE_UPDATES_FAILED; | 1193 installer::REENABLE_UPDATES_FAILED; |
| 1194 } else if (cmd_line.HasSwitch(installer::switches::kSetDisplayVersionPath)) { |
| 1195 const base::string16 registry_path( |
| 1196 cmd_line.GetSwitchValueNative( |
| 1197 installer::switches::kSetDisplayVersionPath)); |
| 1198 const base::string16 registry_value( |
| 1199 cmd_line.GetSwitchValueNative( |
| 1200 installer::switches::kSetDisplayVersionValue)); |
| 1201 *exit_code = OverwriteDisplayVersion(registry_path, registry_value); |
1155 } else { | 1202 } else { |
1156 handled = false; | 1203 handled = false; |
1157 } | 1204 } |
1158 | 1205 |
1159 return handled; | 1206 return handled; |
1160 } | 1207 } |
1161 | 1208 |
1162 // Returns the Custom information for the client identified by the exe path | 1209 // Returns the Custom information for the client identified by the exe path |
1163 // passed in. This information is used for crash reporting. | 1210 // passed in. This information is used for crash reporting. |
1164 google_breakpad::CustomClientInfo* GetCustomInfo(const wchar_t* exe_path) { | 1211 google_breakpad::CustomClientInfo* GetCustomInfo(const wchar_t* exe_path) { |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1700 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT | 1747 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT |
1701 // to pass through, since this is only returned on uninstall which is | 1748 // to pass through, since this is only returned on uninstall which is |
1702 // never invoked directly by Google Update. | 1749 // never invoked directly by Google Update. |
1703 return_code = InstallUtil::GetInstallReturnCode(install_status); | 1750 return_code = InstallUtil::GetInstallReturnCode(install_status); |
1704 } | 1751 } |
1705 | 1752 |
1706 VLOG(1) << "Installation complete, returning: " << return_code; | 1753 VLOG(1) << "Installation complete, returning: " << return_code; |
1707 | 1754 |
1708 return return_code; | 1755 return return_code; |
1709 } | 1756 } |
OLD | NEW |