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

Unified Diff: chrome/renderer/searchbox/searchbox_extension.cc

Issue 2786833003: NTP thumbnails: Always pass singular "thumbnailUrl" to the iframe (Closed)
Patch Set: . Created 3 years, 9 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 | « chrome/browser/resources/local_ntp/most_visited_thumbnail.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/searchbox/searchbox_extension.cc
diff --git a/chrome/renderer/searchbox/searchbox_extension.cc b/chrome/renderer/searchbox/searchbox_extension.cc
index 5cd4a6e2cba75c76c59e341f1b14aca3e3aa9845..aa34ac68909f94fffa737ab42b2dc363909d6c39 100644
--- a/chrome/renderer/searchbox/searchbox_extension.cc
+++ b/chrome/renderer/searchbox/searchbox_extension.cc
@@ -108,9 +108,12 @@ v8::Local<v8::String> GenerateThumbnailURL(
}
v8::Local<v8::String> GenerateThumb2URL(v8::Isolate* isolate,
- const std::string& url) {
- return UTF8ToV8String(
- isolate, base::StringPrintf("chrome-search://thumb2/%s", url.c_str()));
+ const GURL& page_url,
+ const GURL& fallback_thumb_url) {
+ return UTF8ToV8String(isolate,
+ base::StringPrintf("chrome-search://thumb2/%s?fb=%s",
sfiera 2017/03/30 13:40:58 No url-escaping?
Marc Treib 2017/03/30 13:51:03 Nope :-/ Example of what these URLs look like (fr
sfiera 2017/03/30 13:55:19 Ah, so any tile with ?fb= in its URL is probably a
Marc Treib 2017/03/30 14:04:26 Argh, yes - I didn't even notice. Though I think w
+ page_url.spec().c_str(),
+ fallback_thumb_url.spec().c_str()));
}
// Populates a Javascript MostVisitedItem object from |mv_item|.
@@ -149,21 +152,13 @@ v8::Local<v8::Object> GenerateMostVisitedItem(
obj->Set(v8::String::NewFromUtf8(isolate, "rid"),
v8::Int32::New(isolate, restricted_id));
- // If the suggestion already has a suggested thumbnail, we create an thumbnail
- // array with both the local thumbnail and the proposed one.
- // Otherwise, we just create an array with the generated one.
- if (!mv_item.thumbnail.spec().empty()) {
- v8::Local<v8::Array> thumbs = v8::Array::New(isolate, 2);
- // Note: The "thumb2" source captures a thumbnail on the next visit.
- thumbs->Set(0, GenerateThumb2URL(isolate, mv_item.url.spec()));
- thumbs->Set(1, UTF8ToV8String(isolate, mv_item.thumbnail.spec()));
- obj->Set(v8::String::NewFromUtf8(isolate, "thumbnailUrls"), thumbs);
- } else {
- v8::Local<v8::Array> thumbs = v8::Array::New(isolate, 1);
- thumbs->Set(0,
- GenerateThumbnailURL(isolate, render_view_id, restricted_id));
- obj->Set(v8::String::NewFromUtf8(isolate, "thumbnailUrls"), thumbs);
- }
+ // If the suggestion already has a suggested thumbnail, we create a thumbnail
+ // URL with both the local thumbnail and the proposed one as a fallback.
+ // Otherwise, we just pass on the generated one.
+ obj->Set(v8::String::NewFromUtf8(isolate, "thumbnailUrl"),
+ mv_item.thumbnail.is_valid()
+ ? GenerateThumb2URL(isolate, mv_item.url, mv_item.thumbnail)
+ : GenerateThumbnailURL(isolate, render_view_id, restricted_id));
// If the suggestion already has a favicon, we populate the element with it.
if (!mv_item.favicon.spec().empty()) {
« no previous file with comments | « chrome/browser/resources/local_ntp/most_visited_thumbnail.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698