| 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 "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 10 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 ConvertUTF8ToJavaString(env, params.src_url.spec()).obj(), | 96 ConvertUTF8ToJavaString(env, params.src_url.spec()).obj(), |
| 97 ConvertUTF16ToJavaString(env, params.title_text).obj(), | 97 ConvertUTF16ToJavaString(env, params.title_text).obj(), |
| 98 image_was_fetched_lo_fi, | 98 image_was_fetched_lo_fi, |
| 99 ConvertUTF8ToJavaString(env, sanitizedReferrer.spec()).obj(), | 99 ConvertUTF8ToJavaString(env, sanitizedReferrer.spec()).obj(), |
| 100 params.referrer_policy); | 100 params.referrer_policy); |
| 101 | 101 |
| 102 return jmenu_info; | 102 return jmenu_info; |
| 103 } | 103 } |
| 104 | 104 |
| 105 void ContextMenuHelper::OnStartDownload(JNIEnv* env, | 105 void ContextMenuHelper::OnStartDownload(JNIEnv* env, |
| 106 jobject obj, | 106 const JavaParamRef<jobject>& obj, |
| 107 jboolean jis_link, | 107 jboolean jis_link, |
| 108 jstring jheaders) { | 108 const JavaParamRef<jstring>& jheaders) { |
| 109 std::string headers(ConvertJavaStringToUTF8(env, jheaders)); | 109 std::string headers(ConvertJavaStringToUTF8(env, jheaders)); |
| 110 content::DownloadControllerAndroid::Get()->StartContextMenuDownload( | 110 content::DownloadControllerAndroid::Get()->StartContextMenuDownload( |
| 111 context_menu_params_, | 111 context_menu_params_, |
| 112 web_contents_, | 112 web_contents_, |
| 113 jis_link, | 113 jis_link, |
| 114 headers); | 114 headers); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void ContextMenuHelper::SearchForImage(JNIEnv* env, jobject obj) { | 117 void ContextMenuHelper::SearchForImage(JNIEnv* env, |
| 118 const JavaParamRef<jobject>& obj) { |
| 118 CoreTabHelper::FromWebContents(web_contents_)->SearchByImageInNewTab( | 119 CoreTabHelper::FromWebContents(web_contents_)->SearchByImageInNewTab( |
| 119 context_menu_params_.src_url); | 120 context_menu_params_.src_url); |
| 120 } | 121 } |
| 121 | 122 |
| 122 void ContextMenuHelper::ShareImage(JNIEnv* env, jobject obj) { | 123 void ContextMenuHelper::ShareImage(JNIEnv* env, |
| 124 const JavaParamRef<jobject>& obj) { |
| 123 CoreTabHelper::FromWebContents(web_contents_)-> | 125 CoreTabHelper::FromWebContents(web_contents_)-> |
| 124 RequestThumbnailForContextNode( | 126 RequestThumbnailForContextNode( |
| 125 0, | 127 0, |
| 126 gfx::Size(kShareImageMaxWidth, kShareImageMaxHeight), | 128 gfx::Size(kShareImageMaxWidth, kShareImageMaxHeight), |
| 127 base::Bind(&ContextMenuHelper::OnShareImage, | 129 base::Bind(&ContextMenuHelper::OnShareImage, |
| 128 base::Unretained(this))); | 130 base::Unretained(this))); |
| 129 } | 131 } |
| 130 | 132 |
| 131 void ContextMenuHelper::OnShareImage(const std::string& thumbnail_data, | 133 void ContextMenuHelper::OnShareImage(const std::string& thumbnail_data, |
| 132 const gfx::Size& original_size) { | 134 const gfx::Size& original_size) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 152 env, | 154 env, |
| 153 java_obj_.obj(), | 155 java_obj_.obj(), |
| 154 jwindow_android.obj(), | 156 jwindow_android.obj(), |
| 155 j_bytes.obj()); | 157 j_bytes.obj()); |
| 156 } | 158 } |
| 157 | 159 |
| 158 bool RegisterContextMenuHelper(JNIEnv* env) { | 160 bool RegisterContextMenuHelper(JNIEnv* env) { |
| 159 return RegisterNativesImpl(env) && | 161 return RegisterNativesImpl(env) && |
| 160 ContextMenuParamsAndroid::RegisterNativesImpl(env); | 162 ContextMenuParamsAndroid::RegisterNativesImpl(env); |
| 161 } | 163 } |
| OLD | NEW |