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 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 if (pref_value_store()->GetValue(name_, type_, &found_value)) { | 988 if (pref_value_store()->GetValue(name_, type_, &found_value)) { |
989 DCHECK(found_value->IsType(type_)); | 989 DCHECK(found_value->IsType(type_)); |
990 return found_value; | 990 return found_value; |
991 } | 991 } |
992 | 992 |
993 // Every registered preference has at least a default value. | 993 // Every registered preference has at least a default value. |
994 NOTREACHED() << "no valid value found for registered pref " << name_; | 994 NOTREACHED() << "no valid value found for registered pref " << name_; |
995 return NULL; | 995 return NULL; |
996 } | 996 } |
997 | 997 |
| 998 const Value* PrefService::Preference::GetRecommendedValue() const { |
| 999 DCHECK(pref_service_->FindPreference(name_.c_str())) << |
| 1000 "Must register pref before getting its value"; |
| 1001 |
| 1002 const Value* found_value = NULL; |
| 1003 if (pref_value_store()->GetRecommendedValue(name_, type_, &found_value)) { |
| 1004 DCHECK(found_value->IsType(type_)); |
| 1005 return found_value; |
| 1006 } |
| 1007 |
| 1008 // The pref has no recommended value. |
| 1009 return NULL; |
| 1010 } |
| 1011 |
998 bool PrefService::Preference::IsManaged() const { | 1012 bool PrefService::Preference::IsManaged() const { |
999 return pref_value_store()->PrefValueInManagedStore(name_.c_str()); | 1013 return pref_value_store()->PrefValueInManagedStore(name_.c_str()); |
1000 } | 1014 } |
1001 | 1015 |
1002 bool PrefService::Preference::IsRecommended() const { | 1016 bool PrefService::Preference::IsRecommended() const { |
1003 return pref_value_store()->PrefValueFromRecommendedStore(name_.c_str()); | 1017 return pref_value_store()->PrefValueFromRecommendedStore(name_.c_str()); |
1004 } | 1018 } |
1005 | 1019 |
1006 bool PrefService::Preference::HasExtensionSetting() const { | 1020 bool PrefService::Preference::HasExtensionSetting() const { |
1007 return pref_value_store()->PrefValueInExtensionStore(name_.c_str()); | 1021 return pref_value_store()->PrefValueInExtensionStore(name_.c_str()); |
(...skipping 15 matching lines...) Expand all Loading... |
1023 return pref_value_store()->PrefValueFromDefaultStore(name_.c_str()); | 1037 return pref_value_store()->PrefValueFromDefaultStore(name_.c_str()); |
1024 } | 1038 } |
1025 | 1039 |
1026 bool PrefService::Preference::IsUserModifiable() const { | 1040 bool PrefService::Preference::IsUserModifiable() const { |
1027 return pref_value_store()->PrefValueUserModifiable(name_.c_str()); | 1041 return pref_value_store()->PrefValueUserModifiable(name_.c_str()); |
1028 } | 1042 } |
1029 | 1043 |
1030 bool PrefService::Preference::IsExtensionModifiable() const { | 1044 bool PrefService::Preference::IsExtensionModifiable() const { |
1031 return pref_value_store()->PrefValueExtensionModifiable(name_.c_str()); | 1045 return pref_value_store()->PrefValueExtensionModifiable(name_.c_str()); |
1032 } | 1046 } |
OLD | NEW |