| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/android/download/chrome_download_delegate.h" | 5 #include "chrome/browser/android/download/chrome_download_delegate.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <type_traits> | 10 #include <type_traits> |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 env, filename); | 121 env, filename); |
| 122 Java_ChromeDownloadDelegate_onDownloadStarted(env, java_ref_, jfilename); | 122 Java_ChromeDownloadDelegate_onDownloadStarted(env, java_ref_, jfilename); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void ChromeDownloadDelegate::RequestFileAccess(intptr_t callback_id) { | 125 void ChromeDownloadDelegate::RequestFileAccess(intptr_t callback_id) { |
| 126 JNIEnv* env = base::android::AttachCurrentThread(); | 126 JNIEnv* env = base::android::AttachCurrentThread(); |
| 127 Java_ChromeDownloadDelegate_requestFileAccess( | 127 Java_ChromeDownloadDelegate_requestFileAccess( |
| 128 env, java_ref_, callback_id); | 128 env, java_ref_, callback_id); |
| 129 } | 129 } |
| 130 | 130 |
| 131 void ChromeDownloadDelegate::EnqueueDownloadManagerRequest( |
| 132 const std::string& url, |
| 133 const std::string& user_agent, |
| 134 const std::string& content_disposition, |
| 135 const std::string& mime_type, |
| 136 const std::string& cookie, |
| 137 const std::string& referer) { |
| 138 JNIEnv* env = base::android::AttachCurrentThread(); |
| 139 ScopedJavaLocalRef<jstring> jurl = |
| 140 ConvertUTF8ToJavaString(env, url); |
| 141 ScopedJavaLocalRef<jstring> juser_agent = |
| 142 ConvertUTF8ToJavaString(env, user_agent); |
| 143 ScopedJavaLocalRef<jstring> jcontent_disposition = |
| 144 ConvertUTF8ToJavaString(env, content_disposition); |
| 145 ScopedJavaLocalRef<jstring> jmime_type = |
| 146 ConvertUTF8ToJavaString(env, mime_type); |
| 147 ScopedJavaLocalRef<jstring> jcookie = |
| 148 ConvertUTF8ToJavaString(env, cookie); |
| 149 ScopedJavaLocalRef<jstring> jreferer = |
| 150 ConvertUTF8ToJavaString(env, referer); |
| 151 Java_ChromeDownloadDelegate_enqueueAndroidDownloadManagerRequest( |
| 152 env, java_ref_, jurl, juser_agent, jcontent_disposition, jmime_type, |
| 153 jcookie, jreferer); |
| 154 } |
| 155 |
| 131 void Init(JNIEnv* env, | 156 void Init(JNIEnv* env, |
| 132 const JavaParamRef<jobject>& obj, | 157 const JavaParamRef<jobject>& obj, |
| 133 const JavaParamRef<jobject>& jweb_contents) { | 158 const JavaParamRef<jobject>& jweb_contents) { |
| 134 auto* web_contents = WebContents::FromJavaWebContents(jweb_contents); | 159 auto* web_contents = WebContents::FromJavaWebContents(jweb_contents); |
| 135 ChromeDownloadDelegate::CreateForWebContents(web_contents); | 160 ChromeDownloadDelegate::CreateForWebContents(web_contents); |
| 136 ChromeDownloadDelegate::FromWebContents(web_contents)->SetJavaRef(env, obj); | 161 ChromeDownloadDelegate::FromWebContents(web_contents)->SetJavaRef(env, obj); |
| 137 } | 162 } |
| 138 | 163 |
| 139 bool RegisterChromeDownloadDelegate(JNIEnv* env) { | 164 bool RegisterChromeDownloadDelegate(JNIEnv* env) { |
| 140 return RegisterNativesImpl(env); | 165 return RegisterNativesImpl(env); |
| 141 } | 166 } |
| 142 | 167 |
| 143 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ChromeDownloadDelegate); | 168 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ChromeDownloadDelegate); |
| OLD | NEW |