| 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 18 matching lines...) Expand all Loading... |
| 29 #include "ui/gfx/geometry/point.h" | 29 #include "ui/gfx/geometry/point.h" |
| 30 #include "ui/gfx/geometry/size.h" | 30 #include "ui/gfx/geometry/size.h" |
| 31 | 31 |
| 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[] = | |
| 40 "Chrome-Proxy-Accept-Transform: identity\r\n"; | |
| 41 | |
| 42 namespace { | 39 namespace { |
| 43 | 40 |
| 44 class ContextMenuHelperImageRequest : public ImageDecoder::ImageRequest { | 41 class ContextMenuHelperImageRequest : public ImageDecoder::ImageRequest { |
| 45 public: | 42 public: |
| 46 static void Start(const base::android::JavaRef<jobject>& jcallback, | 43 static void Start(const base::android::JavaRef<jobject>& jcallback, |
| 47 const std::vector<uint8_t>& thumbnail_data) { | 44 const std::vector<uint8_t>& thumbnail_data) { |
| 48 ContextMenuHelperImageRequest* request = | 45 ContextMenuHelperImageRequest* request = |
| 49 new ContextMenuHelperImageRequest(jcallback); | 46 new ContextMenuHelperImageRequest(jcallback); |
| 50 ImageDecoder::Start(request, thumbnail_data); | 47 ImageDecoder::Start(request, thumbnail_data); |
| 51 } | 48 } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 return web_contents_->GetJavaWebContents(); | 174 return web_contents_->GetJavaWebContents(); |
| 178 } | 175 } |
| 179 | 176 |
| 180 void ContextMenuHelper::OnStartDownload( | 177 void ContextMenuHelper::OnStartDownload( |
| 181 JNIEnv* env, | 178 JNIEnv* env, |
| 182 const JavaParamRef<jobject>& obj, | 179 const JavaParamRef<jobject>& obj, |
| 183 jboolean jis_link, | 180 jboolean jis_link, |
| 184 jboolean jis_data_reduction_proxy_enabled) { | 181 jboolean jis_data_reduction_proxy_enabled) { |
| 185 std::string headers; | 182 std::string headers; |
| 186 if (jis_data_reduction_proxy_enabled) | 183 if (jis_data_reduction_proxy_enabled) |
| 187 headers = kDataReductionProxyPassthroughHeader; | 184 headers = data_reduction_proxy::chrome_proxy_pass_through_header(); |
| 188 | 185 |
| 189 DownloadControllerBase::Get()->StartContextMenuDownload( | 186 DownloadControllerBase::Get()->StartContextMenuDownload( |
| 190 context_menu_params_, | 187 context_menu_params_, |
| 191 web_contents_, | 188 web_contents_, |
| 192 jis_link, | 189 jis_link, |
| 193 headers); | 190 headers); |
| 194 } | 191 } |
| 195 | 192 |
| 196 void ContextMenuHelper::SearchForImage(JNIEnv* env, | 193 void ContextMenuHelper::SearchForImage(JNIEnv* env, |
| 197 const JavaParamRef<jobject>& obj) { | 194 const JavaParamRef<jobject>& obj) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 auto* thumbnail_capturer_proxy = thumbnail_capturer.get(); | 236 auto* thumbnail_capturer_proxy = thumbnail_capturer.get(); |
| 240 thumbnail_capturer_proxy->RequestThumbnailForContextNode( | 237 thumbnail_capturer_proxy->RequestThumbnailForContextNode( |
| 241 0, gfx::Size(max_dimen_px, max_dimen_px), | 238 0, gfx::Size(max_dimen_px, max_dimen_px), |
| 242 base::Bind(retrieve_callback, base::Passed(&thumbnail_capturer), | 239 base::Bind(retrieve_callback, base::Passed(&thumbnail_capturer), |
| 243 base::android::ScopedJavaGlobalRef<jobject>(env, jcallback))); | 240 base::android::ScopedJavaGlobalRef<jobject>(env, jcallback))); |
| 244 } | 241 } |
| 245 | 242 |
| 246 bool RegisterContextMenuHelper(JNIEnv* env) { | 243 bool RegisterContextMenuHelper(JNIEnv* env) { |
| 247 return RegisterNativesImpl(env); | 244 return RegisterNativesImpl(env); |
| 248 } | 245 } |
| OLD | NEW |