Make certificate viewer a tab-modal dialog.
[chromium-blink-merge.git] / base / prefs / default_pref_store.cc
blobbabb4d536287c0acbf9e5624416ba112230bfcf6
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 size_t DefaultPrefStore::NumberOfObservers() const {
26 return observers_.size();
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() {}