blob: 0e9c87c08385c83473694ebecb60c56c17ee89d4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/prefs/default_pref_store.h"
#include <utility>
#include "base/logging.h"
using base::Value;
DefaultPrefStore::DefaultPrefStore() {}
bool DefaultPrefStore::GetValue(const std::string& key,
const Value** result) const {
return prefs_.GetValue(key, result);
}
std::unique_ptr<base::DictionaryValue> DefaultPrefStore::GetValues() const {
return prefs_.AsDictionaryValue();
}
void DefaultPrefStore::AddObserver(PrefStore::Observer* observer) {
observers_.AddObserver(observer);
}
void DefaultPrefStore::RemoveObserver(PrefStore::Observer* observer) {
observers_.RemoveObserver(observer);
}
bool DefaultPrefStore::HasObservers() const {
return observers_.might_have_observers();
}
void DefaultPrefStore::SetDefaultValue(const std::string& key,
std::unique_ptr<Value> value) {
DCHECK(!GetValue(key, NULL));
prefs_.SetValue(key, std::move(value));
}
void DefaultPrefStore::ReplaceDefaultValue(const std::string& key,
std::unique_ptr<Value> value) {
const Value* old_value = NULL;
GetValue(key, &old_value);
bool notify = !old_value->Equals(value.get());
prefs_.SetValue(key, std::move(value));
if (notify) {
for (Observer& observer : observers_)
observer.OnPrefValueChanged(key);
}
}
DefaultPrefStore::const_iterator DefaultPrefStore::begin() const {
return prefs_.begin();
}
DefaultPrefStore::const_iterator DefaultPrefStore::end() const {
return prefs_.end();
}
DefaultPrefStore::~DefaultPrefStore() {}
|