[email protected] | 273073e | 2012-02-28 13:51:55 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | f0260d2 | 2011-01-25 16:44:37 | [diff] [blame] | 2 | // 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] | 5799981 | 2013-02-24 05:40:52 | [diff] [blame] | 8 | #include "base/files/file_path.h" |
[email protected] | f0260d2 | 2011-01-25 16:44:37 | [diff] [blame] | 9 | #include "base/logging.h" |
[email protected] | f0260d2 | 2011-01-25 16:44:37 | [diff] [blame] | 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" |
| 15 | |
| 16 | namespace installer { |
| 17 | |
[email protected] | 899580d4 | 2013-03-15 22:49:12 | [diff] [blame] | 18 | void ChromeFrameOperations::ReadOptions(const MasterPreferences& prefs, |
[email protected] | 05aab99c | 2013-12-20 09:03:15 | [diff] [blame] | 19 | std::set<base::string16>* options) |
| 20 | const { |
[email protected] | f0260d2 | 2011-01-25 16:44:37 | [diff] [blame] | 21 | DCHECK(options); |
| 22 | |
| 23 | static const struct PrefToOption { |
| 24 | const char* pref_name; |
| 25 | const wchar_t* option_name; |
| 26 | } map[] = { |
[email protected] | f0260d2 | 2011-01-25 16:44:37 | [diff] [blame] | 27 | { 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] | f0260d2 | 2011-01-25 16:44:37 | [diff] [blame] | 37 | } |
| 38 | |
avi | 79bf913 | 2014-12-25 17:48:05 | [diff] [blame] | 39 | void ChromeFrameOperations::ReadOptions( |
| 40 | const base::CommandLine& uninstall_command, |
| 41 | std::set<base::string16>* options) const { |
[email protected] | f0260d2 | 2011-01-25 16:44:37 | [diff] [blame] | 42 | DCHECK(options); |
| 43 | |
| 44 | static const struct FlagToOption { |
| 45 | const char* flag_name; |
| 46 | const wchar_t* option_name; |
| 47 | } map[] = { |
[email protected] | f0260d2 | 2011-01-25 16:44:37 | [diff] [blame] | 48 | { 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] | f0260d2 | 2011-01-25 16:44:37 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | void ChromeFrameOperations::AddKeyFiles( |
[email protected] | 05aab99c | 2013-12-20 09:03:15 | [diff] [blame] | 59 | const std::set<base::string16>& options, |
[email protected] | 152ea30 | 2013-02-11 04:08:40 | [diff] [blame] | 60 | std::vector<base::FilePath>* key_files) const { |
[email protected] | f0260d2 | 2011-01-25 16:44:37 | [diff] [blame] | 61 | DCHECK(key_files); |
[email protected] | 152ea30 | 2013-02-11 04:08:40 | [diff] [blame] | 62 | key_files->push_back(base::FilePath(installer::kChromeFrameDll)); |
| 63 | key_files->push_back(base::FilePath(installer::kChromeFrameHelperExe)); |
[email protected] | f0260d2 | 2011-01-25 16:44:37 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | void ChromeFrameOperations::AddComDllList( |
[email protected] | 05aab99c | 2013-12-20 09:03:15 | [diff] [blame] | 67 | const std::set<base::string16>& options, |
[email protected] | 152ea30 | 2013-02-11 04:08:40 | [diff] [blame] | 68 | std::vector<base::FilePath>* com_dll_list) const { |
[email protected] | f0260d2 | 2011-01-25 16:44:37 | [diff] [blame] | 69 | DCHECK(com_dll_list); |
[email protected] | 152ea30 | 2013-02-11 04:08:40 | [diff] [blame] | 70 | com_dll_list->push_back(base::FilePath(installer::kChromeFrameDll)); |
[email protected] | f0260d2 | 2011-01-25 16:44:37 | [diff] [blame] | 71 | } |
| 72 | |
[email protected] | 273073e | 2012-02-28 13:51:55 | [diff] [blame] | 73 | void ChromeFrameOperations::AppendProductFlags( |
[email protected] | 05aab99c | 2013-12-20 09:03:15 | [diff] [blame] | 74 | const std::set<base::string16>& options, |
avi | 79bf913 | 2014-12-25 17:48:05 | [diff] [blame] | 75 | base::CommandLine* cmd_line) const { |
[email protected] | 1efff12 | 2011-05-12 06:59:54 | [diff] [blame] | 76 | DCHECK(cmd_line); |
| 77 | bool is_multi_install = options.find(kOptionMultiInstall) != options.end(); |
[email protected] | f0260d2 | 2011-01-25 16:44:37 | [diff] [blame] | 78 | |
[email protected] | 1efff12 | 2011-05-12 06:59:54 | [diff] [blame] | 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); |
[email protected] | f0260d2 | 2011-01-25 16:44:37 | [diff] [blame] | 82 | |
[email protected] | 1efff12 | 2011-05-12 06:59:54 | [diff] [blame] | 83 | // --chrome-frame is always needed. |
| 84 | cmd_line->AppendSwitch(switches::kChromeFrame); |
[email protected] | 1efff12 | 2011-05-12 06:59:54 | [diff] [blame] | 85 | } |
| 86 | |
[email protected] | 05aab99c | 2013-12-20 09:03:15 | [diff] [blame] | 87 | void ChromeFrameOperations::AppendRenameFlags( |
| 88 | const std::set<base::string16>& options, |
avi | 79bf913 | 2014-12-25 17:48:05 | [diff] [blame] | 89 | base::CommandLine* cmd_line) const { |
[email protected] | 1efff12 | 2011-05-12 06:59:54 | [diff] [blame] | 90 | 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] | f0260d2 | 2011-01-25 16:44:37 | [diff] [blame] | 100 | } |
| 101 | |
[email protected] | 05aab99c | 2013-12-20 09:03:15 | [diff] [blame] | 102 | bool ChromeFrameOperations::SetChannelFlags( |
| 103 | const std::set<base::string16>& options, |
| 104 | bool set, |
| 105 | ChannelInfo* channel_info) const { |
[email protected] | f0260d2 | 2011-01-25 16:44:37 | [diff] [blame] | 106 | #if defined(GOOGLE_CHROME_BUILD) |
| 107 | DCHECK(channel_info); |
| 108 | bool modified = channel_info->SetChromeFrame(set); |
| 109 | |
[email protected] | adb8b22d | 2013-12-12 18:22:37 | [diff] [blame] | 110 | // Unconditionally remove the legacy -readymode flag. |
| 111 | modified |= channel_info->SetReadyMode(false); |
[email protected] | f0260d2 | 2011-01-25 16:44:37 | [diff] [blame] | 112 | |
| 113 | return modified; |
| 114 | #else |
| 115 | return false; |
| 116 | #endif |
| 117 | } |
| 118 | |
| 119 | bool ChromeFrameOperations::ShouldCreateUninstallEntry( |
[email protected] | 05aab99c | 2013-12-20 09:03:15 | [diff] [blame] | 120 | const std::set<base::string16>& options) const { |
[email protected] | adb8b22d | 2013-12-12 18:22:37 | [diff] [blame] | 121 | return true; |
[email protected] | f0260d2 | 2011-01-25 16:44:37 | [diff] [blame] | 122 | } |
| 123 | |
[email protected] | 2d457e95 | 2012-11-07 20:37:51 | [diff] [blame] | 124 | void ChromeFrameOperations::AddDefaultShortcutProperties( |
| 125 | BrowserDistribution* dist, |
[email protected] | 152ea30 | 2013-02-11 04:08:40 | [diff] [blame] | 126 | const base::FilePath& target_exe, |
[email protected] | 2d457e95 | 2012-11-07 20:37:51 | [diff] [blame] | 127 | ShellUtil::ShortcutProperties* properties) const { |
| 128 | NOTREACHED() << "Chrome Frame does not create shortcuts."; |
| 129 | } |
| 130 | |
[email protected] | 899580d4 | 2013-03-15 22:49:12 | [diff] [blame] | 131 | void ChromeFrameOperations::LaunchUserExperiment( |
| 132 | const base::FilePath& setup_path, |
[email protected] | 05aab99c | 2013-12-20 09:03:15 | [diff] [blame] | 133 | const std::set<base::string16>& options, |
[email protected] | 899580d4 | 2013-03-15 22:49:12 | [diff] [blame] | 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. |
| 138 | NOTREACHED(); |
| 139 | } |
| 140 | |
[email protected] | f0260d2 | 2011-01-25 16:44:37 | [diff] [blame] | 141 | } // namespace installer |