| 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 CONTENT_PUBLIC_BROWSER_ANDROID_DOWNLOAD_CONTROLLER_ANDROID_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_ANDROID_DOWNLOAD_CONTROLLER_ANDROID_H_ | 6 #define CONTENT_PUBLIC_BROWSER_ANDROID_DOWNLOAD_CONTROLLER_ANDROID_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" |
| 8 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
| 9 #include "content/public/common/context_menu_params.h" | 10 #include "content/public/common/context_menu_params.h" |
| 10 | 11 |
| 11 namespace content { | 12 namespace content { |
| 12 class DownloadItem; | 13 class DownloadItem; |
| 13 class WebContents; | 14 class WebContents; |
| 14 | 15 |
| 15 // Interface to request GET downloads and send notifications for POST | 16 // Interface to request GET downloads and send notifications for POST |
| 16 // downloads. | 17 // downloads. |
| 17 class CONTENT_EXPORT DownloadControllerAndroid { | 18 class CONTENT_EXPORT DownloadControllerAndroid { |
| 18 public: | 19 public: |
| 19 // Returns the singleton instance of the DownloadControllerAndroid. | 20 // Returns the singleton instance of the DownloadControllerAndroid. |
| 20 static DownloadControllerAndroid* Get(); | 21 static DownloadControllerAndroid* Get(); |
| 21 | 22 |
| 23 // Called by unit test to mock the DownloadControllerAndroid. |
| 24 static void UseMockControllerForTesting(bool use_mock_controller); |
| 25 |
| 22 // Starts a new download request with Android. Should be called on the | 26 // Starts a new download request with Android. Should be called on the |
| 23 // UI thread. | 27 // UI thread. |
| 24 virtual void CreateGETDownload(int render_process_id, int render_view_id, | 28 virtual void CreateGETDownload(int render_process_id, int render_view_id, |
| 25 int request_id) = 0; | 29 int request_id) = 0; |
| 26 | 30 |
| 27 // Should be called when a download is started. It can be either a GET | 31 // Should be called when a download is started. It can be either a GET |
| 28 // request with authentication or a POST request. Notifies the embedding | 32 // request with authentication or a POST request. Notifies the embedding |
| 29 // app about the download. Should be called on the UI thread. | 33 // app about the download. Should be called on the UI thread. |
| 30 virtual void OnDownloadStarted(DownloadItem* download_item) = 0; | 34 virtual void OnDownloadStarted(DownloadItem* download_item) = 0; |
| 31 | 35 |
| 32 // Called when a download is initiated by context menu. | 36 // Called when a download is initiated by context menu. |
| 33 virtual void StartContextMenuDownload( | 37 virtual void StartContextMenuDownload( |
| 34 const ContextMenuParams& params, WebContents* web_contents, | 38 const ContextMenuParams& params, WebContents* web_contents, |
| 35 bool is_link, const std::string& extra_headers) = 0; | 39 bool is_link, const std::string& extra_headers) = 0; |
| 36 | 40 |
| 37 // Called when a dangerous download item is verified or rejected. | 41 // Called when a dangerous download item is verified or rejected. |
| 38 virtual void DangerousDownloadValidated( | 42 virtual void DangerousDownloadValidated( |
| 39 WebContents* web_contents, int download_id, bool accept) = 0; | 43 WebContents* web_contents, int download_id, bool accept) = 0; |
| 40 | 44 |
| 45 // Callback when user permission prompt finishes. Args: whether file access |
| 46 // permission is acquired. |
| 47 typedef base::Callback<void(bool)> AcquireFileAccessPermissionCallback; |
| 48 |
| 49 // Called to prompt the user for file access permission. When finished, |
| 50 // |callback| will be executed. |
| 51 virtual void AcquireFileAccessPermission( |
| 52 WebContents* web_contents, |
| 53 const AcquireFileAccessPermissionCallback& callback) = 0; |
| 54 |
| 55 // Called by unit test to approve or disapprove file access request. |
| 56 virtual void SetApproveFileAccessRequestForTesting(bool approve) {}; |
| 57 |
| 58 static bool use_mock_controller() { return use_mock_controller_; } |
| 41 protected: | 59 protected: |
| 42 virtual ~DownloadControllerAndroid() {}; | 60 virtual ~DownloadControllerAndroid() {}; |
| 61 |
| 62 private: |
| 63 static bool use_mock_controller_; |
| 43 }; | 64 }; |
| 44 | 65 |
| 45 } // namespace content | 66 } // namespace content |
| 46 | 67 |
| 47 #endif // CONTENT_PUBLIC_BROWSER_ANDROID_DOWNLOAD_CONTROLLER_ANDROID_H_ | 68 #endif // CONTENT_PUBLIC_BROWSER_ANDROID_DOWNLOAD_CONTROLLER_ANDROID_H_ |
| OLD | NEW |