Chromium Code Reviews| 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 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 780 } | 780 } |
| 781 | 781 |
| 782 void PrefService::RegisterPreference(const char* path, | 782 void PrefService::RegisterPreference(const char* path, |
| 783 Value* default_value, | 783 Value* default_value, |
| 784 PrefSyncStatus sync_status) { | 784 PrefSyncStatus sync_status) { |
| 785 DCHECK(CalledOnValidThread()); | 785 DCHECK(CalledOnValidThread()); |
| 786 | 786 |
| 787 // The main code path takes ownership, but most don't. We'll be safe. | 787 // The main code path takes ownership, but most don't. We'll be safe. |
| 788 scoped_ptr<Value> scoped_value(default_value); | 788 scoped_ptr<Value> scoped_value(default_value); |
| 789 | 789 |
| 790 if (FindPreference(path)) { | 790 DCHECK(FindPreference(path) == NULL) << |
|
Bernhard Bauer
2012/10/31 23:06:14
You could just write DCHECK(!FindPreference(path))
Anthony Berent
2012/11/01 10:25:24
Done.
| |
| 791 NOTREACHED() << "Tried to register duplicate pref " << path; | 791 "Tried to register duplicate pref " << path; |
| 792 return; | |
| 793 } | |
| 794 | 792 |
| 795 base::Value::Type orig_type = default_value->GetType(); | 793 base::Value::Type orig_type = default_value->GetType(); |
| 796 DCHECK(orig_type != Value::TYPE_NULL && orig_type != Value::TYPE_BINARY) << | 794 DCHECK(orig_type != Value::TYPE_NULL && orig_type != Value::TYPE_BINARY) << |
| 797 "invalid preference type: " << orig_type; | 795 "invalid preference type: " << orig_type; |
| 798 | 796 |
| 799 // For ListValue and DictionaryValue with non empty default, empty value | 797 // For ListValue and DictionaryValue with non empty default, empty value |
| 800 // for |path| needs to be persisted in |user_pref_store_|. So that | 798 // for |path| needs to be persisted in |user_pref_store_|. So that |
| 801 // non empty default is not used when user sets an empty ListValue or | 799 // non empty default is not used when user sets an empty ListValue or |
| 802 // DictionaryValue. | 800 // DictionaryValue. |
| 803 bool needs_empty_value = false; | 801 bool needs_empty_value = false; |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1060 return pref_value_store()->PrefValueFromDefaultStore(name_.c_str()); | 1058 return pref_value_store()->PrefValueFromDefaultStore(name_.c_str()); |
| 1061 } | 1059 } |
| 1062 | 1060 |
| 1063 bool PrefService::Preference::IsUserModifiable() const { | 1061 bool PrefService::Preference::IsUserModifiable() const { |
| 1064 return pref_value_store()->PrefValueUserModifiable(name_.c_str()); | 1062 return pref_value_store()->PrefValueUserModifiable(name_.c_str()); |
| 1065 } | 1063 } |
| 1066 | 1064 |
| 1067 bool PrefService::Preference::IsExtensionModifiable() const { | 1065 bool PrefService::Preference::IsExtensionModifiable() const { |
| 1068 return pref_value_store()->PrefValueExtensionModifiable(name_.c_str()); | 1066 return pref_value_store()->PrefValueExtensionModifiable(name_.c_str()); |
| 1069 } | 1067 } |
| OLD | NEW |