Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 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/file_path.h" | |
| 9 #include "base/logging.h" | |
| 10 #include "chrome/installer/util/browser_distribution.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<std::wstring>* options) { | |
| 21 DCHECK(options != NULL); | |
| 22 | |
| 23 static const struct PrefToOption { | |
| 24 const char* pref_name; | |
| 25 const wchar_t* option_name; | |
| 26 } map[] = { | |
| 27 { master_preferences::kCeee, kOptionCeee }, | |
| 28 { master_preferences::kChromeFrameReadyMode, kOptionReadyMode }, | |
| 29 { master_preferences::kMultiInstall, kOptionMultiInstall } | |
| 30 }; | |
| 31 | |
| 32 bool pref_value; | |
| 33 | |
| 34 for (const PrefToOption* scan = &map[0], *end = &map[arraysize(map)]; | |
| 35 scan != end; ++scan) { | |
| 36 if (prefs.GetBool(scan->pref_name, &pref_value) && pref_value) | |
| 37 options->insert(scan->option_name); | |
| 38 } | |
| 39 } | |
| 40 | |
| 41 void ChromeFrameOperations::ReadOptions(const CommandLine& uninstall_command, | |
| 42 std::set<std::wstring>* options) { | |
| 43 DCHECK(options != NULL); | |
| 44 | |
| 45 static const struct FlagToOption { | |
| 46 const char* flag_name; | |
| 47 const wchar_t* option_name; | |
| 48 } map[] = { | |
| 49 { switches::kCeee, kOptionCeee }, | |
| 50 { switches::kChromeFrameReadyMode, kOptionReadyMode }, | |
| 51 { switches::kMultiInstall, kOptionMultiInstall } | |
| 52 }; | |
| 53 | |
| 54 for (const FlagToOption* scan = &map[0], *end = &map[arraysize(map)]; | |
| 55 scan != end; ++scan) { | |
| 56 if (uninstall_command.HasSwitch(scan->flag_name)) | |
| 57 options->insert(scan->option_name); | |
| 58 } | |
| 59 } | |
| 60 | |
| 61 void ChromeFrameOperations::AddKeyFiles(const std::set<std::wstring>& options, | |
| 62 std::vector<FilePath>* key_files) { | |
|
robertshield
2011/01/21 19:37:47
DCHECK(key_files);
grt (UTC plus 2)
2011/01/24 16:07:02
Done.
| |
| 63 key_files->push_back(FilePath(installer::kChromeFrameDll)); | |
| 64 if (options.find(kOptionCeee) != options.end()) { | |
| 65 key_files->push_back(FilePath(installer::kCeeeIeDll)); | |
| 66 key_files->push_back(FilePath(installer::kCeeeBrokerExe)); | |
| 67 } | |
| 68 } | |
| 69 | |
| 70 void ChromeFrameOperations::AddComDllList(const std::set<std::wstring>& options, | |
| 71 std::vector<FilePath>* com_dll_list) { | |
|
robertshield
2011/01/21 19:37:47
DCHECK(com_dll_list);
grt (UTC plus 2)
2011/01/24 16:07:02
Done.
| |
| 72 std::vector<FilePath> dll_list; | |
| 73 com_dll_list->push_back(FilePath(installer::kChromeFrameDll)); | |
| 74 if (options.find(kOptionCeee) != options.end()) { | |
| 75 com_dll_list->push_back(FilePath(installer::kCeeeInstallHelperDll)); | |
| 76 com_dll_list->push_back(FilePath(installer::kCeeeIeDll)); | |
| 77 } | |
| 78 } | |
| 79 | |
| 80 void ChromeFrameOperations::AppendProductFlags( | |
| 81 const std::set<std::wstring>& options, | |
| 82 CommandLine* uninstall_command) { | |
| 83 DCHECK(uninstall_command); | |
| 84 uninstall_command->AppendSwitch(switches::kChromeFrame); | |
| 85 | |
| 86 if (options.find(kOptionCeee) != options.end()) | |
| 87 uninstall_command->AppendSwitch(switches::kCeee); | |
| 88 | |
| 89 if (options.find(kOptionMultiInstall) != options.end()) { | |
| 90 if (!uninstall_command->HasSwitch(switches::kMultiInstall)) | |
| 91 uninstall_command->AppendSwitch(switches::kMultiInstall); | |
| 92 | |
| 93 // ready-mode is only supported in multi-installs of Chrome Frame. | |
| 94 if (options.find(kOptionReadyMode) != options.end()) | |
| 95 uninstall_command->AppendSwitch(switches::kChromeFrameReadyMode); | |
| 96 } | |
| 97 } | |
| 98 | |
| 99 bool ChromeFrameOperations::SetChannelFlags( | |
| 100 const std::set<std::wstring>& options, | |
| 101 bool set, | |
| 102 ChannelInfo* channel_info) const { | |
| 103 #if defined(GOOGLE_CHROME_BUILD) | |
| 104 DCHECK(channel_info); | |
| 105 bool modified = channel_info->SetChromeFrame(set); | |
| 106 | |
| 107 // Always remove the options if we're called to remove flags or if the | |
| 108 // corresponding option isn't set. | |
| 109 modified |= channel_info->SetCeee( | |
| 110 set && options.find(kOptionCeee) != options.end()); | |
| 111 | |
| 112 modified |= channel_info->SetReadyMode( | |
| 113 set && options.find(kOptionReadyMode) != options.end()); | |
| 114 | |
| 115 return modified; | |
| 116 #else | |
| 117 return false; | |
| 118 #endif | |
| 119 } | |
| 120 | |
| 121 bool ChromeFrameOperations::ShouldCreateUninstallEntry( | |
| 122 const std::set<std::wstring>& options) const { | |
| 123 return options.find(kOptionReadyMode) == options.end(); | |
| 124 } | |
| 125 | |
| 126 } // namespace installer | |
| OLD | NEW |