OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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 |
| 5 #include "chrome/browser/prefs/dictionary_pref_store.h" |
| 6 |
| 7 #include "base/values.h" |
| 8 |
| 9 DictionaryPrefStore::DictionaryPrefStore(base::DictionaryValue* dictionary) |
| 10 : dictionary_(dictionary) { |
| 11 } |
| 12 |
| 13 bool DictionaryPrefStore::GetValue(const std::string& key, |
| 14 const base::Value** result) const { |
| 15 return dictionary_->Get(key, result); |
| 16 } |
| 17 |
| 18 void DictionaryPrefStore::AddObserver(PrefStore::Observer* observer) { |
| 19 observers_.AddObserver(observer); |
| 20 } |
| 21 |
| 22 void DictionaryPrefStore::RemoveObserver(PrefStore::Observer* observer) { |
| 23 observers_.RemoveObserver(observer); |
| 24 } |
| 25 |
| 26 bool DictionaryPrefStore::HasObservers() const { |
| 27 return observers_.might_have_observers(); |
| 28 } |
| 29 |
| 30 void DictionaryPrefStore::SetValue(const std::string& key, base::Value* value) { |
| 31 dictionary_->Set(key, value); |
| 32 ReportValueChanged(key); |
| 33 } |
| 34 |
| 35 void DictionaryPrefStore::RemoveValue(const std::string& key) { |
| 36 dictionary_->Remove(key, NULL); |
| 37 ReportValueChanged(key); |
| 38 } |
| 39 |
| 40 bool DictionaryPrefStore::GetMutableValue(const std::string& key, |
| 41 base::Value** result) { |
| 42 return dictionary_->Get(key, result); |
| 43 } |
| 44 |
| 45 void DictionaryPrefStore::ReportValueChanged(const std::string& key) { |
| 46 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); |
| 47 } |
| 48 |
| 49 DictionaryPrefStore::~DictionaryPrefStore() { |
| 50 } |
OLD | NEW |