Chromium Code Reviews| Index: chrome/installer/setup/app_launcher_installer.cc |
| diff --git a/chrome/installer/setup/app_launcher_installer.cc b/chrome/installer/setup/app_launcher_installer.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4ca4c48f65051f8f85fc2a54437d6638c69103ec |
| --- /dev/null |
| +++ b/chrome/installer/setup/app_launcher_installer.cc |
| @@ -0,0 +1,111 @@ |
| +// Copyright (c) 2014 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. |
| + |
| +#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/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" |
| + |
| +#include "installer_util_strings.h" // NOLINT |
| + |
| +using base::Version; |
| + |
| +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 kLegacyCmdQuickEnableApplicationHost[] = |
| + L"quick-enable-application-host"; |
| + |
| +base::string16 GetAppLauncherDisplayName() { |
| + return installer::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 |
| + |
| +// static |
| +void AppLauncherInstaller::AddAppLauncherVersionKeyWorkItems( |
| + HKEY root, |
| + const Version& new_version, |
| + bool add_language_identifier, |
| + WorkItemList* list) { |
| + const UpdatingAppRegistrationData |
|
grt (UTC plus 2)
2014/12/18 19:27:36
UpdatingAppRegistrationData should never be used f
huangs
2015/01/05 06:01:12
Wrapping the whole thing with #if defined(GOOGLE_C
|
| + app_launcher_reg_data(installer::kAppLauncherGuid); |
| + installer::AddVersionKeyWorkItems(root, |
| + app_launcher_reg_data.GetVersionKey(), |
| + GetAppLauncherDisplayName(), |
| + new_version, |
| + add_language_identifier, |
| + list); |
| +} |
| + |
| +// static |
| +void AppLauncherInstaller::OnUninstall(HKEY reg_root) { |
| + const UpdatingAppRegistrationData |
| + app_launcher_reg_data(installer::kAppLauncherGuid); |
| + InstallUtil::DeleteRegistryKey( |
| + reg_root, app_launcher_reg_data.GetVersionKey(), WorkItem::kWow64Default); |
| + // We skip deleting the ancient app_host.exe. |
|
grt (UTC plus 2)
2014/12/18 19:27:36
how about adding a WorkItem to delete old app_host
huangs
2015/01/05 06:01:12
Done.
|
| +} |
| + |
| +// static |
| +void AppLauncherInstaller::RemoveLegacyAppCommandsWorkItems( |
| + const InstallerState& installer_state, |
| + WorkItemList* list) { |
| + DCHECK(list); |
| + const Products& products = installer_state.products(); |
| + |
| + for (Products::const_iterator it = products.begin(); it < products.end(); |
| + ++it) { |
| + const Product& p = **it; |
| + if (p.is_chrome()) { |
| + // Remove "install-extension" command from App Launcher. |
|
grt (UTC plus 2)
2014/12/18 19:27:36
install-extension -> install-application
grt (UTC plus 2)
2014/12/18 19:27:36
the installer shouldn't reach into the app launche
huangs
2015/01/05 06:01:12
Done.
huangs
2015/01/05 06:01:12
Done.
|
| + const UpdatingAppRegistrationData |
| + app_launcher_reg_data(installer::kAppLauncherGuid); |
| + AddLegacyAppCommandRemovalItem(installer_state, app_launcher_reg_data, |
| + kLegacyCmdInstallApp, list); |
| + // Remove "install-application" command from Chrome. |
|
grt (UTC plus 2)
2014/12/18 19:27:36
install-application -> install-extension
huangs
2015/01/05 06:01:12
Done.
|
| + const AppRegistrationData& chrome_reg_data = |
| + p.distribution()->GetAppRegistrationData(); |
| + AddLegacyAppCommandRemovalItem(installer_state, chrome_reg_data, |
| + kLegacyCmdInstallExtension, list); |
| + } |
| + if (p.is_chrome_binaries()) { |
| + // Remove "quick-enable-application-host" command from Binaries. |
| + const AppRegistrationData& binaries_reg_data = |
| + p.distribution()->GetAppRegistrationData(); |
| + AddLegacyAppCommandRemovalItem(installer_state, binaries_reg_data, |
| + kLegacyCmdQuickEnableApplicationHost, list); |
| + } |
| + } |
| +} |
| + |
| +} // namespace installer |