| 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/base_paths.h" |
| 14 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 15 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 16 #include "base/files/file_util.h" | 17 #include "base/files/file_util.h" |
| 17 #include "base/logging.h" | 18 #include "base/logging.h" |
| 18 #include "base/numerics/safe_conversions.h" | 19 #include "base/numerics/safe_conversions.h" |
| 20 #include "base/path_service.h" |
| 19 #include "base/process/launch.h" | 21 #include "base/process/launch.h" |
| 20 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
| 21 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
| 23 #include "base/win/shortcut.h" | 25 #include "base/win/shortcut.h" |
| 24 #include "chrome/install_static/install_details.h" | 26 #include "chrome/install_static/install_details.h" |
| 25 #include "chrome/install_static/install_util.h" | 27 #include "chrome/install_static/install_util.h" |
| 26 #include "chrome/installer/setup/install_worker.h" | 28 #include "chrome/installer/setup/install_worker.h" |
| 27 #include "chrome/installer/setup/installer_crash_reporting.h" | 29 #include "chrome/installer/setup/installer_crash_reporting.h" |
| 28 #include "chrome/installer/setup/installer_state.h" | 30 #include "chrome/installer/setup/installer_state.h" |
| 29 #include "chrome/installer/setup/setup_constants.h" | 31 #include "chrome/installer/setup/setup_constants.h" |
| 30 #include "chrome/installer/setup/setup_util.h" | 32 #include "chrome/installer/setup/setup_util.h" |
| 31 #include "chrome/installer/setup/update_active_setup_version_work_item.h" | 33 #include "chrome/installer/setup/update_active_setup_version_work_item.h" |
| 34 #include "chrome/installer/setup/user_experiment.h" |
| 32 #include "chrome/installer/util/beacons.h" | 35 #include "chrome/installer/util/beacons.h" |
| 33 #include "chrome/installer/util/browser_distribution.h" | 36 #include "chrome/installer/util/browser_distribution.h" |
| 34 #include "chrome/installer/util/create_reg_key_work_item.h" | 37 #include "chrome/installer/util/create_reg_key_work_item.h" |
| 35 #include "chrome/installer/util/delete_after_reboot_helper.h" | 38 #include "chrome/installer/util/delete_after_reboot_helper.h" |
| 36 #include "chrome/installer/util/delete_old_versions.h" | 39 #include "chrome/installer/util/delete_old_versions.h" |
| 37 #include "chrome/installer/util/install_util.h" | 40 #include "chrome/installer/util/install_util.h" |
| 38 #include "chrome/installer/util/installation_state.h" | 41 #include "chrome/installer/util/installation_state.h" |
| 39 #include "chrome/installer/util/master_preferences.h" | 42 #include "chrome/installer/util/master_preferences.h" |
| 40 #include "chrome/installer/util/master_preferences_constants.h" | 43 #include "chrome/installer/util/master_preferences_constants.h" |
| 41 #include "chrome/installer/util/util_constants.h" | 44 #include "chrome/installer/util/util_constants.h" |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 else | 660 else |
| 658 LOG(ERROR) << "Failed to bump Active Setup Version on-os-upgrade."; | 661 LOG(ERROR) << "Failed to bump Active Setup Version on-os-upgrade."; |
| 659 } | 662 } |
| 660 } | 663 } |
| 661 | 664 |
| 662 // NOTE: Should the work done here, on Active Setup, change: | 665 // NOTE: Should the work done here, on Active Setup, change: |
| 663 // kActiveSetupMajorVersion in update_active_setup_version_work_item.cc needs to | 666 // kActiveSetupMajorVersion in update_active_setup_version_work_item.cc needs to |
| 664 // be increased for Active Setup to invoke this again for all users of this | 667 // be increased for Active Setup to invoke this again for all users of this |
| 665 // install. It may also be invoked again when a system-level chrome install goes | 668 // install. It may also be invoked again when a system-level chrome install goes |
| 666 // through an OS upgrade. | 669 // through an OS upgrade. |
| 667 void HandleActiveSetupForBrowser(const base::FilePath& installation_root, | 670 void HandleActiveSetupForBrowser(const InstallerState& installer_state, |
| 668 const installer::Product& chrome, | |
| 669 bool force) { | 671 bool force) { |
| 670 std::unique_ptr<WorkItemList> cleanup_list(WorkItem::CreateWorkItemList()); | 672 std::unique_ptr<WorkItemList> cleanup_list(WorkItem::CreateWorkItemList()); |
| 671 cleanup_list->set_log_message("Cleanup deprecated per-user registrations"); | 673 cleanup_list->set_log_message("Cleanup deprecated per-user registrations"); |
| 672 cleanup_list->set_rollback_enabled(false); | 674 cleanup_list->set_rollback_enabled(false); |
| 673 cleanup_list->set_best_effort(true); | 675 cleanup_list->set_best_effort(true); |
| 674 AddCleanupDeprecatedPerUserRegistrationsWorkItems(chrome, cleanup_list.get()); | 676 AddCleanupDeprecatedPerUserRegistrationsWorkItems(installer_state.product(), |
| 677 cleanup_list.get()); |
| 675 cleanup_list->Do(); | 678 cleanup_list->Do(); |
| 676 | 679 |
| 677 // Only create shortcuts on Active Setup if the first run sentinel is not | 680 // Only create shortcuts on Active Setup if the first run sentinel is not |
| 678 // present for this user (as some shortcuts used to be installed on first | 681 // present for this user (as some shortcuts used to be installed on first |
| 679 // run and this could otherwise re-install shortcuts for users that have | 682 // run and this could otherwise re-install shortcuts for users that have |
| 680 // already deleted them in the past). | 683 // already deleted them in the past). |
| 681 // Decide whether to create the shortcuts or simply replace existing | 684 // Decide whether to create the shortcuts or simply replace existing |
| 682 // shortcuts; if the decision is to create them, only shortcuts whose matching | 685 // shortcuts; if the decision is to create them, only shortcuts whose matching |
| 683 // all-users shortcut isn't present on the system will be created. | 686 // all-users shortcut isn't present on the system will be created. |
| 684 InstallShortcutOperation install_operation = | 687 InstallShortcutOperation install_operation = |
| 685 (!force && InstallUtil::IsFirstRunSentinelPresent()) | 688 (!force && InstallUtil::IsFirstRunSentinelPresent()) |
| 686 ? INSTALL_SHORTCUT_REPLACE_EXISTING | 689 ? INSTALL_SHORTCUT_REPLACE_EXISTING |
| 687 : INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL; | 690 : INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL; |
| 688 | 691 |
| 689 // Read master_preferences copied beside chrome.exe at install. | 692 // Read master_preferences copied beside chrome.exe at install for the sake of |
| 693 // creating/updating shortcuts. |
| 694 const base::FilePath installation_root = installer_state.target_path(); |
| 690 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); | 695 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); |
| 691 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); | 696 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); |
| 692 CreateOrUpdateShortcuts( | 697 CreateOrUpdateShortcuts(chrome_exe, installer_state.product(), prefs, |
| 693 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); | 698 CURRENT_USER, install_operation); |
| 694 | 699 |
| 695 UpdateDefaultBrowserBeaconForPath(chrome_exe); | 700 UpdateDefaultBrowserBeaconForPath(chrome_exe); |
| 701 |
| 702 // This install may have been selected into a study for a retention |
| 703 // experiment following a successful update. In case the experiment was not |
| 704 // able to run immediately after the update (e.g., no user was logged on at |
| 705 // the time), try to run it now that the installer is running in the context |
| 706 // of a user. |
| 707 if (ShouldRunUserExperiment(installer_state)) { |
| 708 base::FilePath setup_exe; |
| 709 if (!base::PathService::Get(base::FILE_EXE, &setup_exe)) |
| 710 LOG(ERROR) << "Failed to get path to setup.exe."; |
| 711 else |
| 712 BeginUserExperiment(installer_state, setup_exe, true /* user_context */); |
| 713 } |
| 696 } | 714 } |
| 697 | 715 |
| 698 } // namespace installer | 716 } // namespace installer |
| OLD | NEW |