| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_PUBLIC_BROWSER_ANDROID_DOWNLOAD_CONTROLLER_ANDROID_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_DOWNLOAD_DOWNLOAD_CONTROLLER_BASE_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_ANDROID_DOWNLOAD_CONTROLLER_ANDROID_H_ | 6 #define CHROME_BROWSER_ANDROID_DOWNLOAD_DOWNLOAD_CONTROLLER_BASE_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "content/common/content_export.h" | |
| 10 #include "content/public/browser/download_item.h" | 9 #include "content/public/browser/download_item.h" |
| 11 #include "content/public/common/context_menu_params.h" | 10 #include "content/public/common/context_menu_params.h" |
| 12 | 11 |
| 12 namespace net { |
| 13 class URLRequest; |
| 14 } |
| 15 |
| 13 namespace content { | 16 namespace content { |
| 14 class DownloadItem; | 17 class DownloadItem; |
| 15 class WebContents; | 18 class WebContents; |
| 19 } |
| 16 | 20 |
| 17 // Interface to request GET downloads and send notifications for POST | 21 // Interface to request GET downloads and send notifications for POST |
| 18 // downloads. | 22 // downloads. |
| 19 class CONTENT_EXPORT DownloadControllerAndroid : public DownloadItem::Observer { | 23 class DownloadControllerBase : public content::DownloadItem::Observer { |
| 20 public: | 24 public: |
| 21 // Returns the singleton instance of the DownloadControllerAndroid. | 25 // Returns the singleton instance of the DownloadControllerBase. |
| 22 static DownloadControllerAndroid* Get(); | 26 static DownloadControllerBase* Get(); |
| 23 | 27 |
| 24 // Called to set the DownloadControllerAndroid instance. | 28 // Called to set the DownloadControllerBase instance. |
| 25 static void SetDownloadControllerAndroid( | 29 static void SetDownloadControllerBase( |
| 26 DownloadControllerAndroid* download_controller); | 30 DownloadControllerBase* download_controller); |
| 27 | 31 |
| 28 // Starts a new download request with Android. Should be called on the | 32 // Starts a new download request with Android. Should be called on the |
| 29 // UI thread. | 33 // UI thread. |
| 30 virtual void CreateGETDownload(int render_process_id, int render_view_id, | 34 virtual void CreateGETDownload(int render_process_id, int render_view_id, |
| 31 int request_id, bool must_download) = 0; | 35 const net::URLRequest* request, |
| 36 bool must_download) = 0; |
| 32 | 37 |
| 33 // Should be called when a download is started. It can be either a GET | 38 // Should be called when a download is started. It can be either a GET |
| 34 // request with authentication or a POST request. Notifies the embedding | 39 // request with authentication or a POST request. Notifies the embedding |
| 35 // app about the download. Should be called on the UI thread. | 40 // app about the download. Should be called on the UI thread. |
| 36 virtual void OnDownloadStarted(DownloadItem* download_item) = 0; | 41 virtual void OnDownloadStarted(content::DownloadItem* download_item) = 0; |
| 37 | 42 |
| 38 // Called when a download is initiated by context menu. | 43 // Called when a download is initiated by context menu. |
| 39 virtual void StartContextMenuDownload( | 44 virtual void StartContextMenuDownload( |
| 40 const ContextMenuParams& params, WebContents* web_contents, | 45 const content::ContextMenuParams& params, |
| 46 content::WebContents* web_contents, |
| 41 bool is_link, const std::string& extra_headers) = 0; | 47 bool is_link, const std::string& extra_headers) = 0; |
| 42 | 48 |
| 43 // Called when a dangerous download item is verified or rejected. | 49 // Called when a dangerous download item is verified or rejected. |
| 44 virtual void DangerousDownloadValidated(WebContents* web_contents, | 50 virtual void DangerousDownloadValidated(content::WebContents* web_contents, |
| 45 const std::string& download_guid, | 51 const std::string& download_guid, |
| 46 bool accept) = 0; | 52 bool accept) = 0; |
| 47 | 53 |
| 48 // Callback when user permission prompt finishes. Args: whether file access | 54 // Callback when user permission prompt finishes. Args: whether file access |
| 49 // permission is acquired. | 55 // permission is acquired. |
| 50 typedef base::Callback<void(bool)> AcquireFileAccessPermissionCallback; | 56 typedef base::Callback<void(bool)> AcquireFileAccessPermissionCallback; |
| 51 | 57 |
| 52 // Called to prompt the user for file access permission. When finished, | 58 // Called to prompt the user for file access permission. When finished, |
| 53 // |callback| will be executed. | 59 // |callback| will be executed. |
| 54 virtual void AcquireFileAccessPermission( | 60 virtual void AcquireFileAccessPermission( |
| 55 WebContents* web_contents, | 61 content::WebContents* web_contents, |
| 56 const AcquireFileAccessPermissionCallback& callback) = 0; | 62 const AcquireFileAccessPermissionCallback& callback) = 0; |
| 57 | 63 |
| 58 // Called by unit test to approve or disapprove file access request. | 64 // Called by unit test to approve or disapprove file access request. |
| 59 virtual void SetApproveFileAccessRequestForTesting(bool approve) {}; | 65 virtual void SetApproveFileAccessRequestForTesting(bool approve) {} |
| 60 | 66 |
| 61 // Called to set the default download file name if it cannot be resolved | 67 // Called to set the default download file name if it cannot be resolved |
| 62 // from url and content disposition | 68 // from url and content disposition |
| 63 virtual void SetDefaultDownloadFileName(const std::string& file_name) {} | 69 virtual void SetDefaultDownloadFileName(const std::string& file_name) {} |
| 64 | 70 |
| 65 protected: | 71 protected: |
| 66 ~DownloadControllerAndroid() override {}; | 72 ~DownloadControllerBase() override {} |
| 67 static DownloadControllerAndroid* download_controller_; | 73 static DownloadControllerBase* download_controller_; |
| 68 }; | 74 }; |
| 69 | 75 |
| 70 } // namespace content | 76 #endif // CHROME_BROWSER_ANDROID_DOWNLOAD_DOWNLOAD_CONTROLLER_BASE_H_ |
| 71 | |
| 72 #endif // CONTENT_PUBLIC_BROWSER_ANDROID_DOWNLOAD_CONTROLLER_ANDROID_H_ | |
| OLD | NEW |