| 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.
|
|
|