| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // This class pairs with DownloadController on Java side to forward requests | 5 // This class pairs with DownloadController on Java side to forward requests |
| 6 // for GET downloads to the current DownloadListener. POST downloads are | 6 // for GET downloads to the current DownloadListener. POST downloads are |
| 7 // handled on the native side. | 7 // handled on the native side. |
| 8 // | 8 // |
| 9 // Both classes are Singleton classes. C++ object owns Java object. | 9 // Both classes are Singleton classes. C++ object owns Java object. |
| 10 // | 10 // |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 static bool RegisterDownloadController(JNIEnv* env); | 38 static bool RegisterDownloadController(JNIEnv* env); |
| 39 | 39 |
| 40 // Called when DownloadController Java object is instantiated. | 40 // Called when DownloadController Java object is instantiated. |
| 41 void Init(JNIEnv* env, jobject obj); | 41 void Init(JNIEnv* env, jobject obj); |
| 42 | 42 |
| 43 // DownloadControllerBase implementation. | 43 // DownloadControllerBase implementation. |
| 44 void AcquireFileAccessPermission( | 44 void AcquireFileAccessPermission( |
| 45 content::WebContents* web_contents, | 45 content::WebContents* web_contents, |
| 46 const AcquireFileAccessPermissionCallback& callback) override; | 46 const AcquireFileAccessPermissionCallback& callback) override; |
| 47 void CreateAndroidDownload( |
| 48 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, |
| 49 const DownloadInfo& info) override; |
| 47 | 50 |
| 48 // UMA histogram enum for download cancellation reasons. Keep this | 51 // UMA histogram enum for download cancellation reasons. Keep this |
| 49 // in sync with MobileDownloadCancelReason in histograms.xml. This should be | 52 // in sync with MobileDownloadCancelReason in histograms.xml. This should be |
| 50 // append only. | 53 // append only. |
| 51 enum DownloadCancelReason { | 54 enum DownloadCancelReason { |
| 52 CANCEL_REASON_NOT_CANCELED = 0, | 55 CANCEL_REASON_NOT_CANCELED = 0, |
| 53 CANCEL_REASON_ACTION_BUTTON, | 56 CANCEL_REASON_ACTION_BUTTON, |
| 54 CANCEL_REASON_NOTIFICATION_DISMISSED, | 57 CANCEL_REASON_NOTIFICATION_DISMISSED, |
| 55 CANCEL_REASON_OVERWRITE_INFOBAR_DISMISSED, | 58 CANCEL_REASON_OVERWRITE_INFOBAR_DISMISSED, |
| 56 CANCEL_REASON_NO_STORAGE_PERMISSION, | 59 CANCEL_REASON_NO_STORAGE_PERMISSION, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 80 | 83 |
| 81 // DownloadItem::Observer interface. | 84 // DownloadItem::Observer interface. |
| 82 void OnDownloadUpdated(content::DownloadItem* item) override; | 85 void OnDownloadUpdated(content::DownloadItem* item) override; |
| 83 | 86 |
| 84 // The download item contains dangerous file types. | 87 // The download item contains dangerous file types. |
| 85 void OnDangerousDownload(content::DownloadItem *item); | 88 void OnDangerousDownload(content::DownloadItem *item); |
| 86 | 89 |
| 87 base::android::ScopedJavaLocalRef<jobject> GetContentViewCoreFromWebContents( | 90 base::android::ScopedJavaLocalRef<jobject> GetContentViewCoreFromWebContents( |
| 88 content::WebContents* web_contents); | 91 content::WebContents* web_contents); |
| 89 | 92 |
| 93 // Helper methods to start android download on UI thread. |
| 94 void StartAndroidDownload( |
| 95 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, |
| 96 const DownloadInfo& info); |
| 97 void StartAndroidDownloadInternal( |
| 98 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, |
| 99 const DownloadInfo& info, bool allowed); |
| 100 |
| 90 // Creates Java object if it is not created already and returns it. | 101 // Creates Java object if it is not created already and returns it. |
| 91 JavaObject* GetJavaObject(); | 102 JavaObject* GetJavaObject(); |
| 92 | 103 |
| 93 JavaObject* java_object_; | 104 JavaObject* java_object_; |
| 94 | 105 |
| 95 std::string default_file_name_; | 106 std::string default_file_name_; |
| 96 | 107 |
| 97 DISALLOW_COPY_AND_ASSIGN(DownloadController); | 108 DISALLOW_COPY_AND_ASSIGN(DownloadController); |
| 98 }; | 109 }; |
| 99 | 110 |
| 100 #endif // CHROME_BROWSER_ANDROID_DOWNLOAD_DOWNLOAD_CONTROLLER_H_ | 111 #endif // CHROME_BROWSER_ANDROID_DOWNLOAD_DOWNLOAD_CONTROLLER_H_ |
| OLD | NEW |