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