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_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade
rs.h" | 9 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade
rs.h" |
10 #include "content/public/browser/android/content_view_core.h" | 10 #include "content/public/browser/android/content_view_core.h" |
11 #include "content/public/browser/android/download_controller_android.h" | 11 #include "content/public/browser/android/download_controller_android.h" |
12 #include "content/public/common/context_menu_params.h" | 12 #include "content/public/common/context_menu_params.h" |
13 #include "jni/ContextMenuHelper_jni.h" | 13 #include "jni/ContextMenuHelper_jni.h" |
14 #include "jni/ContextMenuParams_jni.h" | 14 #include "jni/ContextMenuParams_jni.h" |
15 #include "ui/gfx/geometry/point.h" | 15 #include "ui/gfx/geometry/point.h" |
16 | 16 |
| 17 using base::android::ConvertJavaStringToUTF8; |
17 using base::android::ConvertUTF8ToJavaString; | 18 using base::android::ConvertUTF8ToJavaString; |
18 using base::android::ConvertUTF16ToJavaString; | 19 using base::android::ConvertUTF16ToJavaString; |
19 using base::android::ScopedJavaLocalRef; | 20 using base::android::ScopedJavaLocalRef; |
20 | 21 |
21 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ContextMenuHelper); | 22 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ContextMenuHelper); |
22 | 23 |
23 ContextMenuHelper::ContextMenuHelper(content::WebContents* web_contents) | 24 ContextMenuHelper::ContextMenuHelper(content::WebContents* web_contents) |
24 : web_contents_(web_contents) { | 25 : web_contents_(web_contents) { |
25 JNIEnv* env = base::android::AttachCurrentThread(); | 26 JNIEnv* env = base::android::AttachCurrentThread(); |
26 java_obj_.Reset( | 27 java_obj_.Reset( |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 image_was_fetched_lo_fi, | 90 image_was_fetched_lo_fi, |
90 params.is_editable, | 91 params.is_editable, |
91 ConvertUTF8ToJavaString(env, sanitizedReferrer.spec()).obj(), | 92 ConvertUTF8ToJavaString(env, sanitizedReferrer.spec()).obj(), |
92 params.referrer_policy); | 93 params.referrer_policy); |
93 | 94 |
94 return jmenu_info; | 95 return jmenu_info; |
95 } | 96 } |
96 | 97 |
97 void ContextMenuHelper::OnStartDownload(JNIEnv* env, | 98 void ContextMenuHelper::OnStartDownload(JNIEnv* env, |
98 jobject obj, | 99 jobject obj, |
99 jboolean jis_link) { | 100 jboolean jis_link, |
| 101 jstring jheaders) { |
| 102 std::string headers(ConvertJavaStringToUTF8(env, jheaders)); |
100 content::DownloadControllerAndroid::Get()->StartContextMenuDownload( | 103 content::DownloadControllerAndroid::Get()->StartContextMenuDownload( |
101 context_menu_params_, | 104 context_menu_params_, |
102 web_contents_, | 105 web_contents_, |
103 jis_link); | 106 jis_link, |
| 107 headers); |
104 } | 108 } |
105 | 109 |
106 bool RegisterContextMenuHelper(JNIEnv* env) { | 110 bool RegisterContextMenuHelper(JNIEnv* env) { |
107 return RegisterNativesImpl(env) && | 111 return RegisterNativesImpl(env) && |
108 ContextMenuParamsAndroid::RegisterNativesImpl(env); | 112 ContextMenuParamsAndroid::RegisterNativesImpl(env); |
109 } | 113 } |
OLD | NEW |