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

Unified Diff: components/ntp_snippets/content_suggestions_service.cc

Issue 2829963005: [Remote suggestions] Get favicon URLs from archive (Closed)
Patch Set: Fix the unit-test Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/ntp_snippets/remote/remote_suggestions_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_snippets/content_suggestions_service.cc
diff --git a/components/ntp_snippets/content_suggestions_service.cc b/components/ntp_snippets/content_suggestions_service.cc
index 9a5f3fbbb36806f9f3701b724628905eeb88c0d2..6d5fdac6fc6fa210ba78a715ff93899d6bc51816 100644
--- a/components/ntp_snippets/content_suggestions_service.cc
+++ b/components/ntp_snippets/content_suggestions_service.cc
@@ -21,6 +21,7 @@
#include "components/favicon_base/fallback_icon_style.h"
#include "components/favicon_base/favicon_types.h"
#include "components/ntp_snippets/pref_names.h"
+#include "components/ntp_snippets/remote/remote_suggestions_provider.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "ui/gfx/image/image.h"
@@ -160,6 +161,7 @@ void ContentSuggestionsService::FetchSuggestionFavicon(
int minimum_size_in_pixel,
int desired_size_in_pixel,
const ImageFetchedCallback& callback) {
+ GURL domain_with_favicon;
std::vector<ContentSuggestion>* suggestions =
&suggestions_by_category_[suggestion_id.category()];
auto position =
@@ -167,15 +169,24 @@ void ContentSuggestionsService::FetchSuggestionFavicon(
[&suggestion_id](const ContentSuggestion& suggestion) {
return suggestion_id == suggestion.id();
});
- if (position == suggestions->end() || !large_icon_service_) {
+ if (position != suggestions->end()) {
tschumann 2017/04/21 08:27:55 nit: this is a bit tricky to follow (especially wi
jkrcal 2017/04/21 10:57:01 Done.
+ domain_with_favicon = position->url_with_favicon();
+ } else if (remote_suggestions_provider_ &&
+ suggestion_id.category().IsKnownCategory(
+ KnownCategories::ARTICLES)) {
tschumann 2017/04/21 08:27:54 unknown remote suggestions should also be tackled
jkrcal 2017/04/21 10:57:00 Due to privacy, we call the new code path from jav
tschumann 2017/04/21 11:23:58 I would prefer we only have a single place where w
jkrcal 2017/04/21 13:30:54 Okay, done.
+ // TODO(jkrcal): Fix how Fetch more works or find other ways to remove this
+ // hack. crbug.com/714031
+ domain_with_favicon =
+ remote_suggestions_provider_->GetUrlWithFavicon(suggestion_id);
+ }
+
+ if (!domain_with_favicon.is_valid() || !large_icon_service_) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(callback, gfx::Image()));
RecordFaviconFetchResult(FaviconFetchResult::FAILURE);
return;
}
- const GURL& domain_with_favicon = position->url_with_favicon();
-
// TODO(jkrcal): Create a general wrapper function in LargeIconService that
// does handle the get-from-cache-and-fallback-to-google-server functionality
// in one shot (for all clients that do not need to react in between).
« no previous file with comments | « no previous file | components/ntp_snippets/remote/remote_suggestions_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698