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

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

Issue 15907006: Rip out browser-side RID caching for most visited items. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 7 years, 7 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
Index: chrome/renderer/searchbox/searchbox_extension.cc
diff --git a/chrome/renderer/searchbox/searchbox_extension.cc b/chrome/renderer/searchbox/searchbox_extension.cc
index eccea392f776c43cc87a3a8da7a9830ecd45f2d0..b94538a66637b4886b9622ddbdbb9c2429dd34ac 100644
--- a/chrome/renderer/searchbox/searchbox_extension.cc
+++ b/chrome/renderer/searchbox/searchbox_extension.cc
@@ -91,10 +91,14 @@ v8::Handle<v8::String> GenerateThumbnailURL(uint64 most_visited_item_id) {
base::Uint64ToString(most_visited_item_id).c_str()));
}
-v8::Handle<v8::String> GenerateFaviconURL(uint64 most_visited_item_id) {
+v8::Handle<v8::String> GenerateThumbnailURL(const GURL& url) {
Jered 2013/05/31 17:34:33 Instead of overloading based on types, give these
kmadhusu 2013/06/04 02:36:01 Done. As per the next comment, I moved GenerateThu
return UTF8ToV8String(
- base::StringPrintf("chrome-search://favicon/%s",
- base::Uint64ToString(most_visited_item_id).c_str()));
+ base::StringPrintf("chrome-search://thumb/%s", url.spec().c_str()));
+}
+
+v8::Handle<v8::String> GenerateFaviconURL(const GURL& url) {
+ return UTF8ToV8String(
+ base::StringPrintf("chrome-search://favicon/%s", url.spec().c_str()));
}
// If |url| starts with |prefix|, removes |prefix|.
@@ -167,12 +171,17 @@ v8::Handle<v8::Object> GenerateNativeSuggestion(
}
// Populates a Javascript MostVisitedItem object from |mv_item|.
+//
+// Set |privileged_mode| to true to set the most visited item url in thumbnail
Jered 2013/05/31 17:34:33 Instead of doing this, how about always specifying
kmadhusu 2013/06/04 02:36:01 Done.
+// URL.
+//
// 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
// the object. See GetMostVisitedItemsWrapper() in searchbox_api.js.
v8::Handle<v8::Object> GenerateMostVisitedItem(
InstantRestrictedID restricted_id,
- const InstantMostVisitedItem &mv_item) {
+ const InstantMostVisitedItem &mv_item,
+ bool privileged_mode) {
// We set the "dir" attribute of the title, so that in RTL locales, a LTR
// title is rendered left-to-right and truncated from the right. For
// example, the title of http://msdn.microsoft.com/en-us/default.aspx is
@@ -197,9 +206,9 @@ v8::Handle<v8::Object> GenerateMostVisitedItem(
v8::Handle<v8::Object> obj = v8::Object::New();
obj->Set(v8::String::New("rid"), v8::Int32::New(restricted_id));
obj->Set(v8::String::New("thumbnailUrl"),
- GenerateThumbnailURL(restricted_id));
- obj->Set(v8::String::New("faviconUrl"),
- GenerateFaviconURL(restricted_id));
+ privileged_mode ? GenerateThumbnailURL(mv_item.url) :
+ GenerateThumbnailURL(restricted_id));
+ obj->Set(v8::String::New("faviconUrl"), GenerateFaviconURL(mv_item.url));
Jered 2013/05/31 17:34:33 This is priveleged.
kmadhusu 2013/06/04 02:36:01 Fixed.
obj->Set(v8::String::New("title"), UTF16ToV8String(title));
obj->Set(v8::String::New("domain"), UTF8ToV8String(mv_item.url.host()));
obj->Set(v8::String::New("direction"), UTF8ToV8String(direction));
@@ -1255,7 +1264,8 @@ v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetMostVisitedItems(
v8::Handle<v8::Array> v8_mv_items = v8::Array::New(instant_mv_items.size());
for (size_t i = 0; i < instant_mv_items.size(); ++i) {
v8_mv_items->Set(i, GenerateMostVisitedItem(instant_mv_items[i].first,
- instant_mv_items[i].second));
+ instant_mv_items[i].second,
+ false));
}
return v8_mv_items;
}
@@ -1403,7 +1413,7 @@ v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetMostVisitedItemData(
restricted_id, &mv_item)) {
return v8::Undefined();
}
- return GenerateMostVisitedItem(restricted_id, mv_item);
+ return GenerateMostVisitedItem(restricted_id, mv_item, true);
}
// static
« chrome/browser/ui/webui/ntp/thumbnail_source.cc ('K') | « chrome/renderer/searchbox/searchbox.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698