Add options_menu.js to remoting_resources dependencies
[chromium-blink-merge.git] / base / prefs / default_pref_store.cc
blob92abba14c5ae35f1ea32a6f66f9a66bfb862bcbf
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 #include "base/prefs/default_pref_store.h"
6 #include "base/logging.h"
8 using base::Value;
10 DefaultPrefStore::DefaultPrefStore() {}
12 bool DefaultPrefStore::GetValue(const std::string& key,
13 const Value** result) const {
14 return prefs_.GetValue(key, result);
17 void DefaultPrefStore::AddObserver(PrefStore::Observer* observer) {
18 observers_.AddObserver(observer);
21 void DefaultPrefStore::RemoveObserver(PrefStore::Observer* observer) {
22 observers_.RemoveObserver(observer);
25 bool DefaultPrefStore::HasObservers() const {
26 return observers_.might_have_observers();
29 void DefaultPrefStore::SetDefaultValue(const std::string& key,
30 scoped_ptr<Value> value) {
31 DCHECK(!GetValue(key, NULL));
32 prefs_.SetValue(key, value.release());
35 void DefaultPrefStore::ReplaceDefaultValue(const std::string& key,
36 scoped_ptr<Value> value) {
37 const Value* old_value = NULL;
38 GetValue(key, &old_value);
39 bool notify = !old_value->Equals(value.get());
40 prefs_.SetValue(key, value.release());
41 if (notify)
42 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key));
45 DefaultPrefStore::const_iterator DefaultPrefStore::begin() const {
46 return prefs_.begin();
49 DefaultPrefStore::const_iterator DefaultPrefStore::end() const {
50 return prefs_.end();
53 DefaultPrefStore::~DefaultPrefStore() {}