diff options
Diffstat (limited to 'chrome/installer/util')
29 files changed, 1048 insertions, 123 deletions
diff --git a/chrome/installer/util/browser_distribution.cc b/chrome/installer/util/browser_distribution.cc index f958db8..b39ff59 100644 --- a/chrome/installer/util/browser_distribution.cc +++ b/chrome/installer/util/browser_distribution.cc @@ -17,10 +17,11 @@ #include "base/win/registry.h" #include "base/win/windows_version.h" #include "chrome/common/env_vars.h" +#include "chrome/installer/util/chrome_app_host_distribution.h" #include "chrome/installer/util/chrome_frame_distribution.h" #include "chrome/installer/util/chromium_binaries_distribution.h" -#include "chrome/installer/util/google_chrome_distribution.h" #include "chrome/installer/util/google_chrome_binaries_distribution.h" +#include "chrome/installer/util/google_chrome_distribution.h" #include "chrome/installer/util/google_chrome_sxs_distribution.h" #include "chrome/installer/util/install_util.h" #include "chrome/installer/util/l10n_string_util.h" @@ -44,6 +45,7 @@ const wchar_t kICommandExecuteImplUuid[] = BrowserDistribution* g_browser_distribution = NULL; BrowserDistribution* g_chrome_frame_distribution = NULL; BrowserDistribution* g_binaries_distribution = NULL; +BrowserDistribution* g_chrome_app_host_distribution = NULL; // Returns true if currently running in npchrome_frame.dll bool IsChromeFrameModule() { @@ -54,6 +56,8 @@ bool IsChromeFrameModule() { } BrowserDistribution::Type GetCurrentDistributionType() { + // TODO(erikwright): If the app host is installed, but not Chrome, perhaps + // this should return CHROME_APP_HOST. static BrowserDistribution::Type type = (MasterPreferences::ForCurrentProcess().install_chrome_frame() || IsChromeFrameModule()) ? @@ -64,16 +68,6 @@ BrowserDistribution::Type GetCurrentDistributionType() { } // end namespace -// CHROME_BINARIES represents the binaries shared by multi-install products and -// is not a product in and of itself, so it is not present in this collection. -const BrowserDistribution::Type BrowserDistribution::kProductTypes[] = { - BrowserDistribution::CHROME_BROWSER, - BrowserDistribution::CHROME_FRAME, -}; - -const size_t BrowserDistribution::kNumProductTypes = - arraysize(BrowserDistribution::kProductTypes); - BrowserDistribution::BrowserDistribution() : type_(CHROME_BROWSER) { } @@ -126,6 +120,11 @@ BrowserDistribution* BrowserDistribution::GetSpecificDistribution( &g_chrome_frame_distribution); break; + case CHROME_APP_HOST: + dist = GetOrCreateBrowserDistribution<ChromeAppHostDistribution>( + &g_chrome_app_host_distribution); + break; + default: DCHECK_EQ(CHROME_BINARIES, type); #if defined(GOOGLE_CHROME_BUILD) diff --git a/chrome/installer/util/browser_distribution.h b/chrome/installer/util/browser_distribution.h index 6738037..4f609c9 100644 --- a/chrome/installer/util/browser_distribution.h +++ b/chrome/installer/util/browser_distribution.h @@ -29,6 +29,7 @@ class BrowserDistribution { CHROME_BROWSER, CHROME_FRAME, CHROME_BINARIES, + CHROME_APP_HOST, NUM_TYPES }; @@ -46,12 +47,6 @@ class BrowserDistribution { // experiment but does not participate. }; - // An array of the Types representing products; - static const Type kProductTypes[]; - - // The number of elements in the array |kProductTypes|. - static const size_t kNumProductTypes; - virtual ~BrowserDistribution() {} static BrowserDistribution* GetDistribution(); diff --git a/chrome/installer/util/browser_distribution_unittest.cc b/chrome/installer/util/browser_distribution_unittest.cc deleted file mode 100644 index d0e1059..0000000 --- a/chrome/installer/util/browser_distribution_unittest.cc +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2012 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. -// -// Unit tests for BrowserDistribution class. - -#include "chrome/installer/util/browser_distribution.h" -#include "chrome/installer/util/shell_util.h" -#include "testing/gtest/include/gtest/gtest.h" - -// The distribution strings should not be empty. The unit tests are not linking -// with the chrome resources so we cannot test official build. -TEST(BrowserDistributionTest, StringsTest) { - for (size_t i = 0; i < BrowserDistribution::kNumProductTypes; ++i) { - BrowserDistribution* dist = - BrowserDistribution::GetSpecificDistribution( - BrowserDistribution::kProductTypes[i]); - ASSERT_TRUE(dist != NULL); - string16 name = dist->GetBaseAppName(); - EXPECT_FALSE(name.empty()); - string16 desc = dist->GetAppDescription(); - EXPECT_FALSE(desc.empty()); - string16 alt_name = dist->GetAlternateApplicationName(); - EXPECT_FALSE(alt_name.empty()); - } -} - -// The shortcut strings obtained by the shell utility functions should not -// be empty or be the same. -TEST(BrowserDistributionTest, AlternateAndNormalShortcutName) { - string16 normal_name; - string16 alternate_name; - string16 appended_name_one; - string16 appended_name_two; - BrowserDistribution* dist = BrowserDistribution::GetDistribution(); - EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist, false, L"", - &normal_name)); - EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist, true, L"", - &alternate_name)); - EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist, true, L"Sparky", - &appended_name_one)); - EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist, true, L"Sparkles", - &appended_name_two)); - EXPECT_NE(normal_name, alternate_name); - EXPECT_NE(appended_name_one, appended_name_two); - EXPECT_FALSE(normal_name.empty()); - EXPECT_FALSE(alternate_name.empty()); - EXPECT_FALSE(appended_name_one.empty()); - EXPECT_FALSE(appended_name_two.empty()); -} diff --git a/chrome/installer/util/channel_info.cc b/chrome/installer/util/channel_info.cc index 24c5199..a67e7fb 100644 --- a/chrome/installer/util/channel_info.cc +++ b/chrome/installer/util/channel_info.cc @@ -15,6 +15,7 @@ namespace { const wchar_t kModChrome[] = L"-chrome"; const wchar_t kModChromeFrame[] = L"-chromeframe"; +const wchar_t kModAppHost[] = L"-apphost"; const wchar_t kModMultiInstall[] = L"-multi"; const wchar_t kModReadyMode[] = L"-readymode"; const wchar_t kModStage[] = L"-stage:"; @@ -31,6 +32,7 @@ const wchar_t* const kModifiers[] = { kModMultiInstall, kModChrome, kModChromeFrame, + kModAppHost, kModReadyMode, kSfxMultiFail, kSfxFull @@ -41,6 +43,7 @@ enum ModifierIndex { MOD_MULTI_INSTALL, MOD_CHROME, MOD_CHROME_FRAME, + MOD_APP_HOST, MOD_READY_MODE, SFX_MULTI_FAIL, SFX_FULL, @@ -193,6 +196,14 @@ bool ChannelInfo::SetChromeFrame(bool value) { return SetModifier(MOD_CHROME_FRAME, value, &value_); } +bool ChannelInfo::IsAppHost() const { + return HasModifier(MOD_APP_HOST, value_); +} + +bool ChannelInfo::SetAppHost(bool value) { + return SetModifier(MOD_APP_HOST, value, &value_); +} + bool ChannelInfo::IsMultiInstall() const { return HasModifier(MOD_MULTI_INSTALL, value_); } diff --git a/chrome/installer/util/channel_info.h b/chrome/installer/util/channel_info.h index 9ceae32..605b87a 100644 --- a/chrome/installer/util/channel_info.h +++ b/chrome/installer/util/channel_info.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -57,6 +57,13 @@ class ChannelInfo { // modified. bool SetChromeFrame(bool value); + // Returns true if the -apphost modifier is present in the value. + bool IsAppHost() const; + + // Adds or removes the -apphost modifier, returning true if the value is + // modified. + bool SetAppHost(bool value); + // Returns true if the -multi modifier is present in the value. bool IsMultiInstall() const; diff --git a/chrome/installer/util/chrome_app_host_distribution.cc b/chrome/installer/util/chrome_app_host_distribution.cc new file mode 100644 index 0000000..4eef303 --- /dev/null +++ b/chrome/installer/util/chrome_app_host_distribution.cc @@ -0,0 +1,148 @@ +// Copyright (c) 2012 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. +// +// This file defines a specific implementation of BrowserDistribution class for +// Chrome App Host. It overrides the bare minimum of methods necessary to get a +// Chrome App Host installer that does not interact with Google Chrome or +// Chromium installations. + +#include "chrome/installer/util/chrome_app_host_distribution.h" + +#include "base/string_util.h" +#include "chrome/common/net/test_server_locations.h" +#include "chrome/installer/util/channel_info.h" +#include "chrome/installer/util/google_update_constants.h" +#include "chrome/installer/util/google_update_settings.h" +#include "chrome/installer/util/helper.h" +#include "chrome/installer/util/install_util.h" +#include "chrome/installer/util/l10n_string_util.h" + +#include "installer_util_strings.h" // NOLINT + +namespace { +const wchar_t kChromeAppHostGuid[] = L"{FDA71E6F-AC4C-4a00-8B70-9958A68906BF}"; +} + +ChromeAppHostDistribution::ChromeAppHostDistribution() + : BrowserDistribution(CHROME_APP_HOST) { +} + +string16 ChromeAppHostDistribution::GetAppGuid() { + return kChromeAppHostGuid; +} + +string16 ChromeAppHostDistribution::GetBaseAppName() { + return L"Google Chrome App Host"; +} + +string16 ChromeAppHostDistribution::GetAppShortCutName() { + const string16& product_name = + installer::GetLocalizedString(IDS_PRODUCT_APP_HOST_NAME_BASE); + return product_name; +} + +string16 ChromeAppHostDistribution::GetAlternateApplicationName() { + const string16& product_name = + installer::GetLocalizedString(IDS_PRODUCT_APP_HOST_NAME_BASE); + return product_name; +} + +string16 ChromeAppHostDistribution::GetInstallSubDir() { + return BrowserDistribution::GetSpecificDistribution( + BrowserDistribution::CHROME_BINARIES)->GetInstallSubDir(); +} + +string16 ChromeAppHostDistribution::GetPublisherName() { + const string16& publisher_name = + installer::GetLocalizedString(IDS_ABOUT_VERSION_COMPANY_NAME_BASE); + return publisher_name; +} + +string16 ChromeAppHostDistribution::GetAppDescription() { + NOTREACHED() << "This should never be accessed due to no start-menu/task-bar " + << "shortcuts."; + return L"A standalone platform for Chrome apps."; +} + +string16 ChromeAppHostDistribution::GetLongAppDescription() { + NOTREACHED() << "This should never be accessed as Chrome App Host is not a " + << "default browser option."; + return L"A standalone platform for Chrome apps."; +} + +std::string ChromeAppHostDistribution::GetSafeBrowsingName() { + return "googlechromeapphost"; +} + +string16 ChromeAppHostDistribution::GetStateKey() { + string16 key(google_update::kRegPathClientState); + key.append(L"\\"); + key.append(kChromeAppHostGuid); + return key; +} + +string16 ChromeAppHostDistribution::GetStateMediumKey() { + string16 key(google_update::kRegPathClientStateMedium); + key.append(L"\\"); + key.append(kChromeAppHostGuid); + return key; +} + +string16 ChromeAppHostDistribution::GetStatsServerURL() { + return L"https://clients4.google.com/firefox/metrics/collect"; +} + +std::string ChromeAppHostDistribution::GetNetworkStatsServer() const { + return chrome_common_net::kEchoTestServerLocation; +} + +std::string ChromeAppHostDistribution::GetHttpPipeliningTestServer() const { + return chrome_common_net::kPipelineTestServerBaseUrl; +} + +string16 ChromeAppHostDistribution::GetUninstallLinkName() { + NOTREACHED() << "This should never be accessed as Chrome App Host has no " + << "uninstall entry."; + return L"Uninstall Chrome App Host"; +} + +string16 ChromeAppHostDistribution::GetUninstallRegPath() { + NOTREACHED() << "This should never be accessed as Chrome App Host has no " + << "uninstall entry."; + return L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + L"Google Chrome App Host"; +} + +string16 ChromeAppHostDistribution::GetVersionKey() { + string16 key(google_update::kRegPathClients); + key.append(L"\\"); + key.append(kChromeAppHostGuid); + return key; +} + +bool ChromeAppHostDistribution::CanSetAsDefault() { + return false; +} + +bool ChromeAppHostDistribution::CanCreateDesktopShortcuts() { + return false; +} + +bool ChromeAppHostDistribution::GetDelegateExecuteHandlerData( + string16* handler_class_uuid, + string16* type_lib_uuid, + string16* type_lib_version, + string16* interface_uuid) { + return false; +} + +void ChromeAppHostDistribution::UpdateInstallStatus(bool system_install, + installer::ArchiveType archive_type, + installer::InstallStatus install_status) { +#if defined(GOOGLE_CHROME_BUILD) + GoogleUpdateSettings::UpdateInstallStatus(system_install, + archive_type, InstallUtil::GetInstallReturnCode(install_status), + kChromeAppHostGuid); +#endif +} diff --git a/chrome/installer/util/chrome_app_host_distribution.h b/chrome/installer/util/chrome_app_host_distribution.h new file mode 100644 index 0000000..1d5ea40 --- /dev/null +++ b/chrome/installer/util/chrome_app_host_distribution.h @@ -0,0 +1,70 @@ +// Copyright (c) 2012 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. +// +// This file extends the browser distribution with a specific implementation +// for Chrome AppHost. + +#ifndef CHROME_INSTALLER_UTIL_CHROME_APP_HOST_DISTRIBUTION_H_ +#define CHROME_INSTALLER_UTIL_CHROME_APP_HOST_DISTRIBUTION_H_ + +#include "chrome/installer/util/browser_distribution.h" +#include "chrome/installer/util/util_constants.h" + +class ChromeAppHostDistribution : public BrowserDistribution { + public: + virtual string16 GetAppGuid() OVERRIDE; + + virtual string16 GetBaseAppName() OVERRIDE; + + virtual string16 GetAppShortCutName() OVERRIDE; + + virtual string16 GetAlternateApplicationName() OVERRIDE; + + virtual string16 GetInstallSubDir() OVERRIDE; + + virtual string16 GetPublisherName() OVERRIDE; + + virtual string16 GetAppDescription() OVERRIDE; + + virtual string16 GetLongAppDescription() OVERRIDE; + + virtual std::string GetSafeBrowsingName() OVERRIDE; + + virtual string16 GetStateKey() OVERRIDE; + + virtual string16 GetStateMediumKey() OVERRIDE; + + virtual string16 GetStatsServerURL() OVERRIDE; + + virtual std::string GetNetworkStatsServer() const OVERRIDE; + + virtual std::string GetHttpPipeliningTestServer() const OVERRIDE; + + virtual string16 GetUninstallLinkName() OVERRIDE; + + virtual string16 GetUninstallRegPath() OVERRIDE; + + virtual string16 GetVersionKey() OVERRIDE; + + virtual bool CanSetAsDefault() OVERRIDE; + + virtual bool CanCreateDesktopShortcuts() OVERRIDE; + + virtual bool GetDelegateExecuteHandlerData(string16* handler_class_uuid, + string16* type_lib_uuid, + string16* type_lib_version, + string16* interface_uuid) OVERRIDE; + + virtual void UpdateInstallStatus(bool system_install, + installer::ArchiveType archive_type, + installer::InstallStatus install_status) OVERRIDE; + + protected: + friend class BrowserDistribution; + + // Disallow construction from non-friends. + ChromeAppHostDistribution(); +}; + +#endif // CHROME_INSTALLER_UTIL_CHROME_APP_HOST_DISTRIBUTION_H_ diff --git a/chrome/installer/util/chrome_app_host_operations.cc b/chrome/installer/util/chrome_app_host_operations.cc new file mode 100644 index 0000000..07427f5 --- /dev/null +++ b/chrome/installer/util/chrome_app_host_operations.cc @@ -0,0 +1,100 @@ +// Copyright (c) 2012 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/util/chrome_app_host_operations.h" + +#include "base/command_line.h" +#include "base/file_path.h" +#include "base/logging.h" +#include "chrome/installer/util/browser_distribution.h" +#include "chrome/installer/util/channel_info.h" +#include "chrome/installer/util/helper.h" +#include "chrome/installer/util/master_preferences.h" +#include "chrome/installer/util/master_preferences_constants.h" +#include "chrome/installer/util/util_constants.h" + +namespace installer { + +void ChromeAppHostOperations::ReadOptions( + const MasterPreferences& prefs, + std::set<std::wstring>* options) const { + DCHECK(options); + + bool pref_value; + if (prefs.GetBool(master_preferences::kMultiInstall, &pref_value) && + pref_value) { + options->insert(kOptionMultiInstall); + } +} + +void ChromeAppHostOperations::ReadOptions( + const CommandLine& uninstall_command, + std::set<std::wstring>* options) const { + DCHECK(options); + + if (uninstall_command.HasSwitch(switches::kMultiInstall)) + options->insert(kOptionMultiInstall); +} + +void ChromeAppHostOperations::AddKeyFiles( + const std::set<std::wstring>& options, + std::vector<FilePath>* key_files) const { +} + +void ChromeAppHostOperations::AddComDllList( + const std::set<std::wstring>& options, + std::vector<FilePath>* com_dll_list) const { +} + +void ChromeAppHostOperations::AppendProductFlags( + const std::set<std::wstring>& options, + CommandLine* cmd_line) const { + DCHECK(cmd_line); + bool is_multi_install = options.find(kOptionMultiInstall) != options.end(); + + // Non-multi-install not supported for the app host. + DCHECK(is_multi_install); + + // Add --multi-install if it isn't already there. + if (is_multi_install && !cmd_line->HasSwitch(switches::kMultiInstall)) + cmd_line->AppendSwitch(switches::kMultiInstall); + + // --app-host is always needed. + cmd_line->AppendSwitch(switches::kChromeAppHost); +} + +void ChromeAppHostOperations::AppendRenameFlags( + const std::set<std::wstring>& options, + CommandLine* cmd_line) const { + DCHECK(cmd_line); + bool is_multi_install = options.find(kOptionMultiInstall) != options.end(); + + // Non-multi-install not supported for the app host. + DCHECK(is_multi_install); + + // Add --multi-install if it isn't already there. + if (is_multi_install && !cmd_line->HasSwitch(switches::kMultiInstall)) + cmd_line->AppendSwitch(switches::kMultiInstall); +} + +bool ChromeAppHostOperations::SetChannelFlags( + const std::set<std::wstring>& options, + bool set, + ChannelInfo* channel_info) const { +#if defined(GOOGLE_CHROME_BUILD) + DCHECK(channel_info); + bool modified = channel_info->SetAppHost(set); + + return modified; +#else + return false; +#endif +} + +bool ChromeAppHostOperations::ShouldCreateUninstallEntry( + const std::set<std::wstring>& options) const { + return false; +} + +} // namespace installer diff --git a/chrome/installer/util/chrome_app_host_operations.h b/chrome/installer/util/chrome_app_host_operations.h new file mode 100644 index 0000000..bbf0589 --- /dev/null +++ b/chrome/installer/util/chrome_app_host_operations.h @@ -0,0 +1,59 @@ +// Copyright (c) 2012 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. + +#ifndef CHROME_INSTALLER_UTIL_CHROME_APP_HOST_OPERATIONS_H_ +#define CHROME_INSTALLER_UTIL_CHROME_APP_HOST_OPERATIONS_H_ + +#include <set> +#include <string> +#include <vector> + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "base/file_path.h" +#include "chrome/installer/util/product_operations.h" + +namespace installer { + +// Operations specific to Chrome App Host; see ProductOperations for general +// info. +class ChromeAppHostOperations : public ProductOperations { + public: + ChromeAppHostOperations() {} + + virtual void ReadOptions(const MasterPreferences& prefs, + std::set<std::wstring>* options) const OVERRIDE; + + virtual void ReadOptions(const CommandLine& uninstall_command, + std::set<std::wstring>* options) const OVERRIDE; + + virtual void AddKeyFiles(const std::set<std::wstring>& options, + std::vector<FilePath>* key_files) const OVERRIDE; + + virtual void AddComDllList( + const std::set<std::wstring>& options, + std::vector<FilePath>* com_dll_list) const OVERRIDE; + + virtual void AppendProductFlags( + const std::set<std::wstring>& options, + CommandLine* cmd_line) const OVERRIDE; + + virtual void AppendRenameFlags( + const std::set<std::wstring>& options, + CommandLine* cmd_line) const OVERRIDE; + + virtual bool SetChannelFlags(const std::set<std::wstring>& options, + bool set, + ChannelInfo* channel_info) const OVERRIDE; + + virtual bool ShouldCreateUninstallEntry( + const std::set<std::wstring>& options) const OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(ChromeAppHostOperations); +}; + +} // namespace installer + +#endif // CHROME_INSTALLER_UTIL_CHROME_APP_HOST_OPERATIONS_H_ diff --git a/chrome/installer/util/chrome_binaries_operations.cc b/chrome/installer/util/chrome_binaries_operations.cc new file mode 100644 index 0000000..326223a --- /dev/null +++ b/chrome/installer/util/chrome_binaries_operations.cc @@ -0,0 +1,88 @@ +// Copyright (c) 2012 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/util/chrome_binaries_operations.h" + +#include "base/command_line.h" +#include "base/file_path.h" +#include "base/logging.h" +#include "chrome/installer/util/channel_info.h" +#include "chrome/installer/util/helper.h" +#include "chrome/installer/util/master_preferences.h" +#include "chrome/installer/util/master_preferences_constants.h" +#include "chrome/installer/util/util_constants.h" + +namespace installer { + +void ChromeBinariesOperations::ReadOptions( + const MasterPreferences& prefs, + std::set<std::wstring>* options) const { + DCHECK(options); + + bool pref_value; + + if (prefs.GetBool(master_preferences::kMultiInstall, &pref_value) && + pref_value) { + options->insert(kOptionMultiInstall); + } +} + +void ChromeBinariesOperations::ReadOptions( + const CommandLine& uninstall_command, + std::set<std::wstring>* options) const { + DCHECK(options); + + if (uninstall_command.HasSwitch(switches::kMultiInstall)) + options->insert(kOptionMultiInstall); +} + +void ChromeBinariesOperations::AddKeyFiles( + const std::set<std::wstring>& options, + std::vector<FilePath>* key_files) const { + DCHECK(key_files); + key_files->push_back(FilePath(installer::kChromeDll)); +} + +void ChromeBinariesOperations::AddComDllList( + const std::set<std::wstring>& options, + std::vector<FilePath>* com_dll_list) const { +} + +void ChromeBinariesOperations::AppendProductFlags( + const std::set<std::wstring>& options, + CommandLine* cmd_line) const { + DCHECK(cmd_line); + + if (options.find(kOptionMultiInstall) != options.end()) { + // Add --multi-install if it isn't already there. + if (!cmd_line->HasSwitch(switches::kMultiInstall)) + cmd_line->AppendSwitch(switches::kMultiInstall); + } +} + +void ChromeBinariesOperations::AppendRenameFlags( + const std::set<std::wstring>& options, + CommandLine* cmd_line) const { + DCHECK(cmd_line); + + // Add --multi-install if it isn't already there. + if (options.find(kOptionMultiInstall) != options.end() && + !cmd_line->HasSwitch(switches::kMultiInstall)) { + cmd_line->AppendSwitch(switches::kMultiInstall); + } +} + +bool ChromeBinariesOperations::SetChannelFlags( + const std::set<std::wstring>& options, + bool set, + ChannelInfo* channel_info) const { + return false; +} + +bool ChromeBinariesOperations::ShouldCreateUninstallEntry( + const std::set<std::wstring>& options) const { + return false; +} + +} // namespace installer diff --git a/chrome/installer/util/chrome_binaries_operations.h b/chrome/installer/util/chrome_binaries_operations.h new file mode 100644 index 0000000..a40ac41 --- /dev/null +++ b/chrome/installer/util/chrome_binaries_operations.h @@ -0,0 +1,58 @@ +// Copyright (c) 2012 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. + +#ifndef CHROME_INSTALLER_UTIL_CHROME_BINARIES_OPERATIONS_H_ +#define CHROME_INSTALLER_UTIL_CHROME_BINARIES_OPERATIONS_H_ + +#include <set> +#include <string> +#include <vector> + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "chrome/installer/util/product_operations.h" + +namespace installer { + +// Operations specific to the Chrome Binaries; see ProductOperations for general +// info. +class ChromeBinariesOperations : public ProductOperations { + public: + ChromeBinariesOperations() {} + + virtual void ReadOptions(const MasterPreferences& prefs, + std::set<std::wstring>* options) const OVERRIDE; + + virtual void ReadOptions(const CommandLine& uninstall_command, + std::set<std::wstring>* options) const OVERRIDE; + + virtual void AddKeyFiles(const std::set<std::wstring>& options, + std::vector<FilePath>* key_files) const OVERRIDE; + + virtual void AddComDllList( + const std::set<std::wstring>& options, + std::vector<FilePath>* com_dll_list) const OVERRIDE; + + virtual void AppendProductFlags( + const std::set<std::wstring>& options, + CommandLine* cmd_line) const OVERRIDE; + + virtual void AppendRenameFlags( + const std::set<std::wstring>& options, + CommandLine* cmd_line) const OVERRIDE; + + virtual bool SetChannelFlags(const std::set<std::wstring>& options, + bool set, + ChannelInfo* channel_info) const OVERRIDE; + + virtual bool ShouldCreateUninstallEntry( + const std::set<std::wstring>& options) const OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(ChromeBinariesOperations); +}; + +} // namespace installer + +#endif // CHROME_INSTALLER_UTIL_CHROME_BINARIES_OPERATIONS_H_ diff --git a/chrome/installer/util/chrome_frame_operations.cc b/chrome/installer/util/chrome_frame_operations.cc index a1a46ee..ae790ab 100644 --- a/chrome/installer/util/chrome_frame_operations.cc +++ b/chrome/installer/util/chrome_frame_operations.cc @@ -86,7 +86,6 @@ void ChromeFrameOperations::AddComDllList( const std::set<std::wstring>& options, std::vector<FilePath>* com_dll_list) const { DCHECK(com_dll_list); - std::vector<FilePath> dll_list; com_dll_list->push_back(FilePath(installer::kChromeFrameDll)); } diff --git a/chrome/installer/util/chromium_binaries_distribution.cc b/chrome/installer/util/chromium_binaries_distribution.cc index e12f56b..e2d23e9 100644 --- a/chrome/installer/util/chromium_binaries_distribution.cc +++ b/chrome/installer/util/chromium_binaries_distribution.cc @@ -90,7 +90,6 @@ string16 ChromiumBinariesDistribution::GetVersionKey() { } bool ChromiumBinariesDistribution::CanSetAsDefault() { - NOTREACHED(); return false; } diff --git a/chrome/installer/util/installation_state.cc b/chrome/installer/util/installation_state.cc index 6f12eb7..c8c8604 100644 --- a/chrome/installer/util/installation_state.cc +++ b/chrome/installer/util/installation_state.cc @@ -226,9 +226,12 @@ int InstallationState::IndexFromDistType(BrowserDistribution::Type type) { unexpected_chrome_frame_distribution_value_); COMPILE_ASSERT(BrowserDistribution::CHROME_BINARIES == CHROME_BINARIES_INDEX, unexpected_chrome_frame_distribution_value_); + COMPILE_ASSERT(BrowserDistribution::CHROME_APP_HOST == CHROME_APP_HOST_INDEX, + unexpected_chrome_frame_distribution_value_); DCHECK(type == BrowserDistribution::CHROME_BROWSER || type == BrowserDistribution::CHROME_FRAME || - type == BrowserDistribution::CHROME_BINARIES); + type == BrowserDistribution::CHROME_BINARIES || + type == BrowserDistribution::CHROME_APP_HOST); return type; } @@ -249,6 +252,11 @@ void InstallationState::Initialize() { BrowserDistribution::CHROME_BINARIES); user_products_[CHROME_BINARIES_INDEX].Initialize(false, distribution); system_products_[CHROME_BINARIES_INDEX].Initialize(true, distribution); + + distribution = BrowserDistribution::GetSpecificDistribution( + BrowserDistribution::CHROME_APP_HOST); + user_products_[CHROME_APP_HOST_INDEX].Initialize(false, distribution); + system_products_[CHROME_APP_HOST_INDEX].Initialize(true, distribution); } const ProductState* InstallationState::GetNonVersionedProductState( diff --git a/chrome/installer/util/installation_state.h b/chrome/installer/util/installation_state.h index 05cec80..ce72014 100644 --- a/chrome/installer/util/installation_state.h +++ b/chrome/installer/util/installation_state.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -153,6 +153,7 @@ class InstallationState { CHROME_BROWSER_INDEX, CHROME_FRAME_INDEX, CHROME_BINARIES_INDEX, + CHROME_APP_HOST_INDEX, NUM_PRODUCTS }; diff --git a/chrome/installer/util/installation_validator.cc b/chrome/installer/util/installation_validator.cc index 2d109fe..ccfa0a9 100644 --- a/chrome/installer/util/installation_validator.cc +++ b/chrome/installer/util/installation_validator.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -11,6 +11,7 @@ #include "base/logging.h" #include "base/version.h" +#include "chrome/common/chrome_switches.h" #include "chrome/installer/util/browser_distribution.h" #include "chrome/installer/util/helper.h" #include "chrome/installer/util/installation_state.h" @@ -112,6 +113,44 @@ bool InstallationValidator::ChromeFrameRules::UsageStatsAllowed( } BrowserDistribution::Type + InstallationValidator::ChromeAppHostRules::distribution_type() const { + return BrowserDistribution::CHROME_APP_HOST; +} + +void InstallationValidator::ChromeAppHostRules::AddUninstallSwitchExpectations( + const InstallationState& machine_state, + bool system_install, + const ProductState& product_state, + SwitchExpectations* expectations) const { + DCHECK(!system_install); + + // --chrome-app-host must be present. + expectations->push_back(std::make_pair(std::string(switches::kChromeAppHost), + true)); + // --chrome must not be present. + expectations->push_back(std::make_pair(std::string(switches::kChrome), + false)); + + // --chrome-frame must not be present. + expectations->push_back(std::make_pair(std::string(switches::kChromeFrame), + false)); +} + +void InstallationValidator::ChromeAppHostRules::AddRenameSwitchExpectations( + const InstallationState& machine_state, + bool system_install, + const ProductState& product_state, + SwitchExpectations* expectations) const { + // TODO(erikwright): I guess there will be none? +} + +bool InstallationValidator::ChromeAppHostRules::UsageStatsAllowed( + const ProductState& product_state) const { + // App Host doesn't manage usage stats. The Chrome Binaries will. + return false; +} + +BrowserDistribution::Type InstallationValidator::ChromeBinariesRules::distribution_type() const { return BrowserDistribution::CHROME_BINARIES; } @@ -149,9 +188,59 @@ const InstallationValidator::InstallationType CHROME_FRAME_SINGLE_CHROME_MULTI, CHROME_FRAME_MULTI, CHROME_FRAME_MULTI_CHROME_MULTI, - CHROME_FRAME_READY_MODE_CHROME_MULTI + CHROME_FRAME_READY_MODE_CHROME_MULTI, + CHROME_APP_HOST, + CHROME_APP_HOST_CHROME_FRAME_SINGLE, + CHROME_APP_HOST_CHROME_FRAME_SINGLE_CHROME_MULTI, + CHROME_APP_HOST_CHROME_FRAME_MULTI, + CHROME_APP_HOST_CHROME_FRAME_MULTI_CHROME_MULTI, + CHROME_APP_HOST_CHROME_MULTI, + CHROME_APP_HOST_CHROME_MULTI_CHROME_FRAME_READY_MODE, }; +// Validates the "install-application" Google Update product command. +void InstallationValidator::ValidateInstallAppCommand( + const ProductContext& ctx, + const AppCommand& command, + bool* is_valid) { + DCHECK(is_valid); + + CommandLine the_command(CommandLine::FromString(command.command_line())); + + FilePath expected_path( + installer::GetChromeInstallPath(ctx.system_install, ctx.dist) + .Append(installer::kChromeAppHostExe)); + + if (!FilePath::CompareEqualIgnoreCase(expected_path.value(), + the_command.GetProgram().value())) { + *is_valid = false; + LOG(ERROR) << "install-application command's path is not " + << expected_path.value() << ": " + << the_command.GetProgram().value(); + } + + + SwitchExpectations expected; + + expected.push_back( + std::make_pair(std::string(::switches::kAppsInstallFromManifestURL), + true)); + + ValidateCommandExpectations(ctx, the_command, expected, "install application", + is_valid); + + if (!command.sends_pings()) { + *is_valid = false; + LOG(ERROR) << "install-application command is not configured to send " + << "pings."; + } + + if (!command.is_web_accessible()) { + *is_valid = false; + LOG(ERROR) << "install-application command is not web accessible."; + } +} + // Validates the "quick-enable-cf" Google Update product command. void InstallationValidator::ValidateQuickEnableCfCommand( const ProductContext& ctx, @@ -186,6 +275,48 @@ void InstallationValidator::ValidateQuickEnableCfCommand( } } +// Validates the "quick-enable-application-host" Google Update product command. +void InstallationValidator::ValidateQuickEnableApplicationHostCommand( + const ProductContext& ctx, + const AppCommand& command, + bool* is_valid) { + DCHECK(is_valid); + + CommandLine the_command(CommandLine::FromString(command.command_line())); + + ValidateSetupPath(ctx, + the_command.GetProgram(), + "quick enable application host", + is_valid); + + SwitchExpectations expected; + + expected.push_back( + std::make_pair(std::string(switches::kChromeAppHost), true)); + expected.push_back(std::make_pair(std::string(switches::kSystemLevel), + false)); + expected.push_back(std::make_pair(std::string(switches::kMultiInstall), + true)); + + ValidateCommandExpectations(ctx, + the_command, + expected, + "quick enable application host", + is_valid); + + if (!command.sends_pings()) { + *is_valid = false; + LOG(ERROR) << "Quick-enable-application-host command is not configured to " + << "send pings."; + } + + if (!command.is_web_accessible()) { + *is_valid = false; + LOG(ERROR) << "Quick-enable-application-host command is not web " + << "accessible."; + } +} + // Validates a product's set of Google Update product commands against a // collection of expectations. void InstallationValidator::ValidateAppCommandExpectations( @@ -232,18 +363,23 @@ void InstallationValidator::ValidateBinariesCommands( bool* is_valid) { DCHECK(is_valid); - // The quick-enable-cf command must be present if Chrome is installed either - // alone or with CF in ready-mode. + // The quick-enable-cf command must be present if Chrome Binaries are + // installed and Chrome Frame is not installed (or installed in ready mode). const ChannelInfo& channel = ctx.state.channel(); - const ProductState* chrome_state = ctx.machine_state.GetProductState( - ctx.system_install, BrowserDistribution::CHROME_BROWSER); + const ProductState* binaries_state = ctx.machine_state.GetProductState( + ctx.system_install, BrowserDistribution::CHROME_BINARIES); const ProductState* cf_state = ctx.machine_state.GetProductState( ctx.system_install, BrowserDistribution::CHROME_FRAME); CommandExpectations expectations; - if (chrome_state != NULL && (cf_state == NULL || channel.IsReadyMode())) - expectations[kCmdQuickEnableCf] = &ValidateQuickEnableCfCommand; + if (binaries_state != NULL) { + if (cf_state == NULL || channel.IsReadyMode()) + expectations[kCmdQuickEnableCf] = &ValidateQuickEnableCfCommand; + + expectations[kCmdQuickEnableApplicationHost] = + &ValidateQuickEnableApplicationHostCommand; + } ValidateAppCommandExpectations(ctx, expectations, is_valid); } @@ -310,8 +446,28 @@ void InstallationValidator::ValidateBinaries( << "\""; } - // Chrome or Chrome Frame must be present - if (chrome_state == NULL && cf_state == NULL) { + // ap must have -apphost iff Chrome Frame is installed multi + const ProductState* app_host_state = machine_state.GetProductState( + system_install, BrowserDistribution::CHROME_APP_HOST); + if (app_host_state != NULL) { + if (!app_host_state->is_multi_install()) { + *is_valid = false; + LOG(ERROR) << "Chrome App Host is installed in non-multi mode."; + } + if (!channel.IsAppHost()) { + *is_valid = false; + LOG(ERROR) << "Chrome Binaries are missing \"-apphost\" in channel" + " name: \"" << channel.value() << "\""; + } + } else if (channel.IsAppHost()) { + *is_valid = false; + LOG(ERROR) << "Chrome Binaries have \"-apphost\" in channel name, yet " + "Chrome App Host is not installed: \"" << channel.value() + << "\""; + } + + // Chrome, Chrome Frame, or App Host must be present + if (chrome_state == NULL && cf_state == NULL && app_host_state == NULL) { *is_valid = false; LOG(ERROR) << "Chrome Binaries are present with no other products."; } @@ -323,12 +479,12 @@ void InstallationValidator::ValidateBinaries( << "Chrome Binaries are present yet Chrome is not multi-install."; } - // Chrome Frame must be multi-install if Chrome is not present. - if (cf_state != NULL && chrome_state == NULL && + // Chrome Frame must be multi-install if Chrome & App Host are not present. + if (cf_state != NULL && app_host_state == NULL && chrome_state == NULL && !cf_state->is_multi_install()) { *is_valid = false; - LOG(ERROR) << "Chrome Binaries are present without Chrome yet Chrome Frame " - "is not multi-install."; + LOG(ERROR) << "Chrome Binaries are present without Chrome nor App Host " + << "yet Chrome Frame is not multi-install."; } ChromeBinariesRules binaries_rules; @@ -483,24 +639,44 @@ void InstallationValidator::ValidateMultiInstallProduct( const ProductState* binaries = ctx.machine_state.GetProductState(ctx.system_install, BrowserDistribution::CHROME_BINARIES); - DCHECK(binaries); - - // Version must match that of binaries. - if (ctx.state.version().CompareTo(binaries->version()) != 0) { - *is_valid = false; - LOG(ERROR) << "Version of " << ctx.dist->GetAppShortCutName() - << " (" << ctx.state.version().GetString() << ") does not " - "match that of Chrome Binaries (" - << binaries->version().GetString() << ")."; - } + if (!binaries) { + if (ctx.dist->GetType() == BrowserDistribution::CHROME_APP_HOST) { + if (!ctx.machine_state.GetProductState( + true, // system-level + BrowserDistribution::CHROME_BINARIES) && + !ctx.machine_state.GetProductState( + true, // system-level + BrowserDistribution::CHROME_BROWSER)) { + *is_valid = false; + LOG(ERROR) << ctx.dist->GetAppShortCutName() + << " (" << ctx.state.version().GetString() << ") is " + << "installed without Chrome Binaries or a system-level " + << "Chrome."; + } + } else { + *is_valid = false; + LOG(ERROR) << ctx.dist->GetAppShortCutName() + << " (" << ctx.state.version().GetString() << ") is installed " + << "without Chrome Binaries."; + } + } else { + // Version must match that of binaries. + if (ctx.state.version().CompareTo(binaries->version()) != 0) { + *is_valid = false; + LOG(ERROR) << "Version of " << ctx.dist->GetAppShortCutName() + << " (" << ctx.state.version().GetString() << ") does not " + "match that of Chrome Binaries (" + << binaries->version().GetString() << ")."; + } - // Channel value must match that of binaries. - if (!ctx.state.channel().Equals(binaries->channel())) { - *is_valid = false; - LOG(ERROR) << "Channel name of " << ctx.dist->GetAppShortCutName() - << " (" << ctx.state.channel().value() - << ") does not match that of Chrome Binaries (" - << binaries->channel().value() << ")."; + // Channel value must match that of binaries. + if (!ctx.state.channel().Equals(binaries->channel())) { + *is_valid = false; + LOG(ERROR) << "Channel name of " << ctx.dist->GetAppShortCutName() + << " (" << ctx.state.channel().value() + << ") does not match that of Chrome Binaries (" + << binaries->channel().value() << ")."; + } } } @@ -510,8 +686,13 @@ void InstallationValidator::ValidateAppCommands( bool* is_valid) { DCHECK(is_valid); - // Products are not expected to have any commands. - ValidateAppCommandExpectations(ctx, CommandExpectations(), is_valid); + CommandExpectations expectations; + + if (ctx.dist->GetType() == BrowserDistribution::CHROME_APP_HOST) { + expectations[kCmdInstallApp] = &ValidateInstallAppCommand; + } + + ValidateAppCommandExpectations(ctx, expectations, is_valid); } // Validates usagestats for the product or binaries in |ctx|. @@ -609,6 +790,25 @@ bool InstallationValidator::ValidateInstallationTypeForState( *type = static_cast<InstallationType>(*type | cf_bit); } + // Is Chrome App Host installed? + product_state = + machine_state.GetProductState(system_level, + BrowserDistribution::CHROME_APP_HOST); + if (product_state != NULL) { + ChromeAppHostRules chrome_app_host_rules; + ValidateProduct(machine_state, system_level, *product_state, + chrome_app_host_rules, &rock_on); + *type = static_cast<InstallationType>(*type | ProductBits::CHROME_APP_HOST); + if (system_level) { + LOG(ERROR) << "Chrome App Host must not be installed at system level."; + rock_on = false; + } + if (!product_state->is_multi_install()) { + LOG(ERROR) << "Chrome App Host must always be multi-install."; + rock_on = false; + } + } + DCHECK_NE(std::find(&kInstallationTypes[0], &kInstallationTypes[arraysize(kInstallationTypes)], *type), diff --git a/chrome/installer/util/installation_validator.h b/chrome/installer/util/installation_validator.h index ee8cc1c..d06ab9d 100644 --- a/chrome/installer/util/installation_validator.h +++ b/chrome/installer/util/installation_validator.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -36,6 +36,7 @@ class InstallationValidator { CHROME_FRAME_SINGLE = 0x04, CHROME_FRAME_MULTI = 0x08, CHROME_FRAME_READY_MODE = 0x10, + CHROME_APP_HOST = 0x20, }; }; // class ProductBits @@ -58,6 +59,23 @@ class InstallationValidator { ProductBits::CHROME_FRAME_MULTI | ProductBits::CHROME_MULTI, CHROME_FRAME_READY_MODE_CHROME_MULTI = ProductBits::CHROME_FRAME_READY_MODE | ProductBits::CHROME_MULTI, + CHROME_APP_HOST = + ProductBits::CHROME_APP_HOST, + CHROME_APP_HOST_CHROME_FRAME_SINGLE = + ProductBits::CHROME_APP_HOST | ProductBits::CHROME_FRAME_SINGLE, + CHROME_APP_HOST_CHROME_FRAME_SINGLE_CHROME_MULTI = + ProductBits::CHROME_APP_HOST | ProductBits::CHROME_FRAME_SINGLE | + ProductBits::CHROME_MULTI, + CHROME_APP_HOST_CHROME_FRAME_MULTI = + ProductBits::CHROME_APP_HOST | ProductBits::CHROME_FRAME_MULTI, + CHROME_APP_HOST_CHROME_FRAME_MULTI_CHROME_MULTI = + ProductBits::CHROME_APP_HOST | ProductBits::CHROME_FRAME_MULTI | + ProductBits::CHROME_MULTI, + CHROME_APP_HOST_CHROME_MULTI = + ProductBits::CHROME_APP_HOST | ProductBits::CHROME_MULTI, + CHROME_APP_HOST_CHROME_MULTI_CHROME_FRAME_READY_MODE = + ProductBits::CHROME_APP_HOST | ProductBits::CHROME_MULTI | + ProductBits::CHROME_FRAME_READY_MODE, }; // Validates |machine_state| at user or system level, returning true if valid. @@ -136,6 +154,24 @@ class InstallationValidator { const ProductState& product_state) const OVERRIDE; }; + // Validation rules for Chrome App Host. + class ChromeAppHostRules : public ProductRules { + public: + virtual BrowserDistribution::Type distribution_type() const OVERRIDE; + virtual void AddUninstallSwitchExpectations( + const InstallationState& machine_state, + bool system_install, + const ProductState& product_state, + SwitchExpectations* expectations) const OVERRIDE; + virtual void AddRenameSwitchExpectations( + const InstallationState& machine_state, + bool system_install, + const ProductState& product_state, + SwitchExpectations* expectations) const OVERRIDE; + virtual bool UsageStatsAllowed( + const ProductState& product_state) const OVERRIDE; + }; + // Validation rules for the multi-install Chrome binaries. class ChromeBinariesRules : public ProductRules { public: @@ -162,9 +198,17 @@ class InstallationValidator { const ProductRules& rules; }; + static void ValidateInstallAppCommand(const ProductContext& ctx, + const AppCommand& command, + bool* is_valid); static void ValidateQuickEnableCfCommand(const ProductContext& ctx, const AppCommand& command, bool* is_valid); + static void ValidateQuickEnableApplicationHostCommand( + const ProductContext& ctx, + const AppCommand& command, + bool* is_valid); + static void ValidateAppCommandExpectations( const ProductContext& ctx, const CommandExpectations& expectations, diff --git a/chrome/installer/util/installation_validator_unittest.cc b/chrome/installer/util/installation_validator_unittest.cc index 56e854c..c997110 100644 --- a/chrome/installer/util/installation_validator_unittest.cc +++ b/chrome/installer/util/installation_validator_unittest.cc @@ -78,11 +78,14 @@ class FakeProductState : public ProductState { const char* version, int channel_modifiers, Vehicle vehicle); + void AddQuickEnableApplicationHostCommand(BrowserDistribution::Type dist_type, + Level install_level, + const char* version, + int channel_modifiers); void AddQuickEnableCfCommand(BrowserDistribution::Type dist_type, Level install_level, const char* version, int channel_modifiers); - void RemoveQuickEnableCfCommand(BrowserDistribution::Type dist_type); void set_multi_install(bool is_multi_install) { multi_install_ = is_multi_install; } @@ -194,6 +197,23 @@ void FakeProductState::SetUninstallCommand(BrowserDistribution::Type dist_type, uninstall_command_.AppendSwitch(installer::switches::kMsi); } +// Adds the "quick-enable-application-host" Google Update product command. +void FakeProductState::AddQuickEnableApplicationHostCommand( + BrowserDistribution::Type dist_type, + Level install_level, + const char* version, + int channel_modifiers) { + DCHECK_EQ(dist_type, BrowserDistribution::CHROME_BINARIES); + DCHECK_NE(channel_modifiers & CM_MULTI, 0); + + CommandLine cmd_line(GetSetupExePath(dist_type, install_level, version, + channel_modifiers)); + cmd_line.AppendSwitch(installer::switches::kMultiInstall); + cmd_line.AppendSwitch(installer::switches::kChromeAppHost); + commands_.Set(installer::kCmdQuickEnableApplicationHost, + AppCommand(cmd_line.GetCommandLineString(), true, true)); +} + // Adds the "quick-enable-cf" Google Update product command. void FakeProductState::AddQuickEnableCfCommand( BrowserDistribution::Type dist_type, @@ -213,14 +233,6 @@ void FakeProductState::AddQuickEnableCfCommand( AppCommand(cmd_line.GetCommandLineString(), true, true)); } -// Removes the "quick-enable-cf" Google Update product command. -void FakeProductState::RemoveQuickEnableCfCommand( - BrowserDistribution::Type dist_type) { - DCHECK_EQ(dist_type, BrowserDistribution::CHROME_BINARIES); - - commands_.Remove(installer::kCmdQuickEnableCf); -} - } // namespace // Fixture for testing the InstallationValidator. Errors logged by the @@ -412,6 +424,12 @@ void InstallationValidatorTest::MakeProductState( state->AddQuickEnableCfCommand(prod_type, install_level, chrome::kChromeVersion, channel_modifiers); } + if (prod_type == BrowserDistribution::CHROME_BINARIES) { + state->AddQuickEnableApplicationHostCommand(prod_type, + install_level, + chrome::kChromeVersion, + channel_modifiers); + } } // static diff --git a/chrome/installer/util/installer_state.cc b/chrome/installer/util/installer_state.cc index 34ceff4..9e69398 100644 --- a/chrome/installer/util/installer_state.cc +++ b/chrome/installer/util/installer_state.cc @@ -126,6 +126,117 @@ void InstallerState::Initialize(const CommandLine& command_line, VLOG(1) << (is_uninstall ? "Uninstall" : "Install") << " distribution: " << p->distribution()->GetAppShortCutName(); } + if (prefs.install_chrome_app_host()) { + Product* p = + AddProductFromPreferences(BrowserDistribution::CHROME_APP_HOST, prefs, + machine_state); + VLOG(1) << (is_uninstall ? "Uninstall" : "Install") + << " distribution: " << p->distribution()->GetAppShortCutName(); + } + + if (!is_uninstall && is_multi_install()) { + bool need_binaries = false; + if (FindProduct(BrowserDistribution::CHROME_APP_HOST)) { + // App Host will happily use Chrome at system level, or binaries at system + // level, even if app host is user level. + const ProductState* chrome_state = machine_state.GetProductState( + true, // system level + BrowserDistribution::CHROME_BROWSER); + // If Chrome is at system-level, multi- or otherwise. We'll use it. + if (!chrome_state) { + const ProductState* binaries_state = machine_state.GetProductState( + true, // system level + BrowserDistribution::CHROME_BINARIES); + if (!binaries_state) + need_binaries = true; + } + } + + // Chrome/Chrome Frame multi need Binaries at their own level. + if (FindProduct(BrowserDistribution::CHROME_BROWSER)) + need_binaries = true; + + if (FindProduct(BrowserDistribution::CHROME_FRAME)) + need_binaries = true; + + if (need_binaries && !FindProduct(BrowserDistribution::CHROME_BINARIES)) { + // Force binaries to be installed/updated. + Product* p = + AddProductFromPreferences(BrowserDistribution::CHROME_BINARIES, + prefs, + machine_state); + VLOG(1) << "Install distribution: " + << p->distribution()->GetAppShortCutName(); + } + } + + if (is_uninstall && prefs.is_multi_install()) { + if (FindProduct(BrowserDistribution::CHROME_BROWSER)) { + const ProductState* chrome_frame_state = machine_state.GetProductState( + system_install(), BrowserDistribution::CHROME_FRAME); + + if (chrome_frame_state != NULL && + chrome_frame_state->uninstall_command().HasSwitch( + switches::kChromeFrameReadyMode) && + !FindProduct(BrowserDistribution::CHROME_FRAME)) { + // Chrome Frame is installed in Ready Mode. Remove it along with Chrome. + Product* p = AddProductFromPreferences( + BrowserDistribution::CHROME_FRAME, prefs, machine_state); + + VLOG(1) << "Uninstall distribution: " + << p->distribution()->GetAppShortCutName(); + } + } + + bool keep_binaries = false; + // Look for a product that is not the binaries and that is not being + // uninstalled. If not found, binaries are uninstalled too. + for (size_t i = 0; i < BrowserDistribution::NUM_TYPES; ++i) { + BrowserDistribution::Type type = + static_cast<BrowserDistribution::Type>(i); + + if (type == BrowserDistribution::CHROME_BINARIES) + continue; + + if (machine_state.GetProductState(system_install(), type) == NULL) { + // The product is not installed. + continue; + } + + // The product is installed. + + if (!FindProduct(type)) { + // The product is not being uninstalled. + if (type != BrowserDistribution::CHROME_APP_HOST) { + keep_binaries = true; + break; + } else { + // If binaries/chrome are at system-level, we can discard them at + // user-level... + if (!machine_state.GetProductState( + true, // system-level + BrowserDistribution::CHROME_BROWSER) && + !machine_state.GetProductState( + true, // system-level + BrowserDistribution::CHROME_BINARIES)) { + // ... otherwise keep them. + keep_binaries = true; + break; + } + + } + } + + // The product is being uninstalled. + } + if (!keep_binaries) { + Product* p = + AddProductFromPreferences(BrowserDistribution::CHROME_BINARIES, prefs, + machine_state); + VLOG(1) << (is_uninstall ? "Uninstall" : "Install") + << " distribution: " << p->distribution()->GetAppShortCutName(); + } + } BrowserDistribution* operand = NULL; @@ -141,17 +252,26 @@ void InstallerState::Initialize(const CommandLine& command_line, operand = multi_package_distribution_; operation_ = MULTI_UPDATE; } else { - // Initial and over installs will always take place under one of the - // product app guids. Chrome Frame's will be used if only Chrome Frame - // is being installed. In all other cases, Chrome's is used. operation_ = MULTI_INSTALL; } + // Initial, over, and un-installs will always take place under one of the + // product app guids (Chrome, Chrome Frame, or App Host, in order of + // preference). if (operand == NULL) { + BrowserDistribution::Type operand_distribution_type = + BrowserDistribution::CHROME_BINARIES; + if (prefs.install_chrome()) + operand_distribution_type = BrowserDistribution::CHROME_BROWSER; + else if (prefs.install_chrome_frame()) + operand_distribution_type = BrowserDistribution::CHROME_FRAME; + else if (prefs.install_chrome_app_host()) + operand_distribution_type = BrowserDistribution::CHROME_APP_HOST; + else + NOTREACHED(); + operand = BrowserDistribution::GetSpecificDistribution( - prefs.install_chrome() ? - BrowserDistribution::CHROME_BROWSER : - BrowserDistribution::CHROME_FRAME); + operand_distribution_type); } state_key_ = operand->GetStateKey(); diff --git a/chrome/installer/util/installer_state.h b/chrome/installer/util/installer_state.h index 5fe4fc8..6e18ebd 100644 --- a/chrome/installer/util/installer_state.h +++ b/chrome/installer/util/installer_state.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -37,6 +37,12 @@ typedef std::vector<Product*> Products; // Encapsulates the state of the current installation operation. Only valid // for installs and upgrades (not for uninstalls or non-install commands). +// This class interprets the command-line arguments and master preferences and +// determines the operations to be performed. For example, the Chrome Binaries +// are automatically added if required in multi-install mode. +// TODO(erikwright): This is now used a fair bit during uninstall, and +// InstallerState::Initialize() contains a lot of code for uninstall. The class +// comment should probably be updated. // TODO(grt): Rename to InstallerEngine/Conductor or somesuch? class InstallerState { public: diff --git a/chrome/installer/util/master_preferences.cc b/chrome/installer/util/master_preferences.cc index 008c148..59f7270 100644 --- a/chrome/installer/util/master_preferences.cc +++ b/chrome/installer/util/master_preferences.cc @@ -82,6 +82,7 @@ namespace installer { MasterPreferences::MasterPreferences() : distribution_(NULL), preferences_read_from_file_(false), chrome_(true), + chrome_app_host_(false), chrome_frame_(false), multi_install_(false) { InitializeFromCommandLine(*CommandLine::ForCurrentProcess()); @@ -91,6 +92,7 @@ MasterPreferences::MasterPreferences(const CommandLine& cmd_line) : distribution_(NULL), preferences_read_from_file_(false), chrome_(true), + chrome_app_host_(false), chrome_frame_(false), multi_install_(false) { InitializeFromCommandLine(cmd_line); @@ -98,7 +100,8 @@ MasterPreferences::MasterPreferences(const CommandLine& cmd_line) MasterPreferences::MasterPreferences(const FilePath& prefs_path) : distribution_(NULL), preferences_read_from_file_(false), - chrome_(true), chrome_frame_(false), multi_install_(false) { + chrome_(true), chrome_app_host_(false), chrome_frame_(false), + multi_install_(false) { master_dictionary_.reset(ParseDistributionPreferences(prefs_path)); if (!master_dictionary_.get()) { @@ -136,6 +139,8 @@ void MasterPreferences::InitializeFromCommandLine(const CommandLine& cmd_line) { } translate_switches[] = { { installer::switches::kAutoLaunchChrome, installer::master_preferences::kAutoLaunchChrome }, + { installer::switches::kChromeAppHost, + installer::master_preferences::kChromeAppHost }, { installer::switches::kChrome, installer::master_preferences::kChrome }, { installer::switches::kChromeFrame, @@ -207,10 +212,12 @@ void MasterPreferences::InitializeProductFlags() { // Make sure we start out with the correct defaults. multi_install_ = false; chrome_frame_ = false; + chrome_app_host_ = false; chrome_ = true; GetBool(installer::master_preferences::kMultiInstall, &multi_install_); GetBool(installer::master_preferences::kChromeFrame, &chrome_frame_); + GetBool(installer::master_preferences::kChromeAppHost, &chrome_app_host_); // When multi-install is specified, the checks are pretty simple (in theory): // In order to be installed/uninstalled, each product must have its switch diff --git a/chrome/installer/util/master_preferences.h b/chrome/installer/util/master_preferences.h index 8baf9d6a..e698d1d 100644 --- a/chrome/installer/util/master_preferences.h +++ b/chrome/installer/util/master_preferences.h @@ -164,6 +164,10 @@ class MasterPreferences { return chrome_; } + bool install_chrome_app_host() const { + return chrome_app_host_; + } + bool install_chrome_frame() const { return chrome_frame_; } @@ -188,6 +192,7 @@ class MasterPreferences { base::DictionaryValue* distribution_; bool preferences_read_from_file_; bool chrome_; + bool chrome_app_host_; bool chrome_frame_; bool multi_install_; diff --git a/chrome/installer/util/master_preferences_constants.cc b/chrome/installer/util/master_preferences_constants.cc index 2ee5557..8884ce0 100644 --- a/chrome/installer/util/master_preferences_constants.cc +++ b/chrome/installer/util/master_preferences_constants.cc @@ -9,6 +9,7 @@ namespace master_preferences { const char kAltShortcutText[] = "alternate_shortcut_text"; const char kAutoLaunchChrome[] = "auto_launch_chrome"; const char kChrome[] = "chrome"; + const char kChromeAppHost[] = "app_host"; const char kChromeFrame[] = "chrome_frame"; const char kChromeFrameReadyMode[] = "ready_mode"; const char kChromeShortcutIconIndex[] = "chrome_shortcut_icon_index"; diff --git a/chrome/installer/util/master_preferences_constants.h b/chrome/installer/util/master_preferences_constants.h index 45806bb..8a6f6c2 100644 --- a/chrome/installer/util/master_preferences_constants.h +++ b/chrome/installer/util/master_preferences_constants.h @@ -22,6 +22,8 @@ extern const char kAltShortcutText[]; extern const char kAutoLaunchChrome[]; // Boolean. This is to be a Chrome install. (When using MultiInstall) extern const char kChrome[]; +// Boolean. This is to be a Chrome App Host install. +extern const char kChromeAppHost[]; // Boolean. This is to be a Chrome Frame install. extern const char kChromeFrame[]; // Boolean. Chrome Frame is to be installed in ready-mode. diff --git a/chrome/installer/util/prebuild/create_string_rc.py b/chrome/installer/util/prebuild/create_string_rc.py index dd1043b..4dd2852 100755 --- a/chrome/installer/util/prebuild/create_string_rc.py +++ b/chrome/installer/util/prebuild/create_string_rc.py @@ -44,11 +44,14 @@ import FP kStringIds = [ 'IDS_PRODUCT_NAME', 'IDS_SXS_SHORTCUT_NAME', + 'IDS_PRODUCT_APP_HOST_NAME', + 'IDS_PRODUCT_BINARIES_NAME', 'IDS_PRODUCT_DESCRIPTION', 'IDS_PRODUCT_FRAME_NAME', 'IDS_UNINSTALL_CHROME', 'IDS_ABOUT_VERSION_COMPANY_NAME', 'IDS_INSTALL_HIGHER_VERSION', + 'IDS_INSTALL_HIGHER_VERSION_APP_HOST', 'IDS_INSTALL_HIGHER_VERSION_CF', 'IDS_INSTALL_HIGHER_VERSION_CB_CF', 'IDS_INSTALL_SYSTEM_LEVEL_EXISTS', diff --git a/chrome/installer/util/product.cc b/chrome/installer/util/product.cc index f2ab2a7..7747401 100644 --- a/chrome/installer/util/product.cc +++ b/chrome/installer/util/product.cc @@ -10,6 +10,8 @@ #include "base/logging.h" #include "base/process_util.h" #include "base/win/registry.h" +#include "chrome/installer/util/chrome_app_host_operations.h" +#include "chrome/installer/util/chrome_binaries_operations.h" #include "chrome/installer/util/chrome_browser_operations.h" #include "chrome/installer/util/chrome_browser_sxs_operations.h" #include "chrome/installer/util/chrome_frame_operations.h" @@ -36,6 +38,12 @@ Product::Product(BrowserDistribution* distribution) case BrowserDistribution::CHROME_FRAME: operations_.reset(new ChromeFrameOperations()); break; + case BrowserDistribution::CHROME_APP_HOST: + operations_.reset(new ChromeAppHostOperations()); + break; + case BrowserDistribution::CHROME_BINARIES: + operations_.reset(new ChromeBinariesOperations()); + break; default: NOTREACHED() << "Unsupported BrowserDistribution::Type: " << distribution->GetType(); diff --git a/chrome/installer/util/product.h b/chrome/installer/util/product.h index 4b4ec65..eabc3c9 100644 --- a/chrome/installer/util/product.h +++ b/chrome/installer/util/product.h @@ -56,6 +56,14 @@ class Product { return distribution_->GetType() == BrowserDistribution::CHROME_FRAME; } + bool is_chrome_app_host() const { + return distribution_->GetType() == BrowserDistribution::CHROME_APP_HOST; + } + + bool is_chrome_binaries() const { + return distribution_->GetType() == BrowserDistribution::CHROME_BINARIES; + } + bool HasOption(const std::wstring& option) const { return options_.find(option) != options_.end(); } diff --git a/chrome/installer/util/util_constants.cc b/chrome/installer/util/util_constants.cc index 9382fc4..04c4b79 100644 --- a/chrome/installer/util/util_constants.cc +++ b/chrome/installer/util/util_constants.cc @@ -15,6 +15,9 @@ const char kAutoLaunchChrome[] = "auto-launch-chrome"; // Currently this is only required when used in combination with kMultiInstall. const char kChrome[] = "chrome"; +// Install Chrome App Host. +const char kChromeAppHost[] = "app-host"; + // Install Chrome Frame. const char kChromeFrame[] = "chrome-frame"; @@ -167,6 +170,7 @@ const char kToastResultsKey[] = "toast-results-key"; } // namespace switches +const wchar_t kChromeAppHostExe[] = L"app_host.exe"; const wchar_t kChromeDll[] = L"chrome.dll"; const wchar_t kChromeExe[] = L"chrome.exe"; const wchar_t kChromeFrameDll[] = L"npchrome_frame.dll"; @@ -176,6 +180,9 @@ const wchar_t kChromeFrameReadyModeField[] = L"ChromeFrameReadyMode"; const wchar_t kChromeLauncherExe[] = L"chrome_launcher.exe"; const wchar_t kChromeNewExe[] = L"new_chrome.exe"; const wchar_t kChromeOldExe[] = L"old_chrome.exe"; +const wchar_t kCmdInstallApp[] = L"install-application"; +const wchar_t kCmdQuickEnableApplicationHost[] = + L"quick-enable-application-host"; const wchar_t kCmdQuickEnableCf[] = L"quick-enable-cf"; const wchar_t kDelegateExecuteExe[] = L"delegate_execute.exe"; const wchar_t kGoogleChromeInstallSubDir1[] = L"Google"; diff --git a/chrome/installer/util/util_constants.h b/chrome/installer/util/util_constants.h index c4d1af51..9a1da32 100644 --- a/chrome/installer/util/util_constants.h +++ b/chrome/installer/util/util_constants.h @@ -124,6 +124,7 @@ COMPILE_ASSERT(CREATING_VISUAL_MANIFEST == 17, namespace switches { extern const char kAutoLaunchChrome[]; extern const char kChrome[]; +extern const char kChromeAppHost[]; extern const char kChromeFrame[]; extern const char kChromeFrameQuickEnable[]; extern const char kChromeFrameReadyMode[]; @@ -166,6 +167,7 @@ extern const char kExperimentGroup[]; extern const char kToastResultsKey[]; } // namespace switches +extern const wchar_t kChromeAppHostExe[]; extern const wchar_t kChromeDll[]; extern const wchar_t kChromeExe[]; extern const wchar_t kChromeFrameDll[]; @@ -175,6 +177,8 @@ extern const wchar_t kChromeFrameReadyModeField[]; extern const wchar_t kChromeLauncherExe[]; extern const wchar_t kChromeOldExe[]; extern const wchar_t kChromeNewExe[]; +extern const wchar_t kCmdInstallApp[]; +extern const wchar_t kCmdQuickEnableApplicationHost[]; extern const wchar_t kCmdQuickEnableCf[]; extern const wchar_t kDelegateExecuteExe[]; extern const wchar_t kGoogleChromeInstallSubDir1[]; |