| 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 "content/public/browser/web_contents_user_data.h" | 9 #include "content/public/browser/web_contents_user_data.h" |
| 10 | 10 |
| 11 class ChromeDownloadDelegate | 11 class ChromeDownloadDelegate |
| 12 : public content::WebContentsUserData<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 | 19 |
| 20 void SetJavaRef(JNIEnv*, jobject obj); | 20 void SetJavaRef(JNIEnv*, jobject obj); |
| 21 | 21 |
| 22 void OnDownloadStarted(const std::string& filename); | 22 void OnDownloadStarted(const std::string& filename); |
| 23 void RequestFileAccess(intptr_t callback_id); | 23 void RequestFileAccess(intptr_t callback_id); |
| 24 | 24 |
| 25 // TODO(qinmin): consolidate this with the static function above. | 25 // TODO(qinmin): consolidate this with the static function above. |
| 26 void EnqueueDownloadManagerRequest(const std::string& url, | 26 void EnqueueDownloadManagerRequest(const std::string& url, |
| 27 const std::string& user_agent, | 27 const std::string& user_agent, |
| 28 const std::string& content_disposition, | 28 const base::string16& file_name, |
| 29 const std::string& mime_type, | 29 const std::string& mime_type, |
| 30 const std::string& cookie, | 30 const std::string& cookie, |
| 31 const std::string& referer); | 31 const std::string& referer); |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 explicit ChromeDownloadDelegate(content::WebContents* contents); | 34 explicit ChromeDownloadDelegate(content::WebContents* contents); |
| 35 friend class content::WebContentsUserData<ChromeDownloadDelegate>; | 35 friend class content::WebContentsUserData<ChromeDownloadDelegate>; |
| 36 ~ChromeDownloadDelegate() override; | 36 ~ChromeDownloadDelegate() override; |
| 37 | 37 |
| 38 // A reference to the Java ChromeDownloadDelegate object. | 38 // A reference to the Java ChromeDownloadDelegate object. |
| 39 jobject java_ref_; | 39 jobject java_ref_; |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 bool RegisterChromeDownloadDelegate(JNIEnv* env); | 42 bool RegisterChromeDownloadDelegate(JNIEnv* env); |
| 43 | 43 |
| 44 #endif // CHROME_BROWSER_ANDROID_DOWNLOAD_CHROME_DOWNLOAD_DELEGATE_H_ | 44 #endif // CHROME_BROWSER_ANDROID_DOWNLOAD_CHROME_DOWNLOAD_DELEGATE_H_ |
| OLD | NEW |