| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/prefs/pref_service.h" | 5 #include "chrome/browser/prefs/pref_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 return NULL; | 677 return NULL; |
| 678 } | 678 } |
| 679 const Value* value = pref->GetValue(); | 679 const Value* value = pref->GetValue(); |
| 680 if (value->GetType() != Value::TYPE_DICTIONARY) { | 680 if (value->GetType() != Value::TYPE_DICTIONARY) { |
| 681 NOTREACHED(); | 681 NOTREACHED(); |
| 682 return NULL; | 682 return NULL; |
| 683 } | 683 } |
| 684 return static_cast<const DictionaryValue*>(value); | 684 return static_cast<const DictionaryValue*>(value); |
| 685 } | 685 } |
| 686 | 686 |
| 687 const base::Value* PrefService::GetUserPrefValue(const char* path) const { |
| 688 DCHECK(CalledOnValidThread()); |
| 689 |
| 690 const Preference* pref = FindPreference(path); |
| 691 if (!pref) { |
| 692 NOTREACHED() << "Trying to get an unregistered pref: " << path; |
| 693 return NULL; |
| 694 } |
| 695 |
| 696 // Look for an existing preference in the user store. If it doesn't |
| 697 // exist, return NULL. |
| 698 base::Value* value = NULL; |
| 699 if (user_pref_store_->GetMutableValue(path, &value) != |
| 700 PersistentPrefStore::READ_OK) { |
| 701 return NULL; |
| 702 } |
| 703 |
| 704 if (!value->IsType(pref->GetType())) { |
| 705 NOTREACHED() << "Pref value type doesn't match registered type."; |
| 706 return NULL; |
| 707 } |
| 708 |
| 709 return value; |
| 710 } |
| 711 |
| 687 const ListValue* PrefService::GetList(const char* path) const { | 712 const ListValue* PrefService::GetList(const char* path) const { |
| 688 DCHECK(CalledOnValidThread()); | 713 DCHECK(CalledOnValidThread()); |
| 689 | 714 |
| 690 const Preference* pref = FindPreference(path); | 715 const Preference* pref = FindPreference(path); |
| 691 if (!pref) { | 716 if (!pref) { |
| 692 NOTREACHED() << "Trying to read an unregistered pref: " << path; | 717 NOTREACHED() << "Trying to read an unregistered pref: " << path; |
| 693 return NULL; | 718 return NULL; |
| 694 } | 719 } |
| 695 const Value* value = pref->GetValue(); | 720 const Value* value = pref->GetValue(); |
| 696 if (value->GetType() != Value::TYPE_LIST) { | 721 if (value->GetType() != Value::TYPE_LIST) { |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 return pref_value_store()->PrefValueFromDefaultStore(name_.c_str()); | 980 return pref_value_store()->PrefValueFromDefaultStore(name_.c_str()); |
| 956 } | 981 } |
| 957 | 982 |
| 958 bool PrefService::Preference::IsUserModifiable() const { | 983 bool PrefService::Preference::IsUserModifiable() const { |
| 959 return pref_value_store()->PrefValueUserModifiable(name_.c_str()); | 984 return pref_value_store()->PrefValueUserModifiable(name_.c_str()); |
| 960 } | 985 } |
| 961 | 986 |
| 962 bool PrefService::Preference::IsExtensionModifiable() const { | 987 bool PrefService::Preference::IsExtensionModifiable() const { |
| 963 return pref_value_store()->PrefValueExtensionModifiable(name_.c_str()); | 988 return pref_value_store()->PrefValueExtensionModifiable(name_.c_str()); |
| 964 } | 989 } |
| OLD | NEW |