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

Side by Side Diff: chrome/renderer/searchbox/searchbox_extension.cc

Issue 18344010: Completing high dpi support for Instant Extended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and rebase Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/searchbox/searchbox.cc ('k') | chrome/renderer/searchbox/searchbox_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 74
75 v8::Handle<v8::String> GenerateThumbnailURL( 75 v8::Handle<v8::String> GenerateThumbnailURL(
76 int render_view_id, 76 int render_view_id,
77 InstantRestrictedID most_visited_item_id) { 77 InstantRestrictedID most_visited_item_id) {
78 return UTF8ToV8String(base::StringPrintf("chrome-search://thumb/%d/%d", 78 return UTF8ToV8String(base::StringPrintf("chrome-search://thumb/%d/%d",
79 render_view_id, 79 render_view_id,
80 most_visited_item_id)); 80 most_visited_item_id));
81 } 81 }
82 82
83 v8::Handle<v8::String> GenerateFaviconURL(
84 int render_view_id,
85 InstantRestrictedID most_visited_item_id) {
86 return UTF8ToV8String(base::StringPrintf("chrome-search://favicon/%d/%d",
87 render_view_id,
88 most_visited_item_id));
89 }
90
91 // Populates a Javascript MostVisitedItem object from |mv_item|. 83 // Populates a Javascript MostVisitedItem object from |mv_item|.
92 // NOTE: Includes "url", "title" and "domain" which are private data, so should 84 // NOTE: Includes "url", "title" and "domain" which are private data, so should
93 // not be returned to the Instant page. These should be erased before returning 85 // not be returned to the Instant page. These should be erased before returning
94 // the object. See GetMostVisitedItemsWrapper() in searchbox_api.js. 86 // the object. See GetMostVisitedItemsWrapper() in searchbox_api.js.
95 v8::Handle<v8::Object> GenerateMostVisitedItem( 87 v8::Handle<v8::Object> GenerateMostVisitedItem(
96 int render_view_id, 88 int render_view_id,
97 InstantRestrictedID restricted_id, 89 InstantRestrictedID restricted_id,
98 const InstantMostVisitedItem &mv_item) { 90 const InstantMostVisitedItem &mv_item) {
99 // We set the "dir" attribute of the title, so that in RTL locales, a LTR 91 // We set the "dir" attribute of the title, so that in RTL locales, a LTR
100 // title is rendered left-to-right and truncated from the right. For 92 // title is rendered left-to-right and truncated from the right. For
(...skipping 10 matching lines...) Expand all
111 if (base::i18n::StringContainsStrongRTLChars(mv_item.title)) 103 if (base::i18n::StringContainsStrongRTLChars(mv_item.title))
112 direction = kRTLHtmlTextDirection; 104 direction = kRTLHtmlTextDirection;
113 else 105 else
114 direction = kLTRHtmlTextDirection; 106 direction = kLTRHtmlTextDirection;
115 107
116 string16 title = mv_item.title; 108 string16 title = mv_item.title;
117 if (title.empty()) 109 if (title.empty())
118 title = UTF8ToUTF16(mv_item.url.spec()); 110 title = UTF8ToUTF16(mv_item.url.spec());
119 111
120 v8::Handle<v8::Object> obj = v8::Object::New(); 112 v8::Handle<v8::Object> obj = v8::Object::New();
113 obj->Set(v8::String::New("renderViewId"), v8::Int32::New(render_view_id));
121 obj->Set(v8::String::New("rid"), v8::Int32::New(restricted_id)); 114 obj->Set(v8::String::New("rid"), v8::Int32::New(restricted_id));
122 obj->Set(v8::String::New("thumbnailUrl"), 115 obj->Set(v8::String::New("thumbnailUrl"),
123 GenerateThumbnailURL(render_view_id, restricted_id)); 116 GenerateThumbnailURL(render_view_id, restricted_id));
124 obj->Set(v8::String::New("faviconUrl"),
125 GenerateFaviconURL(render_view_id, restricted_id));
126 obj->Set(v8::String::New("title"), UTF16ToV8String(title)); 117 obj->Set(v8::String::New("title"), UTF16ToV8String(title));
127 obj->Set(v8::String::New("domain"), UTF8ToV8String(mv_item.url.host())); 118 obj->Set(v8::String::New("domain"), UTF8ToV8String(mv_item.url.host()));
128 obj->Set(v8::String::New("direction"), UTF8ToV8String(direction)); 119 obj->Set(v8::String::New("direction"), UTF8ToV8String(direction));
129 obj->Set(v8::String::New("url"), UTF8ToV8String(mv_item.url.spec())); 120 obj->Set(v8::String::New("url"), UTF8ToV8String(mv_item.url.spec()));
130 return obj; 121 return obj;
131 } 122 }
132 123
133 // Returns the render view for the current JS context if it matches |origin|, 124 // Returns the render view for the current JS context if it matches |origin|,
134 // otherwise returns NULL. Used to restrict methods that access suggestions and 125 // otherwise returns NULL. Used to restrict methods that access suggestions and
135 // most visited data to pages with origin chrome-search://most-visited and 126 // most visited data to pages with origin chrome-search://most-visited and
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 void SearchBoxExtensionWrapper::UndoMostVisitedDeletion( 891 void SearchBoxExtensionWrapper::UndoMostVisitedDeletion(
901 const v8::FunctionCallbackInfo<v8::Value>& args) { 892 const v8::FunctionCallbackInfo<v8::Value>& args) {
902 content::RenderView* render_view = GetRenderView(); 893 content::RenderView* render_view = GetRenderView();
903 if (!render_view || !args.Length()) return; 894 if (!render_view || !args.Length()) return;
904 895
905 DVLOG(1) << render_view << " UndoMostVisitedDeletion"; 896 DVLOG(1) << render_view << " UndoMostVisitedDeletion";
906 SearchBox::Get(render_view)->UndoMostVisitedDeletion(args[0]->IntegerValue()); 897 SearchBox::Get(render_view)->UndoMostVisitedDeletion(args[0]->IntegerValue());
907 } 898 }
908 899
909 } // namespace extensions_v8 900 } // namespace extensions_v8
OLDNEW
« no previous file with comments | « chrome/renderer/searchbox/searchbox.cc ('k') | chrome/renderer/searchbox/searchbox_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698