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

Unified Diff: chrome/browser/ui/tab_contents/core_tab_helper.cc

Issue 792903002: Image Search: Move thumbnail JPEG encoding to the renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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/browser/ui/tab_contents/core_tab_helper.cc
diff --git a/chrome/browser/ui/tab_contents/core_tab_helper.cc b/chrome/browser/ui/tab_contents/core_tab_helper.cc
index 41cbc7e91397ef8f3ff1dc477511b3dfabb009fc..5e728d63c276c0a1fe2b1feedd854c213ae55a77 100644
--- a/chrome/browser/ui/tab_contents/core_tab_helper.cc
+++ b/chrome/browser/ui/tab_contents/core_tab_helper.cc
@@ -202,10 +202,11 @@ bool CoreTabHelper::OnMessageReceived(
// Handles the image thumbnail for the context node, composes a image search
// request based on the received thumbnail and opens the request in a new tab.
void CoreTabHelper::OnRequestThumbnailForContextNodeACK(
- const SkBitmap& bitmap,
+ const std::string& thumbnail_data,
const gfx::Size& original_size) {
- if (bitmap.isNull())
+ if (thumbnail_data.empty())
return;
+
Profile* profile =
Profile::FromBrowserContext(web_contents()->GetBrowserContext());
@@ -218,18 +219,9 @@ void CoreTabHelper::OnRequestThumbnailForContextNodeACK(
if (!default_provider)
return;
- const int kDefaultQualityForImageSearch = 90;
- std::vector<unsigned char> data;
- if (!gfx::JPEGCodec::Encode(
- reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)),
- gfx::JPEGCodec::FORMAT_SkBitmap, bitmap.width(), bitmap.height(),
- static_cast<int>(bitmap.rowBytes()), kDefaultQualityForImageSearch,
- &data))
- return;
-
TemplateURLRef::SearchTermsArgs search_args =
TemplateURLRef::SearchTermsArgs(base::string16());
- search_args.image_thumbnail_content = std::string(data.begin(), data.end());
+ search_args.image_thumbnail_content = thumbnail_data;
// TODO(jnd): Add a method in WebContentsViewDelegate to get the image URL
// from the ContextMenuParams which creates current context menu.
search_args.image_url = GURL();

Powered by Google App Engine
This is Rietveld 408576698