Fix emulator build error
[platform/framework/web/chromium-efl.git] / components / prefs / pref_service_factory.h
1 // Copyright 2013 The Chromium Authors
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 COMPONENTS_PREFS_PREF_SERVICE_FACTORY_H_
6 #define COMPONENTS_PREFS_PREF_SERVICE_FACTORY_H_
7
8 #include "base/functional/callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "components/prefs/persistent_pref_store.h"
11 #include "components/prefs/pref_registry.h"
12 #include "components/prefs/pref_store.h"
13 #include "components/prefs/pref_value_store.h"
14 #include "components/prefs/prefs_export.h"
15
16 class PrefService;
17
18 namespace base {
19 class FilePath;
20 class SequencedTaskRunner;
21 }
22
23 // A class that allows convenient building of PrefService.
24 class COMPONENTS_PREFS_EXPORT PrefServiceFactory {
25  public:
26   PrefServiceFactory();
27
28   PrefServiceFactory(const PrefServiceFactory&) = delete;
29   PrefServiceFactory& operator=(const PrefServiceFactory&) = delete;
30
31   virtual ~PrefServiceFactory();
32
33   // Functions for setting the various parameters of the PrefService to build.
34   void set_managed_prefs(scoped_refptr<PrefStore> prefs) {
35     managed_prefs_.swap(prefs);
36   }
37
38   void set_supervised_user_prefs(scoped_refptr<PrefStore> prefs) {
39     supervised_user_prefs_.swap(prefs);
40   }
41
42   void set_extension_prefs(scoped_refptr<PrefStore> prefs) {
43     extension_prefs_.swap(prefs);
44   }
45
46   void set_standalone_browser_prefs(scoped_refptr<PersistentPrefStore> prefs) {
47     standalone_browser_prefs_.swap(prefs);
48   }
49
50   void set_command_line_prefs(scoped_refptr<PrefStore> prefs) {
51     command_line_prefs_.swap(prefs);
52   }
53
54   void set_user_prefs(scoped_refptr<PersistentPrefStore> prefs) {
55     user_prefs_.swap(prefs);
56   }
57
58   void set_recommended_prefs(scoped_refptr<PrefStore> prefs) {
59     recommended_prefs_.swap(prefs);
60   }
61
62   // Sets up error callback for the PrefService.  A do-nothing default is
63   // provided if this is not called. This callback is always invoked (async or
64   // not) on the sequence on which Create is invoked.
65   void set_read_error_callback(
66       base::RepeatingCallback<void(PersistentPrefStore::PrefReadError)>
67           read_error_callback) {
68     read_error_callback_ = std::move(read_error_callback);
69   }
70
71   // Specifies to use an actual file-backed user pref store.
72   void SetUserPrefsFile(const base::FilePath& prefs_file,
73                         base::SequencedTaskRunner* task_runner);
74
75   void set_async(bool async) {
76     async_ = async;
77   }
78
79   // Creates a PrefService object initialized with the parameters from
80   // this factory.
81   std::unique_ptr<PrefService> Create(
82       scoped_refptr<PrefRegistry> pref_registry);
83
84  protected:
85   scoped_refptr<PrefStore> managed_prefs_;
86   scoped_refptr<PrefStore> supervised_user_prefs_;
87   scoped_refptr<PrefStore> extension_prefs_;
88   scoped_refptr<PersistentPrefStore> standalone_browser_prefs_;
89   scoped_refptr<PrefStore> command_line_prefs_;
90   scoped_refptr<PersistentPrefStore> user_prefs_;
91   scoped_refptr<PrefStore> recommended_prefs_;
92
93   base::RepeatingCallback<void(PersistentPrefStore::PrefReadError)>
94       read_error_callback_;
95
96   // Defaults to false.
97   bool async_;
98 };
99
100 #endif  // COMPONENTS_PREFS_PREF_SERVICE_FACTORY_H_