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/pref_value_map.h" | 5 #include "chrome/browser/prefs/pref_value_map.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 PrefValueMap::const_iterator PrefValueMap::end() const { | 84 PrefValueMap::const_iterator PrefValueMap::end() const { |
85 return prefs_.end(); | 85 return prefs_.end(); |
86 } | 86 } |
87 | 87 |
88 bool PrefValueMap::GetBoolean(const std::string& key, | 88 bool PrefValueMap::GetBoolean(const std::string& key, |
89 bool* value) const { | 89 bool* value) const { |
90 const Value* stored_value = NULL; | 90 const Value* stored_value = NULL; |
91 return GetValue(key, &stored_value) && stored_value->GetAsBoolean(value); | 91 return GetValue(key, &stored_value) && stored_value->GetAsBoolean(value); |
92 } | 92 } |
93 | 93 |
| 94 void PrefValueMap::SetBoolean(const std::string& key, bool value) { |
| 95 SetValue(key, Value::CreateBooleanValue(value)); |
| 96 } |
| 97 |
94 bool PrefValueMap::GetString(const std::string& key, | 98 bool PrefValueMap::GetString(const std::string& key, |
95 std::string* value) const { | 99 std::string* value) const { |
96 const Value* stored_value = NULL; | 100 const Value* stored_value = NULL; |
97 return GetValue(key, &stored_value) && stored_value->GetAsString(value); | 101 return GetValue(key, &stored_value) && stored_value->GetAsString(value); |
98 } | 102 } |
99 | 103 |
100 void PrefValueMap::SetString(const std::string& key, | 104 void PrefValueMap::SetString(const std::string& key, |
101 const std::string& value) { | 105 const std::string& value) { |
102 SetValue(key, Value::CreateStringValue(value)); | 106 SetValue(key, Value::CreateStringValue(value)); |
103 } | 107 } |
(...skipping 30 matching lines...) Expand all Loading... |
134 ++other_pref; | 138 ++other_pref; |
135 } | 139 } |
136 } | 140 } |
137 | 141 |
138 // Add the remaining entries. | 142 // Add the remaining entries. |
139 for ( ; this_pref != prefs_.end(); ++this_pref) | 143 for ( ; this_pref != prefs_.end(); ++this_pref) |
140 differing_keys->push_back(this_pref->first); | 144 differing_keys->push_back(this_pref->first); |
141 for ( ; other_pref != other->prefs_.end(); ++other_pref) | 145 for ( ; other_pref != other->prefs_.end(); ++other_pref) |
142 differing_keys->push_back(other_pref->first); | 146 differing_keys->push_back(other_pref->first); |
143 } | 147 } |
OLD | NEW |