| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/testing_pref_store.h" | 5 #include "chrome/browser/prefs/testing_pref_store.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 | 8 |
| 9 TestingPrefStore::TestingPrefStore() | 9 TestingPrefStore::TestingPrefStore() |
| 10 : read_only_(true), | 10 : read_only_(true), |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 if (prefs_.RemoveValue(key)) | 48 if (prefs_.RemoveValue(key)) |
| 49 NotifyPrefValueChanged(key); | 49 NotifyPrefValueChanged(key); |
| 50 } | 50 } |
| 51 | 51 |
| 52 bool TestingPrefStore::ReadOnly() const { | 52 bool TestingPrefStore::ReadOnly() const { |
| 53 return read_only_; | 53 return read_only_; |
| 54 } | 54 } |
| 55 | 55 |
| 56 PersistentPrefStore::PrefReadError TestingPrefStore::ReadPrefs() { | 56 PersistentPrefStore::PrefReadError TestingPrefStore::ReadPrefs() { |
| 57 prefs_.Clear(); | 57 prefs_.Clear(); |
| 58 NotifyInitializationCompleted(); |
| 58 return PersistentPrefStore::PREF_READ_ERROR_NONE; | 59 return PersistentPrefStore::PREF_READ_ERROR_NONE; |
| 59 } | 60 } |
| 60 | 61 |
| 62 void TestingPrefStore::ReadPrefsAsync(ReadErrorDelegate* error_delegate_raw) { |
| 63 scoped_ptr<ReadErrorDelegate> error_delegate(error_delegate_raw); |
| 64 prefs_.Clear(); |
| 65 NotifyInitializationCompleted(); |
| 66 } |
| 67 |
| 61 bool TestingPrefStore::WritePrefs() { | 68 bool TestingPrefStore::WritePrefs() { |
| 62 prefs_written_ = true; | 69 prefs_written_ = true; |
| 63 return prefs_written_; | 70 return prefs_written_; |
| 64 } | 71 } |
| 65 | 72 |
| 66 void TestingPrefStore::SetInitializationCompleted() { | 73 void TestingPrefStore::SetInitializationCompleted() { |
| 67 init_complete_ = true; | 74 init_complete_ = true; |
| 68 NotifyInitializationCompleted(); | 75 NotifyInitializationCompleted(); |
| 69 } | 76 } |
| 70 | 77 |
| 71 void TestingPrefStore::NotifyPrefValueChanged(const std::string& key) { | 78 void TestingPrefStore::NotifyPrefValueChanged(const std::string& key) { |
| 72 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); | 79 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); |
| 73 } | 80 } |
| 74 | 81 |
| 75 void TestingPrefStore::NotifyInitializationCompleted() { | 82 void TestingPrefStore::NotifyInitializationCompleted() { |
| 76 FOR_EACH_OBSERVER(Observer, observers_, OnInitializationCompleted()); | 83 FOR_EACH_OBSERVER(Observer, observers_, OnInitializationCompleted(true)); |
| 77 } | 84 } |
| 78 | 85 |
| 79 void TestingPrefStore::ReportValueChanged(const std::string& key) { | 86 void TestingPrefStore::ReportValueChanged(const std::string& key) { |
| 80 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); | 87 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); |
| 81 } | 88 } |
| 82 | 89 |
| 83 void TestingPrefStore::SetString(const std::string& key, | 90 void TestingPrefStore::SetString(const std::string& key, |
| 84 const std::string& value) { | 91 const std::string& value) { |
| 85 SetValue(key, Value::CreateStringValue(value)); | 92 SetValue(key, Value::CreateStringValue(value)); |
| 86 } | 93 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 read_only_ = read_only; | 129 read_only_ = read_only; |
| 123 } | 130 } |
| 124 | 131 |
| 125 void TestingPrefStore::set_prefs_written(bool status) { | 132 void TestingPrefStore::set_prefs_written(bool status) { |
| 126 prefs_written_ = status; | 133 prefs_written_ = status; |
| 127 } | 134 } |
| 128 | 135 |
| 129 bool TestingPrefStore::get_prefs_written() { | 136 bool TestingPrefStore::get_prefs_written() { |
| 130 return prefs_written_; | 137 return prefs_written_; |
| 131 } | 138 } |
| OLD | NEW |