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

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);
tommi (sloooow) - chröme 2011/01/24 19:39:39 nit: use constructor syntax instead of =
grt (UTC plus 2) 2011/01/25 03:09:40 Done.
23 if (ready_mode != options->end() &&
24 options->find(kOptionMultiInstall) == options->end()) {
25 options->erase(ready_mode);
26 }
27 }
28
29 void ChromeFrameOperations::ReadOptions(
30 const MasterPreferences& prefs,
31 std::set<std::wstring>* options) const {
32 DCHECK(options);
33
34 static const struct PrefToOption {
35 const char* pref_name;
36 const wchar_t* option_name;
37 } map[] = {
38 { master_preferences::kCeee, kOptionCeee },
39 { master_preferences::kChromeFrameReadyMode, kOptionReadyMode },
40 { master_preferences::kMultiInstall, kOptionMultiInstall }
41 };
42
43 bool pref_value;
44
45 for (const PrefToOption* scan = &map[0], *end = &map[arraysize(map)];
46 scan != end; ++scan) {
47 if (prefs.GetBool(scan->pref_name, &pref_value) && pref_value)
48 options->insert(scan->option_name);
49 }
50
51 NormalizeOptions(options);
52 }
53
54 void ChromeFrameOperations::ReadOptions(
55 const CommandLine& uninstall_command,
56 std::set<std::wstring>* options) const {
57 DCHECK(options);
58
59 static const struct FlagToOption {
60 const char* flag_name;
61 const wchar_t* option_name;
62 } map[] = {
63 { switches::kCeee, kOptionCeee },
64 { switches::kChromeFrameReadyMode, kOptionReadyMode },
65 { switches::kMultiInstall, kOptionMultiInstall }
66 };
67
68 for (const FlagToOption* scan = &map[0], *end = &map[arraysize(map)];
69 scan != end; ++scan) {
70 if (uninstall_command.HasSwitch(scan->flag_name))
71 options->insert(scan->option_name);
72 }
73
74 NormalizeOptions(options);
75 }
76
77 void ChromeFrameOperations::AddKeyFiles(
78 const std::set<std::wstring>& options,
79 std::vector<FilePath>* key_files) const {
80 DCHECK(key_files);
81 key_files->push_back(FilePath(installer::kChromeFrameDll));
82 if (options.find(kOptionCeee) != options.end()) {
83 key_files->push_back(FilePath(installer::kCeeeIeDll));
84 key_files->push_back(FilePath(installer::kCeeeBrokerExe));
85 }
86 }
87
88 void ChromeFrameOperations::AddComDllList(
89 const std::set<std::wstring>& options,
90 std::vector<FilePath>* com_dll_list) const {
91 DCHECK(com_dll_list);
92 std::vector<FilePath> dll_list;
93 com_dll_list->push_back(FilePath(installer::kChromeFrameDll));
94 if (options.find(kOptionCeee) != options.end()) {
95 com_dll_list->push_back(FilePath(installer::kCeeeInstallHelperDll));
96 com_dll_list->push_back(FilePath(installer::kCeeeIeDll));
97 }
98 }
99
100 void ChromeFrameOperations::AppendProductFlags(
101 const std::set<std::wstring>& options,
102 CommandLine* uninstall_command) const {
103 DCHECK(uninstall_command);
104 uninstall_command->AppendSwitch(switches::kChromeFrame);
105
106 if (options.find(kOptionCeee) != options.end())
107 uninstall_command->AppendSwitch(switches::kCeee);
108
109 if (options.find(kOptionMultiInstall) != options.end()) {
110 if (!uninstall_command->HasSwitch(switches::kMultiInstall))
111 uninstall_command->AppendSwitch(switches::kMultiInstall);
112
113 // ready-mode is only supported in multi-installs of Chrome Frame.
114 if (options.find(kOptionReadyMode) != options.end())
115 uninstall_command->AppendSwitch(switches::kChromeFrameReadyMode);
116 }
117 }
118
119 bool ChromeFrameOperations::SetChannelFlags(
120 const std::set<std::wstring>& options,
121 bool set,
122 ChannelInfo* channel_info) const {
123 #if defined(GOOGLE_CHROME_BUILD)
124 DCHECK(channel_info);
125 bool modified = channel_info->SetChromeFrame(set);
126
127 // Always remove the options if we're called to remove flags or if the
128 // corresponding option isn't set.
129 modified |= channel_info->SetCeee(
130 set && options.find(kOptionCeee) != options.end());
131
132 modified |= channel_info->SetReadyMode(
133 set && options.find(kOptionReadyMode) != options.end());
134
135 return modified;
136 #else
137 return false;
138 #endif
139 }
140
141 bool ChromeFrameOperations::ShouldCreateUninstallEntry(
142 const std::set<std::wstring>& options) const {
143 return options.find(kOptionReadyMode) == options.end();
144 }
145
146 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698