7991f7c5a0a8044d4c8c250a94091a1d0de0bbc3
[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 }
16
17 namespace policy {
18 class PolicyService;
19 }
20
21 namespace user_prefs {
22 class PrefRegistrySyncable;
23 }
24
25 class ManagedUserSettingsService;
26 class PrefHashStore;
27 class PrefRegistry;
28 class PrefRegistrySimple;
29 class PrefService;
30 class PrefServiceSyncable;
31 class PrefStore;
32
33 namespace chrome_prefs {
34
35 namespace internals {
36
37 extern const char kSettingsEnforcementTrialName[];
38 extern const char kSettingsEnforcementGroupNoEnforcement[];
39 extern const char kSettingsEnforcementGroupEnforceOnload[];
40 extern const char kSettingsEnforcementGroupEnforceAlways[];
41
42 }  // namespace internals
43
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
51 // policies.
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
57 // function returned.
58
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,
64     bool async);
65
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,
73     bool async);
74
75 // Schedules verification of the path resolution of the preferences file under
76 // |profile_path|.
77 void SchedulePrefsFilePathVerification(const base::FilePath& profile_path);
78
79 // Call before calling SchedulePrefHashStoresUpdateCheck to cause it to run with
80 // zero delay. For testing only.
81 void EnableZeroDelayPrefHashStoreUpdateForTesting();
82
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);
87
88 // Resets the contents of the preference hash store for the profile at
89 // |profile_path|.
90 void ResetPrefHashStore(const base::FilePath& profile_path);
91
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);
97
98 // Register local state prefs used by chrome preference system.
99 void RegisterPrefs(PrefRegistrySimple* registry);
100
101 }  // namespace chrome_prefs
102
103 #endif  // CHROME_BROWSER_PREFS_CHROME_PREF_SERVICE_FACTORY_H_