| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #if defined(GOOGLE_CHROME_BUILD) | |
| 6 | |
| 7 #include "chrome/installer/setup/app_launcher_installer.h" | 5 #include "chrome/installer/setup/app_launcher_installer.h" |
| 8 | 6 |
| 9 #include "base/strings/string16.h" | 7 #include "base/logging.h" |
| 10 #include "base/version.h" | |
| 11 #include "chrome/installer/setup/install_worker.h" | |
| 12 #include "chrome/installer/setup/setup_util.h" | |
| 13 #include "chrome/installer/util/google_update_constants.h" | |
| 14 #include "chrome/installer/util/install_util.h" | 8 #include "chrome/installer/util/install_util.h" |
| 15 #include "chrome/installer/util/installer_state.h" | |
| 16 #include "chrome/installer/util/installer_util_strings.h" | |
| 17 #include "chrome/installer/util/l10n_string_util.h" | |
| 18 #include "chrome/installer/util/product.h" | |
| 19 #include "chrome/installer/util/updating_app_registration_data.h" | 9 #include "chrome/installer/util/updating_app_registration_data.h" |
| 20 #include "chrome/installer/util/work_item.h" | 10 #include "chrome/installer/util/work_item.h" |
| 21 #include "chrome/installer/util/work_item_list.h" | 11 #include "chrome/installer/util/work_item_list.h" |
| 22 | 12 |
| 23 namespace installer { | 13 namespace installer { |
| 24 | |
| 25 namespace { | 14 namespace { |
| 26 | |
| 27 // The legacy command ids for installing an application or extension. These are | |
| 28 // only here so they can be removed from the registry. | |
| 29 const wchar_t kLegacyCmdInstallApp[] = L"install-application"; | |
| 30 const wchar_t kLegacyCmdInstallExtension[] = L"install-extension"; | |
| 31 const wchar_t kLegacyCmdQueryEULAAcceptance[] = L"query-eula-acceptance"; | |
| 32 const wchar_t kLegacyCmdQuickEnableApplicationHost[] = | |
| 33 L"quick-enable-application-host"; | |
| 34 | |
| 35 // The legacy app_host.exe executable, which should be eradicated. | 15 // The legacy app_host.exe executable, which should be eradicated. |
| 36 const wchar_t kLegacyChromeAppHostExe[] = L"app_host.exe"; | 16 const wchar_t kLegacyChromeAppHostExe[] = L"app_host.exe"; |
| 37 | |
| 38 base::string16 GetAppLauncherDisplayName() { | |
| 39 return GetLocalizedString(IDS_PRODUCT_APP_LAUNCHER_NAME_BASE); | |
| 40 } | |
| 41 | |
| 42 void AddLegacyAppCommandRemovalItem(const InstallerState& installer_state, | |
| 43 const AppRegistrationData& reg_data, | |
| 44 const wchar_t* name, | |
| 45 WorkItemList* list) { | |
| 46 // Ignore failures since this is a clean-up operation and shouldn't block | |
| 47 // install or update. | |
| 48 list->AddDeleteRegKeyWorkItem( | |
| 49 installer_state.root_key(), | |
| 50 GetRegistrationDataCommandKey(reg_data, name), | |
| 51 KEY_WOW64_32KEY) | |
| 52 ->set_ignore_failure(true); | |
| 53 } | |
| 54 | |
| 55 } // namespace | 17 } // namespace |
| 56 | 18 |
| 57 void AddAppLauncherVersionKeyWorkItems(HKEY root, | |
| 58 const base::Version& new_version, | |
| 59 bool add_language_identifier, | |
| 60 WorkItemList* list) { | |
| 61 DCHECK(!InstallUtil::IsChromeSxSProcess()); | |
| 62 const UpdatingAppRegistrationData app_launcher_reg_data(kAppLauncherGuid); | |
| 63 AddVersionKeyWorkItems(root, | |
| 64 app_launcher_reg_data.GetVersionKey(), | |
| 65 GetAppLauncherDisplayName(), | |
| 66 new_version, | |
| 67 add_language_identifier, | |
| 68 list); | |
| 69 } | |
| 70 | |
| 71 void RemoveAppLauncherVersionKey(HKEY reg_root) { | 19 void RemoveAppLauncherVersionKey(HKEY reg_root) { |
| 72 DCHECK(!InstallUtil::IsChromeSxSProcess()); | 20 DCHECK(!InstallUtil::IsChromeSxSProcess()); |
| 73 const UpdatingAppRegistrationData app_launcher_reg_data(kAppLauncherGuid); | 21 const UpdatingAppRegistrationData app_launcher_reg_data(kAppLauncherGuid); |
| 74 InstallUtil::DeleteRegistryKey( | 22 InstallUtil::DeleteRegistryKey( |
| 75 reg_root, app_launcher_reg_data.GetVersionKey(), KEY_WOW64_32KEY); | 23 reg_root, app_launcher_reg_data.GetVersionKey(), KEY_WOW64_32KEY); |
| 76 } | 24 } |
| 77 | 25 |
| 78 void AddRemoveLegacyAppHostExeWorkItems(const base::FilePath& target_path, | 26 void AddRemoveLegacyAppHostExeWorkItems(const base::FilePath& target_path, |
| 79 const base::FilePath& temp_path, | 27 const base::FilePath& temp_path, |
| 80 WorkItemList* list) { | 28 WorkItemList* list) { |
| 81 DCHECK(!InstallUtil::IsChromeSxSProcess()); | 29 DCHECK(!InstallUtil::IsChromeSxSProcess()); |
| 82 list->AddDeleteTreeWorkItem( | 30 auto* delete_tree_work_item = list->AddDeleteTreeWorkItem( |
| 83 target_path.Append(kLegacyChromeAppHostExe), | 31 target_path.Append(kLegacyChromeAppHostExe), temp_path); |
| 84 temp_path)->set_ignore_failure(true); | 32 delete_tree_work_item->set_best_effort(true); |
| 85 } | 33 delete_tree_work_item->set_rollback_enabled(false); |
| 86 | |
| 87 void AddRemoveLegacyAppCommandsWorkItems(const InstallerState& installer_state, | |
| 88 WorkItemList* list) { | |
| 89 DCHECK(!InstallUtil::IsChromeSxSProcess()); | |
| 90 DCHECK(list); | |
| 91 for (const auto* p : installer_state.products()) { | |
| 92 if (p->is_chrome()) { | |
| 93 // Remove "install-application" command from App Launcher. | |
| 94 const UpdatingAppRegistrationData app_launcher_reg_data(kAppLauncherGuid); | |
| 95 AddLegacyAppCommandRemovalItem(installer_state, app_launcher_reg_data, | |
| 96 kLegacyCmdInstallApp, list); | |
| 97 | |
| 98 // Remove "install-extension" command from Chrome. | |
| 99 const AppRegistrationData& chrome_reg_data = | |
| 100 p->distribution()->GetAppRegistrationData(); | |
| 101 AddLegacyAppCommandRemovalItem(installer_state, chrome_reg_data, | |
| 102 kLegacyCmdInstallExtension, list); | |
| 103 } | |
| 104 if (p->is_chrome_binaries()) { | |
| 105 const AppRegistrationData& binaries_reg_data = | |
| 106 p->distribution()->GetAppRegistrationData(); | |
| 107 // Remove "query-eula-acceptance" command from Binaries. | |
| 108 AddLegacyAppCommandRemovalItem(installer_state, binaries_reg_data, | |
| 109 kLegacyCmdQueryEULAAcceptance, list); | |
| 110 // Remove "quick-enable-application-host" command from Binaries. | |
| 111 AddLegacyAppCommandRemovalItem(installer_state, binaries_reg_data, | |
| 112 kLegacyCmdQuickEnableApplicationHost, list); | |
| 113 } | |
| 114 } | |
| 115 } | 34 } |
| 116 | 35 |
| 117 } // namespace installer | 36 } // namespace installer |
| 118 | |
| 119 #endif // GOOGLE_CHROME_BUILD | |
| OLD | NEW |