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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 obj->Set(v8::String::NewFromUtf8(isolate, "renderViewId"), | 161 obj->Set(v8::String::NewFromUtf8(isolate, "renderViewId"), |
162 v8::Int32::New(isolate, render_view_id)); | 162 v8::Int32::New(isolate, render_view_id)); |
163 obj->Set(v8::String::NewFromUtf8(isolate, "rid"), | 163 obj->Set(v8::String::NewFromUtf8(isolate, "rid"), |
164 v8::Int32::New(isolate, restricted_id)); | 164 v8::Int32::New(isolate, restricted_id)); |
165 | 165 |
166 // If the suggestion already has a suggested thumbnail, we create an thumbnail | 166 // If the suggestion already has a suggested thumbnail, we create an thumbnail |
167 // array with both the local thumbnail and the proposed one. | 167 // array with both the local thumbnail and the proposed one. |
168 // Otherwise, we just create an array with the generated one. | 168 // Otherwise, we just create an array with the generated one. |
169 if (!mv_item.thumbnail.spec().empty()) { | 169 if (!mv_item.thumbnail.spec().empty()) { |
170 v8::Local<v8::Array> thumbs = v8::Array::New(isolate, 2); | 170 v8::Local<v8::Array> thumbs = v8::Array::New(isolate, 2); |
| 171 // Note: The "thumb2" source captures a thumbnail on the next visit. |
171 thumbs->Set(0, GenerateThumb2URL(isolate, mv_item.url.spec())); | 172 thumbs->Set(0, GenerateThumb2URL(isolate, mv_item.url.spec())); |
172 thumbs->Set(1, UTF8ToV8String(isolate, mv_item.thumbnail.spec())); | 173 thumbs->Set(1, UTF8ToV8String(isolate, mv_item.thumbnail.spec())); |
173 obj->Set(v8::String::NewFromUtf8(isolate, "thumbnailUrls"), thumbs); | 174 obj->Set(v8::String::NewFromUtf8(isolate, "thumbnailUrls"), thumbs); |
174 } else { | 175 } else { |
175 v8::Local<v8::Array> thumbs = v8::Array::New(isolate, 1); | 176 v8::Local<v8::Array> thumbs = v8::Array::New(isolate, 1); |
176 thumbs->Set(0, | 177 thumbs->Set(0, |
177 GenerateThumbnailURL(isolate, render_view_id, restricted_id)); | 178 GenerateThumbnailURL(isolate, render_view_id, restricted_id)); |
178 obj->Set(v8::String::NewFromUtf8(isolate, "thumbnailUrls"), thumbs); | 179 obj->Set(v8::String::NewFromUtf8(isolate, "thumbnailUrls"), thumbs); |
179 } | 180 } |
180 | 181 |
181 // If the suggestion already has a favicon, we populate the element with it. | 182 // If the suggestion already has a favicon, we populate the element with it. |
182 if (!mv_item.favicon.spec().empty()) { | 183 if (!mv_item.favicon.spec().empty()) { |
183 obj->Set(v8::String::NewFromUtf8(isolate, "faviconUrl"), | 184 obj->Set(v8::String::NewFromUtf8(isolate, "faviconUrl"), |
184 UTF8ToV8String(isolate, mv_item.favicon.spec())); | 185 UTF8ToV8String(isolate, mv_item.favicon.spec())); |
185 } | 186 } |
186 // If the suggestion has an impression url, we populate the element with it. | 187 // If the suggestion has an impression url, we populate the element with it. |
187 if (!mv_item.impression_url.spec().empty()) { | 188 if (!mv_item.impression_url.spec().empty()) { |
188 obj->Set(v8::String::NewFromUtf8(isolate, "impressionUrl"), | 189 obj->Set(v8::String::NewFromUtf8(isolate, "impressionUrl"), |
189 UTF8ToV8String(isolate, mv_item.impression_url.spec())); | 190 UTF8ToV8String(isolate, mv_item.impression_url.spec())); |
190 } | 191 } |
191 // If the suggestion has a click url, we populate the element with it. | 192 // If the suggestion has a click url, we populate the element with it. |
192 if (!mv_item.click_url.spec().empty()) { | 193 if (!mv_item.click_url.spec().empty()) { |
193 obj->Set(v8::String::NewFromUtf8(isolate, "pingUrl"), | 194 obj->Set(v8::String::NewFromUtf8(isolate, "pingUrl"), |
194 UTF8ToV8String(isolate, mv_item.click_url.spec())); | 195 UTF8ToV8String(isolate, mv_item.click_url.spec())); |
195 } | 196 } |
196 | 197 |
| 198 obj->Set(v8::String::NewFromUtf8(isolate, "isServerSide"), |
| 199 v8::Boolean::New(isolate, mv_item.is_server_side_suggestion)); |
| 200 |
197 if (IsIconNTPEnabled()) { | 201 if (IsIconNTPEnabled()) { |
198 // Update website http://www.chromium.org/embeddedsearch when we make this | 202 // Update website http://www.chromium.org/embeddedsearch when we make this |
199 // permanent. | 203 // permanent. |
200 // Large icon size is 48px * window.devicePixelRatio. This is easier to set | 204 // Large icon size is 48px * window.devicePixelRatio. This is easier to set |
201 // from JS, where IsIconNTPEnabled() is not available. So we add stubs | 205 // from JS, where IsIconNTPEnabled() is not available. So we add stubs |
202 // here, and let JS fill in details. | 206 // here, and let JS fill in details. |
203 obj->Set(v8::String::NewFromUtf8(isolate, "largeIconUrl"), | 207 obj->Set(v8::String::NewFromUtf8(isolate, "largeIconUrl"), |
204 v8::String::NewFromUtf8(isolate, "chrome-search://large-icon/")); | 208 v8::String::NewFromUtf8(isolate, "chrome-search://large-icon/")); |
205 obj->Set(v8::String::NewFromUtf8(isolate, "fallbackIconUrl"), | 209 obj->Set(v8::String::NewFromUtf8(isolate, "fallbackIconUrl"), |
206 v8::String::NewFromUtf8(isolate, "chrome-search://fallback-icon/")); | 210 v8::String::NewFromUtf8(isolate, "chrome-search://fallback-icon/")); |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 ThrowInvalidParameters(args); | 1118 ThrowInvalidParameters(args); |
1115 return; | 1119 return; |
1116 } | 1120 } |
1117 | 1121 |
1118 DVLOG(1) << render_view << " UndoMostVisitedDeletion"; | 1122 DVLOG(1) << render_view << " UndoMostVisitedDeletion"; |
1119 SearchBox::Get(render_view) | 1123 SearchBox::Get(render_view) |
1120 ->UndoMostVisitedDeletion(args[0]->ToInteger()->Value()); | 1124 ->UndoMostVisitedDeletion(args[0]->ToInteger()->Value()); |
1121 } | 1125 } |
1122 | 1126 |
1123 } // namespace extensions_v8 | 1127 } // namespace extensions_v8 |
OLD | NEW |