| 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/install.h" | 5 #include "chrome/installer/setup/install.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <shlobj.h> | 8 #include <shlobj.h> |
| 9 #include <time.h> | 9 #include <time.h> |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/files/file_util.h" | 16 #include "base/files/file_util.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/numerics/safe_conversions.h" | 18 #include "base/numerics/safe_conversions.h" |
| 19 #include "base/process/launch.h" | 19 #include "base/process/launch.h" |
| 20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 21 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| 23 #include "base/win/shortcut.h" | 23 #include "base/win/shortcut.h" |
| 24 #include "base/win/windows_version.h" | |
| 25 #include "chrome/common/chrome_constants.h" | |
| 26 #include "chrome/common/chrome_switches.h" | |
| 27 #include "chrome/installer/setup/install_worker.h" | 24 #include "chrome/installer/setup/install_worker.h" |
| 28 #include "chrome/installer/setup/installer_crash_reporting.h" | 25 #include "chrome/installer/setup/installer_crash_reporting.h" |
| 26 #include "chrome/installer/setup/installer_state.h" |
| 29 #include "chrome/installer/setup/setup_constants.h" | 27 #include "chrome/installer/setup/setup_constants.h" |
| 30 #include "chrome/installer/setup/setup_util.h" | 28 #include "chrome/installer/setup/setup_util.h" |
| 31 #include "chrome/installer/setup/update_active_setup_version_work_item.h" | 29 #include "chrome/installer/setup/update_active_setup_version_work_item.h" |
| 32 #include "chrome/installer/util/beacons.h" | 30 #include "chrome/installer/util/beacons.h" |
| 33 #include "chrome/installer/util/browser_distribution.h" | 31 #include "chrome/installer/util/browser_distribution.h" |
| 34 #include "chrome/installer/util/create_reg_key_work_item.h" | 32 #include "chrome/installer/util/create_reg_key_work_item.h" |
| 35 #include "chrome/installer/util/delete_after_reboot_helper.h" | 33 #include "chrome/installer/util/delete_after_reboot_helper.h" |
| 36 #include "chrome/installer/util/delete_old_versions.h" | 34 #include "chrome/installer/util/delete_old_versions.h" |
| 37 #include "chrome/installer/util/google_update_constants.h" | |
| 38 #include "chrome/installer/util/helper.h" | |
| 39 #include "chrome/installer/util/install_util.h" | 35 #include "chrome/installer/util/install_util.h" |
| 36 #include "chrome/installer/util/installation_state.h" |
| 40 #include "chrome/installer/util/master_preferences.h" | 37 #include "chrome/installer/util/master_preferences.h" |
| 41 #include "chrome/installer/util/master_preferences_constants.h" | 38 #include "chrome/installer/util/master_preferences_constants.h" |
| 42 #include "chrome/installer/util/set_reg_value_work_item.h" | |
| 43 #include "chrome/installer/util/util_constants.h" | 39 #include "chrome/installer/util/util_constants.h" |
| 44 #include "chrome/installer/util/work_item.h" | 40 #include "chrome/installer/util/work_item.h" |
| 45 #include "chrome/installer/util/work_item_list.h" | 41 #include "chrome/installer/util/work_item_list.h" |
| 46 | 42 |
| 47 namespace { | 43 namespace { |
| 48 | 44 |
| 49 void LogShortcutOperation(ShellUtil::ShortcutLocation location, | 45 void LogShortcutOperation(ShellUtil::ShortcutLocation location, |
| 50 BrowserDistribution* dist, | 46 BrowserDistribution* dist, |
| 51 const ShellUtil::ShortcutProperties& properties, | 47 const ShellUtil::ShortcutProperties& properties, |
| 52 ShellUtil::ShortcutOperation operation, | 48 ShellUtil::ShortcutOperation operation, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 message.append(base::UTF16ToUTF8(properties.shortcut_name)); | 92 message.append(base::UTF16ToUTF8(properties.shortcut_name)); |
| 97 else | 93 else |
| 98 message.append(base::UTF16ToUTF8(dist->GetDisplayName())); | 94 message.append(base::UTF16ToUTF8(dist->GetDisplayName())); |
| 99 message.push_back('"'); | 95 message.push_back('"'); |
| 100 | 96 |
| 101 message.append(" shortcut to "); | 97 message.append(" shortcut to "); |
| 102 message.append(base::UTF16ToUTF8(properties.target.value())); | 98 message.append(base::UTF16ToUTF8(properties.target.value())); |
| 103 if (properties.has_arguments()) | 99 if (properties.has_arguments()) |
| 104 message.append(base::UTF16ToUTF8(properties.arguments)); | 100 message.append(base::UTF16ToUTF8(properties.arguments)); |
| 105 | 101 |
| 106 if (properties.pin_to_taskbar && | 102 if (properties.pin_to_taskbar && base::win::CanPinShortcutToTaskbar()) |
| 107 base::win::GetVersion() >= base::win::VERSION_WIN7) { | |
| 108 message.append(" and pinning to the taskbar"); | 103 message.append(" and pinning to the taskbar"); |
| 109 } | |
| 110 | 104 |
| 111 message.push_back('.'); | 105 message.push_back('.'); |
| 112 | 106 |
| 113 if (failed) | 107 if (failed) |
| 114 LOG(WARNING) << message; | 108 LOG(WARNING) << message; |
| 115 else | 109 else |
| 116 VLOG(1) << message; | 110 VLOG(1) << message; |
| 117 } | 111 } |
| 118 | 112 |
| 119 void ExecuteAndLogShortcutOperation( | 113 void ExecuteAndLogShortcutOperation( |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 base::PathExists(new_chrome_exe) && current_version->get() && | 210 base::PathExists(new_chrome_exe) && current_version->get() && |
| 217 new_version == *current_version->get() ? | 211 new_version == *current_version->get() ? |
| 218 installer::SAME_VERSION_REPAIR_FAILED : | 212 installer::SAME_VERSION_REPAIR_FAILED : |
| 219 installer::INSTALL_FAILED; | 213 installer::INSTALL_FAILED; |
| 220 LOG(ERROR) << "Install failed, rolling back... result: " << result; | 214 LOG(ERROR) << "Install failed, rolling back... result: " << result; |
| 221 install_list->Rollback(); | 215 install_list->Rollback(); |
| 222 LOG(ERROR) << "Rollback complete. "; | 216 LOG(ERROR) << "Rollback complete. "; |
| 223 return result; | 217 return result; |
| 224 } | 218 } |
| 225 | 219 |
| 226 installer_state.SetStage(installer::REFRESHING_POLICY); | |
| 227 | |
| 228 installer::RefreshElevationPolicy(); | |
| 229 | |
| 230 if (!current_version->get()) { | 220 if (!current_version->get()) { |
| 231 VLOG(1) << "First install of version " << new_version; | 221 VLOG(1) << "First install of version " << new_version; |
| 232 return installer::FIRST_INSTALL_SUCCESS; | 222 return installer::FIRST_INSTALL_SUCCESS; |
| 233 } | 223 } |
| 234 | 224 |
| 235 if (new_version == **current_version) { | 225 if (new_version == **current_version) { |
| 236 VLOG(1) << "Install repaired of version " << new_version; | 226 VLOG(1) << "Install repaired of version " << new_version; |
| 237 return installer::INSTALL_REPAIRED; | 227 return installer::INSTALL_REPAIRED; |
| 238 } | 228 } |
| 239 | 229 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 258 return installer::OLD_VERSION_DOWNGRADE; | 248 return installer::OLD_VERSION_DOWNGRADE; |
| 259 } | 249 } |
| 260 | 250 |
| 261 LOG(ERROR) << "Not sure how we got here while updating" | 251 LOG(ERROR) << "Not sure how we got here while updating" |
| 262 << ", new version: " << new_version | 252 << ", new version: " << new_version |
| 263 << ", old version: " << **current_version; | 253 << ", old version: " << **current_version; |
| 264 | 254 |
| 265 return installer::INSTALL_FAILED; | 255 return installer::INSTALL_FAILED; |
| 266 } | 256 } |
| 267 | 257 |
| 268 } // end namespace | 258 } // namespace |
| 269 | 259 |
| 270 namespace installer { | 260 namespace installer { |
| 271 | 261 |
| 272 void EscapeXmlAttributeValueInSingleQuotes(base::string16* att_value) { | 262 void EscapeXmlAttributeValueInSingleQuotes(base::string16* att_value) { |
| 273 base::ReplaceChars(*att_value, base::ASCIIToUTF16("&"), | 263 base::ReplaceChars(*att_value, base::ASCIIToUTF16("&"), |
| 274 base::ASCIIToUTF16("&"), att_value); | 264 base::ASCIIToUTF16("&"), att_value); |
| 275 base::ReplaceChars(*att_value, base::ASCIIToUTF16("'"), | 265 base::ReplaceChars(*att_value, base::ASCIIToUTF16("'"), |
| 276 base::ASCIIToUTF16("'"), att_value); | 266 base::ASCIIToUTF16("'"), att_value); |
| 277 base::ReplaceChars(*att_value, base::ASCIIToUTF16("<"), | 267 base::ReplaceChars(*att_value, base::ASCIIToUTF16("<"), |
| 278 base::ASCIIToUTF16("<"), att_value); | 268 base::ASCIIToUTF16("<"), att_value); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 | 425 |
| 436 ExecuteAndLogShortcutOperation( | 426 ExecuteAndLogShortcutOperation( |
| 437 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT, dist, | 427 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT, dist, |
| 438 start_menu_properties, shortcut_operation); | 428 start_menu_properties, shortcut_operation); |
| 439 } | 429 } |
| 440 | 430 |
| 441 void RegisterChromeOnMachine(const installer::InstallerState& installer_state, | 431 void RegisterChromeOnMachine(const installer::InstallerState& installer_state, |
| 442 const installer::Product& product, | 432 const installer::Product& product, |
| 443 bool make_chrome_default, | 433 bool make_chrome_default, |
| 444 const base::Version& version) { | 434 const base::Version& version) { |
| 445 DCHECK(product.is_chrome()); | |
| 446 | |
| 447 // Try to add Chrome to Media Player shim inclusion list. We don't do any | 435 // Try to add Chrome to Media Player shim inclusion list. We don't do any |
| 448 // error checking here because this operation will fail if user doesn't | 436 // error checking here because this operation will fail if user doesn't |
| 449 // have admin rights and we want to ignore the error. | 437 // have admin rights and we want to ignore the error. |
| 450 AddChromeToMediaPlayerList(); | 438 AddChromeToMediaPlayerList(); |
| 451 | 439 |
| 452 // Register the event log provider for system-level installs only, as it | 440 // Register the event log provider for system-level installs only, as it |
| 453 // requires admin privileges. | 441 // requires admin privileges. |
| 454 if (installer_state.system_install()) | 442 if (installer_state.system_install()) |
| 455 RegisterEventLogProvider(installer_state.target_path(), version); | 443 RegisterEventLogProvider(installer_state.target_path(), version); |
| 456 | 444 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 473 InstallStatus InstallOrUpdateProduct( | 461 InstallStatus InstallOrUpdateProduct( |
| 474 const installer::InstallationState& original_state, | 462 const installer::InstallationState& original_state, |
| 475 const installer::InstallerState& installer_state, | 463 const installer::InstallerState& installer_state, |
| 476 const base::FilePath& setup_path, | 464 const base::FilePath& setup_path, |
| 477 const base::FilePath& archive_path, | 465 const base::FilePath& archive_path, |
| 478 const base::FilePath& install_temp_path, | 466 const base::FilePath& install_temp_path, |
| 479 const base::FilePath& src_path, | 467 const base::FilePath& src_path, |
| 480 const base::FilePath& prefs_path, | 468 const base::FilePath& prefs_path, |
| 481 const MasterPreferences& prefs, | 469 const MasterPreferences& prefs, |
| 482 const base::Version& new_version) { | 470 const base::Version& new_version) { |
| 483 DCHECK(!installer_state.products().empty()); | |
| 484 | |
| 485 // TODO(robertshield): Removing the pending on-reboot moves should be done | 471 // TODO(robertshield): Removing the pending on-reboot moves should be done |
| 486 // elsewhere. | 472 // elsewhere. |
| 487 // Remove any scheduled MOVEFILE_DELAY_UNTIL_REBOOT entries in the target of | 473 // Remove any scheduled MOVEFILE_DELAY_UNTIL_REBOOT entries in the target of |
| 488 // this installation. These may have been added during a previous uninstall of | 474 // this installation. These may have been added during a previous uninstall of |
| 489 // the same version. | 475 // the same version. |
| 490 LOG_IF(ERROR, !RemoveFromMovesPendingReboot(installer_state.target_path())) | 476 LOG_IF(ERROR, !RemoveFromMovesPendingReboot(installer_state.target_path())) |
| 491 << "Error accessing pending moves value."; | 477 << "Error accessing pending moves value."; |
| 492 | 478 |
| 493 // Create VisualElementManifest.xml in |src_path| (if required) so that it | 479 // Create VisualElementManifest.xml in |src_path| (if required) so that it |
| 494 // looks as if it had been extracted from the archive when calling | 480 // looks as if it had been extracted from the archive when calling |
| 495 // InstallNewVersion() below. | 481 // InstallNewVersion() below. |
| 496 installer_state.SetStage(CREATING_VISUAL_MANIFEST); | 482 installer_state.SetStage(CREATING_VISUAL_MANIFEST); |
| 497 CreateVisualElementsManifest(src_path, new_version); | 483 CreateVisualElementsManifest(src_path, new_version); |
| 498 | 484 |
| 499 std::unique_ptr<base::Version> existing_version; | 485 std::unique_ptr<base::Version> existing_version; |
| 500 InstallStatus result = | 486 InstallStatus result = |
| 501 InstallNewVersion(original_state, installer_state, setup_path, | 487 InstallNewVersion(original_state, installer_state, setup_path, |
| 502 archive_path, src_path, install_temp_path, new_version, | 488 archive_path, src_path, install_temp_path, new_version, |
| 503 &existing_version, IsDowngradeAllowed(prefs)); | 489 &existing_version, IsDowngradeAllowed(prefs)); |
| 504 | 490 |
| 505 // TODO(robertshield): Everything below this line should instead be captured | 491 // TODO(robertshield): Everything below this line should instead be captured |
| 506 // by WorkItems. | 492 // by WorkItems. |
| 507 if (!InstallUtil::GetInstallReturnCode(result)) { | 493 if (!InstallUtil::GetInstallReturnCode(result)) { |
| 508 installer_state.SetStage(UPDATING_CHANNELS); | 494 installer_state.SetStage(UPDATING_CHANNELS); |
| 509 | 495 |
| 510 // Update the modifiers on the channel values for the product(s) being | 496 // Strip evidence of multi-install from the "ap" value. |
| 511 // installed and for the binaries in case of multi-install. | 497 // TODO(grt): Consider doing this earlier, prior to any other work, so that |
| 498 // failed updates benefit from the stripping. |
| 512 installer_state.UpdateChannels(); | 499 installer_state.UpdateChannels(); |
| 513 | 500 |
| 514 installer_state.SetStage(COPYING_PREFERENCES_FILE); | 501 installer_state.SetStage(COPYING_PREFERENCES_FILE); |
| 515 | 502 |
| 516 if (result == FIRST_INSTALL_SUCCESS && !prefs_path.empty()) | 503 if (result == FIRST_INSTALL_SUCCESS && !prefs_path.empty()) |
| 517 CopyPreferenceFileForFirstRun(installer_state, prefs_path); | 504 CopyPreferenceFileForFirstRun(installer_state, prefs_path); |
| 518 | 505 |
| 519 installer_state.SetStage(CREATING_SHORTCUTS); | 506 installer_state.SetStage(CREATING_SHORTCUTS); |
| 520 | 507 |
| 521 const installer::Product* chrome_product = | |
| 522 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); | |
| 523 // Creates shortcuts for Chrome. | 508 // Creates shortcuts for Chrome. |
| 524 if (chrome_product) { | 509 const Product& chrome_product = installer_state.product(); |
| 525 BrowserDistribution* chrome_dist = chrome_product->distribution(); | 510 BrowserDistribution* chrome_dist = chrome_product.distribution(); |
| 526 const base::FilePath chrome_exe( | 511 const base::FilePath chrome_exe( |
| 527 installer_state.target_path().Append(kChromeExe)); | 512 installer_state.target_path().Append(kChromeExe)); |
| 528 | 513 |
| 529 // Install per-user shortcuts on user-level installs and all-users | 514 // Install per-user shortcuts on user-level installs and all-users shortcuts |
| 530 // shortcuts on system-level installs. Note that Active Setup will take | 515 // on system-level installs. Note that Active Setup will take care of |
| 531 // care of installing missing per-user shortcuts on system-level install | 516 // installing missing per-user shortcuts on system-level install (i.e., |
| 532 // (i.e., quick launch, taskbar pin, and possibly deleted all-users | 517 // quick launch, taskbar pin, and possibly deleted all-users shortcuts). |
| 533 // shortcuts). | 518 InstallShortcutLevel install_level = |
| 534 InstallShortcutLevel install_level = installer_state.system_install() ? | 519 installer_state.system_install() ? ALL_USERS : CURRENT_USER; |
| 535 ALL_USERS : CURRENT_USER; | |
| 536 | 520 |
| 537 InstallShortcutOperation install_operation = | 521 InstallShortcutOperation install_operation = |
| 538 INSTALL_SHORTCUT_REPLACE_EXISTING; | 522 INSTALL_SHORTCUT_REPLACE_EXISTING; |
| 539 if (result == installer::FIRST_INSTALL_SUCCESS || | 523 if (result == installer::FIRST_INSTALL_SUCCESS || |
| 540 result == installer::INSTALL_REPAIRED || | 524 result == installer::INSTALL_REPAIRED || |
| 541 !original_state.GetProductState(installer_state.system_install(), | 525 !original_state.GetProductState(installer_state.system_install(), |
| 542 chrome_dist->GetType())) { | 526 chrome_dist->GetType())) { |
| 543 // Always create the shortcuts on a new install, a repair install, and | 527 // Always create the shortcuts on a new install, a repair install, and |
| 544 // when the Chrome product is being added to the current install. | 528 // when the Chrome product is being added to the current install. |
| 545 install_operation = INSTALL_SHORTCUT_CREATE_ALL; | 529 install_operation = INSTALL_SHORTCUT_CREATE_ALL; |
| 546 } | |
| 547 | |
| 548 CreateOrUpdateShortcuts(chrome_exe, *chrome_product, prefs, install_level, | |
| 549 install_operation); | |
| 550 } | 530 } |
| 551 | 531 |
| 552 if (chrome_product) { | 532 CreateOrUpdateShortcuts(chrome_exe, chrome_product, prefs, install_level, |
| 553 // Register Chrome and, if requested, make Chrome the default browser. | 533 install_operation); |
| 554 installer_state.SetStage(REGISTERING_CHROME); | |
| 555 | 534 |
| 556 bool make_chrome_default = false; | 535 // Register Chrome and, if requested, make Chrome the default browser. |
| 557 prefs.GetBool(master_preferences::kMakeChromeDefault, | 536 installer_state.SetStage(REGISTERING_CHROME); |
| 558 &make_chrome_default); | |
| 559 | 537 |
| 560 // If this is not the user's first Chrome install, but they have chosen | 538 bool make_chrome_default = false; |
| 561 // Chrome to become their default browser on the download page, we must | 539 prefs.GetBool(master_preferences::kMakeChromeDefault, &make_chrome_default); |
| 562 // force it here because the master_preferences file will not get copied | |
| 563 // into the build. | |
| 564 bool force_chrome_default_for_user = false; | |
| 565 if (result == NEW_VERSION_UPDATED || result == INSTALL_REPAIRED || | |
| 566 result == OLD_VERSION_DOWNGRADE || result == IN_USE_DOWNGRADE) { | |
| 567 prefs.GetBool(master_preferences::kMakeChromeDefaultForUser, | |
| 568 &force_chrome_default_for_user); | |
| 569 } | |
| 570 | 540 |
| 571 RegisterChromeOnMachine( | 541 // If this is not the user's first Chrome install, but they have chosen |
| 572 installer_state, *chrome_product, | 542 // Chrome to become their default browser on the download page, we must |
| 573 make_chrome_default || force_chrome_default_for_user, new_version); | 543 // force it here because the master_preferences file will not get copied |
| 544 // into the build. |
| 545 bool force_chrome_default_for_user = false; |
| 546 if (result == NEW_VERSION_UPDATED || result == INSTALL_REPAIRED || |
| 547 result == OLD_VERSION_DOWNGRADE || result == IN_USE_DOWNGRADE) { |
| 548 prefs.GetBool(master_preferences::kMakeChromeDefaultForUser, |
| 549 &force_chrome_default_for_user); |
| 550 } |
| 574 | 551 |
| 575 if (!installer_state.system_install()) { | 552 RegisterChromeOnMachine( |
| 576 DCHECK_EQ(chrome_product->distribution(), | 553 installer_state, chrome_product, |
| 577 BrowserDistribution::GetDistribution()); | 554 make_chrome_default || force_chrome_default_for_user, new_version); |
| 578 UpdateDefaultBrowserBeaconForPath( | 555 |
| 579 installer_state.target_path().Append(installer::kChromeExe)); | 556 if (!installer_state.system_install()) { |
| 580 } | 557 DCHECK_EQ(chrome_product.distribution(), |
| 558 BrowserDistribution::GetDistribution()); |
| 559 UpdateDefaultBrowserBeaconForPath( |
| 560 installer_state.target_path().Append(installer::kChromeExe)); |
| 581 } | 561 } |
| 582 | 562 |
| 583 // Delete files that belong to old versions of Chrome. If that fails during | 563 // Delete files that belong to old versions of Chrome. If that fails during |
| 584 // a not-in-use update, launch a --delete-old-version process. If this is an | 564 // a not-in-use update, launch a --delete-old-version process. If this is an |
| 585 // in-use update, a --delete-old-versions process will be launched when | 565 // in-use update, a --delete-old-versions process will be launched when |
| 586 // executables are renamed. | 566 // executables are renamed. |
| 587 installer_state.SetStage(REMOVING_OLD_VERSIONS); | 567 installer_state.SetStage(REMOVING_OLD_VERSIONS); |
| 588 const bool is_in_use = | 568 const bool is_in_use = |
| 589 (result == IN_USE_UPDATED || result == IN_USE_DOWNGRADE); | 569 (result == IN_USE_UPDATED || result == IN_USE_DOWNGRADE); |
| 590 if (!DeleteOldVersions(installer_state.target_path()) && !is_in_use) { | 570 if (!DeleteOldVersions(installer_state.target_path()) && !is_in_use) { |
| 591 const base::FilePath new_version_setup_path = | 571 const base::FilePath new_version_setup_path = |
| 592 installer_state.GetInstallerDirectory(new_version) | 572 installer_state.GetInstallerDirectory(new_version) |
| 593 .Append(setup_path.BaseName()); | 573 .Append(setup_path.BaseName()); |
| 594 LaunchDeleteOldVersionsProcess(new_version_setup_path, installer_state); | 574 LaunchDeleteOldVersionsProcess(new_version_setup_path, installer_state); |
| 595 } | 575 } |
| 596 } | 576 } |
| 597 | 577 |
| 598 return result; | 578 return result; |
| 599 } | 579 } |
| 600 | 580 |
| 601 void LaunchDeleteOldVersionsProcess(const base::FilePath& setup_path, | 581 void LaunchDeleteOldVersionsProcess(const base::FilePath& setup_path, |
| 602 const InstallerState& installer_state) { | 582 const InstallerState& installer_state) { |
| 603 // Deleting old versions is relevant if multi-install binaries are being | |
| 604 // updated or if single-install Chrome is. | |
| 605 const Product* product = | |
| 606 installer_state.FindProduct(BrowserDistribution::CHROME_BINARIES); | |
| 607 if (!product) | |
| 608 product = installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); | |
| 609 if (!product) | |
| 610 return; | |
| 611 | |
| 612 base::CommandLine command_line(setup_path); | 583 base::CommandLine command_line(setup_path); |
| 613 product->AppendProductFlags(&command_line); | 584 installer_state.product().AppendProductFlags(&command_line); |
| 614 command_line.AppendSwitch(switches::kDeleteOldVersions); | 585 command_line.AppendSwitch(switches::kDeleteOldVersions); |
| 615 | 586 |
| 616 if (installer_state.system_install()) | 587 if (installer_state.system_install()) |
| 617 command_line.AppendSwitch(switches::kSystemLevel); | 588 command_line.AppendSwitch(switches::kSystemLevel); |
| 618 // Unconditionally enable verbose logging for now to make diagnosing potential | 589 // Unconditionally enable verbose logging for now to make diagnosing potential |
| 619 // failures possible. | 590 // failures possible. |
| 620 command_line.AppendSwitch(switches::kVerboseLogging); | 591 command_line.AppendSwitch(switches::kVerboseLogging); |
| 621 | 592 |
| 622 base::LaunchOptions launch_options; | 593 base::LaunchOptions launch_options; |
| 623 launch_options.start_hidden = true; | 594 launch_options.start_hidden = true; |
| 624 // Make sure not to launch from a version directory. Otherwise, it wouldn't be | 595 // Make sure not to launch from a version directory. Otherwise, it wouldn't be |
| 625 // possible to delete it. | 596 // possible to delete it. |
| 626 launch_options.current_directory = setup_path.DirName(); | 597 launch_options.current_directory = setup_path.DirName(); |
| 627 launch_options.force_breakaway_from_job_ = true; | 598 launch_options.force_breakaway_from_job_ = true; |
| 628 | 599 |
| 629 VLOG(1) << "Launching \"" << command_line.GetCommandLineString() | 600 VLOG(1) << "Launching \"" << command_line.GetCommandLineString() |
| 630 << "\" to delete old versions."; | 601 << "\" to delete old versions."; |
| 631 base::Process process = base::LaunchProcess(command_line, launch_options); | 602 base::Process process = base::LaunchProcess(command_line, launch_options); |
| 632 PLOG_IF(ERROR, !process.IsValid()) | 603 PLOG_IF(ERROR, !process.IsValid()) |
| 633 << "Failed to launch \"" << command_line.GetCommandLineString() << "\""; | 604 << "Failed to launch \"" << command_line.GetCommandLineString() << "\""; |
| 634 } | 605 } |
| 635 | 606 |
| 636 void HandleOsUpgradeForBrowser(const installer::InstallerState& installer_state, | 607 void HandleOsUpgradeForBrowser(const installer::InstallerState& installer_state, |
| 637 const installer::Product& chrome, | 608 const installer::Product& chrome, |
| 638 const base::Version& installed_version) { | 609 const base::Version& installed_version) { |
| 639 DCHECK(chrome.is_chrome()); | |
| 640 | |
| 641 VLOG(1) << "Updating and registering shortcuts for --on-os-upgrade."; | 610 VLOG(1) << "Updating and registering shortcuts for --on-os-upgrade."; |
| 642 | 611 |
| 643 // Read master_preferences copied beside chrome.exe at install. | 612 // Read master_preferences copied beside chrome.exe at install. |
| 644 const MasterPreferences prefs( | 613 const MasterPreferences prefs( |
| 645 installer_state.target_path().AppendASCII(kDefaultMasterPrefs)); | 614 installer_state.target_path().AppendASCII(kDefaultMasterPrefs)); |
| 646 | 615 |
| 647 // Update shortcuts at this install level (per-user shortcuts on system-level | 616 // Update shortcuts at this install level (per-user shortcuts on system-level |
| 648 // installs will be updated through Active Setup). | 617 // installs will be updated through Active Setup). |
| 649 const InstallShortcutLevel level = | 618 const InstallShortcutLevel level = |
| 650 installer_state.system_install() ? ALL_USERS : CURRENT_USER; | 619 installer_state.system_install() ? ALL_USERS : CURRENT_USER; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 } | 662 } |
| 694 | 663 |
| 695 // NOTE: Should the work done here, on Active Setup, change: | 664 // NOTE: Should the work done here, on Active Setup, change: |
| 696 // kActiveSetupMajorVersion in update_active_setup_version_work_item.cc needs to | 665 // kActiveSetupMajorVersion in update_active_setup_version_work_item.cc needs to |
| 697 // be increased for Active Setup to invoke this again for all users of this | 666 // be increased for Active Setup to invoke this again for all users of this |
| 698 // install. It may also be invoked again when a system-level chrome install goes | 667 // install. It may also be invoked again when a system-level chrome install goes |
| 699 // through an OS upgrade. | 668 // through an OS upgrade. |
| 700 void HandleActiveSetupForBrowser(const base::FilePath& installation_root, | 669 void HandleActiveSetupForBrowser(const base::FilePath& installation_root, |
| 701 const installer::Product& chrome, | 670 const installer::Product& chrome, |
| 702 bool force) { | 671 bool force) { |
| 703 DCHECK(chrome.is_chrome()); | |
| 704 | |
| 705 std::unique_ptr<WorkItemList> cleanup_list(WorkItem::CreateWorkItemList()); | 672 std::unique_ptr<WorkItemList> cleanup_list(WorkItem::CreateWorkItemList()); |
| 706 cleanup_list->set_log_message("Cleanup deprecated per-user registrations"); | 673 cleanup_list->set_log_message("Cleanup deprecated per-user registrations"); |
| 707 cleanup_list->set_rollback_enabled(false); | 674 cleanup_list->set_rollback_enabled(false); |
| 708 cleanup_list->set_best_effort(true); | 675 cleanup_list->set_best_effort(true); |
| 709 AddCleanupDeprecatedPerUserRegistrationsWorkItems(chrome, cleanup_list.get()); | 676 AddCleanupDeprecatedPerUserRegistrationsWorkItems(chrome, cleanup_list.get()); |
| 710 cleanup_list->Do(); | 677 cleanup_list->Do(); |
| 711 | 678 |
| 712 // Only create shortcuts on Active Setup if the first run sentinel is not | 679 // Only create shortcuts on Active Setup if the first run sentinel is not |
| 713 // present for this user (as some shortcuts used to be installed on first | 680 // present for this user (as some shortcuts used to be installed on first |
| 714 // run and this could otherwise re-install shortcuts for users that have | 681 // run and this could otherwise re-install shortcuts for users that have |
| 715 // already deleted them in the past). | 682 // already deleted them in the past). |
| 716 // Decide whether to create the shortcuts or simply replace existing | 683 // Decide whether to create the shortcuts or simply replace existing |
| 717 // shortcuts; if the decision is to create them, only shortcuts whose matching | 684 // shortcuts; if the decision is to create them, only shortcuts whose matching |
| 718 // all-users shortcut isn't present on the system will be created. | 685 // all-users shortcut isn't present on the system will be created. |
| 719 InstallShortcutOperation install_operation = | 686 InstallShortcutOperation install_operation = |
| 720 (!force && InstallUtil::IsFirstRunSentinelPresent()) | 687 (!force && InstallUtil::IsFirstRunSentinelPresent()) |
| 721 ? INSTALL_SHORTCUT_REPLACE_EXISTING | 688 ? INSTALL_SHORTCUT_REPLACE_EXISTING |
| 722 : INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL; | 689 : INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL; |
| 723 | 690 |
| 724 // Read master_preferences copied beside chrome.exe at install. | 691 // Read master_preferences copied beside chrome.exe at install. |
| 725 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); | 692 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); |
| 726 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); | 693 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); |
| 727 CreateOrUpdateShortcuts( | 694 CreateOrUpdateShortcuts( |
| 728 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); | 695 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); |
| 729 | 696 |
| 730 UpdateDefaultBrowserBeaconForPath(chrome_exe); | 697 UpdateDefaultBrowserBeaconForPath(chrome_exe); |
| 731 } | 698 } |
| 732 | 699 |
| 733 } // namespace installer | 700 } // namespace installer |
| OLD | NEW |