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