| OLD | NEW |
| 1 // Copyright (c) 2011 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/common/json_pref_store.h" | 5 #include "chrome/common/json_pref_store.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 } | 162 } |
| 163 | 163 |
| 164 void JsonPrefStore::AddObserver(PrefStore::Observer* observer) { | 164 void JsonPrefStore::AddObserver(PrefStore::Observer* observer) { |
| 165 observers_.AddObserver(observer); | 165 observers_.AddObserver(observer); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void JsonPrefStore::RemoveObserver(PrefStore::Observer* observer) { | 168 void JsonPrefStore::RemoveObserver(PrefStore::Observer* observer) { |
| 169 observers_.RemoveObserver(observer); | 169 observers_.RemoveObserver(observer); |
| 170 } | 170 } |
| 171 | 171 |
| 172 size_t JsonPrefStore::NumberOfObservers() const { |
| 173 return observers_.size(); |
| 174 } |
| 175 |
| 172 bool JsonPrefStore::IsInitializationComplete() const { | 176 bool JsonPrefStore::IsInitializationComplete() const { |
| 173 return initialized_; | 177 return initialized_; |
| 174 } | 178 } |
| 175 | 179 |
| 176 PrefStore::ReadResult JsonPrefStore::GetMutableValue(const std::string& key, | 180 PrefStore::ReadResult JsonPrefStore::GetMutableValue(const std::string& key, |
| 177 Value** result) { | 181 Value** result) { |
| 178 return prefs_->Get(key, result) ? READ_OK : READ_NO_VALUE; | 182 return prefs_->Get(key, result) ? READ_OK : READ_NO_VALUE; |
| 179 } | 183 } |
| 180 | 184 |
| 181 void JsonPrefStore::SetValue(const std::string& key, Value* value) { | 185 void JsonPrefStore::SetValue(const std::string& key, Value* value) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 } | 298 } |
| 295 | 299 |
| 296 bool JsonPrefStore::SerializeData(std::string* output) { | 300 bool JsonPrefStore::SerializeData(std::string* output) { |
| 297 // TODO(tc): Do we want to prune webkit preferences that match the default | 301 // TODO(tc): Do we want to prune webkit preferences that match the default |
| 298 // value? | 302 // value? |
| 299 JSONStringValueSerializer serializer(output); | 303 JSONStringValueSerializer serializer(output); |
| 300 serializer.set_pretty_print(true); | 304 serializer.set_pretty_print(true); |
| 301 scoped_ptr<DictionaryValue> copy(prefs_->DeepCopyWithoutEmptyChildren()); | 305 scoped_ptr<DictionaryValue> copy(prefs_->DeepCopyWithoutEmptyChildren()); |
| 302 return serializer.Serialize(*(copy.get())); | 306 return serializer.Serialize(*(copy.get())); |
| 303 } | 307 } |
| OLD | NEW |