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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 const base::DictionaryValue& dict) { | 150 const base::DictionaryValue& dict) { |
151 const base::ListValue* id_list; | 151 const base::ListValue* id_list; |
152 std::string id; | 152 std::string id; |
153 if (!(dict.GetList("id", &id_list) && | 153 if (!(dict.GetList("id", &id_list) && |
154 id_list->GetString(0, &id))) { // TODO(sfiera): multiple IDs | 154 id_list->GetString(0, &id))) { // TODO(sfiera): multiple IDs |
155 return nullptr; | 155 return nullptr; |
156 } | 156 } |
157 | 157 |
158 auto snippet = base::MakeUnique<NTPSnippet>(id); | 158 auto snippet = base::MakeUnique<NTPSnippet>(id); |
159 snippet->sources_.emplace_back(GURL(), std::string(), GURL()); | 159 snippet->sources_.emplace_back(GURL(), std::string(), GURL()); |
160 auto source = &snippet->sources_.back(); | 160 auto* source = &snippet->sources_.back(); |
161 snippet->best_source_index_ = 0; | 161 snippet->best_source_index_ = 0; |
162 | 162 |
163 if (!(dict.GetString("title", &snippet->title_) && | 163 if (!(dict.GetString("title", &snippet->title_) && |
164 dict.GetString("summaryText", &snippet->snippet_) && | 164 dict.GetString("summaryText", &snippet->snippet_) && |
165 GetTimeValue(dict, "publishTime", &snippet->publish_date_) && | 165 GetTimeValue(dict, "publishTime", &snippet->publish_date_) && |
166 GetTimeValue(dict, "expirationTime", &snippet->expiry_date_) && | 166 GetTimeValue(dict, "expirationTime", &snippet->expiry_date_) && |
167 GetURLValue(dict, "imageUrl", &snippet->salient_image_url_) && | 167 GetURLValue(dict, "imageUrl", &snippet->salient_image_url_) && |
168 GetURLValue(dict, "ampUrl", &source->amp_url) && | 168 GetURLValue(dict, "ampUrl", &source->amp_url) && |
169 dict.GetString("publisherName", &source->publisher_name) && | 169 dict.GetString("publisherName", &source->publisher_name) && |
170 GetURLValue(dict, "fullPageUrl", &source->url))) { | 170 GetURLValue(dict, "fullPageUrl", &source->url))) { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 best_source_index_ = i; | 298 best_source_index_ = i; |
299 if (!source.amp_url.is_empty()) { | 299 if (!source.amp_url.is_empty()) { |
300 // This is the best possible source, stop looking. | 300 // This is the best possible source, stop looking. |
301 break; | 301 break; |
302 } | 302 } |
303 } | 303 } |
304 } | 304 } |
305 } | 305 } |
306 | 306 |
307 } // namespace ntp_snippets | 307 } // namespace ntp_snippets |
OLD | NEW |