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

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

Issue 2714853002: Remove kDistroDict from Preferences. (Closed)
Patch Set: kRlzPingDelay -> kRlzPingDelaySeconds Created 3 years, 9 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
OLDNEW
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"
11 #include "base/json/json_string_value_serializer.h" 11 #include "base/json/json_string_value_serializer.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "chrome/common/env_vars.h" 17 #include "chrome/common/env_vars.h"
18 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
19 #include "chrome/installer/util/master_preferences_constants.h" 19 #include "chrome/installer/util/master_preferences_constants.h"
20 #include "chrome/installer/util/util_constants.h" 20 #include "chrome/installer/util/util_constants.h"
21 #include "components/variations/pref_names.h" 21 #include "components/variations/pref_names.h"
22 #include "rlz/features/features.h"
22 23
23 namespace { 24 namespace {
24 25
25 const char kFirstRunTabs[] = "first_run_tabs"; 26 const char kFirstRunTabs[] = "first_run_tabs";
26 27
27 base::LazyInstance<installer::MasterPreferences> g_master_preferences = 28 base::LazyInstance<installer::MasterPreferences> g_master_preferences =
28 LAZY_INSTANCE_INITIALIZER; 29 LAZY_INSTANCE_INITIALIZER;
29 30
30 bool GetURLFromValue(const base::Value* in_value, std::string* out_value) { 31 bool GetURLFromValue(const base::Value* in_value, std::string* out_value) {
31 return in_value && out_value && in_value->GetAsString(out_value); 32 return in_value && out_value && in_value->GetAsString(out_value);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // Cache a pointer to the distribution dictionary. 201 // Cache a pointer to the distribution dictionary.
201 master_dictionary_->GetDictionary( 202 master_dictionary_->GetDictionary(
202 installer::master_preferences::kDistroDict, &distribution_); 203 installer::master_preferences::kDistroDict, &distribution_);
203 } 204 }
204 205
205 EnforceLegacyPreferences(); 206 EnforceLegacyPreferences();
206 return data_is_valid; 207 return data_is_valid;
207 } 208 }
208 209
209 void MasterPreferences::EnforceLegacyPreferences() { 210 void MasterPreferences::EnforceLegacyPreferences() {
211 // Boolean. This is a legacy preference and should no longer be used; it is
212 // kept around so that old master_preferences which specify
213 // "create_all_shortcuts":false still enforce the new
214 // "do_not_create_(desktop|quick_launch)_shortcut" preferences. Setting this
215 // to true no longer has any impact.
216 static constexpr char kCreateAllShortcuts[] = "create_all_shortcuts";
217
210 // If create_all_shortcuts was explicitly set to false, set 218 // If create_all_shortcuts was explicitly set to false, set
211 // do_not_create_(desktop|quick_launch)_shortcut to true. 219 // do_not_create_(desktop|quick_launch)_shortcut to true.
212 bool create_all_shortcuts = true; 220 bool create_all_shortcuts = true;
213 GetBool(installer::master_preferences::kCreateAllShortcuts, 221 GetBool(kCreateAllShortcuts, &create_all_shortcuts);
214 &create_all_shortcuts);
215 if (!create_all_shortcuts) { 222 if (!create_all_shortcuts) {
216 distribution_->SetBoolean( 223 distribution_->SetBoolean(
217 installer::master_preferences::kDoNotCreateDesktopShortcut, true); 224 installer::master_preferences::kDoNotCreateDesktopShortcut, true);
218 distribution_->SetBoolean( 225 distribution_->SetBoolean(
219 installer::master_preferences::kDoNotCreateQuickLaunchShortcut, true); 226 installer::master_preferences::kDoNotCreateQuickLaunchShortcut, true);
220 } 227 }
228
229 #if BUILDFLAG(ENABLE_RLZ)
230 // Map the RLZ ping delay shipped in the distribution dictionary into real
231 // prefs.
232 static constexpr char kDistroPingDelay[] = "ping_delay";
233 int rlz_ping_delay = 0;
234 if (GetInt(kDistroPingDelay, &rlz_ping_delay))
235 master_dictionary_->SetInteger(prefs::kRlzPingDelaySeconds, rlz_ping_delay);
236 #endif // BUILDFLAG(ENABLE_RLZ)
221 } 237 }
222 238
223 bool MasterPreferences::GetBool(const std::string& name, bool* value) const { 239 bool MasterPreferences::GetBool(const std::string& name, bool* value) const {
224 bool ret = false; 240 bool ret = false;
225 if (distribution_) 241 if (distribution_)
226 ret = distribution_->GetBoolean(name, value); 242 ret = distribution_->GetBoolean(name, value);
227 return ret; 243 return ret;
228 } 244 }
229 245
230 bool MasterPreferences::GetInt(const std::string& name, int* value) const { 246 bool MasterPreferences::GetInt(const std::string& name, int* value) const {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 } 290 }
275 return result; 291 return result;
276 } 292 }
277 293
278 // static 294 // static
279 const MasterPreferences& MasterPreferences::ForCurrentProcess() { 295 const MasterPreferences& MasterPreferences::ForCurrentProcess() {
280 return g_master_preferences.Get(); 296 return g_master_preferences.Get();
281 } 297 }
282 298
283 } // namespace installer 299 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/installer/util/master_preferences.h ('k') | chrome/installer/util/master_preferences_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698