GoogleURLTrackerInfoBarDelegate: Initialize uninitialized member in constructor.
[chromium-blink-merge.git] / chrome / browser / prefs / profile_pref_store_manager.h
blobdafd7d5305e2b15272a5120f4559d82b69943c75
1 // Copyright 2014 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_PROFILE_PREF_STORE_MANAGER_H_
6 #define CHROME_BROWSER_PREFS_PROFILE_PREF_STORE_MANAGER_H_
8 #include <string>
9 #include <vector>
11 #include "base/files/file_path.h"
12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "chrome/browser/prefs/pref_hash_filter.h"
17 class PersistentPrefStore;
18 class PrefHashStoreImpl;
19 class PrefService;
20 class TrackedPreferenceValidationDelegate;
22 namespace base {
23 class DictionaryValue;
24 class SequencedTaskRunner;
25 } // namespace base
27 namespace user_prefs {
28 class PrefRegistrySyncable;
29 } // namespace user_prefs
31 class PrefRegistrySimple;
33 // Provides a facade through which the user preference store may be accessed and
34 // managed.
35 class ProfilePrefStoreManager {
36 public:
37 // Instantiates a ProfilePrefStoreManager with the configuration required to
38 // manage the user preferences of the profile at |profile_path|.
39 // |tracking_configuration| is used for preference tracking.
40 // |reporting_ids_count| is the count of all possible tracked preference IDs
41 // (possibly greater than |tracking_configuration.size()|).
42 // |seed| and |device_id| are used to track preference value changes and must
43 // be the same on each launch in order to verify loaded preference values.
44 ProfilePrefStoreManager(
45 const base::FilePath& profile_path,
46 const std::vector<PrefHashFilter::TrackedPreferenceMetadata>&
47 tracking_configuration,
48 size_t reporting_ids_count,
49 const std::string& seed,
50 const std::string& device_id,
51 PrefService* local_state);
53 ~ProfilePrefStoreManager();
55 static const bool kPlatformSupportsPreferenceTracking;
57 // Register local state prefs used by the profile preferences system.
58 static void RegisterPrefs(PrefRegistrySimple* registry);
60 // Register user prefs used by the profile preferences system.
61 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
63 // Determines the user preferences filename for the profile at |profile_path|.
64 static base::FilePath GetPrefFilePathFromProfilePath(
65 const base::FilePath& profile_path);
67 // Deletes stored hashes for all profiles from |local_state|.
68 static void ResetAllPrefHashStores(PrefService* local_state);
70 // Retrieves the time of the last preference reset event, if any, for
71 // |pref_service|. Assumes that |pref_service| is backed by a PrefStore that
72 // was built by ProfilePrefStoreManager.
73 // If no reset has occurred, returns a null |Time|.
74 static base::Time GetResetTime(PrefService* pref_service);
76 // Clears the time of the last preference reset event, if any, for
77 // |pref_service|. Assumes that |pref_service| is backed by a PrefStore that
78 // was built by ProfilePrefStoreManager.
79 static void ClearResetTime(PrefService* pref_service);
81 // Deletes stored hashes for the managed profile.
82 void ResetPrefHashStore();
84 // Creates a PersistentPrefStore providing access to the user preferences of
85 // the managed profile. An optional |validation_delegate| will be notified
86 // of the status of each tracked preference as they are checked.
87 PersistentPrefStore* CreateProfilePrefStore(
88 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner,
89 TrackedPreferenceValidationDelegate* validation_delegate);
91 // Checks the presence/version of the hash store for the managed profile and
92 // creates or updates it if necessary. Completes asynchronously and is safe if
93 // the preferences/hash store are concurrently loaded/manipulated by another
94 // task.
95 void UpdateProfileHashStoreIfRequired(
96 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner);
98 // Initializes the preferences for the managed profile with the preference
99 // values in |master_prefs|. Acts synchronously, including blocking IO.
100 // Returns true on success.
101 bool InitializePrefsFromMasterPrefs(
102 const base::DictionaryValue& master_prefs);
104 // Creates a single-file PrefStore as was used in M34 and earlier. Used only
105 // for testing migration.
106 PersistentPrefStore* CreateDeprecatedCombinedProfilePrefStore(
107 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner);
109 private:
110 // Returns a PrefHashStoreImpl for the managed profile. Should only be called
111 // if |kPlatformSupportsPreferenceTracking|.
112 scoped_ptr<PrefHashStoreImpl> GetPrefHashStoreImpl();
114 const base::FilePath profile_path_;
115 const std::vector<PrefHashFilter::TrackedPreferenceMetadata>
116 tracking_configuration_;
117 const size_t reporting_ids_count_;
118 const std::string seed_;
119 const std::string device_id_;
120 PrefService* local_state_;
122 DISALLOW_COPY_AND_ASSIGN(ProfilePrefStoreManager);
125 #endif // CHROME_BROWSER_PREFS_PROFILE_PREF_STORE_MANAGER_H_