15ae628783a0f3451093d83506316345c6c047a1
[platform/framework/web/crosswalk.git] / src / chrome / browser / prefs / chrome_pref_service_factory.h
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.
4
5 #ifndef CHROME_BROWSER_PREFS_CHROME_PREF_SERVICE_FACTORY_H_
6 #define CHROME_BROWSER_PREFS_CHROME_PREF_SERVICE_FACTORY_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10
11 namespace base {
12 class DictionaryValue;
13 class FilePath;
14 class SequencedTaskRunner;
15 class Time;
16 }
17
18 namespace policy {
19 class PolicyService;
20 }
21
22 namespace user_prefs {
23 class PrefRegistrySyncable;
24 }
25
26 class ManagedUserSettingsService;
27 class PrefHashStore;
28 class PrefRegistry;
29 class PrefRegistrySimple;
30 class PrefService;
31 class PrefServiceSyncable;
32 class PrefStore;
33 class Profile;
34
35 namespace chrome_prefs {
36
37 namespace internals {
38
39 extern const char kSettingsEnforcementTrialName[];
40 extern const char kSettingsEnforcementGroupNoEnforcement[];
41 extern const char kSettingsEnforcementGroupEnforceOnload[];
42 extern const char kSettingsEnforcementGroupEnforceAlways[];
43
44 }  // namespace internals
45
46 // Factory methods that create and initialize a new instance of a
47 // PrefService for Chrome with the applicable PrefStores. The
48 // |pref_filename| points to the user preference file. This is the
49 // usual way to create a new PrefService.
50 // |extension_pref_store| is used as the source for extension-controlled
51 // preferences and may be NULL.
52 // |policy_service| is used as the source for mandatory or recommended
53 // policies.
54 // |pref_registry| keeps the list of registered prefs and their default values.
55 // If |async| is true, asynchronous version is used.
56 // Notifies using PREF_INITIALIZATION_COMPLETED in the end. Details is set to
57 // the created PrefService or NULL if creation has failed. Note, it is
58 // guaranteed that in asynchronous version initialization happens after this
59 // function returned.
60
61 scoped_ptr<PrefService> CreateLocalState(
62     const base::FilePath& pref_filename,
63     base::SequencedTaskRunner* pref_io_task_runner,
64     policy::PolicyService* policy_service,
65     const scoped_refptr<PrefRegistry>& pref_registry,
66     bool async);
67
68 scoped_ptr<PrefServiceSyncable> CreateProfilePrefs(
69     const base::FilePath& pref_filename,
70     base::SequencedTaskRunner* pref_io_task_runner,
71     policy::PolicyService* policy_service,
72     ManagedUserSettingsService* managed_user_settings,
73     const scoped_refptr<PrefStore>& extension_prefs,
74     const scoped_refptr<user_prefs::PrefRegistrySyncable>& pref_registry,
75     bool async);
76
77 // Schedules verification of the path resolution of the preferences file under
78 // |profile_path|.
79 void SchedulePrefsFilePathVerification(const base::FilePath& profile_path);
80
81 // Call before startup tasks kick in to disable delays in
82 // chrome_prefs::Schedule*() methods and ignore presence of a domain when
83 // determining the active SettingsEnforcement group. For testing only.
84 void DisableDelaysAndDomainCheckForTesting();
85
86 // Schedules an update check for all PrefHashStores, stores whose version
87 // doesn't match the latest version will then be updated. Clears all pref hash
88 // state on platforms that don't yet support a pref hash store.
89 void SchedulePrefHashStoresUpdateCheck(
90     const base::FilePath& initial_profile_path);
91
92 // Resets the contents of the preference hash store for the profile at
93 // |profile_path|.
94 void ResetPrefHashStore(const base::FilePath& profile_path);
95
96 // Initializes the preferences for the profile at |profile_path| with the
97 // preference values in |master_prefs|. Returns true on success.
98 bool InitializePrefsFromMasterPrefs(
99     const base::FilePath& profile_path,
100     const base::DictionaryValue& master_prefs);
101
102 // Retrieves the time of the last preference reset event, if any, for the
103 // provided profile. If no reset has occurred, returns a null |Time|.
104 base::Time GetResetTime(Profile* profile);
105
106 // Clears the time of the last preference reset event, if any, for the provided
107 // profile.
108 void ClearResetTime(Profile* profile);
109
110 // Register local state prefs used by chrome preference system.
111 void RegisterPrefs(PrefRegistrySimple* registry);
112
113 // Register user prefs used by chrome preference system.
114 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
115
116 }  // namespace chrome_prefs
117
118 #endif  // CHROME_BROWSER_PREFS_CHROME_PREF_SERVICE_FACTORY_H_