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