blob: 8e2644cc719125741d98023d45e816278318c9ec [file] [log] [blame]
[email protected]2dea5c02012-04-25 07:01:071// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]9a8c4022011-01-25 14:25:332// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]03b9b4e2012-10-22 20:01:525#include "base/prefs/default_pref_store.h"
[email protected]307cbf22012-11-07 18:06:026#include "base/logging.h"
[email protected]9a8c4022011-01-25 14:25:337
[email protected]bab1c13f2011-08-12 20:59:028using base::Value;
9
[email protected]9a8c4022011-01-25 14:25:3310DefaultPrefStore::DefaultPrefStore() {}
11
[email protected]892f1d62012-11-08 18:24:3412bool DefaultPrefStore::GetValue(
[email protected]307cbf22012-11-07 18:06:0213 const std::string& key,
14 const base::Value** result) const {
[email protected]892f1d62012-11-08 18:24:3415 return prefs_.GetValue(key, result);
[email protected]307cbf22012-11-07 18:06:0216}
17
[email protected]9a8c4022011-01-25 14:25:3318void DefaultPrefStore::SetDefaultValue(const std::string& key, Value* value) {
[email protected]892f1d62012-11-08 18:24:3419 DCHECK(!GetValue(key, NULL));
[email protected]307cbf22012-11-07 18:06:0220 prefs_.SetValue(key, value);
[email protected]9a8c4022011-01-25 14:25:3321}
22
[email protected]7a5f5932011-12-29 10:35:4923void DefaultPrefStore::RemoveDefaultValue(const std::string& key) {
[email protected]892f1d62012-11-08 18:24:3424 DCHECK(GetValue(key, NULL));
[email protected]307cbf22012-11-07 18:06:0225 prefs_.RemoveValue(key);
[email protected]7a5f5932011-12-29 10:35:4926}
27
[email protected]bab1c13f2011-08-12 20:59:0228base::Value::Type DefaultPrefStore::GetType(const std::string& key) const {
[email protected]892f1d62012-11-08 18:24:3429 const Value* value = NULL;
30 return GetValue(key, &value) ? value->GetType() : Value::TYPE_NULL;
[email protected]9a8c4022011-01-25 14:25:3331}
[email protected]2dea5c02012-04-25 07:01:0732
[email protected]307cbf22012-11-07 18:06:0233DefaultPrefStore::const_iterator DefaultPrefStore::begin() const {
34 return prefs_.begin();
35}
36
37DefaultPrefStore::const_iterator DefaultPrefStore::end() const {
38 return prefs_.end();
39}
40
[email protected]2dea5c02012-04-25 07:01:0741DefaultPrefStore::~DefaultPrefStore() {}