Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(583)

Side by Side Diff: chrome/browser/download/download_target_determiner_delegate.h

Issue 12850002: Move download filename determintion into a separate class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 DetermineLocalPath() completes. The argument
29 // should be the determined local path. It should be non-empty on success. If
30 // |virtual_path| is already a local path, then |virtual_path| should be
31 // returned as-is.
32 typedef base::Callback<void(const base::FilePath&)> LocalPathCallback;
33
34 // Callback to be invoked when ReserveVirtualPath() completes. If the path
35 // reservation is successful, then |successful| should be true and
36 // |reserved_path| should contain the reserved path. Otherwise, |successful|
37 // should be false. In the failure case, |reserved_path| is ignored.
38 typedef base::Callback<void(const base::FilePath& reserved_path,
39 bool successful)> ReservedPathCallback;
40
41 // Returns the DownloadProtectionService to use for checking the download
42 // URL. If this returns NULL, the URL will not be checked.
43 virtual safe_browsing::DownloadProtectionService*
44 GetDownloadProtectionService() = 0;
45
46 // If |virtual_path| is not a local path, should return a possibly temporary
47 // local path to use for storing the downloaded file. If |virtual_path| is
48 // already local, then it should return the same path. |callback| should be
49 // invoked to return the path.
50 virtual void DetermineLocalPath(content::DownloadItem* download,
51 const base::FilePath& virtual_path,
52 const LocalPathCallback& callback) = 0;
53
54 // Reserve |virtual_path|. This is expected to check the following:
55 // - Whether |virtual_path| can be written to by the user. If not, the
56 // |virtual_path| can be changed to writeable path if necessary.
57 // - If |should_uniquify_path| is true, then |virtual_path| should be modified
58 // so that the new path is writeable and unique.
59 //
60 // |callback| should be invoked on completion with the results.
61 virtual void ReserveVirtualPath(content::DownloadItem* download,
62 const base::FilePath& virtual_path,
63 bool should_uniquify_path,
64 const ReservedPathCallback& callback) = 0;
65
66 protected:
67 virtual ~DownloadTargetDeterminerDelegate();
68 };
69
70 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698