| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 76 | 76 | 
| 77 ChromeDownloadDelegate::~ChromeDownloadDelegate() { | 77 ChromeDownloadDelegate::~ChromeDownloadDelegate() { | 
| 78    JNIEnv* env = base::android::AttachCurrentThread(); | 78    JNIEnv* env = base::android::AttachCurrentThread(); | 
| 79    env->DeleteGlobalRef(java_ref_); | 79    env->DeleteGlobalRef(java_ref_); | 
| 80 } | 80 } | 
| 81 | 81 | 
| 82 void ChromeDownloadDelegate::SetJavaRef(JNIEnv* env, jobject jobj) { | 82 void ChromeDownloadDelegate::SetJavaRef(JNIEnv* env, jobject jobj) { | 
| 83   java_ref_ = env->NewGlobalRef(jobj); | 83   java_ref_ = env->NewGlobalRef(jobj); | 
| 84 } | 84 } | 
| 85 | 85 | 
| 86 void ChromeDownloadDelegate::OnDownloadStarted(const std::string& filename) { |  | 
| 87   JNIEnv* env = base::android::AttachCurrentThread(); |  | 
| 88   ScopedJavaLocalRef<jstring> jfilename = ConvertUTF8ToJavaString( |  | 
| 89       env, filename); |  | 
| 90   Java_ChromeDownloadDelegate_onDownloadStarted(env, java_ref_, jfilename); |  | 
| 91 } |  | 
| 92 |  | 
| 93 void ChromeDownloadDelegate::EnqueueDownloadManagerRequest( | 86 void ChromeDownloadDelegate::EnqueueDownloadManagerRequest( | 
| 94     const std::string& url, | 87     const std::string& url, | 
| 95     const std::string& user_agent, | 88     const std::string& user_agent, | 
| 96     const base::string16& file_name, | 89     const base::string16& file_name, | 
| 97     const std::string& mime_type, | 90     const std::string& mime_type, | 
| 98     const std::string& cookie, | 91     const std::string& cookie, | 
| 99     const std::string& referer) { | 92     const std::string& referer) { | 
| 100   JNIEnv* env = base::android::AttachCurrentThread(); | 93   JNIEnv* env = base::android::AttachCurrentThread(); | 
| 101   ScopedJavaLocalRef<jstring> jurl = | 94   ScopedJavaLocalRef<jstring> jurl = | 
| 102       ConvertUTF8ToJavaString(env, url); | 95       ConvertUTF8ToJavaString(env, url); | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 121   auto* web_contents = WebContents::FromJavaWebContents(jweb_contents); | 114   auto* web_contents = WebContents::FromJavaWebContents(jweb_contents); | 
| 122   ChromeDownloadDelegate::CreateForWebContents(web_contents); | 115   ChromeDownloadDelegate::CreateForWebContents(web_contents); | 
| 123   ChromeDownloadDelegate::FromWebContents(web_contents)->SetJavaRef(env, obj); | 116   ChromeDownloadDelegate::FromWebContents(web_contents)->SetJavaRef(env, obj); | 
| 124 } | 117 } | 
| 125 | 118 | 
| 126 bool RegisterChromeDownloadDelegate(JNIEnv* env) { | 119 bool RegisterChromeDownloadDelegate(JNIEnv* env) { | 
| 127   return RegisterNativesImpl(env); | 120   return RegisterNativesImpl(env); | 
| 128 } | 121 } | 
| 129 | 122 | 
| 130 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ChromeDownloadDelegate); | 123 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ChromeDownloadDelegate); | 
| OLD | NEW | 
|---|