| 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/testing_pref_store.h" | 5 #include "chrome/browser/prefs/testing_pref_store.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 | 9 |
| 10 TestingPrefStore::TestingPrefStore() | 10 TestingPrefStore::TestingPrefStore() |
| 11 : read_only_(true), | 11 : read_only_(true), |
| 12 prefs_written_(false), | |
| 13 init_complete_(false) { | 12 init_complete_(false) { |
| 14 } | 13 } |
| 15 | 14 |
| 16 PrefStore::ReadResult TestingPrefStore::GetValue(const std::string& key, | 15 PrefStore::ReadResult TestingPrefStore::GetValue(const std::string& key, |
| 17 const Value** value) const { | 16 const Value** value) const { |
| 18 return prefs_.GetValue(key, value) ? READ_OK : READ_NO_VALUE; | 17 return prefs_.GetValue(key, value) ? READ_OK : READ_NO_VALUE; |
| 19 } | 18 } |
| 20 | 19 |
| 21 PrefStore::ReadResult TestingPrefStore::GetMutableValue(const std::string& key, | 20 PrefStore::ReadResult TestingPrefStore::GetMutableValue(const std::string& key, |
| 22 Value** value) { | 21 Value** value) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 57 |
| 59 bool TestingPrefStore::ReadOnly() const { | 58 bool TestingPrefStore::ReadOnly() const { |
| 60 return read_only_; | 59 return read_only_; |
| 61 } | 60 } |
| 62 | 61 |
| 63 PersistentPrefStore::PrefReadError TestingPrefStore::GetReadError() const { | 62 PersistentPrefStore::PrefReadError TestingPrefStore::GetReadError() const { |
| 64 return PersistentPrefStore::PREF_READ_ERROR_NONE; | 63 return PersistentPrefStore::PREF_READ_ERROR_NONE; |
| 65 } | 64 } |
| 66 | 65 |
| 67 PersistentPrefStore::PrefReadError TestingPrefStore::ReadPrefs() { | 66 PersistentPrefStore::PrefReadError TestingPrefStore::ReadPrefs() { |
| 68 prefs_.Clear(); | |
| 69 NotifyInitializationCompleted(); | 67 NotifyInitializationCompleted(); |
| 70 return PersistentPrefStore::PREF_READ_ERROR_NONE; | 68 return PersistentPrefStore::PREF_READ_ERROR_NONE; |
| 71 } | 69 } |
| 72 | 70 |
| 73 void TestingPrefStore::ReadPrefsAsync(ReadErrorDelegate* error_delegate_raw) { | 71 void TestingPrefStore::ReadPrefsAsync(ReadErrorDelegate* error_delegate_raw) { |
| 74 scoped_ptr<ReadErrorDelegate> error_delegate(error_delegate_raw); | 72 scoped_ptr<ReadErrorDelegate> error_delegate(error_delegate_raw); |
| 75 prefs_.Clear(); | |
| 76 NotifyInitializationCompleted(); | 73 NotifyInitializationCompleted(); |
| 77 } | 74 } |
| 78 | 75 |
| 79 void TestingPrefStore::SetInitializationCompleted() { | 76 void TestingPrefStore::SetInitializationCompleted() { |
| 80 init_complete_ = true; | 77 init_complete_ = true; |
| 81 NotifyInitializationCompleted(); | 78 NotifyInitializationCompleted(); |
| 82 } | 79 } |
| 83 | 80 |
| 84 void TestingPrefStore::NotifyPrefValueChanged(const std::string& key) { | 81 void TestingPrefStore::NotifyPrefValueChanged(const std::string& key) { |
| 85 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); | 82 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 return false; | 126 return false; |
| 130 | 127 |
| 131 return stored_value->GetAsBoolean(value); | 128 return stored_value->GetAsBoolean(value); |
| 132 } | 129 } |
| 133 | 130 |
| 134 void TestingPrefStore::set_read_only(bool read_only) { | 131 void TestingPrefStore::set_read_only(bool read_only) { |
| 135 read_only_ = read_only; | 132 read_only_ = read_only; |
| 136 } | 133 } |
| 137 | 134 |
| 138 TestingPrefStore::~TestingPrefStore() {} | 135 TestingPrefStore::~TestingPrefStore() {} |
| OLD | NEW |