Chromium Code Reviews| 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_ANDROID_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_ANDROID_DOWNLOAD_CONTROLLER_ANDROID_H_ | 6 #define CHROME_BROWSER_ANDROID_DOWNLOAD_DOWNLOAD_CONTROLLER_ANDROID_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 |
| 13 namespace content { | 12 namespace content { |
| 14 class DownloadItem; | 13 class DownloadItem; |
| 15 class WebContents; | 14 class WebContents; |
| 15 } | |
| 16 | 16 |
| 17 // Interface to request GET downloads and send notifications for POST | 17 // Interface to request GET downloads and send notifications for POST |
| 18 // downloads. | 18 // downloads. |
| 19 class CONTENT_EXPORT DownloadControllerAndroid : public DownloadItem::Observer { | 19 class DownloadControllerAndroid : public content::DownloadItem::Observer { |
|
no sievers
2016/06/07 21:35:23
nit: you don't need the base class interface anymo
no sievers
2016/06/07 21:37:26
Oops I missed the mock implementation. Maybe Downl
Jinsuk Kim
2016/06/08 06:29:08
Acknowledged.
Jinsuk Kim
2016/06/08 06:29:08
Done.
| |
| 20 public: | 20 public: |
| 21 // Returns the singleton instance of the DownloadControllerAndroid. | 21 // Returns the singleton instance of the DownloadControllerAndroid. |
| 22 static DownloadControllerAndroid* Get(); | 22 static DownloadControllerAndroid* Get(); |
| 23 | 23 |
| 24 // Called to set the DownloadControllerAndroid instance. | 24 // Called to set the DownloadControllerAndroid instance. |
| 25 static void SetDownloadControllerAndroid( | 25 static void SetDownloadControllerAndroid( |
| 26 DownloadControllerAndroid* download_controller); | 26 DownloadControllerAndroid* download_controller); |
| 27 | 27 |
| 28 // Starts a new download request with Android. Should be called on the | 28 // Starts a new download request with Android. Should be called on the |
| 29 // UI thread. | 29 // UI thread. |
| 30 virtual void CreateGETDownload(int render_process_id, int render_view_id, | 30 virtual void CreateGETDownload(int render_process_id, int render_view_id, |
| 31 int request_id, bool must_download) = 0; | 31 int request_id, bool must_download) = 0; |
| 32 | 32 |
| 33 // Should be called when a download is started. It can be either a GET | 33 // 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 | 34 // request with authentication or a POST request. Notifies the embedding |
| 35 // app about the download. Should be called on the UI thread. | 35 // app about the download. Should be called on the UI thread. |
| 36 virtual void OnDownloadStarted(DownloadItem* download_item) = 0; | 36 virtual void OnDownloadStarted(content::DownloadItem* download_item) = 0; |
| 37 | 37 |
| 38 // Called when a download is initiated by context menu. | 38 // Called when a download is initiated by context menu. |
| 39 virtual void StartContextMenuDownload( | 39 virtual void StartContextMenuDownload( |
| 40 const ContextMenuParams& params, WebContents* web_contents, | 40 const content::ContextMenuParams& params, |
| 41 content::WebContents* web_contents, | |
| 41 bool is_link, const std::string& extra_headers) = 0; | 42 bool is_link, const std::string& extra_headers) = 0; |
| 42 | 43 |
| 43 // Called when a dangerous download item is verified or rejected. | 44 // Called when a dangerous download item is verified or rejected. |
| 44 virtual void DangerousDownloadValidated(WebContents* web_contents, | 45 virtual void DangerousDownloadValidated(content::WebContents* web_contents, |
| 45 const std::string& download_guid, | 46 const std::string& download_guid, |
| 46 bool accept) = 0; | 47 bool accept) = 0; |
| 47 | 48 |
| 48 // Callback when user permission prompt finishes. Args: whether file access | 49 // Callback when user permission prompt finishes. Args: whether file access |
| 49 // permission is acquired. | 50 // permission is acquired. |
| 50 typedef base::Callback<void(bool)> AcquireFileAccessPermissionCallback; | 51 typedef base::Callback<void(bool)> AcquireFileAccessPermissionCallback; |
| 51 | 52 |
| 52 // Called to prompt the user for file access permission. When finished, | 53 // Called to prompt the user for file access permission. When finished, |
| 53 // |callback| will be executed. | 54 // |callback| will be executed. |
| 54 virtual void AcquireFileAccessPermission( | 55 virtual void AcquireFileAccessPermission( |
| 55 WebContents* web_contents, | 56 content::WebContents* web_contents, |
| 56 const AcquireFileAccessPermissionCallback& callback) = 0; | 57 const AcquireFileAccessPermissionCallback& callback) = 0; |
| 57 | 58 |
| 58 // Called by unit test to approve or disapprove file access request. | 59 // Called by unit test to approve or disapprove file access request. |
| 59 virtual void SetApproveFileAccessRequestForTesting(bool approve) {}; | 60 virtual void SetApproveFileAccessRequestForTesting(bool approve) {} |
| 60 | 61 |
| 61 // Called to set the default download file name if it cannot be resolved | 62 // Called to set the default download file name if it cannot be resolved |
| 62 // from url and content disposition | 63 // from url and content disposition |
| 63 virtual void SetDefaultDownloadFileName(const std::string& file_name) {} | 64 virtual void SetDefaultDownloadFileName(const std::string& file_name) {} |
| 64 | 65 |
| 65 protected: | 66 protected: |
| 66 ~DownloadControllerAndroid() override {}; | 67 ~DownloadControllerAndroid() override {}; |
| 67 static DownloadControllerAndroid* download_controller_; | 68 static DownloadControllerAndroid* download_controller_; |
| 68 }; | 69 }; |
| 69 | 70 |
| 70 } // namespace content | 71 #endif // CHROME_BROWSER_ANDROID_DOWNLOAD_DOWNLOAD_CONTROLLER_ANDROID_H_ |
| 71 | |
| 72 #endif // CONTENT_PUBLIC_BROWSER_ANDROID_DOWNLOAD_CONTROLLER_ANDROID_H_ | |
| OLD | NEW |