OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/environment.h" | 9 #include "base/environment.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 // Cache a pointer to the distribution dictionary. | 200 // Cache a pointer to the distribution dictionary. |
201 master_dictionary_->GetDictionary( | 201 master_dictionary_->GetDictionary( |
202 installer::master_preferences::kDistroDict, &distribution_); | 202 installer::master_preferences::kDistroDict, &distribution_); |
203 } | 203 } |
204 | 204 |
205 EnforceLegacyPreferences(); | 205 EnforceLegacyPreferences(); |
206 return data_is_valid; | 206 return data_is_valid; |
207 } | 207 } |
208 | 208 |
209 void MasterPreferences::EnforceLegacyPreferences() { | 209 void MasterPreferences::EnforceLegacyPreferences() { |
210 // Boolean. This is a legacy preference and should no longer be used; it is | |
211 // kept around so that old master_preferences which specify | |
212 // "create_all_shortcuts":false still enforce the new | |
213 // "do_not_create_(desktop|quick_launch)_shortcut" preferences. Setting this | |
214 // to true no longer has any impact. | |
215 static constexpr char kCreateAllShortcuts[] = "create_all_shortcuts"; | |
216 | |
210 // If create_all_shortcuts was explicitly set to false, set | 217 // If create_all_shortcuts was explicitly set to false, set |
211 // do_not_create_(desktop|quick_launch)_shortcut to true. | 218 // do_not_create_(desktop|quick_launch)_shortcut to true. |
212 bool create_all_shortcuts = true; | 219 bool create_all_shortcuts = true; |
213 GetBool(installer::master_preferences::kCreateAllShortcuts, | 220 GetBool(kCreateAllShortcuts, &create_all_shortcuts); |
214 &create_all_shortcuts); | |
215 if (!create_all_shortcuts) { | 221 if (!create_all_shortcuts) { |
216 distribution_->SetBoolean( | 222 distribution_->SetBoolean( |
217 installer::master_preferences::kDoNotCreateDesktopShortcut, true); | 223 installer::master_preferences::kDoNotCreateDesktopShortcut, true); |
218 distribution_->SetBoolean( | 224 distribution_->SetBoolean( |
219 installer::master_preferences::kDoNotCreateQuickLaunchShortcut, true); | 225 installer::master_preferences::kDoNotCreateQuickLaunchShortcut, true); |
220 } | 226 } |
227 | |
228 // Deprecated boolean import master preferences now mapped to their duplicate | |
grt (UTC plus 2)
2017/02/23 21:19:01
duplicate -> duplicates
gab
2017/02/23 23:27:53
Done.
| |
229 // in prefs::. | |
230 static constexpr char kDistroImportHistoryPref[] = "import_history"; | |
231 static constexpr char kDistroImportHomePagePref[] = "import_home_page"; | |
232 static constexpr char kDistroImportSearchPref[] = "import_search_engine"; | |
233 static constexpr char kDistroImportBookmarksPref[] = "import_bookmarks"; | |
234 | |
235 static constexpr struct { | |
236 const char* old_distro_pref_path; | |
237 const char* modern_pref_path; | |
238 } kLegacyDistroImportPrefMappings[] = { | |
239 {kDistroImportHistoryPref, prefs::kImportHistory}, | |
240 {kDistroImportHomePagePref, prefs::kImportHomepage}, | |
241 {kDistroImportSearchPref, prefs::kImportSearchEngine}, | |
242 {kDistroImportBookmarksPref, prefs::kImportBookmarks}, | |
243 }; | |
244 | |
245 for (const auto& mapping : kLegacyDistroImportPrefMappings) { | |
246 bool value = false; | |
247 if (GetBool(mapping.old_distro_pref_path, &value)) { | |
grt (UTC plus 2)
2017/02/23 21:19:01
nit: omit braces
gab
2017/02/23 23:27:53
Done.
| |
248 master_dictionary_->SetBoolean(mapping.modern_pref_path, value); | |
249 } | |
250 } | |
221 } | 251 } |
222 | 252 |
223 bool MasterPreferences::GetBool(const std::string& name, bool* value) const { | 253 bool MasterPreferences::GetBool(const std::string& name, bool* value) const { |
224 bool ret = false; | 254 bool ret = false; |
225 if (distribution_) | 255 if (distribution_) |
226 ret = distribution_->GetBoolean(name, value); | 256 ret = distribution_->GetBoolean(name, value); |
227 return ret; | 257 return ret; |
228 } | 258 } |
229 | 259 |
230 bool MasterPreferences::GetInt(const std::string& name, int* value) const { | 260 bool MasterPreferences::GetInt(const std::string& name, int* value) const { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
274 } | 304 } |
275 return result; | 305 return result; |
276 } | 306 } |
277 | 307 |
278 // static | 308 // static |
279 const MasterPreferences& MasterPreferences::ForCurrentProcess() { | 309 const MasterPreferences& MasterPreferences::ForCurrentProcess() { |
280 return g_master_preferences.Get(); | 310 return g_master_preferences.Get(); |
281 } | 311 } |
282 | 312 |
283 } // namespace installer | 313 } // namespace installer |
OLD | NEW |