| 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 void ChromeFrameOperations::ReadOptions(const MasterPreferences& prefs, | 18 void ChromeFrameOperations::ReadOptions(const MasterPreferences& prefs, |
| 19 std::set<string16>* options) const { | 19 std::set<base::string16>* options) |
| 20 const { |
| 20 DCHECK(options); | 21 DCHECK(options); |
| 21 | 22 |
| 22 static const struct PrefToOption { | 23 static const struct PrefToOption { |
| 23 const char* pref_name; | 24 const char* pref_name; |
| 24 const wchar_t* option_name; | 25 const wchar_t* option_name; |
| 25 } map[] = { | 26 } map[] = { |
| 26 { master_preferences::kMultiInstall, kOptionMultiInstall } | 27 { master_preferences::kMultiInstall, kOptionMultiInstall } |
| 27 }; | 28 }; |
| 28 | 29 |
| 29 bool pref_value; | 30 bool pref_value; |
| 30 | 31 |
| 31 for (const PrefToOption* scan = &map[0], *end = &map[arraysize(map)]; | 32 for (const PrefToOption* scan = &map[0], *end = &map[arraysize(map)]; |
| 32 scan != end; ++scan) { | 33 scan != end; ++scan) { |
| 33 if (prefs.GetBool(scan->pref_name, &pref_value) && pref_value) | 34 if (prefs.GetBool(scan->pref_name, &pref_value) && pref_value) |
| 34 options->insert(scan->option_name); | 35 options->insert(scan->option_name); |
| 35 } | 36 } |
| 36 } | 37 } |
| 37 | 38 |
| 38 void ChromeFrameOperations::ReadOptions(const CommandLine& uninstall_command, | 39 void ChromeFrameOperations::ReadOptions(const CommandLine& uninstall_command, |
| 39 std::set<string16>* options) const { | 40 std::set<base::string16>* options) |
| 41 const { |
| 40 DCHECK(options); | 42 DCHECK(options); |
| 41 | 43 |
| 42 static const struct FlagToOption { | 44 static const struct FlagToOption { |
| 43 const char* flag_name; | 45 const char* flag_name; |
| 44 const wchar_t* option_name; | 46 const wchar_t* option_name; |
| 45 } map[] = { | 47 } map[] = { |
| 46 { switches::kMultiInstall, kOptionMultiInstall } | 48 { switches::kMultiInstall, kOptionMultiInstall } |
| 47 }; | 49 }; |
| 48 | 50 |
| 49 for (const FlagToOption* scan = &map[0], *end = &map[arraysize(map)]; | 51 for (const FlagToOption* scan = &map[0], *end = &map[arraysize(map)]; |
| 50 scan != end; ++scan) { | 52 scan != end; ++scan) { |
| 51 if (uninstall_command.HasSwitch(scan->flag_name)) | 53 if (uninstall_command.HasSwitch(scan->flag_name)) |
| 52 options->insert(scan->option_name); | 54 options->insert(scan->option_name); |
| 53 } | 55 } |
| 54 } | 56 } |
| 55 | 57 |
| 56 void ChromeFrameOperations::AddKeyFiles( | 58 void ChromeFrameOperations::AddKeyFiles( |
| 57 const std::set<string16>& options, | 59 const std::set<base::string16>& options, |
| 58 std::vector<base::FilePath>* key_files) const { | 60 std::vector<base::FilePath>* key_files) const { |
| 59 DCHECK(key_files); | 61 DCHECK(key_files); |
| 60 key_files->push_back(base::FilePath(installer::kChromeFrameDll)); | 62 key_files->push_back(base::FilePath(installer::kChromeFrameDll)); |
| 61 key_files->push_back(base::FilePath(installer::kChromeFrameHelperExe)); | 63 key_files->push_back(base::FilePath(installer::kChromeFrameHelperExe)); |
| 62 } | 64 } |
| 63 | 65 |
| 64 void ChromeFrameOperations::AddComDllList( | 66 void ChromeFrameOperations::AddComDllList( |
| 65 const std::set<string16>& options, | 67 const std::set<base::string16>& options, |
| 66 std::vector<base::FilePath>* com_dll_list) const { | 68 std::vector<base::FilePath>* com_dll_list) const { |
| 67 DCHECK(com_dll_list); | 69 DCHECK(com_dll_list); |
| 68 com_dll_list->push_back(base::FilePath(installer::kChromeFrameDll)); | 70 com_dll_list->push_back(base::FilePath(installer::kChromeFrameDll)); |
| 69 } | 71 } |
| 70 | 72 |
| 71 void ChromeFrameOperations::AppendProductFlags( | 73 void ChromeFrameOperations::AppendProductFlags( |
| 72 const std::set<string16>& options, | 74 const std::set<base::string16>& options, |
| 73 CommandLine* cmd_line) const { | 75 CommandLine* cmd_line) const { |
| 74 DCHECK(cmd_line); | 76 DCHECK(cmd_line); |
| 75 bool is_multi_install = options.find(kOptionMultiInstall) != options.end(); | 77 bool is_multi_install = options.find(kOptionMultiInstall) != options.end(); |
| 76 | 78 |
| 77 // Add --multi-install if it isn't already there. | 79 // Add --multi-install if it isn't already there. |
| 78 if (is_multi_install && !cmd_line->HasSwitch(switches::kMultiInstall)) | 80 if (is_multi_install && !cmd_line->HasSwitch(switches::kMultiInstall)) |
| 79 cmd_line->AppendSwitch(switches::kMultiInstall); | 81 cmd_line->AppendSwitch(switches::kMultiInstall); |
| 80 | 82 |
| 81 // --chrome-frame is always needed. | 83 // --chrome-frame is always needed. |
| 82 cmd_line->AppendSwitch(switches::kChromeFrame); | 84 cmd_line->AppendSwitch(switches::kChromeFrame); |
| 83 } | 85 } |
| 84 | 86 |
| 85 void ChromeFrameOperations::AppendRenameFlags(const std::set<string16>& options, | 87 void ChromeFrameOperations::AppendRenameFlags( |
| 86 CommandLine* cmd_line) const { | 88 const std::set<base::string16>& options, |
| 89 CommandLine* cmd_line) const { |
| 87 DCHECK(cmd_line); | 90 DCHECK(cmd_line); |
| 88 bool is_multi_install = options.find(kOptionMultiInstall) != options.end(); | 91 bool is_multi_install = options.find(kOptionMultiInstall) != options.end(); |
| 89 | 92 |
| 90 // Add --multi-install if it isn't already there. | 93 // Add --multi-install if it isn't already there. |
| 91 if (is_multi_install && !cmd_line->HasSwitch(switches::kMultiInstall)) | 94 if (is_multi_install && !cmd_line->HasSwitch(switches::kMultiInstall)) |
| 92 cmd_line->AppendSwitch(switches::kMultiInstall); | 95 cmd_line->AppendSwitch(switches::kMultiInstall); |
| 93 | 96 |
| 94 // --chrome-frame is needed for single installs. | 97 // --chrome-frame is needed for single installs. |
| 95 if (!is_multi_install) | 98 if (!is_multi_install) |
| 96 cmd_line->AppendSwitch(switches::kChromeFrame); | 99 cmd_line->AppendSwitch(switches::kChromeFrame); |
| 97 } | 100 } |
| 98 | 101 |
| 99 bool ChromeFrameOperations::SetChannelFlags(const std::set<string16>& options, | 102 bool ChromeFrameOperations::SetChannelFlags( |
| 100 bool set, | 103 const std::set<base::string16>& options, |
| 101 ChannelInfo* channel_info) const { | 104 bool set, |
| 105 ChannelInfo* channel_info) const { |
| 102 #if defined(GOOGLE_CHROME_BUILD) | 106 #if defined(GOOGLE_CHROME_BUILD) |
| 103 DCHECK(channel_info); | 107 DCHECK(channel_info); |
| 104 bool modified = channel_info->SetChromeFrame(set); | 108 bool modified = channel_info->SetChromeFrame(set); |
| 105 | 109 |
| 106 // Unconditionally remove the legacy -readymode flag. | 110 // Unconditionally remove the legacy -readymode flag. |
| 107 modified |= channel_info->SetReadyMode(false); | 111 modified |= channel_info->SetReadyMode(false); |
| 108 | 112 |
| 109 return modified; | 113 return modified; |
| 110 #else | 114 #else |
| 111 return false; | 115 return false; |
| 112 #endif | 116 #endif |
| 113 } | 117 } |
| 114 | 118 |
| 115 bool ChromeFrameOperations::ShouldCreateUninstallEntry( | 119 bool ChromeFrameOperations::ShouldCreateUninstallEntry( |
| 116 const std::set<string16>& options) const { | 120 const std::set<base::string16>& options) const { |
| 117 return true; | 121 return true; |
| 118 } | 122 } |
| 119 | 123 |
| 120 void ChromeFrameOperations::AddDefaultShortcutProperties( | 124 void ChromeFrameOperations::AddDefaultShortcutProperties( |
| 121 BrowserDistribution* dist, | 125 BrowserDistribution* dist, |
| 122 const base::FilePath& target_exe, | 126 const base::FilePath& target_exe, |
| 123 ShellUtil::ShortcutProperties* properties) const { | 127 ShellUtil::ShortcutProperties* properties) const { |
| 124 NOTREACHED() << "Chrome Frame does not create shortcuts."; | 128 NOTREACHED() << "Chrome Frame does not create shortcuts."; |
| 125 } | 129 } |
| 126 | 130 |
| 127 void ChromeFrameOperations::LaunchUserExperiment( | 131 void ChromeFrameOperations::LaunchUserExperiment( |
| 128 const base::FilePath& setup_path, | 132 const base::FilePath& setup_path, |
| 129 const std::set<string16>& options, | 133 const std::set<base::string16>& options, |
| 130 InstallStatus status, | 134 InstallStatus status, |
| 131 bool system_level) const { | 135 bool system_level) const { |
| 132 // No experiments yet. If adding some in the future, need to have | 136 // No experiments yet. If adding some in the future, need to have |
| 133 // ChromeFrameDistribution::HasUserExperiments() return true. | 137 // ChromeFrameDistribution::HasUserExperiments() return true. |
| 134 NOTREACHED(); | 138 NOTREACHED(); |
| 135 } | 139 } |
| 136 | 140 |
| 137 } // namespace installer | 141 } // namespace installer |
| OLD | NEW |