Do not announce robot account token before account ID is available
[chromium-blink-merge.git] / chrome / installer / setup / app_launcher_installer.cc
blob3c30aaf7798996582da11f693efd50ced2e2fd82
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
3 // found in the LICENSE file.
5 #if defined(GOOGLE_CHROME_BUILD)
7 #include "chrome/installer/setup/app_launcher_installer.h"
9 #include "base/strings/string16.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"
15 #include "chrome/installer/util/installer_state.h"
16 #include "chrome/installer/util/l10n_string_util.h"
17 #include "chrome/installer/util/product.h"
18 #include "chrome/installer/util/updating_app_registration_data.h"
19 #include "chrome/installer/util/work_item.h"
20 #include "chrome/installer/util/work_item_list.h"
22 #include "installer_util_strings.h" // NOLINT
24 namespace installer {
26 namespace {
28 // The legacy command ids for installing an application or extension. These are
29 // only here so they can be removed from the registry.
30 const wchar_t kLegacyCmdInstallApp[] = L"install-application";
31 const wchar_t kLegacyCmdInstallExtension[] = L"install-extension";
32 const wchar_t kLegacyCmdQueryEULAAcceptance[] = L"query-eula-acceptance";
33 const wchar_t kLegacyCmdQuickEnableApplicationHost[] =
34 L"quick-enable-application-host";
36 // The legacy app_host.exe executable, which should be eradicated.
37 const wchar_t kLegacyChromeAppHostExe[] = L"app_host.exe";
39 base::string16 GetAppLauncherDisplayName() {
40 return GetLocalizedString(IDS_PRODUCT_APP_LAUNCHER_NAME_BASE);
43 void AddLegacyAppCommandRemovalItem(const InstallerState& installer_state,
44 const AppRegistrationData& reg_data,
45 const wchar_t* name,
46 WorkItemList* list) {
47 // Ignore failures since this is a clean-up operation and shouldn't block
48 // install or update.
49 list->AddDeleteRegKeyWorkItem(
50 installer_state.root_key(),
51 GetRegistrationDataCommandKey(reg_data, name),
52 KEY_WOW64_32KEY)
53 ->set_ignore_failure(true);
56 } // namespace
58 void AddAppLauncherVersionKeyWorkItems(HKEY root,
59 const base::Version& new_version,
60 bool add_language_identifier,
61 WorkItemList* list) {
62 DCHECK(!InstallUtil::IsChromeSxSProcess());
63 const UpdatingAppRegistrationData app_launcher_reg_data(kAppLauncherGuid);
64 AddVersionKeyWorkItems(root,
65 app_launcher_reg_data.GetVersionKey(),
66 GetAppLauncherDisplayName(),
67 new_version,
68 add_language_identifier,
69 list);
72 void RemoveAppLauncherVersionKey(HKEY reg_root) {
73 DCHECK(!InstallUtil::IsChromeSxSProcess());
74 const UpdatingAppRegistrationData app_launcher_reg_data(kAppLauncherGuid);
75 InstallUtil::DeleteRegistryKey(
76 reg_root, app_launcher_reg_data.GetVersionKey(), KEY_WOW64_32KEY);
79 void AddRemoveLegacyAppHostExeWorkItems(const base::FilePath& target_path,
80 const base::FilePath& temp_path,
81 WorkItemList* list) {
82 DCHECK(!InstallUtil::IsChromeSxSProcess());
83 list->AddDeleteTreeWorkItem(
84 target_path.Append(kLegacyChromeAppHostExe),
85 temp_path)->set_ignore_failure(true);
88 void AddRemoveLegacyAppCommandsWorkItems(const InstallerState& installer_state,
89 WorkItemList* list) {
90 DCHECK(!InstallUtil::IsChromeSxSProcess());
91 DCHECK(list);
92 for (const auto* p : installer_state.products()) {
93 if (p->is_chrome()) {
94 // Remove "install-application" command from App Launcher.
95 const UpdatingAppRegistrationData app_launcher_reg_data(kAppLauncherGuid);
96 AddLegacyAppCommandRemovalItem(installer_state, app_launcher_reg_data,
97 kLegacyCmdInstallApp, list);
99 // Remove "install-extension" command from Chrome.
100 const AppRegistrationData& chrome_reg_data =
101 p->distribution()->GetAppRegistrationData();
102 AddLegacyAppCommandRemovalItem(installer_state, chrome_reg_data,
103 kLegacyCmdInstallExtension, list);
105 if (p->is_chrome_binaries()) {
106 const AppRegistrationData& binaries_reg_data =
107 p->distribution()->GetAppRegistrationData();
108 // Remove "query-eula-acceptance" command from Binaries.
109 AddLegacyAppCommandRemovalItem(installer_state, binaries_reg_data,
110 kLegacyCmdQueryEULAAcceptance, list);
111 // Remove "quick-enable-application-host" command from Binaries.
112 AddLegacyAppCommandRemovalItem(installer_state, binaries_reg_data,
113 kLegacyCmdQuickEnableApplicationHost, list);
118 } // namespace installer
120 #endif // GOOGLE_CHROME_BUILD