| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/renderer/searchbox/searchbox_extension.h" | 5 #include "chrome/renderer/searchbox/searchbox_extension.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 obj->Set(v8::String::NewFromUtf8(isolate, "renderViewId"), | 162 obj->Set(v8::String::NewFromUtf8(isolate, "renderViewId"), |
| 163 v8::Int32::New(isolate, render_view_id)); | 163 v8::Int32::New(isolate, render_view_id)); |
| 164 obj->Set(v8::String::NewFromUtf8(isolate, "rid"), | 164 obj->Set(v8::String::NewFromUtf8(isolate, "rid"), |
| 165 v8::Int32::New(isolate, restricted_id)); | 165 v8::Int32::New(isolate, restricted_id)); |
| 166 | 166 |
| 167 // If the suggestion already has a suggested thumbnail, we create an thumbnail | 167 // If the suggestion already has a suggested thumbnail, we create an thumbnail |
| 168 // array with both the local thumbnail and the proposed one. | 168 // array with both the local thumbnail and the proposed one. |
| 169 // Otherwise, we just create an array with the generated one. | 169 // Otherwise, we just create an array with the generated one. |
| 170 if (!mv_item.thumbnail.spec().empty()) { | 170 if (!mv_item.thumbnail.spec().empty()) { |
| 171 v8::Local<v8::Array> thumbs = v8::Array::New(isolate, 2); | 171 v8::Local<v8::Array> thumbs = v8::Array::New(isolate, 2); |
| 172 // Note: The "thumb2" source captures a thumbnail on the next visit. |
| 172 thumbs->Set(0, GenerateThumb2URL(isolate, mv_item.url.spec())); | 173 thumbs->Set(0, GenerateThumb2URL(isolate, mv_item.url.spec())); |
| 173 thumbs->Set(1, UTF8ToV8String(isolate, mv_item.thumbnail.spec())); | 174 thumbs->Set(1, UTF8ToV8String(isolate, mv_item.thumbnail.spec())); |
| 174 obj->Set(v8::String::NewFromUtf8(isolate, "thumbnailUrls"), thumbs); | 175 obj->Set(v8::String::NewFromUtf8(isolate, "thumbnailUrls"), thumbs); |
| 175 } else { | 176 } else { |
| 176 v8::Local<v8::Array> thumbs = v8::Array::New(isolate, 1); | 177 v8::Local<v8::Array> thumbs = v8::Array::New(isolate, 1); |
| 177 thumbs->Set(0, | 178 thumbs->Set(0, |
| 178 GenerateThumbnailURL(isolate, render_view_id, restricted_id)); | 179 GenerateThumbnailURL(isolate, render_view_id, restricted_id)); |
| 179 obj->Set(v8::String::NewFromUtf8(isolate, "thumbnailUrls"), thumbs); | 180 obj->Set(v8::String::NewFromUtf8(isolate, "thumbnailUrls"), thumbs); |
| 180 } | 181 } |
| 181 | 182 |
| 182 // If the suggestion already has a favicon, we populate the element with it. | 183 // If the suggestion already has a favicon, we populate the element with it. |
| 183 if (!mv_item.favicon.spec().empty()) { | 184 if (!mv_item.favicon.spec().empty()) { |
| 184 obj->Set(v8::String::NewFromUtf8(isolate, "faviconUrl"), | 185 obj->Set(v8::String::NewFromUtf8(isolate, "faviconUrl"), |
| 185 UTF8ToV8String(isolate, mv_item.favicon.spec())); | 186 UTF8ToV8String(isolate, mv_item.favicon.spec())); |
| 186 } | 187 } |
| 187 | 188 |
| 189 obj->Set(v8::String::NewFromUtf8(isolate, "tileSource"), |
| 190 v8::Integer::New(isolate, static_cast<int>(mv_item.source))); |
| 191 |
| 188 if (IsIconNTPEnabled()) { | 192 if (IsIconNTPEnabled()) { |
| 189 // Update website http://www.chromium.org/embeddedsearch when we make this | 193 // Update website http://www.chromium.org/embeddedsearch when we make this |
| 190 // permanent. | 194 // permanent. |
| 191 // Large icon size is 48px * window.devicePixelRatio. This is easier to set | 195 // Large icon size is 48px * window.devicePixelRatio. This is easier to set |
| 192 // from JS, where IsIconNTPEnabled() is not available. So we add stubs | 196 // from JS, where IsIconNTPEnabled() is not available. So we add stubs |
| 193 // here, and let JS fill in details. | 197 // here, and let JS fill in details. |
| 194 obj->Set(v8::String::NewFromUtf8(isolate, "largeIconUrl"), | 198 obj->Set(v8::String::NewFromUtf8(isolate, "largeIconUrl"), |
| 195 v8::String::NewFromUtf8(isolate, "chrome-search://large-icon/")); | 199 v8::String::NewFromUtf8(isolate, "chrome-search://large-icon/")); |
| 196 obj->Set(v8::String::NewFromUtf8(isolate, "fallbackIconUrl"), | 200 obj->Set(v8::String::NewFromUtf8(isolate, "fallbackIconUrl"), |
| 197 v8::String::NewFromUtf8(isolate, "chrome-search://fallback-icon/")); | 201 v8::String::NewFromUtf8(isolate, "chrome-search://fallback-icon/")); |
| (...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 ThrowInvalidParameters(args); | 1111 ThrowInvalidParameters(args); |
| 1108 return; | 1112 return; |
| 1109 } | 1113 } |
| 1110 | 1114 |
| 1111 DVLOG(1) << render_view << " UndoMostVisitedDeletion"; | 1115 DVLOG(1) << render_view << " UndoMostVisitedDeletion"; |
| 1112 SearchBox::Get(render_view) | 1116 SearchBox::Get(render_view) |
| 1113 ->UndoMostVisitedDeletion(args[0]->ToInteger()->Value()); | 1117 ->UndoMostVisitedDeletion(args[0]->ToInteger()->Value()); |
| 1114 } | 1118 } |
| 1115 | 1119 |
| 1116 } // namespace extensions_v8 | 1120 } // namespace extensions_v8 |
| OLD | NEW |