| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/installer/util/chrome_frame_operations.h" | 5 #include "chrome/installer/util/chrome_frame_operations.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/installer/util/channel_info.h" | 10 #include "chrome/installer/util/channel_info.h" |
| 11 #include "chrome/installer/util/helper.h" | 11 #include "chrome/installer/util/helper.h" |
| 12 #include "chrome/installer/util/master_preferences.h" | 12 #include "chrome/installer/util/master_preferences.h" |
| 13 #include "chrome/installer/util/master_preferences_constants.h" | 13 #include "chrome/installer/util/master_preferences_constants.h" |
| 14 #include "chrome/installer/util/util_constants.h" | 14 #include "chrome/installer/util/util_constants.h" |
| 15 | 15 |
| 16 namespace installer { | 16 namespace installer { |
| 17 | 17 |
| 18 // Remove ready-mode if not multi-install. | |
| 19 void ChromeFrameOperations::NormalizeOptions( | |
| 20 std::set<string16>* options) const { | |
| 21 std::set<string16>::iterator ready_mode(options->find(kOptionReadyMode)); | |
| 22 if (ready_mode != options->end() && | |
| 23 options->find(kOptionMultiInstall) == options->end()) { | |
| 24 LOG(WARNING) << "--ready-mode option does not apply when --multi-install " | |
| 25 "is not also specified; ignoring."; | |
| 26 options->erase(ready_mode); | |
| 27 } | |
| 28 } | |
| 29 | |
| 30 void ChromeFrameOperations::ReadOptions(const MasterPreferences& prefs, | 18 void ChromeFrameOperations::ReadOptions(const MasterPreferences& prefs, |
| 31 std::set<string16>* options) const { | 19 std::set<string16>* options) const { |
| 32 DCHECK(options); | 20 DCHECK(options); |
| 33 | 21 |
| 34 static const struct PrefToOption { | 22 static const struct PrefToOption { |
| 35 const char* pref_name; | 23 const char* pref_name; |
| 36 const wchar_t* option_name; | 24 const wchar_t* option_name; |
| 37 } map[] = { | 25 } map[] = { |
| 38 { master_preferences::kChromeFrameReadyMode, kOptionReadyMode }, | |
| 39 { master_preferences::kMultiInstall, kOptionMultiInstall } | 26 { master_preferences::kMultiInstall, kOptionMultiInstall } |
| 40 }; | 27 }; |
| 41 | 28 |
| 42 bool pref_value; | 29 bool pref_value; |
| 43 | 30 |
| 44 for (const PrefToOption* scan = &map[0], *end = &map[arraysize(map)]; | 31 for (const PrefToOption* scan = &map[0], *end = &map[arraysize(map)]; |
| 45 scan != end; ++scan) { | 32 scan != end; ++scan) { |
| 46 if (prefs.GetBool(scan->pref_name, &pref_value) && pref_value) | 33 if (prefs.GetBool(scan->pref_name, &pref_value) && pref_value) |
| 47 options->insert(scan->option_name); | 34 options->insert(scan->option_name); |
| 48 } | 35 } |
| 49 | |
| 50 NormalizeOptions(options); | |
| 51 } | 36 } |
| 52 | 37 |
| 53 void ChromeFrameOperations::ReadOptions(const CommandLine& uninstall_command, | 38 void ChromeFrameOperations::ReadOptions(const CommandLine& uninstall_command, |
| 54 std::set<string16>* options) const { | 39 std::set<string16>* options) const { |
| 55 DCHECK(options); | 40 DCHECK(options); |
| 56 | 41 |
| 57 static const struct FlagToOption { | 42 static const struct FlagToOption { |
| 58 const char* flag_name; | 43 const char* flag_name; |
| 59 const wchar_t* option_name; | 44 const wchar_t* option_name; |
| 60 } map[] = { | 45 } map[] = { |
| 61 { switches::kChromeFrameReadyMode, kOptionReadyMode }, | |
| 62 { switches::kMultiInstall, kOptionMultiInstall } | 46 { switches::kMultiInstall, kOptionMultiInstall } |
| 63 }; | 47 }; |
| 64 | 48 |
| 65 for (const FlagToOption* scan = &map[0], *end = &map[arraysize(map)]; | 49 for (const FlagToOption* scan = &map[0], *end = &map[arraysize(map)]; |
| 66 scan != end; ++scan) { | 50 scan != end; ++scan) { |
| 67 if (uninstall_command.HasSwitch(scan->flag_name)) | 51 if (uninstall_command.HasSwitch(scan->flag_name)) |
| 68 options->insert(scan->option_name); | 52 options->insert(scan->option_name); |
| 69 } | 53 } |
| 70 | |
| 71 NormalizeOptions(options); | |
| 72 } | 54 } |
| 73 | 55 |
| 74 void ChromeFrameOperations::AddKeyFiles( | 56 void ChromeFrameOperations::AddKeyFiles( |
| 75 const std::set<string16>& options, | 57 const std::set<string16>& options, |
| 76 std::vector<base::FilePath>* key_files) const { | 58 std::vector<base::FilePath>* key_files) const { |
| 77 DCHECK(key_files); | 59 DCHECK(key_files); |
| 78 key_files->push_back(base::FilePath(installer::kChromeFrameDll)); | 60 key_files->push_back(base::FilePath(installer::kChromeFrameDll)); |
| 79 key_files->push_back(base::FilePath(installer::kChromeFrameHelperExe)); | 61 key_files->push_back(base::FilePath(installer::kChromeFrameHelperExe)); |
| 80 } | 62 } |
| 81 | 63 |
| 82 void ChromeFrameOperations::AddComDllList( | 64 void ChromeFrameOperations::AddComDllList( |
| 83 const std::set<string16>& options, | 65 const std::set<string16>& options, |
| 84 std::vector<base::FilePath>* com_dll_list) const { | 66 std::vector<base::FilePath>* com_dll_list) const { |
| 85 DCHECK(com_dll_list); | 67 DCHECK(com_dll_list); |
| 86 com_dll_list->push_back(base::FilePath(installer::kChromeFrameDll)); | 68 com_dll_list->push_back(base::FilePath(installer::kChromeFrameDll)); |
| 87 } | 69 } |
| 88 | 70 |
| 89 void ChromeFrameOperations::AppendProductFlags( | 71 void ChromeFrameOperations::AppendProductFlags( |
| 90 const std::set<string16>& options, | 72 const std::set<string16>& options, |
| 91 CommandLine* cmd_line) const { | 73 CommandLine* cmd_line) const { |
| 92 DCHECK(cmd_line); | 74 DCHECK(cmd_line); |
| 93 bool is_multi_install = options.find(kOptionMultiInstall) != options.end(); | 75 bool is_multi_install = options.find(kOptionMultiInstall) != options.end(); |
| 94 | 76 |
| 95 // Add --multi-install if it isn't already there. | 77 // Add --multi-install if it isn't already there. |
| 96 if (is_multi_install && !cmd_line->HasSwitch(switches::kMultiInstall)) | 78 if (is_multi_install && !cmd_line->HasSwitch(switches::kMultiInstall)) |
| 97 cmd_line->AppendSwitch(switches::kMultiInstall); | 79 cmd_line->AppendSwitch(switches::kMultiInstall); |
| 98 | 80 |
| 99 // --chrome-frame is always needed. | 81 // --chrome-frame is always needed. |
| 100 cmd_line->AppendSwitch(switches::kChromeFrame); | 82 cmd_line->AppendSwitch(switches::kChromeFrame); |
| 101 | |
| 102 // ready-mode is only supported in multi-installs of Chrome Frame. | |
| 103 if (is_multi_install && options.find(kOptionReadyMode) != options.end()) | |
| 104 cmd_line->AppendSwitch(switches::kChromeFrameReadyMode); | |
| 105 } | 83 } |
| 106 | 84 |
| 107 void ChromeFrameOperations::AppendRenameFlags(const std::set<string16>& options, | 85 void ChromeFrameOperations::AppendRenameFlags(const std::set<string16>& options, |
| 108 CommandLine* cmd_line) const { | 86 CommandLine* cmd_line) const { |
| 109 DCHECK(cmd_line); | 87 DCHECK(cmd_line); |
| 110 bool is_multi_install = options.find(kOptionMultiInstall) != options.end(); | 88 bool is_multi_install = options.find(kOptionMultiInstall) != options.end(); |
| 111 | 89 |
| 112 // Add --multi-install if it isn't already there. | 90 // Add --multi-install if it isn't already there. |
| 113 if (is_multi_install && !cmd_line->HasSwitch(switches::kMultiInstall)) | 91 if (is_multi_install && !cmd_line->HasSwitch(switches::kMultiInstall)) |
| 114 cmd_line->AppendSwitch(switches::kMultiInstall); | 92 cmd_line->AppendSwitch(switches::kMultiInstall); |
| 115 | 93 |
| 116 // --chrome-frame is needed for single installs. | 94 // --chrome-frame is needed for single installs. |
| 117 if (!is_multi_install) | 95 if (!is_multi_install) |
| 118 cmd_line->AppendSwitch(switches::kChromeFrame); | 96 cmd_line->AppendSwitch(switches::kChromeFrame); |
| 119 } | 97 } |
| 120 | 98 |
| 121 bool ChromeFrameOperations::SetChannelFlags(const std::set<string16>& options, | 99 bool ChromeFrameOperations::SetChannelFlags(const std::set<string16>& options, |
| 122 bool set, | 100 bool set, |
| 123 ChannelInfo* channel_info) const { | 101 ChannelInfo* channel_info) const { |
| 124 #if defined(GOOGLE_CHROME_BUILD) | 102 #if defined(GOOGLE_CHROME_BUILD) |
| 125 DCHECK(channel_info); | 103 DCHECK(channel_info); |
| 126 bool modified = channel_info->SetChromeFrame(set); | 104 bool modified = channel_info->SetChromeFrame(set); |
| 127 | 105 |
| 128 // Always remove the options if we're called to remove flags or if the | 106 // Unconditionally remove the legacy -readymode flag. |
| 129 // corresponding option isn't set. | 107 modified |= channel_info->SetReadyMode(false); |
| 130 modified |= channel_info->SetReadyMode( | |
| 131 set && options.find(kOptionReadyMode) != options.end()); | |
| 132 | 108 |
| 133 return modified; | 109 return modified; |
| 134 #else | 110 #else |
| 135 return false; | 111 return false; |
| 136 #endif | 112 #endif |
| 137 } | 113 } |
| 138 | 114 |
| 139 bool ChromeFrameOperations::ShouldCreateUninstallEntry( | 115 bool ChromeFrameOperations::ShouldCreateUninstallEntry( |
| 140 const std::set<string16>& options) const { | 116 const std::set<string16>& options) const { |
| 141 return options.find(kOptionReadyMode) == options.end(); | 117 return true; |
| 142 } | 118 } |
| 143 | 119 |
| 144 void ChromeFrameOperations::AddDefaultShortcutProperties( | 120 void ChromeFrameOperations::AddDefaultShortcutProperties( |
| 145 BrowserDistribution* dist, | 121 BrowserDistribution* dist, |
| 146 const base::FilePath& target_exe, | 122 const base::FilePath& target_exe, |
| 147 ShellUtil::ShortcutProperties* properties) const { | 123 ShellUtil::ShortcutProperties* properties) const { |
| 148 NOTREACHED() << "Chrome Frame does not create shortcuts."; | 124 NOTREACHED() << "Chrome Frame does not create shortcuts."; |
| 149 } | 125 } |
| 150 | 126 |
| 151 void ChromeFrameOperations::LaunchUserExperiment( | 127 void ChromeFrameOperations::LaunchUserExperiment( |
| 152 const base::FilePath& setup_path, | 128 const base::FilePath& setup_path, |
| 153 const std::set<string16>& options, | 129 const std::set<string16>& options, |
| 154 InstallStatus status, | 130 InstallStatus status, |
| 155 bool system_level) const { | 131 bool system_level) const { |
| 156 // No experiments yet. If adding some in the future, need to have | 132 // No experiments yet. If adding some in the future, need to have |
| 157 // ChromeFrameDistribution::HasUserExperiments() return true. | 133 // ChromeFrameDistribution::HasUserExperiments() return true. |
| 158 NOTREACHED(); | 134 NOTREACHED(); |
| 159 } | 135 } |
| 160 | 136 |
| 161 } // namespace installer | 137 } // namespace installer |
| OLD | NEW |