Chromium Code Reviews| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
| 9 #include "base/json/string_escape.h" | 9 #include "base/json/string_escape.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 | 145 |
| 146 base::string16 title = mv_item.title; | 146 base::string16 title = mv_item.title; |
| 147 if (title.empty()) | 147 if (title.empty()) |
| 148 title = base::UTF8ToUTF16(mv_item.url.spec()); | 148 title = base::UTF8ToUTF16(mv_item.url.spec()); |
| 149 | 149 |
| 150 v8::Local<v8::Object> obj = v8::Object::New(isolate); | 150 v8::Local<v8::Object> obj = v8::Object::New(isolate); |
| 151 obj->Set(v8::String::NewFromUtf8(isolate, "renderViewId"), | 151 obj->Set(v8::String::NewFromUtf8(isolate, "renderViewId"), |
| 152 v8::Int32::New(isolate, render_view_id)); | 152 v8::Int32::New(isolate, render_view_id)); |
| 153 obj->Set(v8::String::NewFromUtf8(isolate, "rid"), | 153 obj->Set(v8::String::NewFromUtf8(isolate, "rid"), |
| 154 v8::Int32::New(isolate, restricted_id)); | 154 v8::Int32::New(isolate, restricted_id)); |
| 155 obj->Set(v8::String::NewFromUtf8(isolate, "thumbnailUrl"), | 155 |
| 156 GenerateThumbnailURL(isolate, render_view_id, restricted_id)); | 156 if (!mv_item.thumbnail.spec().empty()) { |
|
Mathieu
2015/07/28 13:32:42
put a comment above this block
fserb
2015/07/28 17:55:30
Done.
| |
| 157 v8::Local<v8::Array> thumbs = v8::Array::New(isolate, 2); | |
| 158 thumbs->Set(0, UTF8ToV8String(isolate, base::StringPrintf( | |
| 159 "chrome-search://thumb2/%s", | |
| 160 mv_item.url.spec().c_str()))); | |
| 161 thumbs->Set(1, UTF8ToV8String(isolate, mv_item.thumbnail.spec())); | |
| 162 obj->Set(v8::String::NewFromUtf8(isolate, "thumbnailUrls"), thumbs); | |
| 163 } else { | |
| 164 obj->Set(v8::String::NewFromUtf8(isolate, "thumbnailUrl"), | |
| 165 GenerateThumbnailURL(isolate, render_view_id, restricted_id)); | |
| 166 } | |
| 167 | |
| 168 if (!mv_item.favicon.spec().empty()) { | |
|
Mathieu
2015/07/28 13:32:43
...and this block, saying that Chrome can pre-popu
fserb
2015/07/28 17:55:30
Done.
| |
| 169 obj->Set(v8::String::NewFromUtf8(isolate, "faviconUrl"), | |
| 170 UTF8ToV8String(isolate, mv_item.favicon.spec())); | |
| 171 } | |
| 172 | |
| 157 if (IsIconNTPEnabled()) { | 173 if (IsIconNTPEnabled()) { |
| 158 // Update website http://www.chromium.org/embeddedsearch when we make this | 174 // Update website http://www.chromium.org/embeddedsearch when we make this |
| 159 // permanent. | 175 // permanent. |
| 160 // Large icon size is 48px * window.devicePixelRatio. This is easier to set | 176 // Large icon size is 48px * window.devicePixelRatio. This is easier to set |
| 161 // from JS, where IsIconNTPEnabled() is not available. So we add stubs | 177 // from JS, where IsIconNTPEnabled() is not available. So we add stubs |
| 162 // here, and let JS fill in details. | 178 // here, and let JS fill in details. |
| 163 obj->Set(v8::String::NewFromUtf8(isolate, "largeIconUrl"), | 179 obj->Set(v8::String::NewFromUtf8(isolate, "largeIconUrl"), |
| 164 v8::String::NewFromUtf8(isolate, "chrome-search://large-icon/")); | 180 v8::String::NewFromUtf8(isolate, "chrome-search://large-icon/")); |
| 165 obj->Set(v8::String::NewFromUtf8(isolate, "fallbackIconUrl"), | 181 obj->Set(v8::String::NewFromUtf8(isolate, "fallbackIconUrl"), |
| 166 v8::String::NewFromUtf8(isolate, "chrome-search://fallback-icon/")); | 182 v8::String::NewFromUtf8(isolate, "chrome-search://fallback-icon/")); |
| (...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1273 if (!render_view) return; | 1289 if (!render_view) return; |
| 1274 | 1290 |
| 1275 bool display_instant_results = | 1291 bool display_instant_results = |
| 1276 SearchBox::Get(render_view)->display_instant_results(); | 1292 SearchBox::Get(render_view)->display_instant_results(); |
| 1277 DVLOG(1) << render_view << " GetDisplayInstantResults" << | 1293 DVLOG(1) << render_view << " GetDisplayInstantResults" << |
| 1278 display_instant_results; | 1294 display_instant_results; |
| 1279 args.GetReturnValue().Set(display_instant_results); | 1295 args.GetReturnValue().Set(display_instant_results); |
| 1280 } | 1296 } |
| 1281 | 1297 |
| 1282 } // namespace extensions_v8 | 1298 } // namespace extensions_v8 |
| OLD | NEW |