OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "chrome/browser/prefs/pref_registrar_simple.h" |
| 6 |
| 7 #include "base/file_path.h" |
| 8 #include "base/string_number_conversions.h" |
| 9 #include "base/values.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" |
| 11 |
| 12 PrefRegistrarSimple::PrefRegistrarSimple(PrefService* pref_service) |
| 13 : pref_service_(pref_service) { |
| 14 DCHECK(pref_service_->AllowPrefRegistrarSimple()); |
| 15 } |
| 16 |
| 17 void PrefRegistrarSimple::RegisterBooleanPref(const char* path, |
| 18 bool default_value) { |
| 19 pref_service_->RegisterPreference(path, |
| 20 Value::CreateBooleanValue(default_value)); |
| 21 } |
| 22 |
| 23 void PrefRegistrarSimple::RegisterIntegerPref(const char* path, |
| 24 int default_value) { |
| 25 pref_service_->RegisterPreference(path, |
| 26 Value::CreateIntegerValue(default_value)); |
| 27 } |
| 28 |
| 29 void PrefRegistrarSimple::RegisterDoublePref(const char* path, |
| 30 double default_value) { |
| 31 pref_service_->RegisterPreference(path, |
| 32 Value::CreateDoubleValue(default_value)); |
| 33 } |
| 34 |
| 35 void PrefRegistrarSimple::RegisterStringPref(const char* path, |
| 36 const std::string& default_value) { |
| 37 pref_service_->RegisterPreference(path, |
| 38 Value::CreateStringValue(default_value)); |
| 39 } |
| 40 |
| 41 void PrefRegistrarSimple::RegisterFilePathPref(const char* path, |
| 42 const FilePath& default_value) { |
| 43 pref_service_->RegisterPreference( |
| 44 path, |
| 45 Value::CreateStringValue(default_value.value())); |
| 46 } |
| 47 |
| 48 void PrefRegistrarSimple::RegisterListPref(const char* path) { |
| 49 pref_service_->RegisterPreference(path, new ListValue()); |
| 50 } |
| 51 |
| 52 void PrefRegistrarSimple::RegisterListPref(const char* path, |
| 53 ListValue* default_value) { |
| 54 pref_service_->RegisterPreference(path, default_value); |
| 55 } |
| 56 |
| 57 void PrefRegistrarSimple::RegisterDictionaryPref(const char* path) { |
| 58 pref_service_->RegisterPreference(path, new DictionaryValue()); |
| 59 } |
| 60 |
| 61 void PrefRegistrarSimple::RegisterDictionaryPref( |
| 62 const char* path, |
| 63 DictionaryValue* default_value) { |
| 64 pref_service_->RegisterPreference(path, default_value); |
| 65 } |
| 66 |
| 67 void PrefRegistrarSimple::RegisterInt64Pref(const char* path, |
| 68 int64 default_value) { |
| 69 pref_service_->RegisterPreference( |
| 70 path, Value::CreateStringValue(base::Int64ToString(default_value))); |
| 71 } |
| 72 |
| 73 void PrefRegistrarSimple::UnregisterPreference(const char* path) { |
| 74 pref_service_->UnregisterPreference(path); |
| 75 } |
OLD | NEW |