OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/common/pref_service.h" | 5 #include "chrome/common/pref_service.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 pref_observers_.end()); | 130 pref_observers_.end()); |
131 pref_observers_.clear(); | 131 pref_observers_.clear(); |
132 } | 132 } |
133 | 133 |
134 bool PrefService::LoadPersistentPrefs(const std::wstring& file_path) { | 134 bool PrefService::LoadPersistentPrefs(const std::wstring& file_path) { |
135 DCHECK(!file_path.empty()); | 135 DCHECK(!file_path.empty()); |
136 DCHECK(CalledOnValidThread()); | 136 DCHECK(CalledOnValidThread()); |
137 | 137 |
138 JSONFileValueSerializer serializer(file_path); | 138 JSONFileValueSerializer serializer(file_path); |
139 Value* root = NULL; | 139 Value* root = NULL; |
140 if (serializer.Deserialize(&root)) { | 140 if (serializer.Deserialize(&root, NULL)) { |
141 // Preferences should always have a dictionary root. | 141 // Preferences should always have a dictionary root. |
142 if (!root->IsType(Value::TYPE_DICTIONARY)) { | 142 if (!root->IsType(Value::TYPE_DICTIONARY)) { |
143 delete root; | 143 delete root; |
144 return false; | 144 return false; |
145 } | 145 } |
146 | 146 |
147 persistent_.reset(static_cast<DictionaryValue*>(root)); | 147 persistent_.reset(static_cast<DictionaryValue*>(root)); |
148 return true; | 148 return true; |
149 } | 149 } |
150 | 150 |
151 return false; | 151 return false; |
152 } | 152 } |
153 | 153 |
154 void PrefService::ReloadPersistentPrefs() { | 154 void PrefService::ReloadPersistentPrefs() { |
155 DCHECK(CalledOnValidThread()); | 155 DCHECK(CalledOnValidThread()); |
156 | 156 |
157 JSONFileValueSerializer serializer(pref_filename_); | 157 JSONFileValueSerializer serializer(pref_filename_); |
158 Value* root; | 158 Value* root; |
159 if (serializer.Deserialize(&root)) { | 159 if (serializer.Deserialize(&root, NULL)) { |
160 // Preferences should always have a dictionary root. | 160 // Preferences should always have a dictionary root. |
161 if (!root->IsType(Value::TYPE_DICTIONARY)) { | 161 if (!root->IsType(Value::TYPE_DICTIONARY)) { |
162 delete root; | 162 delete root; |
163 return; | 163 return; |
164 } | 164 } |
165 | 165 |
166 persistent_.reset(static_cast<DictionaryValue*>(root)); | 166 persistent_.reset(static_cast<DictionaryValue*>(root)); |
167 for (PreferenceSet::iterator it = prefs_.begin(); | 167 for (PreferenceSet::iterator it = prefs_.begin(); |
168 it != prefs_.end(); ++it) { | 168 it != prefs_.end(); ++it) { |
169 (*it)->root_pref_ = persistent_.get(); | 169 (*it)->root_pref_ = persistent_.get(); |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 | 669 |
670 // Pref not found, just return the app default. | 670 // Pref not found, just return the app default. |
671 return default_value_.get(); | 671 return default_value_.get(); |
672 } | 672 } |
673 | 673 |
674 bool PrefService::Preference::IsDefaultValue() const { | 674 bool PrefService::Preference::IsDefaultValue() const { |
675 DCHECK(default_value_.get()); | 675 DCHECK(default_value_.get()); |
676 return default_value_->Equals(GetValue()); | 676 return default_value_->Equals(GetValue()); |
677 } | 677 } |
678 | 678 |
OLD | NEW |