OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_PREFS_PREF_SERVICE_BUILDER_H_ | 5 #ifndef BASE_PREFS_PREF_SERVICE_BUILDER_H_ |
6 #define BASE_PREFS_PREF_SERVICE_BUILDER_H_ | 6 #define BASE_PREFS_PREF_SERVICE_BUILDER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 // A class that allows convenient building of PrefService. | 23 // A class that allows convenient building of PrefService. |
24 class BASE_PREFS_EXPORT PrefServiceBuilder { | 24 class BASE_PREFS_EXPORT PrefServiceBuilder { |
25 public: | 25 public: |
26 PrefServiceBuilder(); | 26 PrefServiceBuilder(); |
27 virtual ~PrefServiceBuilder(); | 27 virtual ~PrefServiceBuilder(); |
28 | 28 |
29 // Functions for setting the various parameters of the PrefService to build. | 29 // Functions for setting the various parameters of the PrefService to build. |
30 // These take ownership of the |store| parameter. | 30 // These take ownership of the |store| parameter. |
31 PrefServiceBuilder& WithManagedPrefs(PrefStore* store); | 31 PrefServiceBuilder& WithManagedPrefs(PrefStore* store); |
| 32 PrefServiceBuilder& WithManagedUserPrefs(PrefStore* store); |
32 PrefServiceBuilder& WithExtensionPrefs(PrefStore* store); | 33 PrefServiceBuilder& WithExtensionPrefs(PrefStore* store); |
33 PrefServiceBuilder& WithCommandLinePrefs(PrefStore* store); | 34 PrefServiceBuilder& WithCommandLinePrefs(PrefStore* store); |
34 PrefServiceBuilder& WithUserPrefs(PersistentPrefStore* store); | 35 PrefServiceBuilder& WithUserPrefs(PersistentPrefStore* store); |
35 PrefServiceBuilder& WithRecommendedPrefs(PrefStore* store); | 36 PrefServiceBuilder& WithRecommendedPrefs(PrefStore* store); |
36 | 37 |
37 // Sets up error callback for the PrefService. A do-nothing default | 38 // Sets up error callback for the PrefService. A do-nothing default |
38 // is provided if this is not called. | 39 // is provided if this is not called. |
39 PrefServiceBuilder& WithReadErrorCallback( | 40 PrefServiceBuilder& WithReadErrorCallback( |
40 const base::Callback<void(PersistentPrefStore::PrefReadError)>& | 41 const base::Callback<void(PersistentPrefStore::PrefReadError)>& |
41 read_error_callback); | 42 read_error_callback); |
42 | 43 |
43 // Specifies to use an actual file-backed user pref store. | 44 // Specifies to use an actual file-backed user pref store. |
44 PrefServiceBuilder& WithUserFilePrefs( | 45 PrefServiceBuilder& WithUserFilePrefs( |
45 const base::FilePath& prefs_file, | 46 const base::FilePath& prefs_file, |
46 base::SequencedTaskRunner* task_runner); | 47 base::SequencedTaskRunner* task_runner); |
47 | 48 |
48 PrefServiceBuilder& WithAsync(bool async); | 49 PrefServiceBuilder& WithAsync(bool async); |
49 | 50 |
50 // Creates a PrefService object initialized with the parameters from | 51 // Creates a PrefService object initialized with the parameters from |
51 // this builder. | 52 // this builder. |
52 virtual PrefService* Create(PrefRegistry* registry); | 53 virtual PrefService* Create(PrefRegistry* registry); |
53 | 54 |
54 protected: | 55 protected: |
55 virtual void ResetDefaultState(); | 56 virtual void ResetDefaultState(); |
56 | 57 |
57 scoped_refptr<PrefStore> managed_prefs_; | 58 scoped_refptr<PrefStore> managed_prefs_; |
| 59 scoped_refptr<PrefStore> managed_user_prefs_; |
58 scoped_refptr<PrefStore> extension_prefs_; | 60 scoped_refptr<PrefStore> extension_prefs_; |
59 scoped_refptr<PrefStore> command_line_prefs_; | 61 scoped_refptr<PrefStore> command_line_prefs_; |
60 scoped_refptr<PersistentPrefStore> user_prefs_; | 62 scoped_refptr<PersistentPrefStore> user_prefs_; |
61 scoped_refptr<PrefStore> recommended_prefs_; | 63 scoped_refptr<PrefStore> recommended_prefs_; |
62 | 64 |
63 base::Callback<void(PersistentPrefStore::PrefReadError)> read_error_callback_; | 65 base::Callback<void(PersistentPrefStore::PrefReadError)> read_error_callback_; |
64 | 66 |
65 // Defaults to false. | 67 // Defaults to false. |
66 bool async_; | 68 bool async_; |
67 | 69 |
68 private: | 70 private: |
69 DISALLOW_COPY_AND_ASSIGN(PrefServiceBuilder); | 71 DISALLOW_COPY_AND_ASSIGN(PrefServiceBuilder); |
70 }; | 72 }; |
71 | 73 |
72 #endif // BASE_PREFS_PREF_SERVICE_BUILDER_H_ | 74 #endif // BASE_PREFS_PREF_SERVICE_BUILDER_H_ |
OLD | NEW |