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 "base/prefs/testing_pref_store.h" | 5 #include "base/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() |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 void TestingPrefStore::NotifyInitializationCompleted() { | 85 void TestingPrefStore::NotifyInitializationCompleted() { |
86 FOR_EACH_OBSERVER(Observer, observers_, OnInitializationCompleted(true)); | 86 FOR_EACH_OBSERVER(Observer, observers_, OnInitializationCompleted(true)); |
87 } | 87 } |
88 | 88 |
89 void TestingPrefStore::ReportValueChanged(const std::string& key) { | 89 void TestingPrefStore::ReportValueChanged(const std::string& key) { |
90 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); | 90 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); |
91 } | 91 } |
92 | 92 |
93 void TestingPrefStore::SetString(const std::string& key, | 93 void TestingPrefStore::SetString(const std::string& key, |
94 const std::string& value) { | 94 const std::string& value) { |
95 SetValue(key, Value::CreateStringValue(value)); | 95 SetValue(key, new base::StringValue(value)); |
96 } | 96 } |
97 | 97 |
98 void TestingPrefStore::SetInteger(const std::string& key, int value) { | 98 void TestingPrefStore::SetInteger(const std::string& key, int value) { |
99 SetValue(key, Value::CreateIntegerValue(value)); | 99 SetValue(key, new base::FundamentalValue(value)); |
100 } | 100 } |
101 | 101 |
102 void TestingPrefStore::SetBoolean(const std::string& key, bool value) { | 102 void TestingPrefStore::SetBoolean(const std::string& key, bool value) { |
103 SetValue(key, Value::CreateBooleanValue(value)); | 103 SetValue(key, new base::FundamentalValue(value)); |
104 } | 104 } |
105 | 105 |
106 bool TestingPrefStore::GetString(const std::string& key, | 106 bool TestingPrefStore::GetString(const std::string& key, |
107 std::string* value) const { | 107 std::string* value) const { |
108 const Value* stored_value; | 108 const Value* stored_value; |
109 if (!prefs_.GetValue(key, &stored_value) || !stored_value) | 109 if (!prefs_.GetValue(key, &stored_value) || !stored_value) |
110 return false; | 110 return false; |
111 | 111 |
112 return stored_value->GetAsString(value); | 112 return stored_value->GetAsString(value); |
113 } | 113 } |
(...skipping 12 matching lines...) Expand all Loading... |
126 return false; | 126 return false; |
127 | 127 |
128 return stored_value->GetAsBoolean(value); | 128 return stored_value->GetAsBoolean(value); |
129 } | 129 } |
130 | 130 |
131 void TestingPrefStore::set_read_only(bool read_only) { | 131 void TestingPrefStore::set_read_only(bool read_only) { |
132 read_only_ = read_only; | 132 read_only_ = read_only; |
133 } | 133 } |
134 | 134 |
135 TestingPrefStore::~TestingPrefStore() {} | 135 TestingPrefStore::~TestingPrefStore() {} |
OLD | NEW |