blob: a81cea05a8a6a618b8640d10e39d845966beb351 [file] [log] [blame]
[email protected]c753f142013-02-10 13:14:041// 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]f0c8c4992014-05-15 17:37:265#include "components/pref_registry/pref_registry_syncable.h"
[email protected]c753f142013-02-10 13:14:046
[email protected]57999812013-02-24 05:40:527#include "base/files/file_path.h"
[email protected]d5ca8fb2013-04-11 17:54:318#include "base/strings/string_number_conversions.h"
[email protected]c753f142013-02-10 13:14:049#include "base/values.h"
brettwf00b9b42016-02-01 22:11:3810#include "components/prefs/default_pref_store.h"
[email protected]c753f142013-02-10 13:14:0411
[email protected]443e9312013-05-06 06:17:3412namespace user_prefs {
13
[email protected]c753f142013-02-10 13:14:0414PrefRegistrySyncable::PrefRegistrySyncable() {
15}
16
17PrefRegistrySyncable::~PrefRegistrySyncable() {
18}
19
[email protected]c753f142013-02-10 13:14:0420void PrefRegistrySyncable::SetSyncableRegistrationCallback(
21 const SyncableRegistrationCallback& cb) {
22 callback_ = cb;
23}
24
raymes25fb8e7f2015-04-27 01:23:1025void PrefRegistrySyncable::OnPrefRegistered(const std::string& path,
26 base::Value* default_value,
avif57136c12015-12-25 23:27:4527 uint32_t flags) {
raymes51b41a62015-04-24 02:45:0428 // 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]c753f142013-02-10 13:14:0432
raymes51b41a62015-04-24 02:45:0433 if (flags & PrefRegistrySyncable::SYNCABLE_PREF ||
34 flags & PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF) {
[email protected]c753f142013-02-10 13:14:0435 if (!callback_.is_null())
raymes51b41a62015-04-24 02:45:0436 callback_.Run(path, flags);
[email protected]c753f142013-02-10 13:14:0437 }
38}
39
40scoped_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]443e9312013-05-06 06:17:3448
49} // namespace user_prefs