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

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

Issue 10912096: C++ reability review for gab. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile errors 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>
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 arraysize(cf_clsid)); 81 arraysize(cf_clsid));
82 key_path->append(&cf_clsid[0], len - 1); 82 key_path->append(&cf_clsid[0], len - 1);
83 } else { 83 } else {
84 key_path->append(kIELowRightsPolicyOldGuid, 84 key_path->append(kIELowRightsPolicyOldGuid,
85 arraysize(kIELowRightsPolicyOldGuid)- 1); 85 arraysize(kIELowRightsPolicyOldGuid)- 1);
86 } 86 }
87 } 87 }
88 88
89 // Local helper to call AddRegisterComDllWorkItems for all DLLs in a set of 89 // Local helper to call AddRegisterComDllWorkItems for all DLLs in a set of
90 // products managed by a given package. 90 // products managed by a given package.
91 // |old_version| can be NULL to indicate no Chrome is currently installed.
91 void AddRegisterComDllWorkItemsForPackage(const InstallerState& installer_state, 92 void AddRegisterComDllWorkItemsForPackage(const InstallerState& installer_state,
92 const Version* old_version, 93 const Version* old_version,
93 const Version& new_version, 94 const Version& new_version,
94 WorkItemList* work_item_list) { 95 WorkItemList* work_item_list) {
95 // First collect the list of DLLs to be registered from each product. 96 // First collect the list of DLLs to be registered from each product.
96 std::vector<FilePath> com_dll_list; 97 std::vector<FilePath> com_dll_list;
97 installer_state.AddComDllList(&com_dll_list); 98 installer_state.AddComDllList(&com_dll_list);
98 99
99 // Then, if we got some, attempt to unregister the DLLs from the old 100 // Then, if we got some, attempt to unregister the DLLs from the old
100 // version directory and then re-register them in the new one. 101 // version directory and then re-register them in the new one.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 // setup.exe cannot be run again without regenerating the archive, so copy 164 // setup.exe cannot be run again without regenerating the archive, so copy
164 // it instead in this case to save developer time. 165 // it instead in this case to save developer time.
165 install_list->AddCopyTreeWorkItem(archive_path.value(), archive_dst.value(), 166 install_list->AddCopyTreeWorkItem(archive_path.value(), archive_dst.value(),
166 temp_path.value(), WorkItem::ALWAYS); 167 temp_path.value(), WorkItem::ALWAYS);
167 #endif // COMPONENT_BUILD 168 #endif // COMPONENT_BUILD
168 } 169 }
169 } 170 }
170 171
171 void AddInstallAppCommandWorkItems(const InstallerState& installer_state, 172 void AddInstallAppCommandWorkItems(const InstallerState& installer_state,
172 const InstallationState& machine_state, 173 const InstallationState& machine_state,
173 const FilePath* setup_path, 174 const FilePath& setup_path,
174 const Version* new_version, 175 const Version& new_version,
175 const Product& product, 176 const Product& product,
176 WorkItemList* work_item_list) { 177 WorkItemList* work_item_list) {
177 DCHECK(product.is_chrome_app_host()); 178 DCHECK(product.is_chrome_app_host());
178 179
179 string16 cmd_key(product.distribution()->GetVersionKey()); 180 string16 cmd_key(product.distribution()->GetVersionKey());
180 cmd_key.append(1, L'\\').append(google_update::kRegCommandsKey) 181 cmd_key.append(1, L'\\').append(google_update::kRegCommandsKey)
181 .append(1, L'\\').append(kCmdInstallApp); 182 .append(1, L'\\').append(kCmdInstallApp);
182 183
183 if (installer_state.operation() != InstallerState::UNINSTALL) { 184 if (installer_state.operation() == InstallerState::UNINSTALL) {
184 FilePath target_path(installer_state.target_path()); 185 work_item_list->AddDeleteRegKeyWorkItem(
185 CommandLine cmd_line(target_path.Append(installer::kChromeAppHostExe)); 186 installer_state.root_key(), cmd_key)->set_log_message(
187 "removing install-application command");
188 } else {
189 CommandLine cmd_line(
190 installer_state.target_path().Append(installer::kChromeAppHostExe));
186 cmd_line.AppendSwitchASCII(::switches::kAppsInstallFromManifestURL, "%1"); 191 cmd_line.AppendSwitchASCII(::switches::kAppsInstallFromManifestURL, "%1");
187 192
188 AppCommand cmd(cmd_line.GetCommandLineString()); 193 AppCommand cmd(cmd_line.GetCommandLineString());
189 cmd.set_sends_pings(true); 194 cmd.set_sends_pings(true);
190 cmd.set_is_web_accessible(true); 195 cmd.set_is_web_accessible(true);
191 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list); 196 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list);
192 } else {
193 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(),
194 cmd_key)->set_log_message(
195 "removing install-application command");
196 } 197 }
197 } 198 }
198 199
199 void AddProductSpecificWorkItems(const InstallationState& original_state, 200 void AddProductSpecificWorkItems(const InstallationState& original_state,
200 const InstallerState& installer_state, 201 const InstallerState& installer_state,
201 const FilePath& setup_path, 202 const FilePath& setup_path,
202 const Version& new_version, 203 const Version& new_version,
203 WorkItemList* list) { 204 WorkItemList* list) {
204 const Products& products = installer_state.products(); 205 const Products& products = installer_state.products();
205 for (size_t i = 0; i < products.size(); ++i) { 206 for (Products::const_iterator it = products.begin(); it < products.end();
206 const Product& p = *products[i]; 207 ++it) {
208 const Product& p = **it;
207 if (p.is_chrome_frame()) { 209 if (p.is_chrome_frame()) {
208 AddChromeFrameWorkItems(original_state, installer_state, setup_path, 210 AddChromeFrameWorkItems(original_state, installer_state, setup_path,
209 new_version, p, list); 211 new_version, p, list);
210 } 212 }
211 if (p.is_chrome_app_host()) { 213 if (p.is_chrome_app_host()) {
212 AddInstallAppCommandWorkItems(installer_state, original_state, 214 AddInstallAppCommandWorkItems(installer_state, original_state,
213 &setup_path, &new_version, p, list); 215 setup_path, new_version, p, list);
214 } 216 }
215 if (p.is_chrome()) { 217 if (p.is_chrome()) {
216 AddOsUpgradeWorkItems(installer_state, &setup_path, &new_version, p, 218 AddOsUpgradeWorkItems(installer_state, setup_path, new_version, p,
217 list); 219 list);
218 } 220 }
219 } 221 }
220 } 222 }
221 223
222 // This is called when an MSI installation is run. It may be that a user is 224 // This is called when an MSI installation is run. It may be that a user is
223 // attempting to install the MSI on top of a non-MSI managed installation. 225 // attempting to install the MSI on top of a non-MSI managed installation.
224 // If so, try and remove any existing uninstallation shortcuts, as we want the 226 // If so, try and remove any existing uninstallation shortcuts, as we want the
225 // uninstall to be managed entirely by the MSI machinery (accessible via the 227 // uninstall to be managed entirely by the MSI machinery (accessible via the
226 // Add/Remove programs dialog). 228 // Add/Remove programs dialog).
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 VLOG(1) << "Deleting old uninstall shortcut (if present): " 260 VLOG(1) << "Deleting old uninstall shortcut (if present): "
259 << uninstall_link.value(); 261 << uninstall_link.value();
260 WorkItem* delete_link = work_item_list->AddDeleteTreeWorkItem( 262 WorkItem* delete_link = work_item_list->AddDeleteTreeWorkItem(
261 uninstall_link, temp_path); 263 uninstall_link, temp_path);
262 delete_link->set_ignore_failure(true); 264 delete_link->set_ignore_failure(true);
263 delete_link->set_log_message( 265 delete_link->set_log_message(
264 "Failed to delete old uninstall shortcut."); 266 "Failed to delete old uninstall shortcut.");
265 } 267 }
266 } 268 }
267 269
270 // Adds Chrome specific install work items to |install_list|.
271 // |current_version| can be NULL to indicate no Chrome is currently installed.
268 void AddChromeWorkItems(const InstallationState& original_state, 272 void AddChromeWorkItems(const InstallationState& original_state,
269 const InstallerState& installer_state, 273 const InstallerState& installer_state,
270 const FilePath& setup_path, 274 const FilePath& setup_path,
271 const FilePath& archive_path, 275 const FilePath& archive_path,
272 const FilePath& src_path, 276 const FilePath& src_path,
273 const FilePath& temp_path, 277 const FilePath& temp_path,
278 const Version* current_version,
274 const Version& new_version, 279 const Version& new_version,
275 scoped_ptr<Version>* current_version,
276 WorkItemList* install_list) { 280 WorkItemList* install_list) {
277 const FilePath& target_path = installer_state.target_path(); 281 const FilePath& target_path = installer_state.target_path();
278 282
279 if (current_version != NULL && current_version->get() != NULL) { 283 if (current_version) {
280 // Delete the archive from an existing install to save some disk space. We 284 // Delete the archive from an existing install to save some disk space. We
281 // make this an unconditional work item since there's no need to roll this 285 // make this an unconditional work item since there's no need to roll this
282 // back; if installation fails we'll be moved to the "-full" channel anyway. 286 // back; if installation fails we'll be moved to the "-full" channel anyway.
283 FilePath old_installer_dir( 287 FilePath old_installer_dir(
284 installer_state.GetInstallerDirectory(**current_version)); 288 installer_state.GetInstallerDirectory(*current_version));
285 FilePath old_archive(old_installer_dir.Append(installer::kChromeArchive)); 289 FilePath old_archive(old_installer_dir.Append(installer::kChromeArchive));
286 // Don't delete the archive that we are actually installing from. 290 // Don't delete the archive that we are actually installing from.
287 if (archive_path != old_archive) { 291 if (archive_path != old_archive) {
288 install_list->AddDeleteTreeWorkItem(old_archive, temp_path) 292 install_list->AddDeleteTreeWorkItem(old_archive, temp_path)->
289 ->set_ignore_failure(true); 293 set_ignore_failure(true);
290 } 294 }
291 } 295 }
292 296
293 // Delete any new_chrome.exe if present (we will end up creating a new one 297 // Delete any new_chrome.exe if present (we will end up creating a new one
294 // if required) and then copy chrome.exe 298 // if required) and then copy chrome.exe
295 FilePath new_chrome_exe(target_path.Append(installer::kChromeNewExe)); 299 FilePath new_chrome_exe(target_path.Append(installer::kChromeNewExe));
296 300
297 install_list->AddDeleteTreeWorkItem(new_chrome_exe, temp_path); 301 install_list->AddDeleteTreeWorkItem(new_chrome_exe, temp_path);
298 302
299 if (installer_state.IsChromeFrameRunning(original_state)) { 303 if (installer_state.IsChromeFrameRunning(original_state)) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 temp_path.value(), 367 temp_path.value(),
364 WorkItem::ALWAYS_MOVE); 368 WorkItem::ALWAYS_MOVE);
365 #endif // defined(COMPONENT_BUILD) 369 #endif // defined(COMPONENT_BUILD)
366 370
367 // In the past, we copied rather than moved for system level installs so that 371 // In the past, we copied rather than moved for system level installs so that
368 // the permissions of %ProgramFiles% would be picked up. Now that |temp_path| 372 // the permissions of %ProgramFiles% would be picked up. Now that |temp_path|
369 // is in %ProgramFiles% for system level installs (and in %LOCALAPPDATA% 373 // is in %ProgramFiles% for system level installs (and in %LOCALAPPDATA%
370 // otherwise), there is no need to do this. 374 // otherwise), there is no need to do this.
371 // Note that we pass true for check_duplicates to avoid failing on in-use 375 // Note that we pass true for check_duplicates to avoid failing on in-use
372 // repair runs if the current_version is the same as the new_version. 376 // repair runs if the current_version is the same as the new_version.
373 bool check_for_duplicates = 377 bool check_for_duplicates = (current_version &&
374 (current_version != NULL && current_version->get() != NULL && 378 current_version->Equals(new_version));
375 current_version->get()->Equals(new_version));
376 install_list->AddMoveTreeWorkItem( 379 install_list->AddMoveTreeWorkItem(
377 src_path.AppendASCII(new_version.GetString()).value(), 380 src_path.AppendASCII(new_version.GetString()).value(),
378 target_path.AppendASCII(new_version.GetString()).value(), 381 target_path.AppendASCII(new_version.GetString()).value(),
379 temp_path.value(), 382 temp_path.value(),
380 check_for_duplicates ? WorkItem::CHECK_DUPLICATES : 383 check_for_duplicates ? WorkItem::CHECK_DUPLICATES :
381 WorkItem::ALWAYS_MOVE); 384 WorkItem::ALWAYS_MOVE);
382 385
383 // Delete any old_chrome.exe if present (ignore failure if it's in use). 386 // Delete any old_chrome.exe if present (ignore failure if it's in use).
384 install_list->AddDeleteTreeWorkItem( 387 install_list->AddDeleteTreeWorkItem(
385 target_path.Append(installer::kChromeOldExe), temp_path) 388 target_path.Append(installer::kChromeOldExe), temp_path)->
386 ->set_ignore_failure(true); 389 set_ignore_failure(true);
387 390
388 // Copy installer in install directory and 391 // Copy installer in install directory and
389 // add shortcut in Control Panel->Add/Remove Programs. 392 // add shortcut in Control Panel->Add/Remove Programs.
390 AddInstallerCopyTasks(installer_state, setup_path, archive_path, temp_path, 393 AddInstallerCopyTasks(installer_state, setup_path, archive_path, temp_path,
391 new_version, install_list); 394 new_version, install_list);
392 } 395 }
393 396
394 // Probes COM machinery to get an instance of delegate_execute.exe's 397 // Probes COM machinery to get an instance of delegate_execute.exe's
395 // CommandExecuteImpl class. This is required so that COM purges its cache of 398 // CommandExecuteImpl class. This is required so that COM purges its cache of
396 // the path to the binary, which changes on updates. This callback 399 // the path to the binary, which changes on updates. This callback
(...skipping 19 matching lines...) Expand all
416 LOG(ERROR) << "Unexpected result creating CommandExecuteImpl; hr=0x" 419 LOG(ERROR) << "Unexpected result creating CommandExecuteImpl; hr=0x"
417 << std::hex << hr; 420 << std::hex << hr;
418 } 421 }
419 } 422 }
420 423
421 return true; 424 return true;
422 } 425 }
423 426
424 void AddGenericQuickEnableWorkItems(const InstallerState& installer_state, 427 void AddGenericQuickEnableWorkItems(const InstallerState& installer_state,
425 const InstallationState& machine_state, 428 const InstallationState& machine_state,
426 const FilePath* setup_path, 429 const FilePath& setup_path,
427 const Version* new_version, 430 const Version& new_version,
428 WorkItemList* work_item_list,
429 bool have_child_product, 431 bool have_child_product,
430 const CommandLine& child_product_switches, 432 const CommandLine& child_product_switches,
431 const string16& command_id) { 433 const string16& command_id,
432 DCHECK(setup_path || 434 WorkItemList* work_item_list) {
433 installer_state.operation() == InstallerState::UNINSTALL);
434 DCHECK(new_version ||
435 installer_state.operation() == InstallerState::UNINSTALL);
436 DCHECK(work_item_list); 435 DCHECK(work_item_list);
437 436
438 const bool system_install = installer_state.system_install(); 437 const bool system_install = installer_state.system_install();
439 bool have_chrome_binaries = false; 438 bool have_chrome_binaries = false;
440 439
441 // STEP 1: Figure out the state of the machine before the operation. 440 // STEP 1: Figure out the state of the machine before the operation.
442 const ProductState* product_state = NULL; 441 const ProductState* product_state = NULL;
443 442
444 // Are the Chrome Binaries already on the machine? 443 // Are the Chrome Binaries already on the machine?
445 product_state = 444 product_state = machine_state.GetProductState(
446 machine_state.GetProductState(system_install, 445 system_install, BrowserDistribution::CHROME_BINARIES);
447 BrowserDistribution::CHROME_BINARIES);
448 if (product_state != NULL && product_state->is_multi_install()) 446 if (product_state != NULL && product_state->is_multi_install())
449 have_chrome_binaries = true; 447 have_chrome_binaries = true;
450 448
451 // STEP 2: Now take into account the current operation. 449 // STEP 2: Now take into account the current operation.
452 const Product* product = NULL; 450 const Product* product = NULL;
453 451
454 if (installer_state.operation() == InstallerState::UNINSTALL) { 452 if (installer_state.operation() == InstallerState::UNINSTALL) {
455 // Forget about multi-install Chrome if it is being uninstalled. 453 // Forget about multi-install Chrome if it is being uninstalled.
456 product = 454 product = installer_state.FindProduct(BrowserDistribution::CHROME_BINARIES);
457 installer_state.FindProduct(BrowserDistribution::CHROME_BINARIES);
458 if (product != NULL && installer_state.is_multi_install()) 455 if (product != NULL && installer_state.is_multi_install())
459 have_chrome_binaries = false; 456 have_chrome_binaries = false;
460 } else { 457 } else {
461 // Check if we're installing Chrome Binaries 458 // Check if we're installing Chrome Binaries
462 product = 459 product = installer_state.FindProduct(BrowserDistribution::CHROME_BINARIES);
463 installer_state.FindProduct(BrowserDistribution::CHROME_BINARIES);
464 if (product != NULL && installer_state.is_multi_install()) 460 if (product != NULL && installer_state.is_multi_install())
465 have_chrome_binaries = true; 461 have_chrome_binaries = true;
466 } 462 }
467 463
468 // STEP 3: Decide what to do based on the final state of things. 464 // STEP 3: Decide what to do based on the final state of things.
469 enum QuickEnableOperation { 465 enum QuickEnableOperation {
470 DO_NOTHING, 466 DO_NOTHING,
471 ADD_COMMAND, 467 ADD_COMMAND,
472 REMOVE_COMMAND 468 REMOVE_COMMAND
473 } operation = DO_NOTHING; 469 } operation = DO_NOTHING;
474 FilePath binaries_setup_path; 470 FilePath binaries_setup_path;
475 471
476 if (have_child_product) { 472 if (have_child_product) {
477 // Child product is being uninstalled. Unconditionally remove the Quick 473 // Child product is being uninstalled. Unconditionally remove the Quick
478 // Enable command from the binaries. We do this even if multi-install Chrome 474 // Enable command from the binaries. We do this even if multi-install Chrome
479 // isn't installed since we don't want them left behind in any case. 475 // isn't installed since we don't want them left behind in any case.
480 operation = REMOVE_COMMAND; 476 operation = REMOVE_COMMAND;
481 } else if (have_chrome_binaries) { 477 } else if (have_chrome_binaries) {
482 // Child product isn't (to be) installed while multi-install Chrome is (to 478 // Child product isn't (to be) installed while multi-install Chrome is (to
483 // be) installed. Add the Quick Enable command to the binaries. 479 // be) installed. Add the Quick Enable command to the binaries.
484 operation = ADD_COMMAND; 480 operation = ADD_COMMAND;
485 // The path to setup.exe contains the version of the Chrome binaries, so it 481 // The path to setup.exe contains the version of the Chrome binaries, so it
486 // takes a little work to get it right. 482 // takes a little work to get it right.
487 if (installer_state.operation() == InstallerState::UNINSTALL) { 483 if (installer_state.operation() == InstallerState::UNINSTALL) {
488 // One or more products are being uninstalled, but not the binaries. Use 484 // One or more products are being uninstalled, but not the binaries. Use
489 // the path to the currently installed Chrome setup.exe. 485 // the path to the currently installed Chrome setup.exe.
490 product_state = 486 product_state = machine_state.GetProductState(
491 machine_state.GetProductState(system_install, 487 system_install, BrowserDistribution::CHROME_BINARIES);
492 BrowserDistribution::CHROME_BINARIES);
493 DCHECK(product_state); 488 DCHECK(product_state);
494 binaries_setup_path = product_state->uninstall_command().GetProgram(); 489 binaries_setup_path = product_state->uninstall_command().GetProgram();
495 } else { 490 } else {
496 // Chrome Binaries are being installed, updated, or otherwise operated on. 491 // Chrome Binaries are being installed, updated, or otherwise operated on.
497 // Use the path to the given |setup_path| in the normal location of 492 // Use the path to the given |setup_path| in the normal location of
498 // multi-install Chrome Binaries of the given |version|. 493 // multi-install Chrome Binaries of the given |version|.
499 DCHECK(installer_state.is_multi_install()); 494 DCHECK(installer_state.is_multi_install());
500 binaries_setup_path = 495 binaries_setup_path =
501 installer_state.GetInstallerDirectory(*new_version).Append( 496 installer_state.GetInstallerDirectory(new_version).Append(
502 setup_path->BaseName()); 497 setup_path.BaseName());
503 } 498 }
504 } 499 }
505 500
506 // STEP 4: Take action. 501 // STEP 4: Take action.
507 if (operation != DO_NOTHING) { 502 if (operation != DO_NOTHING) {
508 // Get the path to the quick-enable-cf command for the binaries. 503 // Get the path to the quick-enable-cf command for the binaries.
509 BrowserDistribution* binaries = 504 BrowserDistribution* binaries =
510 BrowserDistribution::GetSpecificDistribution( 505 BrowserDistribution::GetSpecificDistribution(
511 BrowserDistribution::CHROME_BINARIES); 506 BrowserDistribution::CHROME_BINARIES);
512 string16 cmd_key(binaries->GetVersionKey()); 507 string16 cmd_key(binaries->GetVersionKey());
513 cmd_key.append(1, L'\\').append(google_update::kRegCommandsKey) 508 cmd_key.append(1, L'\\').append(google_update::kRegCommandsKey)
514 .append(1, L'\\').append(command_id); 509 .append(1, L'\\').append(command_id);
515 510
516 if (operation == ADD_COMMAND) { 511 if (operation == ADD_COMMAND) {
517 DCHECK(!binaries_setup_path.empty()); 512 DCHECK(!binaries_setup_path.empty());
518 CommandLine cmd_line(binaries_setup_path); 513 CommandLine cmd_line(binaries_setup_path);
519 cmd_line.AppendArguments(child_product_switches, 514 cmd_line.AppendArguments(child_product_switches,
520 false); // include_program 515 false); // include_program
521 if (installer_state.verbose_logging()) 516 if (installer_state.verbose_logging())
522 cmd_line.AppendSwitch(switches::kVerboseLogging); 517 cmd_line.AppendSwitch(switches::kVerboseLogging);
523 AppCommand cmd(cmd_line.GetCommandLineString()); 518 AppCommand cmd(cmd_line.GetCommandLineString());
524 cmd.set_sends_pings(true); 519 cmd.set_sends_pings(true);
525 cmd.set_is_web_accessible(true); 520 cmd.set_is_web_accessible(true);
526 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list); 521 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list);
527 } else { 522 } else {
528 DCHECK(operation == REMOVE_COMMAND); 523 DCHECK(operation == REMOVE_COMMAND);
529 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), 524 work_item_list->AddDeleteRegKeyWorkItem(
530 cmd_key)->set_log_message( 525 installer_state.root_key(), cmd_key)->set_log_message(
531 "removing " + WideToASCII(command_id) + " command"); 526 "removing " + WideToASCII(command_id) + " command");
532 } 527 }
533 } 528 }
534 } 529 }
535 530
536 } // namespace 531 } // namespace
537 532
538 // This method adds work items to create (or update) Chrome uninstall entry in 533 // This method adds work items to create (or update) Chrome uninstall entry in
539 // either the Control Panel->Add/Remove Programs list or in the Omaha client 534 // either the Control Panel->Add/Remove Programs list or in the Omaha client
540 // state key if running under an MSI installer. 535 // state key if running under an MSI installer.
541 void AddUninstallShortcutWorkItems(const InstallerState& installer_state, 536 void AddUninstallShortcutWorkItems(const InstallerState& installer_state,
542 const FilePath& setup_path, 537 const FilePath& setup_path,
543 const Version& new_version, 538 const Version& new_version,
544 WorkItemList* install_list, 539 const Product& product,
545 const Product& product) { 540 WorkItemList* install_list) {
546 HKEY reg_root = installer_state.root_key(); 541 HKEY reg_root = installer_state.root_key();
547 BrowserDistribution* browser_dist = product.distribution(); 542 BrowserDistribution* browser_dist = product.distribution();
548 DCHECK(browser_dist); 543 DCHECK(browser_dist);
549 544
550 // When we are installed via an MSI, we need to store our uninstall strings 545 // When we are installed via an MSI, we need to store our uninstall strings
551 // in the Google Update client state key. We do this even for non-MSI 546 // in the Google Update client state key. We do this even for non-MSI
552 // managed installs to avoid breaking the edge case whereby an MSI-managed 547 // managed installs to avoid breaking the edge case whereby an MSI-managed
553 // install is updated by a non-msi installer (which would confuse the MSI 548 // install is updated by a non-msi installer (which would confuse the MSI
554 // machinery if these strings were not also updated). The UninstallString 549 // machinery if these strings were not also updated). The UninstallString
555 // value placed in the client state key is also used by the mini_installer to 550 // value placed in the client state key is also used by the mini_installer to
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 // Nothing is being installed? Entirely unexpected, so do no harm. 703 // Nothing is being installed? Entirely unexpected, so do no harm.
709 LOG(ERROR) << "No products found in AddOemInstallWorkItems"; 704 LOG(ERROR) << "No products found in AddOemInstallWorkItems";
710 return; 705 return;
711 } 706 }
712 const ProductState* source_product = 707 const ProductState* source_product =
713 original_state.GetNonVersionedProductState(system_install, source_type); 708 original_state.GetNonVersionedProductState(system_install, source_type);
714 709
715 string16 oem_install; 710 string16 oem_install;
716 if (source_product->GetOemInstall(&oem_install)) { 711 if (source_product->GetOemInstall(&oem_install)) {
717 VLOG(1) << "Mirroring oeminstall=\"" << oem_install << "\" from " 712 VLOG(1) << "Mirroring oeminstall=\"" << oem_install << "\" from "
718 << BrowserDistribution::GetSpecificDistribution(source_type) 713 << BrowserDistribution::GetSpecificDistribution(source_type)->
719 ->GetAppShortCutName(); 714 GetAppShortCutName();
720 install_list->AddCreateRegKeyWorkItem(root_key, multi_key); 715 install_list->AddCreateRegKeyWorkItem(root_key, multi_key);
721 // Always overwrite an old value. 716 // Always overwrite an old value.
722 install_list->AddSetRegValueWorkItem(root_key, multi_key, 717 install_list->AddSetRegValueWorkItem(root_key, multi_key,
723 google_update::kRegOemInstallField, 718 google_update::kRegOemInstallField,
724 oem_install, true); 719 oem_install, true);
725 } else { 720 } else {
726 // Clear any old value. 721 // Clear any old value.
727 install_list->AddDeleteRegValueWorkItem( 722 install_list->AddDeleteRegValueWorkItem(
728 root_key, multi_key, google_update::kRegOemInstallField); 723 root_key, multi_key, google_update::kRegOemInstallField);
729 } 724 }
(...skipping 13 matching lines...) Expand all
743 BrowserDistribution::CHROME_BINARIES)) { 738 BrowserDistribution::CHROME_BINARIES)) {
744 const HKEY root_key = installer_state.root_key(); 739 const HKEY root_key = installer_state.root_key();
745 string16 multi_key( 740 string16 multi_key(
746 installer_state.multi_package_binaries_distribution()->GetStateKey()); 741 installer_state.multi_package_binaries_distribution()->GetStateKey());
747 742
748 // Copy the value from the product with the greatest value. 743 // Copy the value from the product with the greatest value.
749 bool have_eula_accepted = false; 744 bool have_eula_accepted = false;
750 BrowserDistribution::Type product_type; 745 BrowserDistribution::Type product_type;
751 DWORD eula_accepted; 746 DWORD eula_accepted;
752 const Products& products = installer_state.products(); 747 const Products& products = installer_state.products();
753 for (size_t i = 0, count = products.size(); i != count; ++i) { 748 for (Products::const_iterator it = products.begin(); it < products.end();
754 if (products[i]->is_chrome_binaries()) 749 ++it) {
750 const Product& product = **it;
751 if (product.is_chrome_binaries())
755 continue; 752 continue;
756 DWORD dword_value = 0; 753 DWORD dword_value = 0;
757 BrowserDistribution::Type this_type = 754 BrowserDistribution::Type this_type = product.distribution()->GetType();
758 products[i]->distribution()->GetType();
759 const ProductState* product_state = 755 const ProductState* product_state =
760 original_state.GetNonVersionedProductState( 756 original_state.GetNonVersionedProductState(
761 system_install, this_type); 757 system_install, this_type);
762 if (product_state->GetEulaAccepted(&dword_value) && 758 if (product_state->GetEulaAccepted(&dword_value) &&
763 (!have_eula_accepted || dword_value > eula_accepted)) { 759 (!have_eula_accepted || dword_value > eula_accepted)) {
764 have_eula_accepted = true; 760 have_eula_accepted = true;
765 eula_accepted = dword_value; 761 eula_accepted = dword_value;
766 product_type = this_type; 762 product_type = this_type;
767 } 763 }
768 } 764 }
769 765
770 if (have_eula_accepted) { 766 if (have_eula_accepted) {
771 VLOG(1) << "Mirroring eulaaccepted=" << eula_accepted << " from " 767 VLOG(1) << "Mirroring eulaaccepted=" << eula_accepted << " from "
772 << BrowserDistribution::GetSpecificDistribution(product_type) 768 << BrowserDistribution::GetSpecificDistribution(product_type)->
773 ->GetAppShortCutName(); 769 GetAppShortCutName();
774 install_list->AddCreateRegKeyWorkItem(root_key, multi_key); 770 install_list->AddCreateRegKeyWorkItem(root_key, multi_key);
775 install_list->AddSetRegValueWorkItem( 771 install_list->AddSetRegValueWorkItem(
776 root_key, multi_key, google_update::kRegEULAAceptedField, 772 root_key, multi_key, google_update::kRegEULAAceptedField,
777 eula_accepted, true); 773 eula_accepted, true);
778 } else { 774 } else {
779 // Clear any old value. 775 // Clear any old value.
780 install_list->AddDeleteRegValueWorkItem( 776 install_list->AddDeleteRegValueWorkItem(
781 root_key, multi_key, google_update::kRegEULAAceptedField); 777 root_key, multi_key, google_update::kRegEULAAceptedField);
782 } 778 }
783 } 779 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 // if one is already present (although this shouldn't happen). 819 // if one is already present (although this shouldn't happen).
824 install_list->AddSetRegValueWorkItem(root_key, 820 install_list->AddSetRegValueWorkItem(root_key,
825 multi_key, 821 multi_key,
826 google_update::kRegBrandField, 822 google_update::kRegBrandField,
827 brand, 823 brand,
828 false); 824 false);
829 } 825 }
830 } 826 }
831 827
832 AddOemInstallWorkItems(original_state, installer_state, install_list); 828 AddOemInstallWorkItems(original_state, installer_state, install_list);
833
834 AddEulaAcceptedWorkItems(original_state, installer_state, install_list); 829 AddEulaAcceptedWorkItems(original_state, installer_state, install_list);
835
836 AddUsageStatsWorkItems(original_state, installer_state, install_list); 830 AddUsageStatsWorkItems(original_state, installer_state, install_list);
837 831
838 // TODO(grt): check for other keys/values we should put in the package's 832 // TODO(grt): check for other keys/values we should put in the package's
839 // ClientState and/or Clients key. 833 // ClientState and/or Clients key.
840 } 834 }
841 835
842 void AddUsageStatsWorkItems(const InstallationState& original_state, 836 void AddUsageStatsWorkItems(const InstallationState& original_state,
843 const InstallerState& installer_state, 837 const InstallerState& installer_state,
844 WorkItemList* install_list) { 838 WorkItemList* install_list) {
845 DCHECK(installer_state.operation() == InstallerState::MULTI_INSTALL || 839 DCHECK(installer_state.operation() == InstallerState::MULTI_INSTALL ||
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 if (installer_state.system_install()) { 876 if (installer_state.system_install()) {
883 install_list->AddDeleteRegValueWorkItem( 877 install_list->AddDeleteRegValueWorkItem(
884 root_key, dist->GetStateMediumKey(), 878 root_key, dist->GetStateMediumKey(),
885 google_update::kRegUsageStatsField); 879 google_update::kRegUsageStatsField);
886 // Previous versions of Chrome also wrote a value in HKCU even for 880 // Previous versions of Chrome also wrote a value in HKCU even for
887 // system-level installs, so clean that up. 881 // system-level installs, so clean that up.
888 install_list->AddDeleteRegValueWorkItem( 882 install_list->AddDeleteRegValueWorkItem(
889 HKEY_CURRENT_USER, dist->GetStateKey(), 883 HKEY_CURRENT_USER, dist->GetStateKey(),
890 google_update::kRegUsageStatsField); 884 google_update::kRegUsageStatsField);
891 } 885 }
892 install_list->AddDeleteRegValueWorkItem(root_key, dist->GetStateKey(), 886 install_list->AddDeleteRegValueWorkItem(
893 google_update::kRegUsageStatsField); 887 root_key, dist->GetStateKey(), google_update::kRegUsageStatsField);
894 } 888 }
895 } 889 }
896 } 890 }
897 891
898 // After a successful copying of all the files, this function is called to
899 // do a few post install tasks:
900 // - Handle the case of in-use-update by updating "opv" (old version) key or
901 // deleting it if not required.
902 // - Register any new dlls and unregister old dlls.
903 // - If this is an MSI install, ensures that the MSI marker is set, and sets
904 // it if not.
905 // If these operations are successful, the function returns true, otherwise
906 // false.
907 bool AppendPostInstallTasks(const InstallerState& installer_state, 892 bool AppendPostInstallTasks(const InstallerState& installer_state,
908 const FilePath& setup_path, 893 const FilePath& setup_path,
909 const Version* current_version, 894 const Version* current_version,
910 const Version& new_version, 895 const Version& new_version,
911 const FilePath& temp_path, 896 const FilePath& temp_path,
912 WorkItemList* post_install_task_list) { 897 WorkItemList* post_install_task_list) {
913 DCHECK(post_install_task_list); 898 DCHECK(post_install_task_list);
914 899
915 HKEY root = installer_state.root_key(); 900 HKEY root = installer_state.root_key();
916 const Products& products = installer_state.products(); 901 const Products& products = installer_state.products();
(...skipping 23 matching lines...) Expand all
940 rename.AppendSwitch(switches::kSystemLevel); 925 rename.AppendSwitch(switches::kSystemLevel);
941 926
942 if (installer_state.verbose_logging()) 927 if (installer_state.verbose_logging())
943 rename.AppendSwitch(switches::kVerboseLogging); 928 rename.AppendSwitch(switches::kVerboseLogging);
944 929
945 string16 version_key; 930 string16 version_key;
946 for (size_t i = 0; i < products.size(); ++i) { 931 for (size_t i = 0; i < products.size(); ++i) {
947 BrowserDistribution* dist = products[i]->distribution(); 932 BrowserDistribution* dist = products[i]->distribution();
948 version_key = dist->GetVersionKey(); 933 version_key = dist->GetVersionKey();
949 934
950 if (current_version != NULL) { 935 if (current_version) {
951 in_use_update_work_items->AddSetRegValueWorkItem(root, version_key, 936 in_use_update_work_items->AddSetRegValueWorkItem(root, version_key,
952 google_update::kRegOldVersionField, 937 google_update::kRegOldVersionField,
953 ASCIIToWide(current_version->GetString()), true); 938 ASCIIToWide(current_version->GetString()), true);
954 } 939 }
955 if (critical_version.IsValid()) { 940 if (critical_version.IsValid()) {
956 in_use_update_work_items->AddSetRegValueWorkItem(root, version_key, 941 in_use_update_work_items->AddSetRegValueWorkItem(root, version_key,
957 google_update::kRegCriticalVersionField, 942 google_update::kRegCriticalVersionField,
958 ASCIIToWide(critical_version.GetString()), true); 943 ASCIIToWide(critical_version.GetString()), true);
959 } else { 944 } else {
960 in_use_update_work_items->AddDeleteRegValueWorkItem(root, version_key, 945 in_use_update_work_items->AddDeleteRegValueWorkItem(root, version_key,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 1020
1036 return true; 1021 return true;
1037 } 1022 }
1038 1023
1039 void AddInstallWorkItems(const InstallationState& original_state, 1024 void AddInstallWorkItems(const InstallationState& original_state,
1040 const InstallerState& installer_state, 1025 const InstallerState& installer_state,
1041 const FilePath& setup_path, 1026 const FilePath& setup_path,
1042 const FilePath& archive_path, 1027 const FilePath& archive_path,
1043 const FilePath& src_path, 1028 const FilePath& src_path,
1044 const FilePath& temp_path, 1029 const FilePath& temp_path,
1030 const Version* current_version,
1045 const Version& new_version, 1031 const Version& new_version,
1046 scoped_ptr<Version>* current_version,
1047 WorkItemList* install_list) { 1032 WorkItemList* install_list) {
1048 DCHECK(install_list); 1033 DCHECK(install_list);
1049 1034
1050 const FilePath& target_path = installer_state.target_path(); 1035 const FilePath& target_path = installer_state.target_path();
1051 1036
1052 // A temp directory that work items need and the actual install directory. 1037 // A temp directory that work items need and the actual install directory.
1053 install_list->AddCreateDirWorkItem(temp_path); 1038 install_list->AddCreateDirWorkItem(temp_path);
1054 install_list->AddCreateDirWorkItem(target_path); 1039 install_list->AddCreateDirWorkItem(target_path);
1055 1040
1056 if (installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER) || 1041 if (installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER) ||
1057 installer_state.FindProduct(BrowserDistribution::CHROME_FRAME) || 1042 installer_state.FindProduct(BrowserDistribution::CHROME_FRAME) ||
1058 installer_state.FindProduct(BrowserDistribution::CHROME_BINARIES)) { 1043 installer_state.FindProduct(BrowserDistribution::CHROME_BINARIES)) {
1059 AddChromeWorkItems(original_state, 1044 AddChromeWorkItems(original_state,
1060 installer_state, 1045 installer_state,
1061 setup_path, 1046 setup_path,
1062 archive_path, 1047 archive_path,
1063 src_path, 1048 src_path,
1064 temp_path, 1049 temp_path,
1050 current_version,
1065 new_version, 1051 new_version,
1066 current_version,
1067 install_list); 1052 install_list);
1068 } 1053 }
1069 1054
1070 if (installer_state.FindProduct(BrowserDistribution::CHROME_APP_HOST)) { 1055 if (installer_state.FindProduct(BrowserDistribution::CHROME_APP_HOST)) {
1071 install_list->AddCopyTreeWorkItem( 1056 install_list->AddCopyTreeWorkItem(
1072 src_path.Append(installer::kChromeAppHostExe).value(), 1057 src_path.Append(installer::kChromeAppHostExe).value(),
1073 target_path.Append(installer::kChromeAppHostExe).value(), 1058 target_path.Append(installer::kChromeAppHostExe).value(),
1074 temp_path.value(), 1059 temp_path.value(),
1075 WorkItem::ALWAYS, 1060 WorkItem::ALWAYS,
1076 L""); 1061 L"");
1077 } 1062 }
1078 1063
1079 const HKEY root = installer_state.root_key(); 1064 const HKEY root = installer_state.root_key();
1080 // Only set "lang" for user-level installs since for system-level, the install 1065 // Only set "lang" for user-level installs since for system-level, the install
1081 // language may not be related to a given user's runtime language. 1066 // language may not be related to a given user's runtime language.
1082 const bool add_language_identifier = !installer_state.system_install(); 1067 const bool add_language_identifier = !installer_state.system_install();
1083 1068
1084 const Products& products = installer_state.products(); 1069 const Products& products = installer_state.products();
1085 for (size_t i = 0; i < products.size(); ++i) { 1070 for (Products::const_iterator it = products.begin(); it < products.end();
1086 const Product* product = products[i]; 1071 ++it) {
1072 const Product& product = **it;
1087 1073
1088 AddUninstallShortcutWorkItems(installer_state, setup_path, new_version, 1074 AddUninstallShortcutWorkItems(installer_state, setup_path, new_version,
1089 install_list, *product); 1075 product, install_list);
1090 1076
1091 AddVersionKeyWorkItems(root, product->distribution(), new_version, 1077 AddVersionKeyWorkItems(root, product.distribution(), new_version,
1092 add_language_identifier, install_list); 1078 add_language_identifier, install_list);
1093 1079
1094 AddDelegateExecuteWorkItems(installer_state, src_path, new_version, 1080 AddDelegateExecuteWorkItems(installer_state, src_path, new_version,
1095 *product, install_list); 1081 product, install_list);
1096 1082
1097 // TODO(gab): This is only disabled for M22 as the shortcut CL using Active 1083 // TODO(gab): This is only disabled for M22 as the shortcut CL using Active
1098 // Setup will not make it in M22. 1084 // Setup will not make it in M22.
1099 #if 0 1085 #if 0
1100 AddActiveSetupWorkItems(installer_state, new_version, *product, 1086 AddActiveSetupWorkItems(installer_state, new_version, *product,
1101 install_list); 1087 install_list);
1102 #endif 1088 #endif
1103 } 1089 }
1104 1090
1105 // Add any remaining work items that involve special settings for 1091 // Add any remaining work items that involve special settings for
1106 // each product. 1092 // each product.
1107 AddProductSpecificWorkItems(original_state, installer_state, setup_path, 1093 AddProductSpecificWorkItems(original_state, installer_state, setup_path,
1108 new_version, install_list); 1094 new_version, install_list);
1109 1095
1110 // Copy over brand, usagestats, and other values. 1096 // Copy over brand, usagestats, and other values.
1111 AddGoogleUpdateWorkItems(original_state, installer_state, install_list); 1097 AddGoogleUpdateWorkItems(original_state, installer_state, install_list);
1112 1098
1113 AddQuickEnableApplicationHostWorkItems(installer_state, original_state, 1099 AddQuickEnableApplicationHostWorkItems(installer_state, original_state,
1114 &setup_path, &new_version, 1100 setup_path, new_version,
1115 install_list); 1101 install_list);
1116 1102
1117 AddQuickEnableChromeFrameWorkItems(installer_state, original_state, 1103 AddQuickEnableChromeFrameWorkItems(installer_state, original_state,
1118 &setup_path, &new_version, install_list); 1104 setup_path, new_version, install_list);
1119 1105
1120 // Append the tasks that run after the installation. 1106 // Append the tasks that run after the installation.
1121 AppendPostInstallTasks(installer_state, 1107 AppendPostInstallTasks(installer_state,
1122 setup_path, 1108 setup_path,
1123 current_version->get(), 1109 current_version,
1124 new_version, 1110 new_version,
1125 temp_path, 1111 temp_path,
1126 install_list); 1112 install_list);
1127 } 1113 }
1128 1114
1129 void AddRegisterComDllWorkItems(const FilePath& dll_folder, 1115 void AddRegisterComDllWorkItems(const FilePath& dll_folder,
1130 const std::vector<FilePath>& dll_list, 1116 const std::vector<FilePath>& dll_list,
1131 bool system_level, 1117 bool system_level,
1132 bool do_register, 1118 bool do_register,
1133 bool ignore_failures, 1119 bool ignore_failures,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 BrowserDistribution* dist = 1168 BrowserDistribution* dist =
1183 installer_state.multi_package_binaries_distribution(); 1169 installer_state.multi_package_binaries_distribution();
1184 if (ready_mode) { 1170 if (ready_mode) {
1185 // If GCF is being installed in ready mode, we write an entry to the 1171 // If GCF is being installed in ready mode, we write an entry to the
1186 // multi-install state key. If the value already exists, we will not 1172 // multi-install state key. If the value already exists, we will not
1187 // overwrite it since the user might have opted out. 1173 // overwrite it since the user might have opted out.
1188 list->AddCreateRegKeyWorkItem(root, dist->GetStateKey()); 1174 list->AddCreateRegKeyWorkItem(root, dist->GetStateKey());
1189 list->AddSetRegValueWorkItem(root, dist->GetStateKey(), 1175 list->AddSetRegValueWorkItem(root, dist->GetStateKey(),
1190 kChromeFrameReadyModeField, 1176 kChromeFrameReadyModeField,
1191 static_cast<int64>(is_install ? 1 : 0), // The value we want to set. 1177 static_cast<int64>(is_install ? 1 : 0), // The value we want to set.
1192 is_install ? false : true); // Overwrite existing value. 1178 !is_install); // Overwrite existing value.
1193 if (is_install) { 1179 if (is_install) {
1194 FilePath installer_path(installer_state 1180 FilePath installer_path(installer_state
1195 .GetInstallerDirectory(new_version).Append(setup_path.BaseName())); 1181 .GetInstallerDirectory(new_version).Append(setup_path.BaseName()));
1196 1182
1197 CommandLine basic_cl(installer_path); 1183 CommandLine basic_cl(installer_path);
1198 basic_cl.AppendSwitch(switches::kChromeFrame); 1184 basic_cl.AppendSwitch(switches::kChromeFrame);
1199 basic_cl.AppendSwitch(switches::kMultiInstall); 1185 basic_cl.AppendSwitch(switches::kMultiInstall);
1200 1186
1201 if (installer_state.system_install()) 1187 if (installer_state.system_install())
1202 basic_cl.AppendSwitch(switches::kSystemLevel); 1188 basic_cl.AppendSwitch(switches::kSystemLevel);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 google_update::kRegCFOptOutCmdField); 1263 google_update::kRegCFOptOutCmdField);
1278 list->AddDeleteRegValueWorkItem(root, version_key, 1264 list->AddDeleteRegValueWorkItem(root, version_key,
1279 google_update::kRegCFOptInCmdField); 1265 google_update::kRegCFOptInCmdField);
1280 } 1266 }
1281 1267
1282 if (update_chrome_uninstall_command) { 1268 if (update_chrome_uninstall_command) {
1283 // Chrome is not a part of this installation run, so we have to explicitly 1269 // Chrome is not a part of this installation run, so we have to explicitly
1284 // check if Chrome is installed, and if so, update its uninstallation 1270 // check if Chrome is installed, and if so, update its uninstallation
1285 // command lines. 1271 // command lines.
1286 const ProductState* chrome_state = original_state.GetProductState( 1272 const ProductState* chrome_state = original_state.GetProductState(
1287 installer_state.system_install(), 1273 installer_state.system_install(), BrowserDistribution::CHROME_BROWSER);
1288 BrowserDistribution::CHROME_BROWSER);
1289 if (chrome_state != NULL) { 1274 if (chrome_state != NULL) {
1290 DCHECK(chrome_state->is_multi_install()); 1275 DCHECK(chrome_state->is_multi_install());
1291 Product chrome(BrowserDistribution::GetSpecificDistribution( 1276 Product chrome(BrowserDistribution::GetSpecificDistribution(
1292 BrowserDistribution::CHROME_BROWSER)); 1277 BrowserDistribution::CHROME_BROWSER));
1293 chrome.InitializeFromUninstallCommand(chrome_state->uninstall_command()); 1278 chrome.InitializeFromUninstallCommand(chrome_state->uninstall_command());
1294 AddUninstallShortcutWorkItems(installer_state, setup_path, 1279 AddUninstallShortcutWorkItems(installer_state, setup_path,
1295 chrome_state->version(), list, chrome); 1280 chrome_state->version(), chrome, list);
1296 } else { 1281 } else {
1297 NOTREACHED() << "What happened to Chrome?"; 1282 NOTREACHED() << "What happened to Chrome?";
1298 } 1283 }
1299 } 1284 }
1300 } 1285 }
1301 1286
1302 void AddDelegateExecuteWorkItems(const InstallerState& installer_state, 1287 void AddDelegateExecuteWorkItems(const InstallerState& installer_state,
1303 const FilePath& src_path, 1288 const FilePath& src_path,
1304 const Version& new_version, 1289 const Version& new_version,
1305 const Product& product, 1290 const Product& product,
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 } 1475 }
1491 1476
1492 FreeLibrary(ieframe); 1477 FreeLibrary(ieframe);
1493 } else { 1478 } else {
1494 VLOG(1) << "Cannot load " << kIEFrameDll; 1479 VLOG(1) << "Cannot load " << kIEFrameDll;
1495 } 1480 }
1496 } 1481 }
1497 1482
1498 void AddQuickEnableChromeFrameWorkItems(const InstallerState& installer_state, 1483 void AddQuickEnableChromeFrameWorkItems(const InstallerState& installer_state,
1499 const InstallationState& machine_state, 1484 const InstallationState& machine_state,
1500 const FilePath* setup_path, 1485 const FilePath& setup_path,
1501 const Version* new_version, 1486 const Version& new_version,
1502 WorkItemList* work_item_list) { 1487 WorkItemList* work_item_list) {
1503 DCHECK(setup_path ||
1504 installer_state.operation() == InstallerState::UNINSTALL);
1505 DCHECK(new_version ||
1506 installer_state.operation() == InstallerState::UNINSTALL);
1507 DCHECK(work_item_list); 1488 DCHECK(work_item_list);
1508 1489
1509 const bool system_install = installer_state.system_install(); 1490 const bool system_install = installer_state.system_install();
1510 bool have_chrome_frame = false; 1491 bool have_chrome_frame = false;
1511 1492
1512 // STEP 1: Figure out the state of the machine before the operation. 1493 // STEP 1: Figure out the state of the machine before the operation.
1513 const ProductState* product_state = NULL; 1494 const ProductState* product_state = NULL;
1514 1495
1515 // Is Chrome Frame !ready-mode already on the machine? 1496 // Is Chrome Frame !ready-mode already on the machine?
1516 product_state = 1497 product_state = machine_state.GetProductState(
1517 machine_state.GetProductState(system_install, 1498 system_install, BrowserDistribution::CHROME_FRAME);
1518 BrowserDistribution::CHROME_FRAME);
1519 if (product_state != NULL && 1499 if (product_state != NULL &&
1520 !product_state->uninstall_command().HasSwitch( 1500 !product_state->uninstall_command().HasSwitch(
1521 switches::kChromeFrameReadyMode)) 1501 switches::kChromeFrameReadyMode))
1522 have_chrome_frame = true; 1502 have_chrome_frame = true;
1523 1503
1524 // STEP 2: Now take into account the current operation. 1504 // STEP 2: Now take into account the current operation.
1525 const Product* product = NULL; 1505 const Product* product = NULL;
1526 1506
1527 if (installer_state.operation() == InstallerState::UNINSTALL) { 1507 if (installer_state.operation() == InstallerState::UNINSTALL) {
1528 // Forget about Chrome Frame if it is being uninstalled. Note that we don't 1508 // Forget about Chrome Frame if it is being uninstalled. Note that we don't
(...skipping 14 matching lines...) Expand all
1543 CommandLine cmd_line(CommandLine::NO_PROGRAM); 1523 CommandLine cmd_line(CommandLine::NO_PROGRAM);
1544 cmd_line.AppendSwitch(switches::kMultiInstall); 1524 cmd_line.AppendSwitch(switches::kMultiInstall);
1545 if (installer_state.system_install()) 1525 if (installer_state.system_install())
1546 cmd_line.AppendSwitch(switches::kSystemLevel); 1526 cmd_line.AppendSwitch(switches::kSystemLevel);
1547 cmd_line.AppendSwitch(switches::kChromeFrameQuickEnable); 1527 cmd_line.AppendSwitch(switches::kChromeFrameQuickEnable);
1548 1528
1549 AddGenericQuickEnableWorkItems(installer_state, 1529 AddGenericQuickEnableWorkItems(installer_state,
1550 machine_state, 1530 machine_state,
1551 setup_path, 1531 setup_path,
1552 new_version, 1532 new_version,
1553 work_item_list,
1554 have_chrome_frame, 1533 have_chrome_frame,
1555 cmd_line, 1534 cmd_line,
1556 kCmdQuickEnableCf); 1535 kCmdQuickEnableCf,
1536 work_item_list);
1557 } 1537 }
1558 1538
1559 void AddQuickEnableApplicationHostWorkItems( 1539 void AddQuickEnableApplicationHostWorkItems(
1560 const InstallerState& installer_state, 1540 const InstallerState& installer_state,
1561 const InstallationState& machine_state, 1541 const InstallationState& machine_state,
1562 const FilePath* setup_path, 1542 const FilePath& setup_path,
1563 const Version* new_version, 1543 const Version& new_version,
1564 WorkItemList* work_item_list) { 1544 WorkItemList* work_item_list) {
1565 DCHECK(setup_path ||
1566 installer_state.operation() == InstallerState::UNINSTALL);
1567 DCHECK(new_version ||
1568 installer_state.operation() == InstallerState::UNINSTALL);
1569 DCHECK(work_item_list); 1545 DCHECK(work_item_list);
1570 1546
1571 CommandLine cmd_line(CommandLine::NO_PROGRAM); 1547 CommandLine cmd_line(CommandLine::NO_PROGRAM);
1572 cmd_line.AppendSwitch(switches::kMultiInstall); 1548 cmd_line.AppendSwitch(switches::kMultiInstall);
1573 cmd_line.AppendSwitch(switches::kChromeAppHost); 1549 cmd_line.AppendSwitch(switches::kChromeAppHost);
1574 1550
1575 // For system-level binaries there is no way to keep the command state in sync 1551 // For system-level binaries there is no way to keep the command state in sync
1576 // with the installation/uninstallation of the Application Host (which is 1552 // with the installation/uninstallation of the Application Host (which is
1577 // always at user-level). 1553 // always at user-level).
1578 // So we pass false for 'have_child_product' to cause this command to always 1554 // So we pass false for 'have_child_product' to cause this command to always
1579 // be installed if the Chrome Binaries are installed. 1555 // be installed if the Chrome Binaries are installed.
1580 AddGenericQuickEnableWorkItems(installer_state, 1556 AddGenericQuickEnableWorkItems(installer_state,
1581 machine_state, 1557 machine_state,
1582 setup_path, 1558 setup_path,
1583 new_version, 1559 new_version,
1584 work_item_list,
1585 false, // have_child_product 1560 false, // have_child_product
1586 cmd_line, 1561 cmd_line,
1587 kCmdQuickEnableApplicationHost); 1562 kCmdQuickEnableApplicationHost,
1563 work_item_list);
1588 } 1564 }
1589 1565
1590 void AddOsUpgradeWorkItems(const InstallerState& installer_state, 1566 void AddOsUpgradeWorkItems(const InstallerState& installer_state,
1591 const FilePath* setup_path, 1567 const FilePath& setup_path,
1592 const Version* new_version, 1568 const Version& new_version,
1593 const Product& product, 1569 const Product& product,
1594 WorkItemList* install_list) { 1570 WorkItemList* install_list) {
1595 const HKEY root_key = installer_state.root_key(); 1571 const HKEY root_key = installer_state.root_key();
1596 string16 cmd_key(product.distribution()->GetVersionKey()); 1572 string16 cmd_key(product.distribution()->GetVersionKey());
1597 cmd_key.append(1, FilePath::kSeparators[0]) 1573 cmd_key.append(1, FilePath::kSeparators[0])
1598 .append(google_update::kRegCommandsKey) 1574 .append(google_update::kRegCommandsKey)
1599 .append(1, FilePath::kSeparators[0]) 1575 .append(1, FilePath::kSeparators[0])
1600 .append(kCmdOnOsUpgrade); 1576 .append(kCmdOnOsUpgrade);
1601 1577
1602 // This will make Google Update call setup.exe with --on-os-upgrade switch. 1578 if (installer_state.operation() == InstallerState::UNINSTALL) {
1603 // For Chrome, this leads to HandleOsUpgradeForBrowser() being called. 1579 install_list->AddDeleteRegKeyWorkItem(root_key, cmd_key)->
1604 if (installer_state.operation() != InstallerState::UNINSTALL) { 1580 set_log_message("Removing OS upgrade command");
1581 } else {
1582 // Register with Google Update to have setup.exe --on-os-upgrade called on
1583 // OS upgrade.
1605 CommandLine cmd_line(installer_state 1584 CommandLine cmd_line(installer_state
1606 .GetInstallerDirectory(*new_version) 1585 .GetInstallerDirectory(new_version)
1607 .Append(setup_path->BaseName())); 1586 .Append(setup_path.BaseName()));
1608 // Add the main option to indicate OS upgrade flow. 1587 // Add the main option to indicate OS upgrade flow.
1609 cmd_line.AppendSwitch(installer::switches::kOnOsUpgrade); 1588 cmd_line.AppendSwitch(installer::switches::kOnOsUpgrade);
1610 // Add product-specific options. 1589 // Add product-specific options.
1611 product.AppendProductFlags(&cmd_line); 1590 product.AppendProductFlags(&cmd_line);
1612 if (installer_state.system_install()) 1591 if (installer_state.system_install())
1613 cmd_line.AppendSwitch(installer::switches::kSystemLevel); 1592 cmd_line.AppendSwitch(installer::switches::kSystemLevel);
1614 // Log everything for now. 1593 // Log everything for now.
1615 cmd_line.AppendSwitch(installer::switches::kVerboseLogging); 1594 cmd_line.AppendSwitch(installer::switches::kVerboseLogging);
1616 1595
1617 AppCommand cmd(cmd_line.GetCommandLineString()); 1596 AppCommand cmd(cmd_line.GetCommandLineString());
1618 cmd.set_is_auto_run_on_os_upgrade(true); 1597 cmd.set_is_auto_run_on_os_upgrade(true);
1619 cmd.AddWorkItems(installer_state.root_key(), cmd_key, install_list); 1598 cmd.AddWorkItems(installer_state.root_key(), cmd_key, install_list);
1620 } else {
1621 install_list->AddDeleteRegKeyWorkItem(root_key, cmd_key)
1622 ->set_log_message("Removing OS upgrade command");
1623 } 1599 }
1624 } 1600 }
1625 1601
1626 } // namespace installer 1602 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/installer/setup/install_worker.h ('k') | chrome/installer/setup/install_worker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698