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