Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_DELEGATE_H_ | |
| 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_DELEGATE_H_ | |
| 7 | |
| 8 #include "base/callback_forward.h" | |
| 9 | |
| 10 class ExtensionDownloadsEventRouter; | |
| 11 | |
| 12 namespace base { | |
| 13 class FilePath; | |
| 14 } | |
| 15 | |
| 16 namespace content { | |
| 17 class DownloadItem; | |
| 18 } | |
| 19 | |
| 20 namespace safe_browsing { | |
| 21 class DownloadProtectionService; | |
| 22 } | |
| 23 | |
| 24 // Delegate for DownloadTargetDeterminer. The delegate isn't owned by | |
| 25 // DownloadTargetDeterminer and is expected to outlive it. | |
| 26 class DownloadTargetDeterminerDelegate { | |
| 27 public: | |
| 28 // Callback to be invoked when PromptUserForDownloadPath() completes. If the | |
| 29 // user selection is successful, the arguments should be as follows: | |
| 30 // | |
| 31 // |virtual_path|: The opaque path representing the virtual target chosen by | |
| 32 // the user. If the target is local file system, then this should be the | |
| 33 // same as |local_path|. | |
| 34 // |local_path|: The path on the local file system to use for storing the | |
| 35 // downloaded file. | |
| 36 // | |
| 37 // If the path selection is successful, both paths should be non-empty and | |
| 38 // valid. Otherwise, if the user cancels the selection, both paths should be | |
| 39 // empty. | |
| 40 typedef base::Callback<void( | |
| 41 const base::FilePath& virtual_path, | |
| 42 const base::FilePath& local_path)> FileSelectedCallback; | |
| 43 | |
| 44 // Callback to be invoked when DetermineLocalPath() completes. The argument | |
| 45 // should be the determined local path. It should be non-empty on success. If | |
| 46 // |virtual_path| is already a local path, then |virtual_path| should be | |
| 47 // returned as-is. | |
| 48 typedef base::Callback<void(const base::FilePath&)> LocalPathCallback; | |
| 49 | |
| 50 // Callback to be invoked when ReserveVirtualPath() completes. If the path | |
| 51 // reservation is successful, then |successful| should be true and | |
| 52 // |reserved_path| should contain the reserved path. Otherwise, |successful| | |
| 53 // should be false. In the failure case, |reserved_path| is ignored. | |
| 54 typedef base::Callback<void(const base::FilePath& reserved_path, | |
| 55 bool successful)> ReservedPathCallback; | |
| 56 | |
| 57 // Returns the DownloadProtectionService to use for checking the download | |
| 58 // URL. If this returns NULL, the URL will not be checked. | |
| 59 virtual safe_browsing::DownloadProtectionService* | |
| 60 GetDownloadProtectionService() = 0; | |
| 61 | |
| 62 // Returns ExtensionDownloadsEventRouter to be used for notifying extensions | |
| 63 // of the target name determination. | |
| 64 virtual ExtensionDownloadsEventRouter* GetExtensionEventRouter() = 0; | |
|
Randy Smith (Not in Mondays)
2013/04/09 19:32:17
Does this need to be a delegate routine? It doesn
asanka
2013/04/16 20:34:01
Moved it out of the delegate.
| |
| 65 | |
| 66 // Display a prompt to the user requesting that a download target be chosen. | |
| 67 // Should invoke |callback| upon completion. | |
| 68 virtual void PromptUserForDownloadPath( | |
|
Randy Smith (Not in Mondays)
2013/04/09 19:32:17
Same comment as above--this doesn't seem like it n
asanka
2013/04/16 20:34:01
DownloadTestFileActivityObserver relies on being a
| |
| 69 content::DownloadItem* download, | |
| 70 const base::FilePath& virtual_path, | |
| 71 const FileSelectedCallback& callback) = 0; | |
| 72 | |
| 73 // If |virtual_path| is not a local path, should return a possibly temporary | |
| 74 // local path to use for storing the downloaded file. If |virtual_path| is | |
| 75 // already local, then it should return the same path. |callback| should be | |
| 76 // invoked to return the path. | |
| 77 virtual void DetermineLocalPath(content::DownloadItem* download, | |
| 78 const base::FilePath& virtual_path, | |
| 79 const LocalPathCallback& callback) = 0; | |
| 80 | |
| 81 // Reserve |virtual_path|. This is expected to check the following: | |
| 82 // - Whether |virtual_path| can be written to by the user. If not, the | |
| 83 // |virtual_path| can be changed to writeable path if necessary. | |
| 84 // - If |should_uniquify_path| is true, then |virtual_path| should be modified | |
| 85 // so that the new path is writeable and unique. | |
| 86 // | |
| 87 // |callback| should be invoked on completion with the results. | |
| 88 virtual void ReserveVirtualPath(content::DownloadItem* download, | |
| 89 const base::FilePath& virtual_path, | |
| 90 bool should_uniquify_path, | |
| 91 const ReservedPathCallback& callback) = 0; | |
| 92 | |
| 93 protected: | |
| 94 virtual ~DownloadTargetDeterminerDelegate(); | |
| 95 }; | |
| 96 | |
| 97 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_DELEGATE_H_ | |
| OLD | NEW |