1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/installer/util/chrome_frame_operations.h"
7 #include "base/command_line.h"
8 #include "base/files/file_path.h"
9 #include "base/logging.h"
10 #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"
18 void ChromeFrameOperations::ReadOptions(const MasterPreferences
& prefs
,
19 std::set
<base::string16
>* options
)
23 static const struct PrefToOption
{
24 const char* pref_name
;
25 const wchar_t* option_name
;
27 { master_preferences::kMultiInstall
, kOptionMultiInstall
}
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
);
39 void ChromeFrameOperations::ReadOptions(
40 const base::CommandLine
& uninstall_command
,
41 std::set
<base::string16
>* options
) const {
44 static const struct FlagToOption
{
45 const char* flag_name
;
46 const wchar_t* option_name
;
48 { switches::kMultiInstall
, kOptionMultiInstall
}
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
);
58 void ChromeFrameOperations::AddKeyFiles(
59 const std::set
<base::string16
>& options
,
60 std::vector
<base::FilePath
>* key_files
) const {
62 key_files
->push_back(base::FilePath(installer::kChromeFrameDll
));
63 key_files
->push_back(base::FilePath(installer::kChromeFrameHelperExe
));
66 void ChromeFrameOperations::AddComDllList(
67 const std::set
<base::string16
>& options
,
68 std::vector
<base::FilePath
>* com_dll_list
) const {
70 com_dll_list
->push_back(base::FilePath(installer::kChromeFrameDll
));
73 void ChromeFrameOperations::AppendProductFlags(
74 const std::set
<base::string16
>& options
,
75 base::CommandLine
* cmd_line
) const {
77 bool is_multi_install
= options
.find(kOptionMultiInstall
) != options
.end();
79 // 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
);
83 // --chrome-frame is always needed.
84 cmd_line
->AppendSwitch(switches::kChromeFrame
);
87 void ChromeFrameOperations::AppendRenameFlags(
88 const std::set
<base::string16
>& options
,
89 base::CommandLine
* cmd_line
) const {
91 bool is_multi_install
= options
.find(kOptionMultiInstall
) != options
.end();
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
);
97 // --chrome-frame is needed for single installs.
98 if (!is_multi_install
)
99 cmd_line
->AppendSwitch(switches::kChromeFrame
);
102 bool ChromeFrameOperations::SetChannelFlags(
103 const std::set
<base::string16
>& options
,
105 ChannelInfo
* channel_info
) const {
106 #if defined(GOOGLE_CHROME_BUILD)
107 DCHECK(channel_info
);
108 bool modified
= channel_info
->SetChromeFrame(set
);
110 // Unconditionally remove the legacy -readymode flag.
111 modified
|= channel_info
->SetReadyMode(false);
119 bool ChromeFrameOperations::ShouldCreateUninstallEntry(
120 const std::set
<base::string16
>& options
) const {
124 void ChromeFrameOperations::AddDefaultShortcutProperties(
125 BrowserDistribution
* dist
,
126 const base::FilePath
& target_exe
,
127 ShellUtil::ShortcutProperties
* properties
) const {
128 NOTREACHED() << "Chrome Frame does not create shortcuts.";
131 void ChromeFrameOperations::LaunchUserExperiment(
132 const base::FilePath
& setup_path
,
133 const std::set
<base::string16
>& options
,
134 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.
141 } // namespace installer