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

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, 5 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
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..5dac68e71fa6b221d9002715f9bec734417a3404 100644
--- a/chrome/renderer/searchbox/searchbox_extension.cc
+++ b/chrome/renderer/searchbox/searchbox_extension.cc
@@ -152,8 +152,30 @@ 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, UTF8ToV8String(isolate, base::StringPrintf(
+ "chrome-search://thumb2/%s",
+ mv_item.url.spec().c_str())));
+ 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.
« chrome/browser/search/instant_service.cc ('K') | « chrome/common/render_messages.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698