| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/ui/android/context_menu_helper.h" | 5 #include "chrome/browser/ui/android/context_menu_helper.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 using base::android::ConvertJavaStringToUTF8; | 32 using base::android::ConvertJavaStringToUTF8; |
| 33 using base::android::ConvertUTF8ToJavaString; | 33 using base::android::ConvertUTF8ToJavaString; |
| 34 using base::android::ConvertUTF16ToJavaString; | 34 using base::android::ConvertUTF16ToJavaString; |
| 35 using base::android::JavaParamRef; | 35 using base::android::JavaParamRef; |
| 36 | 36 |
| 37 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ContextMenuHelper); | 37 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ContextMenuHelper); |
| 38 | 38 |
| 39 const char kDataReductionProxyPassthroughHeader[] = | 39 const char kDataReductionProxyPassthroughHeader[] = |
| 40 "Chrome-Proxy-Accept-Transform: identity\r\n"; | 40 "Chrome-Proxy-Accept-Transform: identity\r\n"; |
| 41 | 41 |
| 42 const bool kUsePNGCodec = true; |
| 43 |
| 42 namespace { | 44 namespace { |
| 43 | 45 |
| 44 class ContextMenuHelperImageRequest : public ImageDecoder::ImageRequest { | 46 class ContextMenuHelperImageRequest : public ImageDecoder::ImageRequest { |
| 45 public: | 47 public: |
| 46 static void Start(const base::android::JavaRef<jobject>& jcallback, | 48 static void Start(const base::android::JavaRef<jobject>& jcallback, |
| 47 const std::vector<uint8_t>& thumbnail_data) { | 49 const std::vector<uint8_t>& thumbnail_data) { |
| 48 ContextMenuHelperImageRequest* request = | 50 ContextMenuHelperImageRequest* request = |
| 49 new ContextMenuHelperImageRequest(jcallback); | 51 new ContextMenuHelperImageRequest(jcallback); |
| 50 ImageDecoder::Start(request, thumbnail_data); | 52 ImageDecoder::Start(request, thumbnail_data); |
| 51 } | 53 } |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); | 233 content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); |
| 232 if (!render_frame_host) | 234 if (!render_frame_host) |
| 233 return; | 235 return; |
| 234 | 236 |
| 235 chrome::mojom::ThumbnailCapturerPtr thumbnail_capturer; | 237 chrome::mojom::ThumbnailCapturerPtr thumbnail_capturer; |
| 236 render_frame_host->GetRemoteInterfaces()->GetInterface(&thumbnail_capturer); | 238 render_frame_host->GetRemoteInterfaces()->GetInterface(&thumbnail_capturer); |
| 237 // Bind the InterfacePtr into the callback so that it's kept alive | 239 // Bind the InterfacePtr into the callback so that it's kept alive |
| 238 // until there's either a connection error or a response. | 240 // until there's either a connection error or a response. |
| 239 auto* thumbnail_capturer_proxy = thumbnail_capturer.get(); | 241 auto* thumbnail_capturer_proxy = thumbnail_capturer.get(); |
| 240 thumbnail_capturer_proxy->RequestThumbnailForContextNode( | 242 thumbnail_capturer_proxy->RequestThumbnailForContextNode( |
| 241 0, gfx::Size(max_dimen_px, max_dimen_px), | 243 0, gfx::Size(max_dimen_px, max_dimen_px), kUsePNGCodec, |
| 242 base::Bind(retrieve_callback, base::Passed(&thumbnail_capturer), | 244 base::Bind(retrieve_callback, base::Passed(&thumbnail_capturer), |
| 243 base::android::ScopedJavaGlobalRef<jobject>(env, jcallback))); | 245 base::android::ScopedJavaGlobalRef<jobject>(env, jcallback))); |
| 244 } | 246 } |
| 245 | 247 |
| 246 bool RegisterContextMenuHelper(JNIEnv* env) { | 248 bool RegisterContextMenuHelper(JNIEnv* env) { |
| 247 return RegisterNativesImpl(env); | 249 return RegisterNativesImpl(env); |
| 248 } | 250 } |
| OLD | NEW |