| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 NotifyInitializationCompleted(); | 58 NotifyInitializationCompleted(); |
| 59 return PersistentPrefStore::PREF_READ_ERROR_NONE; | 59 return PersistentPrefStore::PREF_READ_ERROR_NONE; |
| 60 } | 60 } |
| 61 | 61 |
| 62 void TestingPrefStore::ReadPrefsAsync(ReadErrorDelegate* error_delegate_raw) { | 62 void TestingPrefStore::ReadPrefsAsync(ReadErrorDelegate* error_delegate_raw) { |
| 63 scoped_ptr<ReadErrorDelegate> error_delegate(error_delegate_raw); | 63 scoped_ptr<ReadErrorDelegate> error_delegate(error_delegate_raw); |
| 64 prefs_.Clear(); | 64 prefs_.Clear(); |
| 65 NotifyInitializationCompleted(); | 65 NotifyInitializationCompleted(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 bool TestingPrefStore::WritePrefs() { | |
| 69 prefs_written_ = true; | |
| 70 return prefs_written_; | |
| 71 } | |
| 72 | |
| 73 void TestingPrefStore::SetInitializationCompleted() { | 68 void TestingPrefStore::SetInitializationCompleted() { |
| 74 init_complete_ = true; | 69 init_complete_ = true; |
| 75 NotifyInitializationCompleted(); | 70 NotifyInitializationCompleted(); |
| 76 } | 71 } |
| 77 | 72 |
| 78 void TestingPrefStore::NotifyPrefValueChanged(const std::string& key) { | 73 void TestingPrefStore::NotifyPrefValueChanged(const std::string& key) { |
| 79 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); | 74 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); |
| 80 } | 75 } |
| 81 | 76 |
| 82 void TestingPrefStore::NotifyInitializationCompleted() { | 77 void TestingPrefStore::NotifyInitializationCompleted() { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 const Value* stored_value; | 116 const Value* stored_value; |
| 122 if (!prefs_.GetValue(key, &stored_value) || !stored_value) | 117 if (!prefs_.GetValue(key, &stored_value) || !stored_value) |
| 123 return false; | 118 return false; |
| 124 | 119 |
| 125 return stored_value->GetAsBoolean(value); | 120 return stored_value->GetAsBoolean(value); |
| 126 } | 121 } |
| 127 | 122 |
| 128 void TestingPrefStore::set_read_only(bool read_only) { | 123 void TestingPrefStore::set_read_only(bool read_only) { |
| 129 read_only_ = read_only; | 124 read_only_ = read_only; |
| 130 } | 125 } |
| 131 | |
| 132 void TestingPrefStore::set_prefs_written(bool status) { | |
| 133 prefs_written_ = status; | |
| 134 } | |
| 135 | |
| 136 bool TestingPrefStore::get_prefs_written() { | |
| 137 return prefs_written_; | |
| 138 } | |
| OLD | NEW |