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

Unified Diff: chrome/renderer/searchbox/searchbox_extension.cc

Issue 1016793003: [Icons NTP] Make largeIconUrl and fallbackIconUrl available for Local NTP, behind flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added reminder to update website when this is permanent. Created 5 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/searchbox/searchbox_extension.cc
diff --git a/chrome/renderer/searchbox/searchbox_extension.cc b/chrome/renderer/searchbox/searchbox_extension.cc
index cf42cac0cd6da5d333eabac1ce7b4d3348f94ee1..21bf0b6746f379fb1e3831faa53ebbec5e74bdb1 100644
--- a/chrome/renderer/searchbox/searchbox_extension.cc
+++ b/chrome/renderer/searchbox/searchbox_extension.cc
@@ -6,6 +6,7 @@
#include "base/i18n/rtl.h"
#include "base/json/string_escape.h"
+#include "base/metrics/field_trial.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
@@ -61,6 +62,12 @@ base::string16 V8ValueToUTF16(v8::Handle<v8::Value> v) {
return base::string16(reinterpret_cast<const base::char16*>(*s), s.length());
}
+// Returns whether we should use large icons on NTP.
+bool IsIconNTPEnabled() {
+ return StartsWithASCII(base::FieldTrialList::FindFullName("IconNTP"),
+ "Enabled", true);
+}
+
// Converts string16 to V8 String.
v8::Handle<v8::String> UTF16ToV8String(v8::Isolate* isolate,
const base::string16& s) {
@@ -99,6 +106,27 @@ v8::Handle<v8::String> GenerateThumbnailURL(
"chrome-search://thumb/%d/%d", render_view_id, most_visited_item_id));
}
+v8::Handle<v8::String> GenerateLargeIconURL(
+ v8::Isolate* isolate,
+ int render_view_id,
+ InstantRestrictedID most_visited_item_id) {
+ const int kIconSize = 96; // To support high DPI; on screen it's 48 dp.
+ return UTF8ToV8String(
+ isolate,
+ base::StringPrintf("chrome-search://large-icon/%d/%d/%d",
+ kIconSize, render_view_id, most_visited_item_id));
+}
+
+v8::Handle<v8::String> GenerateFallbackIconURL(
+ v8::Isolate* isolate,
+ int render_view_id,
+ InstantRestrictedID most_visited_item_id) {
+ return UTF8ToV8String(
+ isolate,
+ base::StringPrintf("chrome-search://fallback-icon/,,,,1/%d/%d",
+ render_view_id, most_visited_item_id));
+}
+
// 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
@@ -136,6 +164,14 @@ v8::Handle<v8::Object> GenerateMostVisitedItem(
v8::Int32::New(isolate, restricted_id));
obj->Set(v8::String::NewFromUtf8(isolate, "thumbnailUrl"),
GenerateThumbnailURL(isolate, render_view_id, restricted_id));
+ if (IsIconNTPEnabled()) {
+ // Update website http://www.chromium.org/embeddedsearch when we make this
+ // permanent.
+ obj->Set(v8::String::NewFromUtf8(isolate, "largeIconUrl"),
+ GenerateLargeIconURL(isolate, render_view_id, restricted_id));
+ obj->Set(v8::String::NewFromUtf8(isolate, "fallbackIconUrl"),
+ GenerateFallbackIconURL(isolate, render_view_id, restricted_id));
+ }
obj->Set(v8::String::NewFromUtf8(isolate, "title"),
UTF16ToV8String(isolate, title));
obj->Set(v8::String::NewFromUtf8(isolate, "domain"),
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698