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 to set the DownloadControllerAndroid instance. |
| 24 static void SetDownloadControllerAndroid( |
| 25 DownloadControllerAndroid* download_controller); |
| 26 |
22 // Starts a new download request with Android. Should be called on the | 27 // Starts a new download request with Android. Should be called on the |
23 // UI thread. | 28 // UI thread. |
24 virtual void CreateGETDownload(int render_process_id, int render_view_id, | 29 virtual void CreateGETDownload(int render_process_id, int render_view_id, |
25 int request_id) = 0; | 30 int request_id) = 0; |
26 | 31 |
27 // Should be called when a download is started. It can be either a GET | 32 // 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 | 33 // request with authentication or a POST request. Notifies the embedding |
29 // app about the download. Should be called on the UI thread. | 34 // app about the download. Should be called on the UI thread. |
30 virtual void OnDownloadStarted(DownloadItem* download_item) = 0; | 35 virtual void OnDownloadStarted(DownloadItem* download_item) = 0; |
31 | 36 |
32 // Called when a download is initiated by context menu. | 37 // Called when a download is initiated by context menu. |
33 virtual void StartContextMenuDownload( | 38 virtual void StartContextMenuDownload( |
34 const ContextMenuParams& params, WebContents* web_contents, | 39 const ContextMenuParams& params, WebContents* web_contents, |
35 bool is_link, const std::string& extra_headers) = 0; | 40 bool is_link, const std::string& extra_headers) = 0; |
36 | 41 |
37 // Called when a dangerous download item is verified or rejected. | 42 // Called when a dangerous download item is verified or rejected. |
38 virtual void DangerousDownloadValidated( | 43 virtual void DangerousDownloadValidated( |
39 WebContents* web_contents, int download_id, bool accept) = 0; | 44 WebContents* web_contents, int download_id, bool accept) = 0; |
40 | 45 |
| 46 // Callback when user permission prompt finishes. Args: whether file access |
| 47 // permission is acquired. |
| 48 typedef base::Callback<void(bool)> AcquireFileAccessPermissionCallback; |
| 49 |
| 50 // Called to prompt the user for file access permission. When finished, |
| 51 // |callback| will be executed. |
| 52 virtual void AcquireFileAccessPermission( |
| 53 WebContents* web_contents, |
| 54 const AcquireFileAccessPermissionCallback& callback) = 0; |
| 55 |
| 56 // Called by unit test to approve or disapprove file access request. |
| 57 virtual void SetApproveFileAccessRequestForTesting(bool approve) {}; |
| 58 |
41 protected: | 59 protected: |
42 virtual ~DownloadControllerAndroid() {}; | 60 virtual ~DownloadControllerAndroid() {}; |
| 61 static DownloadControllerAndroid* download_controller_; |
43 }; | 62 }; |
44 | 63 |
45 } // namespace content | 64 } // namespace content |
46 | 65 |
47 #endif // CONTENT_PUBLIC_BROWSER_ANDROID_DOWNLOAD_CONTROLLER_ANDROID_H_ | 66 #endif // CONTENT_PUBLIC_BROWSER_ANDROID_DOWNLOAD_CONTROLLER_ANDROID_H_ |
OLD | NEW |