Chromium Code Reviews| 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 RequestHTTPGetDownload(const std::string& url, | |
| 22 const std::string& user_agent, | |
| 23 const std::string& content_disposition, | |
| 24 const std::string& mime_type, | |
| 25 const std::string& cookie, | |
| 26 const std::string& referer, | |
| 27 const base::string16& file_name, | |
| 28 int64_t content_length, | |
| 29 bool has_user_geature, | |
| 30 bool must_download); | |
| 31 void OnDownloadStarted(const std::string& filename, | |
| 32 const std::string& mime_type); | |
| 33 void OnDangerousDownload(const std::string& filename, | |
| 34 const std::string& guid); | |
| 35 void RequestFileAccess(intptr_t callback_id); | |
| 36 | |
| 37 void SetDelegate(JNIEnv*, jobject obj); | |
| 38 | |
| 39 ~ChromeDownloadDelegate() override; | |
|
no sievers
2016/06/07 21:35:22
nit: I think the destructor can be private too sin
Jinsuk Kim
2016/06/08 06:29:08
Done.
| |
| 40 | |
| 41 private: | |
| 42 explicit ChromeDownloadDelegate(content::WebContents* contents); | |
| 43 friend class content::WebContentsUserData<ChromeDownloadDelegate>; | |
| 44 | |
| 45 JavaObjectWeakGlobalRef weak_java_ref_; | |
|
no sievers
2016/06/07 21:35:23
I think that pattern makes sense for a delegate (w
Jinsuk Kim
2016/06/08 06:29:08
Done.
| |
| 19 }; | 46 }; |
| 20 | 47 |
| 21 bool RegisterChromeDownloadDelegate(JNIEnv* env); | 48 bool RegisterChromeDownloadDelegate(JNIEnv* env); |
| 22 | 49 |
| 23 #endif // CHROME_BROWSER_ANDROID_DOWNLOAD_CHROME_DOWNLOAD_DELEGATE_H_ | 50 #endif // CHROME_BROWSER_ANDROID_DOWNLOAD_CHROME_DOWNLOAD_DELEGATE_H_ |
| OLD | NEW |