Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1053)

Side by Side Diff: components/ntp_snippets/physical_web_pages/physical_web_page_suggestions_provider.cc

Issue 2591673002: [NTP::PhysicalWeb] Do not show published time. (Closed)
Patch Set: mvanouwerkerk@ comments. Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/physical_web_pages/physical_web_page_suggestio ns_provider.h" 5 #include "components/ntp_snippets/physical_web_pages/physical_web_page_suggestio ns_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 } 235 }
236 suggestions.push_back(ConvertPhysicalWebPage(*page_dictionary)); 236 suggestions.push_back(ConvertPhysicalWebPage(*page_dictionary));
237 } 237 }
238 238
239 return suggestions; 239 return suggestions;
240 } 240 }
241 241
242 ContentSuggestion PhysicalWebPageSuggestionsProvider::ConvertPhysicalWebPage( 242 ContentSuggestion PhysicalWebPageSuggestionsProvider::ConvertPhysicalWebPage(
243 const DictionaryValue& page) const { 243 const DictionaryValue& page) const {
244 std::string scanned_url, raw_resolved_url, title, description; 244 std::string scanned_url, raw_resolved_url, title, description;
245 int scan_timestamp;
246 bool success = page.GetString(physical_web::kScannedUrlKey, &scanned_url); 245 bool success = page.GetString(physical_web::kScannedUrlKey, &scanned_url);
247 success = page.GetInteger(physical_web::kScanTimestampKey, &scan_timestamp) &&
248 success;
249 success = page.GetString(physical_web::kResolvedUrlKey, &raw_resolved_url) && 246 success = page.GetString(physical_web::kResolvedUrlKey, &raw_resolved_url) &&
250 success; 247 success;
251 success = page.GetString(physical_web::kTitleKey, &title) && success; 248 success = page.GetString(physical_web::kTitleKey, &title) && success;
252 success = 249 success =
253 page.GetString(physical_web::kDescriptionKey, &description) && success; 250 page.GetString(physical_web::kDescriptionKey, &description) && success;
254 if (!success) { 251 if (!success) {
255 LOG(DFATAL) << "Expected field is missing."; 252 LOG(DFATAL) << "Expected field is missing.";
256 } 253 }
257 254
258 const GURL resolved_url(raw_resolved_url); 255 const GURL resolved_url(raw_resolved_url);
259 ContentSuggestion suggestion(provided_category_, GetPageId(page), 256 ContentSuggestion suggestion(provided_category_, GetPageId(page),
260 resolved_url); 257 resolved_url);
261 DCHECK(base::IsStringUTF8(title)); 258 DCHECK(base::IsStringUTF8(title));
262 suggestion.set_title(base::UTF8ToUTF16(title)); 259 suggestion.set_title(base::UTF8ToUTF16(title));
263 // TODO(vitaliii): Set the time properly once the proper value is provided
264 // (see crbug.com/667722).
265 suggestion.set_publish_date(
266 base::Time::FromTimeT(static_cast<time_t>(scan_timestamp)));
267 suggestion.set_publisher_name(base::UTF8ToUTF16(resolved_url.host())); 260 suggestion.set_publisher_name(base::UTF8ToUTF16(resolved_url.host()));
268 DCHECK(base::IsStringUTF8(description)); 261 DCHECK(base::IsStringUTF8(description));
269 suggestion.set_snippet_text(base::UTF8ToUTF16(description)); 262 suggestion.set_snippet_text(base::UTF8ToUTF16(description));
270 return suggestion; 263 return suggestion;
271 } 264 }
272 265
273 // PhysicalWebListener implementation. 266 // PhysicalWebListener implementation.
274 void PhysicalWebPageSuggestionsProvider::OnFound(const GURL& url) { 267 void PhysicalWebPageSuggestionsProvider::OnFound(const GURL& url) {
275 FetchPhysicalWebPages(); 268 FetchPhysicalWebPages();
276 } 269 }
(...skipping 29 matching lines...) Expand all
306 } 299 }
307 300
308 void PhysicalWebPageSuggestionsProvider::StoreDismissedIDsToPrefs( 301 void PhysicalWebPageSuggestionsProvider::StoreDismissedIDsToPrefs(
309 const std::set<std::string>& dismissed_ids) { 302 const std::set<std::string>& dismissed_ids) {
310 prefs::StoreDismissedIDsToPrefs(pref_service_, 303 prefs::StoreDismissedIDsToPrefs(pref_service_,
311 prefs::kDismissedPhysicalWebPageSuggestions, 304 prefs::kDismissedPhysicalWebPageSuggestions,
312 dismissed_ids); 305 dismissed_ids);
313 } 306 }
314 307
315 } // namespace ntp_snippets 308 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698