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

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

Issue 2565023002: Use GURLs in Physical Web data source (Closed)
Patch Set: Register missing dependencies Created 4 years 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
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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 // (see crbug.com/667722). 265 // (see crbug.com/667722).
266 suggestion.set_publish_date( 266 suggestion.set_publish_date(
267 base::Time::FromTimeT(static_cast<time_t>(scan_timestamp))); 267 base::Time::FromTimeT(static_cast<time_t>(scan_timestamp)));
268 suggestion.set_publisher_name(base::UTF8ToUTF16(resolved_url.host())); 268 suggestion.set_publisher_name(base::UTF8ToUTF16(resolved_url.host()));
269 DCHECK(base::IsStringUTF8(description)); 269 DCHECK(base::IsStringUTF8(description));
270 suggestion.set_snippet_text(base::UTF8ToUTF16(description)); 270 suggestion.set_snippet_text(base::UTF8ToUTF16(description));
271 return suggestion; 271 return suggestion;
272 } 272 }
273 273
274 // PhysicalWebListener implementation. 274 // PhysicalWebListener implementation.
275 void PhysicalWebPageSuggestionsProvider::OnFound(const std::string& url) { 275 void PhysicalWebPageSuggestionsProvider::OnFound(const GURL& url) {
276 FetchPhysicalWebPages(); 276 FetchPhysicalWebPages();
277 } 277 }
278 278
279 void PhysicalWebPageSuggestionsProvider::OnLost(const std::string& url) { 279 void PhysicalWebPageSuggestionsProvider::OnLost(const GURL& url) {
280 InvalidateSuggestion(url); 280 InvalidateSuggestion(url.spec());
nyquist 2016/12/13 18:01:40 Nit: This seems to be the only caller of Invalidat
cco3 2016/12/13 19:53:41 I think a page_id is supposed to be a string rathe
281 } 281 }
282 282
283 void PhysicalWebPageSuggestionsProvider::OnDistanceChanged( 283 void PhysicalWebPageSuggestionsProvider::OnDistanceChanged(
284 const std::string& url, 284 const GURL& url,
285 double distance_estimate) { 285 double distance_estimate) {
286 FetchPhysicalWebPages(); 286 FetchPhysicalWebPages();
287 } 287 }
288 288
289 void PhysicalWebPageSuggestionsProvider::InvalidateSuggestion( 289 void PhysicalWebPageSuggestionsProvider::InvalidateSuggestion(
290 const std::string& page_id) { 290 const std::string& page_id) {
291 observer()->OnSuggestionInvalidated( 291 observer()->OnSuggestionInvalidated(
292 this, ContentSuggestion::ID(provided_category_, page_id)); 292 this, ContentSuggestion::ID(provided_category_, page_id));
293 293
294 // Remove |page_id| from dismissed suggestions, if present. 294 // Remove |page_id| from dismissed suggestions, if present.
(...skipping 12 matching lines...) Expand all
307 } 307 }
308 308
309 void PhysicalWebPageSuggestionsProvider::StoreDismissedIDsToPrefs( 309 void PhysicalWebPageSuggestionsProvider::StoreDismissedIDsToPrefs(
310 const std::set<std::string>& dismissed_ids) { 310 const std::set<std::string>& dismissed_ids) {
311 prefs::StoreDismissedIDsToPrefs(pref_service_, 311 prefs::StoreDismissedIDsToPrefs(pref_service_,
312 prefs::kDismissedPhysicalWebPageSuggestions, 312 prefs::kDismissedPhysicalWebPageSuggestions,
313 dismissed_ids); 313 dismissed_ids);
314 } 314 }
315 315
316 } // namespace ntp_snippets 316 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698