Add a stub __cxa_demangle to disable LLVM's demangler.
[chromium-blink-merge.git] / components / pref_registry / pref_registry_syncable.h
blob1d8bb05a6751534af45b5243dae85207b1bd82db
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.
5 #ifndef COMPONENTS_PREF_REGISTRY_PREF_REGISTRY_SYNCABLE_H_
6 #define COMPONENTS_PREF_REGISTRY_PREF_REGISTRY_SYNCABLE_H_
8 #include <string>
10 #include "base/callback.h"
11 #include "base/prefs/pref_registry_simple.h"
12 #include "components/pref_registry/pref_registry_export.h"
14 namespace base {
15 class DictionaryValue;
16 class FilePath;
17 class ListValue;
18 class Value;
21 // TODO(tfarina): Change this namespace to pref_registry.
22 namespace user_prefs {
24 // A PrefRegistry that forces users to choose whether each registered
25 // preference is syncable or not.
27 // Classes or components that want to register such preferences should
28 // define a static function named RegisterUserPrefs that takes a
29 // PrefRegistrySyncable*, and the top-level application using the
30 // class or embedding the component should call this function at an
31 // appropriate time before the PrefService for these preferences is
32 // constructed. See e.g. chrome/browser/prefs/browser_prefs.cc which
33 // does this for Chrome.
35 // TODO(raymes): This class only exists to support SyncableRegistrationCallback
36 // logic which is only required to support pref registration after the
37 // PrefService has been created which is only used by tests. We can remove this
38 // entire class and those tests with some work.
39 class PREF_REGISTRY_EXPORT PrefRegistrySyncable : public PrefRegistrySimple {
40 public:
41 // Enum of flags used when registering preferences to determine if it should
42 // be synced or not. These flags are mutually exclusive, only one of them
43 // should ever be specified.
45 // Note: These must NOT overlap with PrefRegistry::PrefRegistrationFlags.
46 enum PrefRegistrationFlags : uint32 {
47 // The pref will be synced.
48 SYNCABLE_PREF = 1 << 0,
50 // The pref will be synced. The pref will never be encrypted and will be
51 // synced before other datatypes. Because they're never encrypted, on first
52 // sync, they can be synced down before the user is prompted for a
53 // passphrase.
54 SYNCABLE_PRIORITY_PREF = 1 << 1,
57 typedef base::Callback<void(const std::string& path, uint32 flags)>
58 SyncableRegistrationCallback;
60 PrefRegistrySyncable();
62 // Exactly one callback can be set for the event of a syncable
63 // preference being registered. It will be fired after the
64 // registration has occurred.
66 // Calling this method after a callback has already been set will
67 // make the object forget the previous callback and use the new one
68 // instead.
69 void SetSyncableRegistrationCallback(const SyncableRegistrationCallback& cb);
71 // Returns a new PrefRegistrySyncable that uses the same defaults
72 // store.
73 scoped_refptr<PrefRegistrySyncable> ForkForIncognito();
75 private:
76 ~PrefRegistrySyncable() override;
78 // PrefRegistrySimple overrides.
79 void OnPrefRegistered(const std::string& path,
80 base::Value* default_value,
81 uint32 flags) override;
83 SyncableRegistrationCallback callback_;
85 DISALLOW_COPY_AND_ASSIGN(PrefRegistrySyncable);
88 } // namespace user_prefs
90 #endif // COMPONENTS_PREF_REGISTRY_PREF_REGISTRY_SYNCABLE_H_