Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: chrome/installer/setup/install_worker.cc

Issue 10916018: Force COM machinery to notice that the path to the DelegateExecute verb handler has changed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
33 #include "chrome/installer/util/conditional_work_item_list.h" 35 #include "chrome/installer/util/conditional_work_item_list.h"
34 #include "chrome/installer/util/create_reg_key_work_item.h" 36 #include "chrome/installer/util/create_reg_key_work_item.h"
35 #include "chrome/installer/util/google_update_constants.h" 37 #include "chrome/installer/util/google_update_constants.h"
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 BrowserDistribution::CHROME_BROWSER)); 1108 BrowserDistribution::CHROME_BROWSER));
1107 chrome.InitializeFromUninstallCommand(chrome_state->uninstall_command()); 1109 chrome.InitializeFromUninstallCommand(chrome_state->uninstall_command());
1108 AddUninstallShortcutWorkItems(installer_state, setup_path, 1110 AddUninstallShortcutWorkItems(installer_state, setup_path,
1109 chrome_state->version(), list, chrome); 1111 chrome_state->version(), list, chrome);
1110 } else { 1112 } else {
1111 NOTREACHED() << "What happened to Chrome?"; 1113 NOTREACHED() << "What happened to Chrome?";
1112 } 1114 }
1113 } 1115 }
1114 } 1116 }
1115 1117
1118 // Probes COM machinery to get an instance of delegate_execute.exe's
1119 // CommandExecuteImpl class. This is required so that COM purges its cache of
1120 // the path to the binary, which changes on updates. This callback
1121 // unconditionally returns true since an install should not be aborted if the
1122 // probe fails.
1123 bool ProbeCommandExecuteCallback(const string16& command_execute_id,
1124 const CallbackWorkItem& work_item) {
1125 // Noop on rollback.
1126 if (work_item.IsRollback())
1127 return true;
1128
1129 CLSID class_id = {};
1130
1131 HRESULT hr = CLSIDFromString(command_execute_id.c_str(), &class_id);
1132 if (FAILED(hr)) {
1133 LOG(DFATAL) << "Failed converting \"" << command_execute_id << "\" to "
1134 "CLSID; hr=0x" << std::hex << hr;
1135 } else {
1136 base::win::ScopedComPtr<IUnknown> command_execute_impl;
1137 hr = command_execute_impl.CreateInstance(class_id, NULL,
1138 CLSCTX_LOCAL_SERVER);
1139 if (hr != REGDB_E_CLASSNOTREG) {
1140 LOG(ERROR) << "Unexpected result creating CommandExecuteImpl; hr=0x"
1141 << std::hex << hr;
1142 }
1143 }
1144
1145 return true;
1146 }
1147
1116 void AddDelegateExecuteWorkItems(const InstallerState& installer_state, 1148 void AddDelegateExecuteWorkItems(const InstallerState& installer_state,
1117 const FilePath& src_path, 1149 const FilePath& src_path,
1118 const Version& new_version, 1150 const Version& new_version,
1119 const Product& product, 1151 const Product& product,
1120 WorkItemList* list) { 1152 WorkItemList* list) {
1121 string16 handler_class_uuid; 1153 string16 handler_class_uuid;
1122 string16 type_lib_uuid; 1154 string16 type_lib_uuid;
1123 string16 type_lib_version; 1155 string16 type_lib_version;
1124 string16 interface_uuid; 1156 string16 interface_uuid;
1125 BrowserDistribution* distribution = product.distribution(); 1157 BrowserDistribution* distribution = product.distribution();
1126 if (!distribution->GetDelegateExecuteHandlerData( 1158 if (!distribution->GetDelegateExecuteHandlerData(
1127 &handler_class_uuid, &type_lib_uuid, &type_lib_version, 1159 &handler_class_uuid, &type_lib_uuid, &type_lib_version,
1128 &interface_uuid)) { 1160 &interface_uuid)) {
1129 VLOG(1) << "No DelegateExecute verb handler processing to do for " 1161 VLOG(1) << "No DelegateExecute verb handler processing to do for "
1130 << distribution->GetAppShortCutName(); 1162 << distribution->GetAppShortCutName();
1131 return; 1163 return;
1132 } 1164 }
1133 1165
1134 HKEY root = installer_state.root_key(); 1166 HKEY root = installer_state.root_key();
1135 const bool is_install = 1167 const bool is_install =
1136 (installer_state.operation() != InstallerState::UNINSTALL); 1168 (installer_state.operation() != InstallerState::UNINSTALL);
1137 string16 delegate_execute_path(L"Software\\Classes\\CLSID\\"); 1169 string16 delegate_execute_path(L"Software\\Classes\\CLSID\\");
1138 delegate_execute_path.append(handler_class_uuid); 1170 delegate_execute_path.append(handler_class_uuid);
1139 string16 typelib_path(L"Software\\Classes\\TypeLib\\"); 1171 string16 typelib_path(L"Software\\Classes\\TypeLib\\");
1140 typelib_path.append(type_lib_uuid); 1172 typelib_path.append(type_lib_uuid);
1141 string16 interface_path(L"Software\\Classes\\Interface\\"); 1173 string16 interface_path(L"Software\\Classes\\Interface\\");
1142 interface_path.append(interface_uuid); 1174 interface_path.append(interface_uuid);
1143 1175
1176 VLOG(1) << "Adding unregistration items for DelegateExecute verb handler.";
1177 list->AddDeleteRegKeyWorkItem(root, delegate_execute_path);
1178 list->AddDeleteRegKeyWorkItem(root, typelib_path);
1179 list->AddDeleteRegKeyWorkItem(root, interface_path);
1180
1144 // Add work items to register the handler iff it is present. Remove its 1181 // Add work items to register the handler iff it is present. Remove its
1145 // registration otherwise since builds after r132190 included it when it 1182 // registration otherwise since builds after r132190 included it when it
1146 // wasn't strictly necessary. 1183 // wasn't strictly necessary.
1147 // TODO(grt): remove the extra check for the .exe when it's ever-present; 1184 // TODO(grt): remove the extra check for the .exe when it's ever-present;
1148 // see also shell_util.cc's GetProgIdEntries. 1185 // see also shell_util.cc's GetProgIdEntries.
1149 if (is_install && 1186 if (is_install &&
1150 file_util::PathExists(src_path.AppendASCII(new_version.GetString()) 1187 file_util::PathExists(src_path.AppendASCII(new_version.GetString())
1151 .Append(kDelegateExecuteExe))) { 1188 .Append(kDelegateExecuteExe))) {
1152 VLOG(1) << "Adding registration items for DelegateExecute verb handler."; 1189 VLOG(1) << "Adding registration items for DelegateExecute verb handler.";
1153 1190
1191 list->AddCallbackWorkItem(base::Bind(&ProbeCommandExecuteCallback,
1192 handler_class_uuid));
1193
1154 // The path to the exe (in the version directory). 1194 // The path to the exe (in the version directory).
1155 FilePath delegate_execute( 1195 FilePath delegate_execute(
1156 installer_state.target_path().AppendASCII(new_version.GetString())); 1196 installer_state.target_path().AppendASCII(new_version.GetString()));
1157 delegate_execute = delegate_execute.Append(kDelegateExecuteExe); 1197 delegate_execute = delegate_execute.Append(kDelegateExecuteExe);
1158 1198
1159 // Command-line featuring the quoted path to the exe. 1199 // Command-line featuring the quoted path to the exe.
1160 string16 command(1, L'"'); 1200 string16 command(1, L'"');
1161 command.append(delegate_execute.value()).append(1, L'"'); 1201 command.append(delegate_execute.value()).append(1, L'"');
1162 1202
1163 // Register the CommandExecuteImpl class at 1203 // Register the CommandExecuteImpl class at
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 1259
1220 subkey.assign(interface_path).append(L"\\ProxyStubClsid32"); 1260 subkey.assign(interface_path).append(L"\\ProxyStubClsid32");
1221 list->AddCreateRegKeyWorkItem(root, subkey); 1261 list->AddCreateRegKeyWorkItem(root, subkey);
1222 list->AddSetRegValueWorkItem(root, subkey, L"", kPSOAInterfaceUuid, true); 1262 list->AddSetRegValueWorkItem(root, subkey, L"", kPSOAInterfaceUuid, true);
1223 1263
1224 subkey.assign(interface_path).append(L"\\TypeLib"); 1264 subkey.assign(interface_path).append(L"\\TypeLib");
1225 list->AddCreateRegKeyWorkItem(root, subkey); 1265 list->AddCreateRegKeyWorkItem(root, subkey);
1226 list->AddSetRegValueWorkItem(root, subkey, L"", type_lib_uuid, true); 1266 list->AddSetRegValueWorkItem(root, subkey, L"", type_lib_uuid, true);
1227 list->AddSetRegValueWorkItem(root, subkey, L"Version", type_lib_version, 1267 list->AddSetRegValueWorkItem(root, subkey, L"Version", type_lib_version,
1228 true); 1268 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 } 1269 }
1237 } 1270 }
1238 1271
1239 void AddActiveSetupWorkItems(const InstallerState& installer_state, 1272 void AddActiveSetupWorkItems(const InstallerState& installer_state,
1240 const Version& new_version, 1273 const Version& new_version,
1241 const Product& product, 1274 const Product& product,
1242 WorkItemList* list) { 1275 WorkItemList* list) {
1243 DCHECK(installer_state.operation() != InstallerState::UNINSTALL); 1276 DCHECK(installer_state.operation() != InstallerState::UNINSTALL);
1244 BrowserDistribution* distribution = product.distribution(); 1277 BrowserDistribution* distribution = product.distribution();
1245 1278
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 machine_state, 1620 machine_state,
1588 setup_path, 1621 setup_path,
1589 new_version, 1622 new_version,
1590 work_item_list, 1623 work_item_list,
1591 false, // have_child_product 1624 false, // have_child_product
1592 cmd_line, 1625 cmd_line,
1593 kCmdQuickEnableApplicationHost); 1626 kCmdQuickEnableApplicationHost);
1594 } 1627 }
1595 1628
1596 } // namespace installer 1629 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698