summaryrefslogtreecommitdiff
path: root/chromium/components/ntp_snippets
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/components/ntp_snippets')
-rw-r--r--chromium/components/ntp_snippets/contextual/cluster.cc4
-rw-r--r--chromium/components/ntp_snippets/contextual/contextual_content_suggestions_service_proxy.cc11
-rw-r--r--chromium/components/ntp_snippets/contextual/contextual_content_suggestions_service_proxy.h3
-rw-r--r--chromium/components/ntp_snippets/contextual/contextual_suggestion.cc11
-rw-r--r--chromium/components/ntp_snippets/contextual/contextual_suggestion.h4
-rw-r--r--chromium/components/ntp_snippets/contextual/contextual_suggestions_fetch.cc9
-rw-r--r--chromium/components/ntp_snippets/contextual/proto/get_pivots_response.proto16
7 files changed, 49 insertions, 9 deletions
diff --git a/chromium/components/ntp_snippets/contextual/cluster.cc b/chromium/components/ntp_snippets/contextual/cluster.cc
index b706a794850..ebd3c491d39 100644
--- a/chromium/components/ntp_snippets/contextual/cluster.cc
+++ b/chromium/components/ntp_snippets/contextual/cluster.cc
@@ -30,6 +30,8 @@ ClusterBuilder::ClusterBuilder(const ClusterBuilder& other) {
.PublisherName(suggestion.publisher_name)
.Snippet(suggestion.snippet)
.ImageId(suggestion.image_id)
+ .FaviconImageId(suggestion.favicon_image_id)
+ .FaviconImageUrl(suggestion.favicon_image_url)
.Build());
}
}
@@ -43,4 +45,4 @@ Cluster ClusterBuilder::Build() {
return std::move(cluster_);
}
-} // namespace contextual_suggestions \ No newline at end of file
+} // namespace contextual_suggestions
diff --git a/chromium/components/ntp_snippets/contextual/contextual_content_suggestions_service_proxy.cc b/chromium/components/ntp_snippets/contextual/contextual_content_suggestions_service_proxy.cc
index 9f3a2e3fb66..d622fd3b833 100644
--- a/chromium/components/ntp_snippets/contextual/contextual_content_suggestions_service_proxy.cc
+++ b/chromium/components/ntp_snippets/contextual/contextual_content_suggestions_service_proxy.cc
@@ -60,7 +60,10 @@ void ContextualContentSuggestionsServiceProxy::FetchContextualSuggestionImage(
return;
}
- FetchImageImpl(suggestion_iter->second.image_id, std::move(callback));
+ std::string& image_id = suggestion_iter->second.image_id;
+ GURL image_url = ImageUrlFromId(image_id);
+
+ FetchImageImpl(image_url, image_id, std::move(callback));
}
void ContextualContentSuggestionsServiceProxy::FetchContextualSuggestionFavicon(
@@ -74,7 +77,8 @@ void ContextualContentSuggestionsServiceProxy::FetchContextualSuggestionFavicon(
return;
}
- FetchImageImpl(suggestion_iter->second.favicon_image_id, std::move(callback));
+ FetchImageImpl(GURL(suggestion_iter->second.favicon_image_url),
+ suggestion_iter->second.favicon_image_id, std::move(callback));
}
void ContextualContentSuggestionsServiceProxy::ClearState() {
@@ -111,10 +115,9 @@ void ContextualContentSuggestionsServiceProxy::FlushMetrics() {
}
void ContextualContentSuggestionsServiceProxy::FetchImageImpl(
+ const GURL& image_url,
const std::string& image_id,
ntp_snippets::ImageFetchedCallback callback) {
- GURL image_url = ImageUrlFromId(image_id);
-
ntp_snippets::ContentSuggestion::ID synthetic_cache_id(
ntp_snippets::Category::FromKnownCategory(
ntp_snippets::KnownCategories::CONTEXTUAL),
diff --git a/chromium/components/ntp_snippets/contextual/contextual_content_suggestions_service_proxy.h b/chromium/components/ntp_snippets/contextual/contextual_content_suggestions_service_proxy.h
index e448659558a..d5dfc58e8c5 100644
--- a/chromium/components/ntp_snippets/contextual/contextual_content_suggestions_service_proxy.h
+++ b/chromium/components/ntp_snippets/contextual/contextual_content_suggestions_service_proxy.h
@@ -58,7 +58,8 @@ class ContextualContentSuggestionsServiceProxy {
void FlushMetrics();
private:
- void FetchImageImpl(const std::string& image_id,
+ void FetchImageImpl(const GURL& image_url,
+ const std::string& image_id,
ntp_snippets::ImageFetchedCallback callback);
void CacheSuggestions(ClustersCallback callback,
diff --git a/chromium/components/ntp_snippets/contextual/contextual_suggestion.cc b/chromium/components/ntp_snippets/contextual/contextual_suggestion.cc
index 20cb47ca881..ce8e1bd5158 100644
--- a/chromium/components/ntp_snippets/contextual/contextual_suggestion.cc
+++ b/chromium/components/ntp_snippets/contextual/contextual_suggestion.cc
@@ -21,7 +21,8 @@ ContextualSuggestion::ContextualSuggestion(
publisher_name(std::move(other.publisher_name)),
snippet(std::move(other.snippet)),
image_id(std::move(other.image_id)),
- favicon_image_id(std::move(other.favicon_image_id)) {}
+ favicon_image_id(std::move(other.favicon_image_id)),
+ favicon_image_url(std::move(other.favicon_image_url)) {}
ContextualSuggestion::~ContextualSuggestion() = default;
@@ -57,8 +58,14 @@ SuggestionBuilder& SuggestionBuilder::FaviconImageId(
return *this;
}
+SuggestionBuilder& SuggestionBuilder::FaviconImageUrl(
+ const std::string& favicon_image_url) {
+ suggestion_.favicon_image_url = favicon_image_url;
+ return *this;
+}
+
ContextualSuggestion SuggestionBuilder::Build() {
return std::move(suggestion_);
}
-} // namespace ntp_snippets \ No newline at end of file
+} // namespace ntp_snippets
diff --git a/chromium/components/ntp_snippets/contextual/contextual_suggestion.h b/chromium/components/ntp_snippets/contextual/contextual_suggestion.h
index c13753653df..8e015ce879d 100644
--- a/chromium/components/ntp_snippets/contextual/contextual_suggestion.h
+++ b/chromium/components/ntp_snippets/contextual/contextual_suggestion.h
@@ -38,6 +38,9 @@ struct ContextualSuggestion {
// As above, but for identifying the favicon for the site the suggestion
// resides on.
std::string favicon_image_id;
+
+ // The favicon URL for the suggestion.
+ std::string favicon_image_url;
};
// Allows compact, precise construction of a ContextualSuggestion. Its main
@@ -52,6 +55,7 @@ class SuggestionBuilder {
SuggestionBuilder& Snippet(const std::string& snippet);
SuggestionBuilder& ImageId(const std::string& image_id);
SuggestionBuilder& FaviconImageId(const std::string& favicon_image_id);
+ SuggestionBuilder& FaviconImageUrl(const std::string& favicon_image_url);
ContextualSuggestion Build();
private:
diff --git a/chromium/components/ntp_snippets/contextual/contextual_suggestions_fetch.cc b/chromium/components/ntp_snippets/contextual/contextual_suggestions_fetch.cc
index 0e42aa0b048..4985c3d23b2 100644
--- a/chromium/components/ntp_snippets/contextual/contextual_suggestions_fetch.cc
+++ b/chromium/components/ntp_snippets/contextual/contextual_suggestions_fetch.cc
@@ -47,12 +47,19 @@ std::string Unescape(const std::string& encoded_text) {
ContextualSuggestion ItemToSuggestion(const PivotItem& item) {
PivotDocument document = item.document();
+ std::string favicon_url;
+ if (document.favicon_image().source_data().has_raster()) {
+ favicon_url =
+ document.favicon_image().source_data().raster().url().raw_url();
+ }
+
return SuggestionBuilder(GURL(document.url().raw_url()))
.Title(Unescape(document.title()))
.Snippet(Unescape(document.summary()))
.PublisherName(Unescape(document.site_name()))
.ImageId(document.image().id().encrypted_docid())
.FaviconImageId(document.favicon_image().id().encrypted_docid())
+ .FaviconImageUrl(favicon_url)
.Build();
}
@@ -279,4 +286,4 @@ void ContextualSuggestionsFetch::ReportFetchMetrics(
std::move(metrics_callback).Run(event);
}
-} // namespace contextual_suggestions \ No newline at end of file
+} // namespace contextual_suggestions
diff --git a/chromium/components/ntp_snippets/contextual/proto/get_pivots_response.proto b/chromium/components/ntp_snippets/contextual/proto/get_pivots_response.proto
index 826c8f4f9e7..72b54f6bc16 100644
--- a/chromium/components/ntp_snippets/contextual/proto/get_pivots_response.proto
+++ b/chromium/components/ntp_snippets/contextual/proto/get_pivots_response.proto
@@ -108,6 +108,9 @@ message Url {
message Image {
// The identity of this image.
optional ImageId id = 1;
+
+ // The underlying source data that encodes the image.
+ optional ImageSource source_data = 2;
}
message ImageId {
@@ -123,3 +126,16 @@ message ImageId {
// ... has an encrypted doc ID of "e-AB_0zkH08qtM".
optional string encrypted_docid = 1;
}
+
+// Represents the underlying encoding / source data for an image.
+message ImageSource {
+ // The raster image representation.
+ optional RasterImage raster = 1;
+}
+
+// A representation of an image as a collection of pixels at a specific size.
+message RasterImage {
+ // A URL at which the image may be retrieved. The format of the image
+ // is determined by the "Content-Type" of the HTTP response for the URL.
+ optional Url url = 2;
+}