Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: chrome/installer/util/chrome_frame_operations.cc

Issue 6288009: More installer refactoring in the interest of fixing some bugs and cleaning t... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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 // Remove ready-mode if not multi-install.
20 void ChromeFrameOperations::NormalizeOptions(
21 std::set<std::wstring>* options) const {
22 std::set<std::wstring>::iterator ready_mode(options->find(kOptionReadyMode));
23 if (ready_mode != options->end() &&
24 options->find(kOptionMultiInstall) == options->end()) {
25 LOG(WARNING) << "--ready-mode option does not apply when --multi-install "
26 "is not also specified; ignoring.";
27 options->erase(ready_mode);
28 }
29 }
30
31 void ChromeFrameOperations::ReadOptions(
32 const MasterPreferences& prefs,
33 std::set<std::wstring>* options) const {
34 DCHECK(options);
35
36 static const struct PrefToOption {
37 const char* pref_name;
38 const wchar_t* option_name;
39 } map[] = {
40 { master_preferences::kCeee, kOptionCeee },
41 { master_preferences::kChromeFrameReadyMode, kOptionReadyMode },
42 { master_preferences::kMultiInstall, kOptionMultiInstall }
43 };
44
45 bool pref_value;
46
47 for (const PrefToOption* scan = &map[0], *end = &map[arraysize(map)];
48 scan != end; ++scan) {
49 if (prefs.GetBool(scan->pref_name, &pref_value) && pref_value)
50 options->insert(scan->option_name);
51 }
52
53 NormalizeOptions(options);
54 }
55
56 void ChromeFrameOperations::ReadOptions(
57 const CommandLine& uninstall_command,
58 std::set<std::wstring>* options) const {
59 DCHECK(options);
60
61 static const struct FlagToOption {
62 const char* flag_name;
63 const wchar_t* option_name;
64 } map[] = {
65 { switches::kCeee, kOptionCeee },
66 { switches::kChromeFrameReadyMode, kOptionReadyMode },
67 { switches::kMultiInstall, kOptionMultiInstall }
68 };
69
70 for (const FlagToOption* scan = &map[0], *end = &map[arraysize(map)];
71 scan != end; ++scan) {
72 if (uninstall_command.HasSwitch(scan->flag_name))
73 options->insert(scan->option_name);
74 }
75
76 NormalizeOptions(options);
77 }
78
79 void ChromeFrameOperations::AddKeyFiles(
80 const std::set<std::wstring>& options,
81 std::vector<FilePath>* key_files) const {
82 DCHECK(key_files);
83 key_files->push_back(FilePath(installer::kChromeFrameDll));
84 if (options.find(kOptionCeee) != options.end()) {
85 key_files->push_back(FilePath(installer::kCeeeIeDll));
86 key_files->push_back(FilePath(installer::kCeeeBrokerExe));
87 }
88 }
89
90 void ChromeFrameOperations::AddComDllList(
91 const std::set<std::wstring>& options,
92 std::vector<FilePath>* com_dll_list) const {
93 DCHECK(com_dll_list);
94 std::vector<FilePath> dll_list;
95 com_dll_list->push_back(FilePath(installer::kChromeFrameDll));
96 if (options.find(kOptionCeee) != options.end()) {
97 com_dll_list->push_back(FilePath(installer::kCeeeInstallHelperDll));
98 com_dll_list->push_back(FilePath(installer::kCeeeIeDll));
99 }
100 }
101
102 void ChromeFrameOperations::AppendProductFlags(
103 const std::set<std::wstring>& options,
104 CommandLine* uninstall_command) const {
105 DCHECK(uninstall_command);
106 uninstall_command->AppendSwitch(switches::kChromeFrame);
107
108 if (options.find(kOptionCeee) != options.end())
109 uninstall_command->AppendSwitch(switches::kCeee);
110
111 if (options.find(kOptionMultiInstall) != options.end()) {
112 if (!uninstall_command->HasSwitch(switches::kMultiInstall))
113 uninstall_command->AppendSwitch(switches::kMultiInstall);
114
115 // ready-mode is only supported in multi-installs of Chrome Frame.
116 if (options.find(kOptionReadyMode) != options.end())
117 uninstall_command->AppendSwitch(switches::kChromeFrameReadyMode);
118 }
119 }
120
121 bool ChromeFrameOperations::SetChannelFlags(
122 const std::set<std::wstring>& options,
123 bool set,
124 ChannelInfo* channel_info) const {
125 #if defined(GOOGLE_CHROME_BUILD)
126 DCHECK(channel_info);
127 bool modified = channel_info->SetChromeFrame(set);
128
129 // Always remove the options if we're called to remove flags or if the
130 // corresponding option isn't set.
131 modified |= channel_info->SetCeee(
132 set && options.find(kOptionCeee) != options.end());
133
134 modified |= channel_info->SetReadyMode(
135 set && options.find(kOptionReadyMode) != options.end());
136
137 return modified;
138 #else
139 return false;
140 #endif
141 }
142
143 bool ChromeFrameOperations::ShouldCreateUninstallEntry(
144 const std::set<std::wstring>& options) const {
145 return options.find(kOptionReadyMode) == options.end();
146 }
147
148 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/installer/util/chrome_frame_operations.h ('k') | chrome/installer/util/chromium_binaries_distribution.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698