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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PREFS_CHROME_PREF_SERVICE_FACTORY_H_
6 #define CHROME_BROWSER_PREFS_CHROME_PREF_SERVICE_FACTORY_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
12 class DictionaryValue;
14 class SequencedTaskRunner;
21 namespace user_prefs {
22 class PrefRegistrySyncable;
25 class ManagedUserSettingsService;
28 class PrefRegistrySimple;
30 class PrefServiceSyncable;
33 namespace chrome_prefs {
37 extern const char kSettingsEnforcementTrialName[];
38 extern const char kSettingsEnforcementGroupNoEnforcement[];
39 extern const char kSettingsEnforcementGroupEnforceOnload[];
40 extern const char kSettingsEnforcementGroupEnforceAlways[];
42 } // namespace internals
44 // Factory methods that create and initialize a new instance of a
45 // PrefService for Chrome with the applicable PrefStores. The
46 // |pref_filename| points to the user preference file. This is the
47 // usual way to create a new PrefService.
48 // |extension_pref_store| is used as the source for extension-controlled
49 // preferences and may be NULL.
50 // |policy_service| is used as the source for mandatory or recommended
52 // |pref_registry| keeps the list of registered prefs and their default values.
53 // If |async| is true, asynchronous version is used.
54 // Notifies using PREF_INITIALIZATION_COMPLETED in the end. Details is set to
55 // the created PrefService or NULL if creation has failed. Note, it is
56 // guaranteed that in asynchronous version initialization happens after this
59 scoped_ptr<PrefService> CreateLocalState(
60 const base::FilePath& pref_filename,
61 base::SequencedTaskRunner* pref_io_task_runner,
62 policy::PolicyService* policy_service,
63 const scoped_refptr<PrefRegistry>& pref_registry,
66 scoped_ptr<PrefServiceSyncable> CreateProfilePrefs(
67 const base::FilePath& pref_filename,
68 base::SequencedTaskRunner* pref_io_task_runner,
69 policy::PolicyService* policy_service,
70 ManagedUserSettingsService* managed_user_settings,
71 const scoped_refptr<PrefStore>& extension_prefs,
72 const scoped_refptr<user_prefs::PrefRegistrySyncable>& pref_registry,
75 // Schedules verification of the path resolution of the preferences file under
77 void SchedulePrefsFilePathVerification(const base::FilePath& profile_path);
79 // Call before calling SchedulePrefHashStoresUpdateCheck to cause it to run with
80 // zero delay. For testing only.
81 void EnableZeroDelayPrefHashStoreUpdateForTesting();
83 // Shedules an update check for all PrefHashStores, stores whose version doesn't
84 // match the latest version will then be updated.
85 void SchedulePrefHashStoresUpdateCheck(
86 const base::FilePath& initial_profile_path);
88 // Resets the contents of the preference hash store for the profile at
90 void ResetPrefHashStore(const base::FilePath& profile_path);
92 // Initializes the preferences for the profile at |profile_path| with the
93 // preference values in |master_prefs|. Returns true on success.
94 bool InitializePrefsFromMasterPrefs(
95 const base::FilePath& profile_path,
96 const base::DictionaryValue& master_prefs);
98 // Register local state prefs used by chrome preference system.
99 void RegisterPrefs(PrefRegistrySimple* registry);
101 } // namespace chrome_prefs
103 #endif // CHROME_BROWSER_PREFS_CHROME_PREF_SERVICE_FACTORY_H_