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 "components/prefs/pref_value_map.h" | 5 #include "components/prefs/pref_value_map.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } | 96 } |
97 | 97 |
98 bool PrefValueMap::GetString(const std::string& key, | 98 bool PrefValueMap::GetString(const std::string& key, |
99 std::string* value) const { | 99 std::string* value) const { |
100 const base::Value* stored_value = nullptr; | 100 const base::Value* stored_value = nullptr; |
101 return GetValue(key, &stored_value) && stored_value->GetAsString(value); | 101 return GetValue(key, &stored_value) && stored_value->GetAsString(value); |
102 } | 102 } |
103 | 103 |
104 void PrefValueMap::SetString(const std::string& key, | 104 void PrefValueMap::SetString(const std::string& key, |
105 const std::string& value) { | 105 const std::string& value) { |
106 SetValue(key, base::MakeUnique<base::StringValue>(value)); | 106 SetValue(key, base::MakeUnique<base::Value>(value)); |
107 } | 107 } |
108 | 108 |
109 bool PrefValueMap::GetInteger(const std::string& key, int* value) const { | 109 bool PrefValueMap::GetInteger(const std::string& key, int* value) const { |
110 const base::Value* stored_value = nullptr; | 110 const base::Value* stored_value = nullptr; |
111 return GetValue(key, &stored_value) && stored_value->GetAsInteger(value); | 111 return GetValue(key, &stored_value) && stored_value->GetAsInteger(value); |
112 } | 112 } |
113 | 113 |
114 void PrefValueMap::SetInteger(const std::string& key, const int value) { | 114 void PrefValueMap::SetInteger(const std::string& key, const int value) { |
115 SetValue(key, base::MakeUnique<base::Value>(value)); | 115 SetValue(key, base::MakeUnique<base::Value>(value)); |
116 } | 116 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 differing_keys->push_back(other_pref->first); | 158 differing_keys->push_back(other_pref->first); |
159 } | 159 } |
160 | 160 |
161 std::unique_ptr<base::DictionaryValue> PrefValueMap::AsDictionaryValue() const { | 161 std::unique_ptr<base::DictionaryValue> PrefValueMap::AsDictionaryValue() const { |
162 auto dictionary = base::MakeUnique<base::DictionaryValue>(); | 162 auto dictionary = base::MakeUnique<base::DictionaryValue>(); |
163 for (const auto& value : prefs_) { | 163 for (const auto& value : prefs_) { |
164 dictionary->Set(value.first, value.second->CreateDeepCopy()); | 164 dictionary->Set(value.first, value.second->CreateDeepCopy()); |
165 } | 165 } |
166 return dictionary; | 166 return dictionary; |
167 } | 167 } |
OLD | NEW |