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
;
22 namespace user_prefs
{
23 class PrefRegistrySyncable
;
26 class ManagedUserSettingsService
;
29 class PrefRegistrySimple
;
31 class PrefServiceSyncable
;
35 namespace chrome_prefs
{
39 extern const char kSettingsEnforcementTrialName
[];
40 extern const char kSettingsEnforcementGroupNoEnforcement
[];
41 extern const char kSettingsEnforcementGroupEnforceOnload
[];
42 extern const char kSettingsEnforcementGroupEnforceAlways
[];
43 extern const char kSettingsEnforcementGroupEnforceAlwaysWithExtensions
[];
45 } // namespace internals
47 // Factory methods that create and initialize a new instance of a
48 // PrefService for Chrome with the applicable PrefStores. The
49 // |pref_filename| points to the user preference file. This is the
50 // usual way to create a new PrefService.
51 // |extension_pref_store| is used as the source for extension-controlled
52 // preferences and may be NULL.
53 // |policy_service| is used as the source for mandatory or recommended
55 // |pref_registry| keeps the list of registered prefs and their default values.
56 // If |async| is true, asynchronous version is used.
57 // Notifies using PREF_INITIALIZATION_COMPLETED in the end. Details is set to
58 // the created PrefService or NULL if creation has failed. Note, it is
59 // guaranteed that in asynchronous version initialization happens after this
62 scoped_ptr
<PrefService
> CreateLocalState(
63 const base::FilePath
& pref_filename
,
64 base::SequencedTaskRunner
* pref_io_task_runner
,
65 policy::PolicyService
* policy_service
,
66 const scoped_refptr
<PrefRegistry
>& pref_registry
,
69 scoped_ptr
<PrefServiceSyncable
> CreateProfilePrefs(
70 const base::FilePath
& pref_filename
,
71 base::SequencedTaskRunner
* pref_io_task_runner
,
72 policy::PolicyService
* policy_service
,
73 ManagedUserSettingsService
* managed_user_settings
,
74 const scoped_refptr
<PrefStore
>& extension_prefs
,
75 const scoped_refptr
<user_prefs::PrefRegistrySyncable
>& pref_registry
,
78 // Schedules verification of the path resolution of the preferences file under
80 void SchedulePrefsFilePathVerification(const base::FilePath
& profile_path
);
82 // Call before startup tasks kick in to disable delays in
83 // chrome_prefs::Schedule*() methods and ignore presence of a domain when
84 // determining the active SettingsEnforcement group. For testing only.
85 void DisableDelaysAndDomainCheckForTesting();
87 // Schedules an update check for all PrefHashStores, stores whose version
88 // doesn't match the latest version will then be updated. Clears all pref hash
89 // state on platforms that don't yet support a pref hash store.
90 void SchedulePrefHashStoresUpdateCheck(
91 const base::FilePath
& initial_profile_path
);
93 // Resets the contents of the preference hash store for the profile at
95 void ResetPrefHashStore(const base::FilePath
& profile_path
);
97 // Initializes the preferences for the profile at |profile_path| with the
98 // preference values in |master_prefs|. Returns true on success.
99 bool InitializePrefsFromMasterPrefs(
100 const base::FilePath
& profile_path
,
101 const base::DictionaryValue
& master_prefs
);
103 // Retrieves the time of the last preference reset event, if any, for the
104 // provided profile. If no reset has occurred, returns a null |Time|.
105 base::Time
GetResetTime(Profile
* profile
);
107 // Clears the time of the last preference reset event, if any, for the provided
109 void ClearResetTime(Profile
* profile
);
111 // Register local state prefs used by chrome preference system.
112 void RegisterPrefs(PrefRegistrySimple
* registry
);
114 // Register user prefs used by chrome preference system.
115 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable
* registry
);
117 } // namespace chrome_prefs
119 #endif // CHROME_BROWSER_PREFS_CHROME_PREF_SERVICE_FACTORY_H_