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

Side by Side Diff: content/browser/download/download_item_impl_delegate.h

Issue 10912173: Replace the DownloadFileManager with direct ownership of DownloadFileImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync'd to LKGR (r162700) Created 8 years, 2 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "content/common/content_export.h" 10 #include "content/common/content_export.h"
11 #include "content/public/browser/download_danger_type.h"
12 #include "content/public/browser/download_item.h"
11 13
12 class DownloadFileManager; 14 class DownloadFileManager;
13 class DownloadItemImpl; 15 class DownloadItemImpl;
14 16
15 namespace content { 17 namespace content {
16 class BrowserContext; 18 class BrowserContext;
17 } 19 }
18 20
19 // Delegate for operations that a DownloadItemImpl can't do for itself. 21 // Delegate for operations that a DownloadItemImpl can't do for itself.
20 // The base implementation of this class does nothing (returning false 22 // The base implementation of this class does nothing (returning false
21 // on predicates) so interfaces not of interest to a derived class may 23 // on predicates) so interfaces not of interest to a derived class may
22 // be left unimplemented. 24 // be left unimplemented.
23 class CONTENT_EXPORT DownloadItemImplDelegate { 25 class CONTENT_EXPORT DownloadItemImplDelegate {
24 public: 26 public:
27 typedef base::Callback<void(
28 const FilePath&, // Target path
29 content::DownloadItem::TargetDisposition, // overwrite/uniquify target
30 content::DownloadDangerType,
31 const FilePath& // Intermediate file path
32 )> DownloadTargetCallback;
33
25 DownloadItemImplDelegate(); 34 DownloadItemImplDelegate();
26 virtual ~DownloadItemImplDelegate(); 35 virtual ~DownloadItemImplDelegate();
27 36
28 // Used for catching use-after-free errors. 37 // Used for catching use-after-free errors.
29 void Attach(); 38 void Attach();
30 void Detach(); 39 void Detach();
31 40
41 // Request determination of the download target from the delegate.
42 virtual void DetermineDownloadTarget(
43 DownloadItemImpl* download, const DownloadTargetCallback& callback);
44
32 // Allows the delegate to delay completion of the download. This function 45 // Allows the delegate to delay completion of the download. This function
33 // will call the callback passed when the download is ready for completion. 46 // will call the callback passed when the download is ready for completion.
34 // This may be done immediately, from within the routine itself, or it 47 // This may be done immediately, from within the routine itself, or it
35 // may be delayed. 48 // may be delayed.
36 // This routine should only be called once per download. 49 // This routine should only be called once per download.
37 virtual void ReadyForDownloadCompletion( 50 virtual void ReadyForDownloadCompletion(
38 DownloadItemImpl* download, 51 DownloadItemImpl* download,
39 const base::Closure& complete_callback); 52 const base::Closure& complete_callback);
40 53
41 // Tests if a file type should be opened automatically.
42 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path);
43
44 // Allows the delegate to override the opening of a download. If it returns 54 // Allows the delegate to override the opening of a download. If it returns
45 // true then it's reponsible for opening the item. 55 // true then it's reponsible for opening the item.
46 virtual bool ShouldOpenDownload(DownloadItemImpl* download); 56 virtual bool ShouldOpenDownload(DownloadItemImpl* download);
47 57
58 // Tests if a file type should be opened automatically.
59 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path);
60
48 // Checks whether a downloaded file still exists and updates the 61 // Checks whether a downloaded file still exists and updates the
49 // file's state if the file is already removed. 62 // file's state if the file is already removed.
50 // The check may or may not result in a later asynchronous call 63 // The check may or may not result in a later asynchronous call
51 // to OnDownloadedFileRemoved(). 64 // to OnDownloadedFileRemoved().
52 virtual void CheckForFileRemoval(DownloadItemImpl* download_item); 65 virtual void CheckForFileRemoval(DownloadItemImpl* download_item);
53 66
54 // For contextual issues like language and prefs. 67 // For contextual issues like language and prefs.
55 virtual content::BrowserContext* GetBrowserContext() const; 68 virtual content::BrowserContext* GetBrowserContext() const;
56 69
57 // Get the DownloadFileManager to use for this download. 70 // Get the DownloadFileManager to use for this download.
(...skipping 16 matching lines...) Expand all
74 virtual void AssertStateConsistent(DownloadItemImpl* download) const; 87 virtual void AssertStateConsistent(DownloadItemImpl* download) const;
75 88
76 private: 89 private:
77 // For "Outlives attached DownloadItemImpl" invariant assertion. 90 // For "Outlives attached DownloadItemImpl" invariant assertion.
78 int count_; 91 int count_;
79 92
80 DISALLOW_COPY_AND_ASSIGN(DownloadItemImplDelegate); 93 DISALLOW_COPY_AND_ASSIGN(DownloadItemImplDelegate);
81 }; 94 };
82 95
83 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_ 96 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_
OLDNEW
« no previous file with comments | « content/browser/download/download_item_impl.cc ('k') | content/browser/download/download_item_impl_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698