OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/interests/interests_fetcher.h" | 5 #include "chrome/browser/interests/interests_fetcher.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 return nullptr; | 175 return nullptr; |
176 } | 176 } |
177 | 177 |
178 const base::ListValue* interests_list = nullptr; | 178 const base::ListValue* interests_list = nullptr; |
179 if (!dict->GetList(kIdInterests, &interests_list)) { | 179 if (!dict->GetList(kIdInterests, &interests_list)) { |
180 DLOG(WARNING) << "Failed to parse interests list."; | 180 DLOG(WARNING) << "Failed to parse interests list."; |
181 return nullptr; | 181 return nullptr; |
182 } | 182 } |
183 | 183 |
184 std::unique_ptr<std::vector<Interest>> res(new std::vector<Interest>()); | 184 std::unique_ptr<std::vector<Interest>> res(new std::vector<Interest>()); |
185 for (const base::Value* entry : *interests_list) { | 185 for (const auto& entry : *interests_list) { |
186 const base::DictionaryValue* interest_dict = nullptr; | 186 const base::DictionaryValue* interest_dict = nullptr; |
187 if (!entry->GetAsDictionary(&interest_dict)) { | 187 if (!entry->GetAsDictionary(&interest_dict)) { |
188 DLOG(WARNING) << "Failed to parse interest dictionary."; | 188 DLOG(WARNING) << "Failed to parse interest dictionary."; |
189 continue; | 189 continue; |
190 } | 190 } |
191 | 191 |
192 // Extract the parts of the interest. | 192 // Extract the parts of the interest. |
193 std::string name; | 193 std::string name; |
194 std::string image_url; | 194 std::string image_url; |
195 double relevance = 0; | 195 double relevance = 0; |
(...skipping 11 matching lines...) Expand all Loading... |
207 if (!interest_dict->GetDouble(kIdInterestRelevance, &relevance)) { | 207 if (!interest_dict->GetDouble(kIdInterestRelevance, &relevance)) { |
208 DLOG(WARNING) << "Failed to parse interest relevance."; | 208 DLOG(WARNING) << "Failed to parse interest relevance."; |
209 continue; | 209 continue; |
210 } | 210 } |
211 | 211 |
212 res->push_back(Interest{name, GURL(image_url), relevance}); | 212 res->push_back(Interest{name, GURL(image_url), relevance}); |
213 } | 213 } |
214 | 214 |
215 return res; | 215 return res; |
216 } | 216 } |
OLD | NEW |