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
;
28 class PrefRegistrySimple
;
30 class PrefServiceSyncable
;
33 class SupervisedUserSettingsService
;
34 class TrackedPreferenceValidationDelegate
;
36 namespace chrome_prefs
{
40 extern const char kSettingsEnforcementTrialName
[];
41 extern const char kSettingsEnforcementGroupNoEnforcement
[];
42 extern const char kSettingsEnforcementGroupEnforceAlways
[];
43 extern const char kSettingsEnforcementGroupEnforceAlwaysWithDSE
[];
44 extern const char kSettingsEnforcementGroupEnforceAlwaysWithExtensionsAndDSE
[];
46 } // namespace internals
48 // Factory methods that create and initialize a new instance of a
49 // PrefService for Chrome with the applicable PrefStores. The
50 // |pref_filename| points to the user preference file. This is the
51 // usual way to create a new PrefService.
52 // |extension_pref_store| is used as the source for extension-controlled
53 // preferences and may be NULL.
54 // |policy_service| is used as the source for mandatory or recommended
56 // |pref_registry| keeps the list of registered prefs and their default values.
57 // If |async| is true, asynchronous version is used.
58 // Notifies using PREF_INITIALIZATION_COMPLETED in the end. Details is set to
59 // the created PrefService or NULL if creation has failed. Note, it is
60 // guaranteed that in asynchronous version initialization happens after this
63 scoped_ptr
<PrefService
> CreateLocalState(
64 const base::FilePath
& pref_filename
,
65 base::SequencedTaskRunner
* pref_io_task_runner
,
66 policy::PolicyService
* policy_service
,
67 const scoped_refptr
<PrefRegistry
>& pref_registry
,
70 scoped_ptr
<PrefServiceSyncable
> CreateProfilePrefs(
71 const base::FilePath
& pref_filename
,
72 base::SequencedTaskRunner
* pref_io_task_runner
,
73 TrackedPreferenceValidationDelegate
* validation_delegate
,
74 policy::PolicyService
* policy_service
,
75 SupervisedUserSettingsService
* supervised_user_settings
,
76 const scoped_refptr
<PrefStore
>& extension_prefs
,
77 const scoped_refptr
<user_prefs::PrefRegistrySyncable
>& pref_registry
,
80 // Schedules verification of the path resolution of the preferences file under
82 void SchedulePrefsFilePathVerification(const base::FilePath
& profile_path
);
84 // Call before startup tasks kick in to ignore the presence of a domain when
85 // determining the active SettingsEnforcement group. For testing only.
86 void DisableDomainCheckForTesting();
88 // Initializes the preferences for the profile at |profile_path| with the
89 // preference values in |master_prefs|. Returns true on success.
90 bool InitializePrefsFromMasterPrefs(
91 const base::FilePath
& profile_path
,
92 const base::DictionaryValue
& master_prefs
);
94 // Retrieves the time of the last preference reset event, if any, for the
95 // provided profile. If no reset has occurred, returns a null |Time|.
96 base::Time
GetResetTime(Profile
* profile
);
98 // Clears the time of the last preference reset event, if any, for the provided
100 void ClearResetTime(Profile
* profile
);
102 // Register local state prefs used by chrome preference system.
103 void RegisterPrefs(PrefRegistrySimple
* registry
);
105 // Register user prefs used by chrome preference system.
106 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable
* registry
);
108 } // namespace chrome_prefs
110 #endif // CHROME_BROWSER_PREFS_CHROME_PREF_SERVICE_FACTORY_H_