Commit 2b339c05 authored by Dan Harrington's avatar Dan Harrington Committed by Commit Bot

Add salient_image_url to ContentSuggestion

This is populated for RemoteSuggestions.
The plan is to use this in offline_pages/ to fetch the suggested image URL,
instead of relying on ntp_snippets to fetch the URL.

Bug: 841522
Change-Id: I18ad866ec3b6ad39509df50421eef51a7a976380
Reviewed-on: https://chromium-review.googlesource.com/1147319Reviewed-by: default avatarCarlos Knippschild <carlosk@chromium.org>
Reviewed-by: default avatarFilip Gorski <fgorski@chromium.org>
Commit-Queue: Dan H <harringtond@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578368}
parent b01e0beb
...@@ -109,6 +109,13 @@ class ContentSuggestion { ...@@ -109,6 +109,13 @@ class ContentSuggestion {
url_with_favicon_ = url_with_favicon; url_with_favicon_ = url_with_favicon;
} }
// A URL for an image that represents the content of the suggestion.
// Empty when an image is not available.
GURL salient_image_url() const { return salient_image_url_; }
void set_salient_image_url(const GURL& salient_image_url) {
salient_image_url_ = salient_image_url;
}
static GURL GetFaviconDomain(const GURL& favicon_url); static GURL GetFaviconDomain(const GURL& favicon_url);
// Title of the suggestion. // Title of the suggestion.
...@@ -191,6 +198,7 @@ class ContentSuggestion { ...@@ -191,6 +198,7 @@ class ContentSuggestion {
ID id_; ID id_;
GURL url_; GURL url_;
GURL url_with_favicon_; GURL url_with_favicon_;
GURL salient_image_url_;
base::string16 title_; base::string16 title_;
base::string16 snippet_text_; base::string16 snippet_text_;
base::Time publish_date_; base::Time publish_date_;
......
...@@ -305,6 +305,8 @@ ContentSuggestion RemoteSuggestion::ToContentSuggestion( ...@@ -305,6 +305,8 @@ ContentSuggestion RemoteSuggestion::ToContentSuggestion(
suggestion.set_publish_date(publish_date_); suggestion.set_publish_date(publish_date_);
suggestion.set_publisher_name(base::UTF8ToUTF16(publisher_name_)); suggestion.set_publisher_name(base::UTF8ToUTF16(publisher_name_));
suggestion.set_score(score_); suggestion.set_score(score_);
suggestion.set_salient_image_url(salient_image_url_);
if (should_notify_) { if (should_notify_) {
NotificationExtra extra; NotificationExtra extra;
extra.deadline = notification_deadline_; extra.deadline = notification_deadline_;
......
...@@ -280,6 +280,8 @@ TEST(RemoteSuggestionTest, ToContentSuggestion) { ...@@ -280,6 +280,8 @@ TEST(RemoteSuggestionTest, ToContentSuggestion) {
EXPECT_THAT(sugg.publish_date().ToJavaTime(), Eq(1467284497000)); EXPECT_THAT(sugg.publish_date().ToJavaTime(), Eq(1467284497000));
EXPECT_THAT(sugg.publisher_name(), Eq(base::UTF8ToUTF16("Foo News"))); EXPECT_THAT(sugg.publisher_name(), Eq(base::UTF8ToUTF16("Foo News")));
EXPECT_THAT(sugg.score(), Eq(9001)); EXPECT_THAT(sugg.score(), Eq(9001));
EXPECT_THAT(sugg.salient_image_url(),
Eq(GURL("http://localhost/foobar.jpg")));
EXPECT_THAT(sugg.download_suggestion_extra(), IsNull()); EXPECT_THAT(sugg.download_suggestion_extra(), IsNull());
EXPECT_THAT(sugg.notification_extra(), IsNull()); EXPECT_THAT(sugg.notification_extra(), IsNull());
EXPECT_THAT(sugg.fetch_date(), Eq(fetch_date)); EXPECT_THAT(sugg.fetch_date(), Eq(fetch_date));
......
...@@ -119,6 +119,7 @@ const char kSuggestionUrl[] = "http://localhost/foobar"; ...@@ -119,6 +119,7 @@ const char kSuggestionUrl[] = "http://localhost/foobar";
const char kSuggestionTitle[] = "Title"; const char kSuggestionTitle[] = "Title";
const char kSuggestionText[] = "Suggestion"; const char kSuggestionText[] = "Suggestion";
const char kSuggestionPublisherName[] = "Foo News"; const char kSuggestionPublisherName[] = "Foo News";
const char kImageUrl[] = "http://image/image.png";
const char kSuggestionUrl2[] = "http://foo.com/bar"; const char kSuggestionUrl2[] = "http://foo.com/bar";
...@@ -715,6 +716,7 @@ TEST_F(RemoteSuggestionsProviderImplTest, Full) { ...@@ -715,6 +716,7 @@ TEST_F(RemoteSuggestionsProviderImplTest, Full) {
.AddId(kSuggestionUrl) .AddId(kSuggestionUrl)
.SetTitle(kSuggestionTitle) .SetTitle(kSuggestionTitle)
.SetSnippet(kSuggestionText) .SetSnippet(kSuggestionText)
.SetImageUrl(kImageUrl)
.SetPublishDate(GetDefaultCreationTime()) .SetPublishDate(GetDefaultCreationTime())
.SetPublisher(kSuggestionPublisherName)) .SetPublisher(kSuggestionPublisherName))
.Build()); .Build());
...@@ -732,6 +734,7 @@ TEST_F(RemoteSuggestionsProviderImplTest, Full) { ...@@ -732,6 +734,7 @@ TEST_F(RemoteSuggestionsProviderImplTest, Full) {
EXPECT_EQ(MakeArticleID(kSuggestionUrl), suggestion.id()); EXPECT_EQ(MakeArticleID(kSuggestionUrl), suggestion.id());
EXPECT_EQ(kSuggestionTitle, base::UTF16ToUTF8(suggestion.title())); EXPECT_EQ(kSuggestionTitle, base::UTF16ToUTF8(suggestion.title()));
EXPECT_EQ(kSuggestionText, base::UTF16ToUTF8(suggestion.snippet_text())); EXPECT_EQ(kSuggestionText, base::UTF16ToUTF8(suggestion.snippet_text()));
EXPECT_EQ(kImageUrl, suggestion.salient_image_url());
EXPECT_EQ(GetDefaultCreationTime(), suggestion.publish_date()); EXPECT_EQ(GetDefaultCreationTime(), suggestion.publish_date());
EXPECT_EQ(kSuggestionPublisherName, EXPECT_EQ(kSuggestionPublisherName,
base::UTF16ToUTF8(suggestion.publisher_name())); base::UTF16ToUTF8(suggestion.publisher_name()));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment