summaryrefslogtreecommitdiffstats
path: root/chrome/installer/setup/app_launcher_installer.cc
blob: 46670faa2d0fdbe3f8a8ef96f424e1ff2dffc629 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#if defined(GOOGLE_CHROME_BUILD)

#include "chrome/installer/setup/app_launcher_installer.h"

#include "base/strings/string16.h"
#include "base/version.h"
#include "chrome/installer/setup/install_worker.h"
#include "chrome/installer/setup/setup_util.h"
#include "chrome/installer/util/google_update_constants.h"
#include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/installer_state.h"
#include "chrome/installer/util/installer_util_strings.h"
#include "chrome/installer/util/l10n_string_util.h"
#include "chrome/installer/util/product.h"
#include "chrome/installer/util/updating_app_registration_data.h"
#include "chrome/installer/util/work_item.h"
#include "chrome/installer/util/work_item_list.h"

namespace installer {

namespace {

// The legacy command ids for installing an application or extension. These are
// only here so they can be removed from the registry.
const wchar_t kLegacyCmdInstallApp[] = L"install-application";
const wchar_t kLegacyCmdInstallExtension[] = L"install-extension";
const wchar_t kLegacyCmdQueryEULAAcceptance[] = L"query-eula-acceptance";
const wchar_t kLegacyCmdQuickEnableApplicationHost[] =
    L"quick-enable-application-host";

// The legacy app_host.exe executable, which should be eradicated.
const wchar_t kLegacyChromeAppHostExe[] = L"app_host.exe";

base::string16 GetAppLauncherDisplayName() {
  return GetLocalizedString(IDS_PRODUCT_APP_LAUNCHER_NAME_BASE);
}

void AddLegacyAppCommandRemovalItem(const InstallerState& installer_state,
                                    const AppRegistrationData& reg_data,
                                    const wchar_t* name,
                                    WorkItemList* list) {
  // Ignore failures since this is a clean-up operation and shouldn't block
  // install or update.
  list->AddDeleteRegKeyWorkItem(
                      installer_state.root_key(),
                      GetRegistrationDataCommandKey(reg_data, name),
                      KEY_WOW64_32KEY)
      ->set_ignore_failure(true);
}

}  // namespace

void AddAppLauncherVersionKeyWorkItems(HKEY root,
                                       const base::Version& new_version,
                                       bool add_language_identifier,
                                       WorkItemList* list) {
  DCHECK(!InstallUtil::IsChromeSxSProcess());
  const UpdatingAppRegistrationData app_launcher_reg_data(kAppLauncherGuid);
  AddVersionKeyWorkItems(root,
                         app_launcher_reg_data.GetVersionKey(),
                         GetAppLauncherDisplayName(),
                         new_version,
                         add_language_identifier,
                         list);
}

void RemoveAppLauncherVersionKey(HKEY reg_root) {
  DCHECK(!InstallUtil::IsChromeSxSProcess());
  const UpdatingAppRegistrationData app_launcher_reg_data(kAppLauncherGuid);
  InstallUtil::DeleteRegistryKey(
      reg_root, app_launcher_reg_data.GetVersionKey(), KEY_WOW64_32KEY);
}

void AddRemoveLegacyAppHostExeWorkItems(const base::FilePath& target_path,
                                        const base::FilePath& temp_path,
                                        WorkItemList* list) {
  DCHECK(!InstallUtil::IsChromeSxSProcess());
  list->AddDeleteTreeWorkItem(
      target_path.Append(kLegacyChromeAppHostExe),
      temp_path)->set_ignore_failure(true);
}

void AddRemoveLegacyAppCommandsWorkItems(const InstallerState& installer_state,
                                         WorkItemList* list) {
  DCHECK(!InstallUtil::IsChromeSxSProcess());
  DCHECK(list);
  for (const auto* p : installer_state.products()) {
    if (p->is_chrome()) {
      // Remove "install-application" command from App Launcher.
      const UpdatingAppRegistrationData app_launcher_reg_data(kAppLauncherGuid);
      AddLegacyAppCommandRemovalItem(installer_state, app_launcher_reg_data,
                                     kLegacyCmdInstallApp, list);

      // Remove "install-extension" command from Chrome.
      const AppRegistrationData& chrome_reg_data =
          p->distribution()->GetAppRegistrationData();
      AddLegacyAppCommandRemovalItem(installer_state, chrome_reg_data,
                                     kLegacyCmdInstallExtension, list);
    }
    if (p->is_chrome_binaries()) {
      const AppRegistrationData& binaries_reg_data =
          p->distribution()->GetAppRegistrationData();
      // Remove "query-eula-acceptance" command from Binaries.
      AddLegacyAppCommandRemovalItem(installer_state, binaries_reg_data,
                                     kLegacyCmdQueryEULAAcceptance, list);
      // Remove "quick-enable-application-host" command from Binaries.
      AddLegacyAppCommandRemovalItem(installer_state, binaries_reg_data,
          kLegacyCmdQuickEnableApplicationHost, list);
    }
  }
}

}  // namespace installer

#endif  // GOOGLE_CHROME_BUILD