| 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 #ifndef CHROME_BROWSER_ANDROID_DOWNLOAD_CHROME_DOWNLOAD_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_DOWNLOAD_CHROME_DOWNLOAD_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_ANDROID_DOWNLOAD_CHROME_DOWNLOAD_DELEGATE_H_ | 6 #define CHROME_BROWSER_ANDROID_DOWNLOAD_CHROME_DOWNLOAD_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_weak_ref.h" | 9 #include "base/android/jni_weak_ref.h" |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "content/public/browser/web_contents_user_data.h" |
| 11 | 11 |
| 12 class ChromeDownloadDelegate { | 12 class ChromeDownloadDelegate |
| 13 : public content::WebContentsUserData<ChromeDownloadDelegate> { |
| 13 public: | 14 public: |
| 14 // Returns true iff this request resulted in the tab creating the download | 15 // Returns true iff this request resulted in the tab creating the download |
| 15 // to close. | 16 // to close. |
| 16 static bool EnqueueDownloadManagerRequest(jobject chrome_download_delegate, | 17 static bool EnqueueDownloadManagerRequest(jobject chrome_download_delegate, |
| 17 bool overwrite, | 18 bool overwrite, |
| 18 jobject download_info); | 19 jobject download_info); |
| 20 |
| 21 void Init(JNIEnv*, jobject obj); |
| 22 |
| 23 void RequestHTTPGetDownload(const std::string& url, |
| 24 const std::string& user_agent, |
| 25 const std::string& content_disposition, |
| 26 const std::string& mime_type, |
| 27 const std::string& cookie, |
| 28 const std::string& referer, |
| 29 const base::string16& file_name, |
| 30 int64_t content_length, |
| 31 bool has_user_geature, |
| 32 bool must_download); |
| 33 void OnDownloadStarted(const std::string& filename, |
| 34 const std::string& mime_type); |
| 35 void OnDangerousDownload(const std::string& filename, |
| 36 const std::string& guid); |
| 37 void RequestFileAccess(intptr_t callback_id); |
| 38 |
| 39 private: |
| 40 explicit ChromeDownloadDelegate(content::WebContents* contents); |
| 41 friend class content::WebContentsUserData<ChromeDownloadDelegate>; |
| 42 ~ChromeDownloadDelegate() override; |
| 43 |
| 44 // A weak reference to the Java ChromeDownloadDelegate object. |
| 45 // The receiver is expected to outlive |this|. |
| 46 JavaObjectWeakGlobalRef weak_java_ref_; |
| 19 }; | 47 }; |
| 20 | 48 |
| 21 bool RegisterChromeDownloadDelegate(JNIEnv* env); | 49 bool RegisterChromeDownloadDelegate(JNIEnv* env); |
| 22 | 50 |
| 23 #endif // CHROME_BROWSER_ANDROID_DOWNLOAD_CHROME_DOWNLOAD_DELEGATE_H_ | 51 #endif // CHROME_BROWSER_ANDROID_DOWNLOAD_CHROME_DOWNLOAD_DELEGATE_H_ |
| OLD | NEW |