blob: 6ed2edc3d0e77447dafe7f09be62accc08285487 [file] [log] [blame]
[email protected]273073e2012-02-28 13:51:551// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]f0260d22011-01-25 16:44:372// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/installer/util/chrome_frame_operations.h"
6
7#include "base/command_line.h"
[email protected]57999812013-02-24 05:40:528#include "base/files/file_path.h"
[email protected]f0260d22011-01-25 16:44:379#include "base/logging.h"
[email protected]f0260d22011-01-25 16:44:3710#include "chrome/installer/util/channel_info.h"
11#include "chrome/installer/util/helper.h"
12#include "chrome/installer/util/master_preferences.h"
13#include "chrome/installer/util/master_preferences_constants.h"
14#include "chrome/installer/util/util_constants.h"
15
16namespace installer {
17
[email protected]899580d42013-03-15 22:49:1218void ChromeFrameOperations::ReadOptions(const MasterPreferences& prefs,
[email protected]05aab99c2013-12-20 09:03:1519 std::set<base::string16>* options)
20 const {
[email protected]f0260d22011-01-25 16:44:3721 DCHECK(options);
22
23 static const struct PrefToOption {
24 const char* pref_name;
25 const wchar_t* option_name;
26 } map[] = {
[email protected]f0260d22011-01-25 16:44:3727 { master_preferences::kMultiInstall, kOptionMultiInstall }
28 };
29
30 bool pref_value;
31
32 for (const PrefToOption* scan = &map[0], *end = &map[arraysize(map)];
33 scan != end; ++scan) {
34 if (prefs.GetBool(scan->pref_name, &pref_value) && pref_value)
35 options->insert(scan->option_name);
36 }
[email protected]f0260d22011-01-25 16:44:3737}
38
avi79bf9132014-12-25 17:48:0539void ChromeFrameOperations::ReadOptions(
40 const base::CommandLine& uninstall_command,
41 std::set<base::string16>* options) const {
[email protected]f0260d22011-01-25 16:44:3742 DCHECK(options);
43
44 static const struct FlagToOption {
45 const char* flag_name;
46 const wchar_t* option_name;
47 } map[] = {
[email protected]f0260d22011-01-25 16:44:3748 { switches::kMultiInstall, kOptionMultiInstall }
49 };
50
51 for (const FlagToOption* scan = &map[0], *end = &map[arraysize(map)];
52 scan != end; ++scan) {
53 if (uninstall_command.HasSwitch(scan->flag_name))
54 options->insert(scan->option_name);
55 }
[email protected]f0260d22011-01-25 16:44:3756}
57
58void ChromeFrameOperations::AddKeyFiles(
[email protected]05aab99c2013-12-20 09:03:1559 const std::set<base::string16>& options,
[email protected]152ea302013-02-11 04:08:4060 std::vector<base::FilePath>* key_files) const {
[email protected]f0260d22011-01-25 16:44:3761 DCHECK(key_files);
[email protected]152ea302013-02-11 04:08:4062 key_files->push_back(base::FilePath(installer::kChromeFrameDll));
63 key_files->push_back(base::FilePath(installer::kChromeFrameHelperExe));
[email protected]f0260d22011-01-25 16:44:3764}
65
66void ChromeFrameOperations::AddComDllList(
[email protected]05aab99c2013-12-20 09:03:1567 const std::set<base::string16>& options,
[email protected]152ea302013-02-11 04:08:4068 std::vector<base::FilePath>* com_dll_list) const {
[email protected]f0260d22011-01-25 16:44:3769 DCHECK(com_dll_list);
[email protected]152ea302013-02-11 04:08:4070 com_dll_list->push_back(base::FilePath(installer::kChromeFrameDll));
[email protected]f0260d22011-01-25 16:44:3771}
72
[email protected]273073e2012-02-28 13:51:5573void ChromeFrameOperations::AppendProductFlags(
[email protected]05aab99c2013-12-20 09:03:1574 const std::set<base::string16>& options,
avi79bf9132014-12-25 17:48:0575 base::CommandLine* cmd_line) const {
[email protected]1efff122011-05-12 06:59:5476 DCHECK(cmd_line);
77 bool is_multi_install = options.find(kOptionMultiInstall) != options.end();
[email protected]f0260d22011-01-25 16:44:3778
[email protected]1efff122011-05-12 06:59:5479 // Add --multi-install if it isn't already there.
80 if (is_multi_install && !cmd_line->HasSwitch(switches::kMultiInstall))
81 cmd_line->AppendSwitch(switches::kMultiInstall);
[email protected]f0260d22011-01-25 16:44:3782
[email protected]1efff122011-05-12 06:59:5483 // --chrome-frame is always needed.
84 cmd_line->AppendSwitch(switches::kChromeFrame);
[email protected]1efff122011-05-12 06:59:5485}
86
[email protected]05aab99c2013-12-20 09:03:1587void ChromeFrameOperations::AppendRenameFlags(
88 const std::set<base::string16>& options,
avi79bf9132014-12-25 17:48:0589 base::CommandLine* cmd_line) const {
[email protected]1efff122011-05-12 06:59:5490 DCHECK(cmd_line);
91 bool is_multi_install = options.find(kOptionMultiInstall) != options.end();
92
93 // Add --multi-install if it isn't already there.
94 if (is_multi_install && !cmd_line->HasSwitch(switches::kMultiInstall))
95 cmd_line->AppendSwitch(switches::kMultiInstall);
96
97 // --chrome-frame is needed for single installs.
98 if (!is_multi_install)
99 cmd_line->AppendSwitch(switches::kChromeFrame);
[email protected]f0260d22011-01-25 16:44:37100}
101
[email protected]05aab99c2013-12-20 09:03:15102bool ChromeFrameOperations::SetChannelFlags(
103 const std::set<base::string16>& options,
104 bool set,
105 ChannelInfo* channel_info) const {
[email protected]f0260d22011-01-25 16:44:37106#if defined(GOOGLE_CHROME_BUILD)
107 DCHECK(channel_info);
108 bool modified = channel_info->SetChromeFrame(set);
109
[email protected]adb8b22d2013-12-12 18:22:37110 // Unconditionally remove the legacy -readymode flag.
111 modified |= channel_info->SetReadyMode(false);
[email protected]f0260d22011-01-25 16:44:37112
113 return modified;
114#else
115 return false;
116#endif
117}
118
119bool ChromeFrameOperations::ShouldCreateUninstallEntry(
[email protected]05aab99c2013-12-20 09:03:15120 const std::set<base::string16>& options) const {
[email protected]adb8b22d2013-12-12 18:22:37121 return true;
[email protected]f0260d22011-01-25 16:44:37122}
123
[email protected]2d457e952012-11-07 20:37:51124void ChromeFrameOperations::AddDefaultShortcutProperties(
125 BrowserDistribution* dist,
[email protected]152ea302013-02-11 04:08:40126 const base::FilePath& target_exe,
[email protected]2d457e952012-11-07 20:37:51127 ShellUtil::ShortcutProperties* properties) const {
128 NOTREACHED() << "Chrome Frame does not create shortcuts.";
129}
130
[email protected]899580d42013-03-15 22:49:12131void ChromeFrameOperations::LaunchUserExperiment(
132 const base::FilePath& setup_path,
[email protected]05aab99c2013-12-20 09:03:15133 const std::set<base::string16>& options,
[email protected]899580d42013-03-15 22:49:12134 InstallStatus status,
135 bool system_level) const {
136 // No experiments yet. If adding some in the future, need to have
137 // ChromeFrameDistribution::HasUserExperiments() return true.
138 NOTREACHED();
139}
140
[email protected]f0260d22011-01-25 16:44:37141} // namespace installer