OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_DELEGATE_H_ |
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_DELEGATE_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_DELEGATE_H_ |
7 | 7 |
8 #include <string> | |
9 | |
8 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
9 | 11 #include "chrome/browser/download/download_confirmation_reason.h" |
12 #include "chrome/browser/download/download_confirmation_result.h" | |
10 #include "chrome/browser/download/download_path_reservation_tracker.h" | 13 #include "chrome/browser/download/download_path_reservation_tracker.h" |
11 #include "content/public/browser/download_danger_type.h" | 14 #include "content/public/browser/download_danger_type.h" |
12 | 15 |
13 class ExtensionDownloadsEventRouter; | 16 class ExtensionDownloadsEventRouter; |
14 | 17 |
15 namespace base { | 18 namespace base { |
16 class FilePath; | 19 class FilePath; |
17 } | 20 } |
18 | 21 |
19 namespace content { | 22 namespace content { |
20 class DownloadItem; | 23 class DownloadItem; |
21 } | 24 } |
22 | 25 |
23 // Delegate for DownloadTargetDeterminer. The delegate isn't owned by | 26 // Delegate for DownloadTargetDeterminer. The delegate isn't owned by |
24 // DownloadTargetDeterminer and is expected to outlive it. | 27 // DownloadTargetDeterminer and is expected to outlive it. |
25 class DownloadTargetDeterminerDelegate { | 28 class DownloadTargetDeterminerDelegate { |
26 public: | 29 public: |
27 // Callback to be invoked after NotifyExtensions() completes. The | 30 // Callback to be invoked after NotifyExtensions() completes. The |
28 // |new_virtual_path| should be set to a new path if an extension wishes to | 31 // |new_virtual_path| should be set to a new path if an extension wishes to |
29 // override the download path. |conflict_action| should be set to the action | 32 // override the download path. |conflict_action| should be set to the action |
30 // to take if a file exists at |new_virtual_path|. If |new_virtual_path| is | 33 // to take if a file exists at |new_virtual_path|. If |new_virtual_path| is |
31 // empty, then the download target will be unchanged and |conflict_action| is | 34 // empty, then the download target will be unchanged and |conflict_action| is |
32 // ignored. | 35 // ignored. |
33 typedef base::Callback<void( | 36 typedef base::Callback<void( |
34 const base::FilePath& new_virtual_path, | 37 const base::FilePath& new_virtual_path, |
35 DownloadPathReservationTracker::FilenameConflictAction conflict_action)> | 38 DownloadPathReservationTracker::FilenameConflictAction conflict_action)> |
36 NotifyExtensionsCallback; | 39 NotifyExtensionsCallback; |
37 | 40 |
38 // Callback to be invoked when ReserveVirtualPath() completes. If the path | 41 // Callback to be invoked when ReserveVirtualPath() completes. |
39 // reservation is successful, then |successful| should be true and | |
40 // |reserved_path| should contain the reserved path. Otherwise, |successful| | |
41 // should be false. In the failure case, |reserved_path| is ignored. | |
42 typedef base::Callback<void(const base::FilePath& reserved_path, | 42 typedef base::Callback<void(const base::FilePath& reserved_path, |
svaldez
2016/10/28 17:29:36
Might want to align ReservedPath... and FileSelect
asanka
2016/11/07 19:50:15
Done.
| |
43 bool successful)> ReservedPathCallback; | 43 DownloadTargetResult)> |
44 ReservedPathCallback; | |
44 | 45 |
45 // Callback to be invoked when PromptUserForDownloadPath() completes. | 46 // Callback to be invoked when RequestConfirmation() completes. |
46 // |virtual_path|: The path chosen by the user. If the user cancels the file | 47 // |virtual_path|: The path chosen by the user. If the user cancels the file |
47 // selection, then this parameter will be the empty path. On Chrome OS, | 48 // selection, then this parameter will be the empty path. On Chrome OS, |
48 // this path may contain virtual mount points if the user chose a virtual | 49 // this path may contain virtual mount points if the user chose a virtual |
49 // path (e.g. Google Drive). | 50 // path (e.g. Google Drive). |
50 typedef base::Callback<void(const base::FilePath& virtual_path)> | 51 typedef base::Callback<void(DownloadConfirmationResult, |
51 FileSelectedCallback; | 52 const base::FilePath& virtual_path)> |
53 FileSelectedCallback; | |
52 | 54 |
53 // Callback to be invoked when DetermineLocalPath() completes. The argument | 55 // Callback to be invoked when DetermineLocalPath() completes. The argument |
54 // should be the determined local path. It should be non-empty on success. If | 56 // should be the determined local path. It should be non-empty on success. If |
55 // |virtual_path| is already a local path, then |virtual_path| should be | 57 // |virtual_path| is already a local path, then |virtual_path| should be |
56 // returned as-is. | 58 // returned as-is. |
57 typedef base::Callback<void(const base::FilePath&)> LocalPathCallback; | 59 typedef base::Callback<void(const base::FilePath&)> LocalPathCallback; |
58 | 60 |
59 // Callback to be invoked after CheckDownloadUrl() completes. The parameter to | 61 // Callback to be invoked after CheckDownloadUrl() completes. The parameter to |
60 // the callback should indicate the danger type of the download based on the | 62 // the callback should indicate the danger type of the download based on the |
61 // results of the URL check. | 63 // results of the URL check. |
(...skipping 27 matching lines...) Expand all Loading... | |
89 // |callback| should be invoked on completion with the results. | 91 // |callback| should be invoked on completion with the results. |
90 virtual void ReserveVirtualPath( | 92 virtual void ReserveVirtualPath( |
91 content::DownloadItem* download, | 93 content::DownloadItem* download, |
92 const base::FilePath& virtual_path, | 94 const base::FilePath& virtual_path, |
93 bool create_directory, | 95 bool create_directory, |
94 DownloadPathReservationTracker::FilenameConflictAction conflict_action, | 96 DownloadPathReservationTracker::FilenameConflictAction conflict_action, |
95 const ReservedPathCallback& callback) = 0; | 97 const ReservedPathCallback& callback) = 0; |
96 | 98 |
97 // Display a prompt to the user requesting that a download target be chosen. | 99 // Display a prompt to the user requesting that a download target be chosen. |
98 // Should invoke |callback| upon completion. | 100 // Should invoke |callback| upon completion. |
99 virtual void PromptUserForDownloadPath( | 101 virtual void RequestConfirmation(content::DownloadItem* download, |
100 content::DownloadItem* download, | 102 const base::FilePath& virtual_path, |
101 const base::FilePath& virtual_path, | 103 DownloadConfirmationReason reason, |
102 const FileSelectedCallback& callback) = 0; | 104 const FileSelectedCallback& callback) = 0; |
103 | 105 |
104 // If |virtual_path| is not a local path, should return a possibly temporary | 106 // If |virtual_path| is not a local path, should return a possibly temporary |
105 // local path to use for storing the downloaded file. If |virtual_path| is | 107 // local path to use for storing the downloaded file. If |virtual_path| is |
106 // already local, then it should return the same path. |callback| should be | 108 // already local, then it should return the same path. |callback| should be |
107 // invoked to return the path. | 109 // invoked to return the path. |
108 virtual void DetermineLocalPath(content::DownloadItem* download, | 110 virtual void DetermineLocalPath(content::DownloadItem* download, |
109 const base::FilePath& virtual_path, | 111 const base::FilePath& virtual_path, |
110 const LocalPathCallback& callback) = 0; | 112 const LocalPathCallback& callback) = 0; |
111 | 113 |
112 // Check whether the download URL is malicious and invoke |callback| with a | 114 // Check whether the download URL is malicious and invoke |callback| with a |
113 // suggested danger type for the download. | 115 // suggested danger type for the download. |
114 virtual void CheckDownloadUrl(content::DownloadItem* download, | 116 virtual void CheckDownloadUrl(content::DownloadItem* download, |
115 const base::FilePath& virtual_path, | 117 const base::FilePath& virtual_path, |
116 const CheckDownloadUrlCallback& callback) = 0; | 118 const CheckDownloadUrlCallback& callback) = 0; |
117 | 119 |
118 // Get the MIME type for the given file. | 120 // Get the MIME type for the given file. |
119 virtual void GetFileMimeType(const base::FilePath& path, | 121 virtual void GetFileMimeType(const base::FilePath& path, |
120 const GetFileMimeTypeCallback& callback) = 0; | 122 const GetFileMimeTypeCallback& callback) = 0; |
123 | |
121 protected: | 124 protected: |
122 virtual ~DownloadTargetDeterminerDelegate(); | 125 virtual ~DownloadTargetDeterminerDelegate(); |
123 }; | 126 }; |
124 | 127 |
125 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_DELEGATE_H_ | 128 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_DELEGATE_H_ |
OLD | NEW |