| 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 // This file contains the definitions of the installer functions that build | 5 // This file contains the definitions of the installer functions that build |
| 6 // the WorkItemList used to install the application. | 6 // the WorkItemList used to install the application. |
| 7 | 7 |
| 8 #include "chrome/installer/setup/install_worker.h" | 8 #include "chrome/installer/setup/install_worker.h" |
| 9 | 9 |
| 10 #include <oaidl.h> | 10 #include <oaidl.h> |
| 11 #include <shlobj.h> | 11 #include <shlobj.h> |
| 12 #include <time.h> | 12 #include <time.h> |
| 13 | 13 |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/bind.h" |
| 16 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 17 #include "base/file_path.h" | 18 #include "base/file_path.h" |
| 18 #include "base/file_util.h" | 19 #include "base/file_util.h" |
| 19 #include "base/logging.h" | 20 #include "base/logging.h" |
| 20 #include "base/path_service.h" | 21 #include "base/path_service.h" |
| 21 #include "base/string16.h" | 22 #include "base/string16.h" |
| 22 #include "base/string_util.h" | 23 #include "base/string_util.h" |
| 23 #include "base/utf_string_conversions.h" | 24 #include "base/utf_string_conversions.h" |
| 24 #include "base/version.h" | 25 #include "base/version.h" |
| 25 #include "base/win/registry.h" | 26 #include "base/win/registry.h" |
| 27 #include "base/win/scoped_comptr.h" |
| 26 #include "base/win/windows_version.h" | 28 #include "base/win/windows_version.h" |
| 27 #include "chrome/common/chrome_constants.h" | 29 #include "chrome/common/chrome_constants.h" |
| 28 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
| 29 #include "chrome/installer/setup/install.h" | 31 #include "chrome/installer/setup/install.h" |
| 30 #include "chrome/installer/setup/setup_constants.h" | 32 #include "chrome/installer/setup/setup_constants.h" |
| 31 #include "chrome/installer/setup/setup_util.h" | 33 #include "chrome/installer/setup/setup_util.h" |
| 32 #include "chrome/installer/util/browser_distribution.h" | 34 #include "chrome/installer/util/browser_distribution.h" |
| 35 #include "chrome/installer/util/callback_work_item.h" |
| 33 #include "chrome/installer/util/conditional_work_item_list.h" | 36 #include "chrome/installer/util/conditional_work_item_list.h" |
| 34 #include "chrome/installer/util/create_reg_key_work_item.h" | 37 #include "chrome/installer/util/create_reg_key_work_item.h" |
| 35 #include "chrome/installer/util/google_update_constants.h" | 38 #include "chrome/installer/util/google_update_constants.h" |
| 36 #include "chrome/installer/util/helper.h" | 39 #include "chrome/installer/util/helper.h" |
| 37 #include "chrome/installer/util/install_util.h" | 40 #include "chrome/installer/util/install_util.h" |
| 38 #include "chrome/installer/util/installation_state.h" | 41 #include "chrome/installer/util/installation_state.h" |
| 39 #include "chrome/installer/util/installer_state.h" | 42 #include "chrome/installer/util/installer_state.h" |
| 40 #include "chrome/installer/util/l10n_string_util.h" | 43 #include "chrome/installer/util/l10n_string_util.h" |
| 41 #include "chrome/installer/util/product.h" | 44 #include "chrome/installer/util/product.h" |
| 42 #include "chrome/installer/util/set_reg_value_work_item.h" | 45 #include "chrome/installer/util/set_reg_value_work_item.h" |
| (...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1106 BrowserDistribution::CHROME_BROWSER)); | 1109 BrowserDistribution::CHROME_BROWSER)); |
| 1107 chrome.InitializeFromUninstallCommand(chrome_state->uninstall_command()); | 1110 chrome.InitializeFromUninstallCommand(chrome_state->uninstall_command()); |
| 1108 AddUninstallShortcutWorkItems(installer_state, setup_path, | 1111 AddUninstallShortcutWorkItems(installer_state, setup_path, |
| 1109 chrome_state->version(), list, chrome); | 1112 chrome_state->version(), list, chrome); |
| 1110 } else { | 1113 } else { |
| 1111 NOTREACHED() << "What happened to Chrome?"; | 1114 NOTREACHED() << "What happened to Chrome?"; |
| 1112 } | 1115 } |
| 1113 } | 1116 } |
| 1114 } | 1117 } |
| 1115 | 1118 |
| 1119 // Probes COM machinery to get an instance of delegate_execute.exe's |
| 1120 // CommandExecuteImpl class. This is required so that COM purges its cache of |
| 1121 // the path to the binary, which changes on updates. This callback |
| 1122 // unconditionally returns true since an install should not be aborted if the |
| 1123 // probe fails. |
| 1124 bool ProbeCommandExecuteCallback(const string16& command_execute_id, |
| 1125 const CallbackWorkItem& work_item) { |
| 1126 // Noop on rollback. |
| 1127 if (work_item.IsRollback()) |
| 1128 return true; |
| 1129 |
| 1130 CLSID class_id = {}; |
| 1131 |
| 1132 HRESULT hr = CLSIDFromString(command_execute_id.c_str(), &class_id); |
| 1133 if (FAILED(hr)) { |
| 1134 LOG(DFATAL) << "Failed converting \"" << command_execute_id << "\" to " |
| 1135 "CLSID; hr=0x" << std::hex << hr; |
| 1136 } else { |
| 1137 base::win::ScopedComPtr<IUnknown> command_execute_impl; |
| 1138 hr = command_execute_impl.CreateInstance(class_id, NULL, |
| 1139 CLSCTX_LOCAL_SERVER); |
| 1140 if (hr != REGDB_E_CLASSNOTREG) { |
| 1141 LOG(ERROR) << "Unexpected result creating CommandExecuteImpl; hr=0x" |
| 1142 << std::hex << hr; |
| 1143 } |
| 1144 } |
| 1145 |
| 1146 return true; |
| 1147 } |
| 1148 |
| 1116 void AddDelegateExecuteWorkItems(const InstallerState& installer_state, | 1149 void AddDelegateExecuteWorkItems(const InstallerState& installer_state, |
| 1117 const FilePath& src_path, | 1150 const FilePath& src_path, |
| 1118 const Version& new_version, | 1151 const Version& new_version, |
| 1119 const Product& product, | 1152 const Product& product, |
| 1120 WorkItemList* list) { | 1153 WorkItemList* list) { |
| 1121 string16 handler_class_uuid; | 1154 string16 handler_class_uuid; |
| 1122 string16 type_lib_uuid; | 1155 string16 type_lib_uuid; |
| 1123 string16 type_lib_version; | 1156 string16 type_lib_version; |
| 1124 string16 interface_uuid; | 1157 string16 interface_uuid; |
| 1125 BrowserDistribution* distribution = product.distribution(); | 1158 BrowserDistribution* distribution = product.distribution(); |
| 1126 if (!distribution->GetDelegateExecuteHandlerData( | 1159 if (!distribution->GetDelegateExecuteHandlerData( |
| 1127 &handler_class_uuid, &type_lib_uuid, &type_lib_version, | 1160 &handler_class_uuid, &type_lib_uuid, &type_lib_version, |
| 1128 &interface_uuid)) { | 1161 &interface_uuid)) { |
| 1129 VLOG(1) << "No DelegateExecute verb handler processing to do for " | 1162 VLOG(1) << "No DelegateExecute verb handler processing to do for " |
| 1130 << distribution->GetAppShortCutName(); | 1163 << distribution->GetAppShortCutName(); |
| 1131 return; | 1164 return; |
| 1132 } | 1165 } |
| 1133 | 1166 |
| 1134 HKEY root = installer_state.root_key(); | 1167 HKEY root = installer_state.root_key(); |
| 1135 const bool is_install = | 1168 const bool is_install = |
| 1136 (installer_state.operation() != InstallerState::UNINSTALL); | 1169 (installer_state.operation() != InstallerState::UNINSTALL); |
| 1137 string16 delegate_execute_path(L"Software\\Classes\\CLSID\\"); | 1170 string16 delegate_execute_path(L"Software\\Classes\\CLSID\\"); |
| 1138 delegate_execute_path.append(handler_class_uuid); | 1171 delegate_execute_path.append(handler_class_uuid); |
| 1139 string16 typelib_path(L"Software\\Classes\\TypeLib\\"); | 1172 string16 typelib_path(L"Software\\Classes\\TypeLib\\"); |
| 1140 typelib_path.append(type_lib_uuid); | 1173 typelib_path.append(type_lib_uuid); |
| 1141 string16 interface_path(L"Software\\Classes\\Interface\\"); | 1174 string16 interface_path(L"Software\\Classes\\Interface\\"); |
| 1142 interface_path.append(interface_uuid); | 1175 interface_path.append(interface_uuid); |
| 1143 | 1176 |
| 1177 VLOG(1) << "Adding unregistration items for DelegateExecute verb handler."; |
| 1178 list->AddDeleteRegKeyWorkItem(root, delegate_execute_path); |
| 1179 list->AddDeleteRegKeyWorkItem(root, typelib_path); |
| 1180 list->AddDeleteRegKeyWorkItem(root, interface_path); |
| 1181 |
| 1144 // Add work items to register the handler iff it is present. Remove its | 1182 // Add work items to register the handler iff it is present. Remove its |
| 1145 // registration otherwise since builds after r132190 included it when it | 1183 // registration otherwise since builds after r132190 included it when it |
| 1146 // wasn't strictly necessary. | 1184 // wasn't strictly necessary. |
| 1147 // TODO(grt): remove the extra check for the .exe when it's ever-present; | 1185 // TODO(grt): remove the extra check for the .exe when it's ever-present; |
| 1148 // see also shell_util.cc's GetProgIdEntries. | 1186 // see also shell_util.cc's GetProgIdEntries. |
| 1149 if (is_install && | 1187 if (is_install && |
| 1150 file_util::PathExists(src_path.AppendASCII(new_version.GetString()) | 1188 file_util::PathExists(src_path.AppendASCII(new_version.GetString()) |
| 1151 .Append(kDelegateExecuteExe))) { | 1189 .Append(kDelegateExecuteExe))) { |
| 1152 VLOG(1) << "Adding registration items for DelegateExecute verb handler."; | 1190 VLOG(1) << "Adding registration items for DelegateExecute verb handler."; |
| 1153 | 1191 |
| 1192 list->AddCallbackWorkItem(base::Bind(&ProbeCommandExecuteCallback, |
| 1193 handler_class_uuid)); |
| 1194 |
| 1154 // The path to the exe (in the version directory). | 1195 // The path to the exe (in the version directory). |
| 1155 FilePath delegate_execute( | 1196 FilePath delegate_execute( |
| 1156 installer_state.target_path().AppendASCII(new_version.GetString())); | 1197 installer_state.target_path().AppendASCII(new_version.GetString())); |
| 1157 delegate_execute = delegate_execute.Append(kDelegateExecuteExe); | 1198 delegate_execute = delegate_execute.Append(kDelegateExecuteExe); |
| 1158 | 1199 |
| 1159 // Command-line featuring the quoted path to the exe. | 1200 // Command-line featuring the quoted path to the exe. |
| 1160 string16 command(1, L'"'); | 1201 string16 command(1, L'"'); |
| 1161 command.append(delegate_execute.value()).append(1, L'"'); | 1202 command.append(delegate_execute.value()).append(1, L'"'); |
| 1162 | 1203 |
| 1163 // Register the CommandExecuteImpl class at | 1204 // Register the CommandExecuteImpl class at |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 | 1260 |
| 1220 subkey.assign(interface_path).append(L"\\ProxyStubClsid32"); | 1261 subkey.assign(interface_path).append(L"\\ProxyStubClsid32"); |
| 1221 list->AddCreateRegKeyWorkItem(root, subkey); | 1262 list->AddCreateRegKeyWorkItem(root, subkey); |
| 1222 list->AddSetRegValueWorkItem(root, subkey, L"", kPSOAInterfaceUuid, true); | 1263 list->AddSetRegValueWorkItem(root, subkey, L"", kPSOAInterfaceUuid, true); |
| 1223 | 1264 |
| 1224 subkey.assign(interface_path).append(L"\\TypeLib"); | 1265 subkey.assign(interface_path).append(L"\\TypeLib"); |
| 1225 list->AddCreateRegKeyWorkItem(root, subkey); | 1266 list->AddCreateRegKeyWorkItem(root, subkey); |
| 1226 list->AddSetRegValueWorkItem(root, subkey, L"", type_lib_uuid, true); | 1267 list->AddSetRegValueWorkItem(root, subkey, L"", type_lib_uuid, true); |
| 1227 list->AddSetRegValueWorkItem(root, subkey, L"Version", type_lib_version, | 1268 list->AddSetRegValueWorkItem(root, subkey, L"Version", type_lib_version, |
| 1228 true); | 1269 true); |
| 1229 | |
| 1230 } else { | |
| 1231 VLOG(1) << "Adding unregistration items for DelegateExecute verb handler."; | |
| 1232 | |
| 1233 list->AddDeleteRegKeyWorkItem(root, delegate_execute_path); | |
| 1234 list->AddDeleteRegKeyWorkItem(root, typelib_path); | |
| 1235 list->AddDeleteRegKeyWorkItem(root, interface_path); | |
| 1236 } | 1270 } |
| 1237 } | 1271 } |
| 1238 | 1272 |
| 1239 void AddActiveSetupWorkItems(const InstallerState& installer_state, | 1273 void AddActiveSetupWorkItems(const InstallerState& installer_state, |
| 1240 const Version& new_version, | 1274 const Version& new_version, |
| 1241 const Product& product, | 1275 const Product& product, |
| 1242 WorkItemList* list) { | 1276 WorkItemList* list) { |
| 1243 DCHECK(installer_state.operation() != InstallerState::UNINSTALL); | 1277 DCHECK(installer_state.operation() != InstallerState::UNINSTALL); |
| 1244 BrowserDistribution* distribution = product.distribution(); | 1278 BrowserDistribution* distribution = product.distribution(); |
| 1245 | 1279 |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1587 machine_state, | 1621 machine_state, |
| 1588 setup_path, | 1622 setup_path, |
| 1589 new_version, | 1623 new_version, |
| 1590 work_item_list, | 1624 work_item_list, |
| 1591 false, // have_child_product | 1625 false, // have_child_product |
| 1592 cmd_line, | 1626 cmd_line, |
| 1593 kCmdQuickEnableApplicationHost); | 1627 kCmdQuickEnableApplicationHost); |
| 1594 } | 1628 } |
| 1595 | 1629 |
| 1596 } // namespace installer | 1630 } // namespace installer |
| OLD | NEW |