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 "components/ntp_snippets/ntp_snippet.h" | 5 #include "components/ntp_snippets/ntp_snippet.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 const base::DictionaryValue& dict) { | 141 const base::DictionaryValue& dict) { |
142 const base::ListValue* id_list; | 142 const base::ListValue* id_list; |
143 std::string id; | 143 std::string id; |
144 if (!(dict.GetList("id", &id_list) && | 144 if (!(dict.GetList("id", &id_list) && |
145 id_list->GetString(0, &id))) { // TODO(sfiera): multiple IDs | 145 id_list->GetString(0, &id))) { // TODO(sfiera): multiple IDs |
146 return nullptr; | 146 return nullptr; |
147 } | 147 } |
148 | 148 |
149 auto snippet = base::MakeUnique<NTPSnippet>(id); | 149 auto snippet = base::MakeUnique<NTPSnippet>(id); |
150 snippet->sources_.emplace_back(GURL(), std::string(), GURL()); | 150 snippet->sources_.emplace_back(GURL(), std::string(), GURL()); |
151 auto source = &snippet->sources_.back(); | 151 auto* source = &snippet->sources_.back(); |
152 snippet->best_source_index_ = 0; | 152 snippet->best_source_index_ = 0; |
153 | 153 |
154 if (!(dict.GetString("title", &snippet->title_) && | 154 if (!(dict.GetString("title", &snippet->title_) && |
155 dict.GetString("summaryText", &snippet->snippet_) && | 155 dict.GetString("summaryText", &snippet->snippet_) && |
156 GetTimeValue(dict, "publishTime", &snippet->publish_date_) && | 156 GetTimeValue(dict, "publishTime", &snippet->publish_date_) && |
157 GetTimeValue(dict, "expirationTime", &snippet->expiry_date_) && | 157 GetTimeValue(dict, "expirationTime", &snippet->expiry_date_) && |
158 GetURLValue(dict, "imageUrl", &snippet->salient_image_url_) && | 158 GetURLValue(dict, "imageUrl", &snippet->salient_image_url_) && |
159 dict.GetString("publisherName", &source->publisher_name) && | 159 dict.GetString("publisherName", &source->publisher_name) && |
160 GetURLValue(dict, "fullPageUrl", &source->url))) { | 160 GetURLValue(dict, "fullPageUrl", &source->url))) { |
161 return nullptr; | 161 return nullptr; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 best_source_index_ = i; | 276 best_source_index_ = i; |
277 if (!source.amp_url.is_empty()) { | 277 if (!source.amp_url.is_empty()) { |
278 // This is the best possible source, stop looking. | 278 // This is the best possible source, stop looking. |
279 break; | 279 break; |
280 } | 280 } |
281 } | 281 } |
282 } | 282 } |
283 } | 283 } |
284 | 284 |
285 } // namespace ntp_snippets | 285 } // namespace ntp_snippets |
OLD | NEW |