[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 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 | |||||
[email protected] | f0c8c499 | 2014-05-15 17:37:26 | [diff] [blame] | 5 | #include "components/pref_registry/pref_registry_syncable.h" |
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 6 | |
[email protected] | 5799981 | 2013-02-24 05:40:52 | [diff] [blame] | 7 | #include "base/files/file_path.h" |
[email protected] | d5ca8fb | 2013-04-11 17:54:31 | [diff] [blame] | 8 | #include "base/strings/string_number_conversions.h" |
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 9 | #include "base/values.h" |
brettw | f00b9b4 | 2016-02-01 22:11:38 | [diff] [blame] | 10 | #include "components/prefs/default_pref_store.h" |
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 11 | |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 12 | namespace user_prefs { |
13 | |||||
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 14 | PrefRegistrySyncable::PrefRegistrySyncable() { |
15 | } | ||||
16 | |||||
17 | PrefRegistrySyncable::~PrefRegistrySyncable() { | ||||
18 | } | ||||
19 | |||||
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 20 | void PrefRegistrySyncable::SetSyncableRegistrationCallback( |
21 | const SyncableRegistrationCallback& cb) { | ||||
22 | callback_ = cb; | ||||
23 | } | ||||
24 | |||||
raymes | 25fb8e7f | 2015-04-27 01:23:10 | [diff] [blame] | 25 | void PrefRegistrySyncable::OnPrefRegistered(const std::string& path, |
26 | base::Value* default_value, | ||||
avi | f57136c1 | 2015-12-25 23:27:45 | [diff] [blame] | 27 | uint32_t flags) { |
raymes | 51b41a6 | 2015-04-24 02:45:04 | [diff] [blame] | 28 | // Tests that |flags| does not contain both SYNCABLE_PREF and |
29 | // SYNCABLE_PRIORITY_PREF flags at the same time. | ||||
30 | DCHECK(!(flags & PrefRegistrySyncable::SYNCABLE_PREF) || | ||||
31 | !(flags & PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF)); | ||||
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 32 | |
raymes | 51b41a6 | 2015-04-24 02:45:04 | [diff] [blame] | 33 | if (flags & PrefRegistrySyncable::SYNCABLE_PREF || |
34 | flags & PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF) { | ||||
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 35 | if (!callback_.is_null()) |
raymes | 51b41a6 | 2015-04-24 02:45:04 | [diff] [blame] | 36 | callback_.Run(path, flags); |
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 37 | } |
38 | } | ||||
39 | |||||
40 | scoped_refptr<PrefRegistrySyncable> PrefRegistrySyncable::ForkForIncognito() { | ||||
41 | // TODO(joi): We can directly reuse the same PrefRegistry once | ||||
42 | // PrefService no longer registers for callbacks on registration and | ||||
43 | // unregistration. | ||||
44 | scoped_refptr<PrefRegistrySyncable> registry(new PrefRegistrySyncable()); | ||||
45 | registry->defaults_ = defaults_; | ||||
46 | return registry; | ||||
47 | } | ||||
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 48 | |
49 | } // namespace user_prefs |