Index: chrome/browser/prefs/dictionary_pref_store.cc |
diff --git a/chrome/browser/prefs/dictionary_pref_store.cc b/chrome/browser/prefs/dictionary_pref_store.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8f51ab52d1c0b65407adf97f3e87c543e1ef7809 |
--- /dev/null |
+++ b/chrome/browser/prefs/dictionary_pref_store.cc |
@@ -0,0 +1,50 @@ |
+// Copyright 2014 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 "chrome/browser/prefs/dictionary_pref_store.h" |
+ |
+#include "base/values.h" |
+ |
+DictionaryPrefStore::DictionaryPrefStore(base::DictionaryValue* dictionary) |
+ : dictionary_(dictionary) { |
+} |
+ |
+bool DictionaryPrefStore::GetValue(const std::string& key, |
+ const base::Value** result) const { |
+ return dictionary_->Get(key, result); |
+} |
+ |
+void DictionaryPrefStore::AddObserver(PrefStore::Observer* observer) { |
+ observers_.AddObserver(observer); |
+} |
+ |
+void DictionaryPrefStore::RemoveObserver(PrefStore::Observer* observer) { |
+ observers_.RemoveObserver(observer); |
+} |
+ |
+bool DictionaryPrefStore::HasObservers() const { |
+ return observers_.might_have_observers(); |
+} |
+ |
+void DictionaryPrefStore::SetValue(const std::string& key, base::Value* value) { |
+ dictionary_->Set(key, value); |
+ ReportValueChanged(key); |
+} |
+ |
+void DictionaryPrefStore::RemoveValue(const std::string& key) { |
+ dictionary_->Remove(key, NULL); |
+ ReportValueChanged(key); |
+} |
+ |
+bool DictionaryPrefStore::GetMutableValue(const std::string& key, |
+ base::Value** result) { |
+ return dictionary_->Get(key, result); |
+} |
+ |
+void DictionaryPrefStore::ReportValueChanged(const std::string& key) { |
+ FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); |
+} |
+ |
+DictionaryPrefStore::~DictionaryPrefStore() { |
+} |