OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/master_preferences.h" | 5 #include "chrome/installer/util/master_preferences.h" |
6 | 6 |
7 #include "base/environment.h" | 7 #include "base/environment.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/json/json_value_serializer.h" | 9 #include "base/json/json_value_serializer.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 } | 73 } |
74 return static_cast<DictionaryValue*>(root.release()); | 74 return static_cast<DictionaryValue*>(root.release()); |
75 } | 75 } |
76 | 76 |
77 } // namespace | 77 } // namespace |
78 | 78 |
79 namespace installer { | 79 namespace installer { |
80 | 80 |
81 MasterPreferences::MasterPreferences() : distribution_(NULL), | 81 MasterPreferences::MasterPreferences() : distribution_(NULL), |
82 preferences_read_from_file_(false), | 82 preferences_read_from_file_(false), |
83 ceee_(false), | |
84 chrome_(true), | 83 chrome_(true), |
85 chrome_frame_(false), | 84 chrome_frame_(false), |
86 multi_install_(false) { | 85 multi_install_(false) { |
87 InitializeFromCommandLine(*CommandLine::ForCurrentProcess()); | 86 InitializeFromCommandLine(*CommandLine::ForCurrentProcess()); |
88 } | 87 } |
89 | 88 |
90 MasterPreferences::MasterPreferences(const CommandLine& cmd_line) | 89 MasterPreferences::MasterPreferences(const CommandLine& cmd_line) |
91 : distribution_(NULL), | 90 : distribution_(NULL), |
92 preferences_read_from_file_(false), | 91 preferences_read_from_file_(false), |
93 ceee_(false), | |
94 chrome_(true), | 92 chrome_(true), |
95 chrome_frame_(false), | 93 chrome_frame_(false), |
96 multi_install_(false) { | 94 multi_install_(false) { |
97 InitializeFromCommandLine(cmd_line); | 95 InitializeFromCommandLine(cmd_line); |
98 } | 96 } |
99 | 97 |
100 MasterPreferences::MasterPreferences(const FilePath& prefs_path) | 98 MasterPreferences::MasterPreferences(const FilePath& prefs_path) |
101 : distribution_(NULL), preferences_read_from_file_(false), ceee_(false), | 99 : distribution_(NULL), preferences_read_from_file_(false), |
102 chrome_(true), chrome_frame_(false), multi_install_(false) { | 100 chrome_(true), chrome_frame_(false), multi_install_(false) { |
103 master_dictionary_.reset(ParseDistributionPreferences(prefs_path)); | 101 master_dictionary_.reset(ParseDistributionPreferences(prefs_path)); |
104 | 102 |
105 if (!master_dictionary_.get()) { | 103 if (!master_dictionary_.get()) { |
106 master_dictionary_.reset(new DictionaryValue()); | 104 master_dictionary_.reset(new DictionaryValue()); |
107 } else { | 105 } else { |
108 preferences_read_from_file_ = true; | 106 preferences_read_from_file_ = true; |
109 // Cache a pointer to the distribution dictionary. | 107 // Cache a pointer to the distribution dictionary. |
110 master_dictionary_->GetDictionary(kDistroDict, &distribution_); | 108 master_dictionary_->GetDictionary(kDistroDict, &distribution_); |
111 } | 109 } |
(...skipping 18 matching lines...) Expand all Loading... | |
130 | 128 |
131 // A simple map from command line switches to equivalent switches in the | 129 // A simple map from command line switches to equivalent switches in the |
132 // distribution dictionary. Currently all switches added will be set to | 130 // distribution dictionary. Currently all switches added will be set to |
133 // 'true'. | 131 // 'true'. |
134 static const struct CmdLineSwitchToDistributionSwitch { | 132 static const struct CmdLineSwitchToDistributionSwitch { |
135 const char* cmd_line_switch; | 133 const char* cmd_line_switch; |
136 const char* distribution_switch; | 134 const char* distribution_switch; |
137 } translate_switches[] = { | 135 } translate_switches[] = { |
138 { installer::switches::kAutoLaunchChrome, | 136 { installer::switches::kAutoLaunchChrome, |
139 installer::master_preferences::kAutoLaunchChrome }, | 137 installer::master_preferences::kAutoLaunchChrome }, |
140 { installer::switches::kCeee, | |
141 installer::master_preferences::kCeee }, | |
142 { installer::switches::kChrome, | 138 { installer::switches::kChrome, |
143 installer::master_preferences::kChrome }, | 139 installer::master_preferences::kChrome }, |
144 { installer::switches::kChromeFrame, | 140 { installer::switches::kChromeFrame, |
145 installer::master_preferences::kChromeFrame }, | 141 installer::master_preferences::kChromeFrame }, |
146 { installer::switches::kChromeFrameReadyMode, | 142 { installer::switches::kChromeFrameReadyMode, |
147 installer::master_preferences::kChromeFrameReadyMode }, | 143 installer::master_preferences::kChromeFrameReadyMode }, |
148 { installer::switches::kCreateAllShortcuts, | 144 { installer::switches::kCreateAllShortcuts, |
149 installer::master_preferences::kCreateAllShortcuts }, | 145 installer::master_preferences::kCreateAllShortcuts }, |
150 { installer::switches::kDisableLogging, | 146 { installer::switches::kDisableLogging, |
151 installer::master_preferences::kDisableLogging }, | 147 installer::master_preferences::kDisableLogging }, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 master_dictionary_->GetDictionary(kDistroDict, &distribution_); | 201 master_dictionary_->GetDictionary(kDistroDict, &distribution_); |
206 | 202 |
207 InitializeProductFlags(); | 203 InitializeProductFlags(); |
208 #endif | 204 #endif |
209 } | 205 } |
210 | 206 |
211 void MasterPreferences::InitializeProductFlags() { | 207 void MasterPreferences::InitializeProductFlags() { |
212 // Make sure we start out with the correct defaults. | 208 // Make sure we start out with the correct defaults. |
213 multi_install_ = false; | 209 multi_install_ = false; |
214 chrome_frame_ = false; | 210 chrome_frame_ = false; |
215 ceee_ = false; | |
216 chrome_ = true; | 211 chrome_ = true; |
217 | 212 |
218 GetBool(installer::master_preferences::kMultiInstall, &multi_install_); | 213 GetBool(installer::master_preferences::kMultiInstall, &multi_install_); |
219 GetBool(installer::master_preferences::kChromeFrame, &chrome_frame_); | 214 GetBool(installer::master_preferences::kChromeFrame, &chrome_frame_); |
220 GetBool(installer::master_preferences::kCeee, &ceee_); | |
221 | 215 |
222 // When multi-install is specified, the checks are pretty simple (in theory): | 216 // When multi-install is specified, the checks are pretty simple (in theory): |
223 // In order to be installed/uninstalled, each product must have its switch | 217 // In order to be installed/uninstalled, each product must have its switch |
224 // present on the command line. | 218 // present on the command line. |
225 // Before multi-install was introduced however, we only supported installing | 219 // Before multi-install was introduced however, we only supported installing |
226 // two products, Chrome and Chrome Frame. For the time being we need to | 220 // two products, Chrome and Chrome Frame. For the time being we need to |
227 // continue to support this mode where multi-install is not set. | 221 // continue to support this mode where multi-install is not set. |
228 // So, when multi-install is not set, we continue to support mutually | |
229 // exclusive installation of Chrome and Chrome Frame in addition to supporting | |
mad-corp
2011/12/15 19:45:37
Don't we want to keep the first part of the senten
grt (UTC plus 2)
2011/12/16 04:24:52
Yes, please keep the first part (up to "...and Chr
Roger Tawa OOO till Jul 10th
2011/12/16 16:24:30
Done.
Roger Tawa OOO till Jul 10th
2011/12/16 16:24:30
Done.
| |
230 // installation of CEEE with Chrome Frame. | |
231 | |
232 // Regardless of multi install being present, CEEE always needs CF to | |
233 // be installed. | |
234 if (ceee_) | |
235 chrome_frame_ = true; | |
236 | 222 |
237 if (multi_install_) { | 223 if (multi_install_) { |
238 if (!GetBool(installer::master_preferences::kChrome, &chrome_)) | 224 if (!GetBool(installer::master_preferences::kChrome, &chrome_)) |
239 chrome_ = false; | 225 chrome_ = false; |
240 } else { | 226 } else { |
241 // If chrome-frame is on the command line however, we only install CF. | 227 // If chrome-frame is on the command line however, we only install CF. |
242 chrome_ = !chrome_frame_; | 228 chrome_ = !chrome_frame_; |
243 } | 229 } |
244 } | 230 } |
245 | 231 |
(...skipping 26 matching lines...) Expand all Loading... | |
272 bool MasterPreferences::GetExtensionsBlock(DictionaryValue** extensions) const { | 258 bool MasterPreferences::GetExtensionsBlock(DictionaryValue** extensions) const { |
273 return master_dictionary_->GetDictionary( | 259 return master_dictionary_->GetDictionary( |
274 master_preferences::kExtensionsBlock, extensions); | 260 master_preferences::kExtensionsBlock, extensions); |
275 } | 261 } |
276 | 262 |
277 // static | 263 // static |
278 const MasterPreferences& MasterPreferences::ForCurrentProcess() { | 264 const MasterPreferences& MasterPreferences::ForCurrentProcess() { |
279 return g_master_preferences.Get(); | 265 return g_master_preferences.Get(); |
280 } | 266 } |
281 } // installer_util | 267 } // installer_util |
OLD | NEW |