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

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

Issue 1260113002: Adds an experiment that enabled SuggestionsService suggestions (MostLikely) on LocalNTP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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/common/render_messages.h ('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 17e7bf15a118c7bc1cc64b0afbdc8239a520900a..9258b761822c9d056c27b133b5dc83f09321191e 100644
--- a/chrome/renderer/searchbox/searchbox_extension.cc
+++ b/chrome/renderer/searchbox/searchbox_extension.cc
@@ -117,6 +117,11 @@ v8::Local<v8::String> GenerateThumbnailURL(
"chrome-search://thumb/%d/%d", render_view_id, most_visited_item_id));
}
+v8::Local<v8::String> GenerateThumb2URL(v8::Isolate* isolate, std::string url) {
+ return UTF8ToV8String(
+ isolate, base::StringPrintf("chrome-search://thumb2/%s", url.c_str()));
+}
+
// Populates a Javascript MostVisitedItem object from |mv_item|.
// NOTE: Includes "url", "title" and "domain" which are private data, so should
// not be returned to the Instant page. These should be erased before returning
@@ -152,8 +157,28 @@ v8::Local<v8::Object> GenerateMostVisitedItem(
v8::Int32::New(isolate, render_view_id));
obj->Set(v8::String::NewFromUtf8(isolate, "rid"),
v8::Int32::New(isolate, restricted_id));
- obj->Set(v8::String::NewFromUtf8(isolate, "thumbnailUrl"),
- GenerateThumbnailURL(isolate, render_view_id, 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);
+ 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 favicon, we populate the element with it.
+ if (!mv_item.favicon.spec().empty()) {
+ obj->Set(v8::String::NewFromUtf8(isolate, "faviconUrl"),
+ UTF8ToV8String(isolate, mv_item.favicon.spec()));
+ }
+
if (IsIconNTPEnabled()) {
// Update website http://www.chromium.org/embeddedsearch when we make this
// permanent.
« no previous file with comments | « chrome/common/render_messages.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698