Chromium Code Reviews| Index: chrome/installer/util/chrome_app_host_operations.cc |
| 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 0000000000000000000000000000000000000000..d0f4ca8fa747e6b8897409e034a25a0644c87ca3 |
| --- /dev/null |
| +++ b/chrome/installer/util/chrome_app_host_operations.cc |
| @@ -0,0 +1,122 @@ |
| +// 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); |
| + |
| + static const struct PrefToOption { |
| + const char* pref_name; |
| + const wchar_t* option_name; |
| + } map[] = { |
| + { master_preferences::kMultiInstall, kOptionMultiInstall } |
| + }; |
| + |
| + bool pref_value; |
| + |
| + for (const PrefToOption* scan = &map[0], *end = &map[arraysize(map)]; |
| + scan != end; ++scan) { |
| + if (prefs.GetBool(scan->pref_name, &pref_value) && pref_value) |
| + options->insert(scan->option_name); |
| + } |
| +} |
| + |
| +void ChromeAppHostOperations::ReadOptions( |
| + const CommandLine& uninstall_command, |
| + std::set<std::wstring>* options) const { |
| + DCHECK(options); |
| + |
| + static const struct FlagToOption { |
| + const char* flag_name; |
| + const wchar_t* option_name; |
| + } map[] = { |
| + { switches::kMultiInstall, kOptionMultiInstall } |
| + }; |
| + |
| + for (const FlagToOption* scan = &map[0], *end = &map[arraysize(map)]; |
| + scan != end; ++scan) { |
| + if (uninstall_command.HasSwitch(scan->flag_name)) |
| + options->insert(scan->option_name); |
| + } |
| +} |
| + |
| +void ChromeAppHostOperations::AddKeyFiles( |
| + const std::set<std::wstring>& options, |
| + std::vector<FilePath>* key_files) const { |
| + // TODO(erikwright): I guess this isn't needed? |
|
grt (UTC plus 2)
2012/07/12 18:37:10
if it's the case now that the binaries' product is
erikwright (departed)
2012/07/16 20:13:11
Done.
|
| + DCHECK(key_files); |
| + key_files->push_back(FilePath(installer::kChromeDll)); |
| +} |
| + |
| +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 |