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

Side by Side Diff: content/public/browser/download_manager_delegate.h

Issue 10704052: Download filename determination refactor (3/3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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_PUBLIC_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_
6 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_ 6 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 24 matching lines...) Expand all
35 35
36 // Browser's download manager: manages all downloads and destination view. 36 // Browser's download manager: manages all downloads and destination view.
37 class CONTENT_EXPORT DownloadManagerDelegate { 37 class CONTENT_EXPORT DownloadManagerDelegate {
38 public: 38 public:
39 // Lets the delegate know that the download manager is shutting down. 39 // Lets the delegate know that the download manager is shutting down.
40 virtual void Shutdown() {} 40 virtual void Shutdown() {}
41 41
42 // Returns a new DownloadId. 42 // Returns a new DownloadId.
43 virtual DownloadId GetNextId(); 43 virtual DownloadId GetNextId();
44 44
45 // Notifies the delegate that a download is starting. The delegate can return 45 // Notifies the delegate that a new download needs
Randy Smith (Not in Mondays) 2012/07/05 15:42:32 nit: dangling sentence.
asanka 2012/07/09 21:13:46 Done.
46 // false to delay the start of the download, in which case it should call
47 // DownloadManager::RestartDownload when it's ready.
48 virtual bool ShouldStartDownload(int32 download_id);
49 46
50 // Asks the user for the path for a download. The delegate calls 47 // The delegate needs to generate a filename for the new download |item|. Once
51 // DownloadManager::FileSelected or DownloadManager::FileSelectionCanceled to 48 // the target information has been determined, the delegate is required to
52 // give the answer. 49 // call DownloadItem::OnDownloadTargetDetermined(). This function should
53 virtual void ChooseDownloadPath(DownloadItem* item) {} 50 // return |true| if it has or will invoke OnDownloadTargetDetermined(). If it
Randy Smith (Not in Mondays) 2012/07/05 15:42:32 The interface on DMI is OnDownloadTargetAvailable,
Randy Smith (Not in Mondays) 2012/07/05 15:42:32 Could we do this through a callback rather than a
asanka 2012/07/09 21:13:46 Done.
asanka 2012/07/09 21:13:46 Done.
54 51 // returns |false|, the download manager will continue the download using a
55 // Allows the embedder to set an intermediate name for the download until it's 52 // default, possibly empty, target path.
Randy Smith (Not in Mondays) 2012/07/05 15:42:32 When I look at the new DMI interface (OnDownloadTa
asanka 2012/07/09 21:13:46 I added a callback parameter that the DMD is suppo
56 // complete. The return value is the intermediate path to use. If the embedder 53 virtual bool DetermineDownloadTarget(DownloadItem* item);
57 // doesn't want to set an intermediate path, it should return
58 // item.GetTargetFilePath(). If there's already a file at the returned path,
59 // it will not be overwritten. Instead the path will be uniquified by adding a
60 // suffix to the filename.
61 virtual FilePath GetIntermediatePath(const DownloadItem& item);
62 54
63 // Called when the download system wants to alert a WebContents that a 55 // Called when the download system wants to alert a WebContents that a
64 // download has started, but the TabConetnts has gone away. This lets an 56 // download has started, but the TabConetnts has gone away. This lets an
65 // delegate return an alternative WebContents. The delegate can return NULL. 57 // delegate return an alternative WebContents. The delegate can return NULL.
66 virtual WebContents* GetAlternativeWebContentsToNotifyForDownload(); 58 virtual WebContents* GetAlternativeWebContentsToNotifyForDownload();
67 59
68 // Tests if a file type should be opened automatically. 60 // Tests if a file type should be opened automatically.
69 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path); 61 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path);
70 62
71 // Allows the delegate to delay completion of the download. This function 63 // Allows the delegate to delay completion of the download. This function
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 102
111 // Notifies the delegate that it should remove the download item from its 103 // Notifies the delegate that it should remove the download item from its
112 // persistent store. 104 // persistent store.
113 virtual void RemoveItemFromPersistentStore(DownloadItem* item) {} 105 virtual void RemoveItemFromPersistentStore(DownloadItem* item) {}
114 106
115 // Notifies the delegate to remove downloads from the given time range. 107 // Notifies the delegate to remove downloads from the given time range.
116 virtual void RemoveItemsFromPersistentStoreBetween( 108 virtual void RemoveItemsFromPersistentStoreBetween(
117 base::Time remove_begin, 109 base::Time remove_begin,
118 base::Time remove_end) {} 110 base::Time remove_end) {}
119 111
112 // Invoked when history is being cleared to clear the delegate's transient
113 // state.
114 virtual void ClearTransientState() {}
115
120 // Retrieve the directories to save html pages and downloads to. 116 // Retrieve the directories to save html pages and downloads to.
121 virtual void GetSaveDir(WebContents* web_contents, 117 virtual void GetSaveDir(WebContents* web_contents,
122 FilePath* website_save_dir, 118 FilePath* website_save_dir,
123 FilePath* download_save_dir, 119 FilePath* download_save_dir,
124 bool* skip_dir_check) {} 120 bool* skip_dir_check) {}
125 121
126 // Asks the user for the path to save a page. The delegate calls the callback 122 // Asks the user for the path to save a page. The delegate calls the callback
127 // to give the answer. 123 // to give the answer.
128 virtual void ChooseSavePath(WebContents* web_contents, 124 virtual void ChooseSavePath(WebContents* web_contents,
129 const FilePath& suggested_path, 125 const FilePath& suggested_path,
130 const FilePath::StringType& default_extension, 126 const FilePath::StringType& default_extension,
131 bool can_save_as_complete, 127 bool can_save_as_complete,
132 const SavePackagePathPickedCallback& callback) { 128 const SavePackagePathPickedCallback& callback) {
133 } 129 }
134 130
135 protected: 131 protected:
136 virtual ~DownloadManagerDelegate(); 132 virtual ~DownloadManagerDelegate();
137 }; 133 };
138 134
139 } // namespace content 135 } // namespace content
140 136
141 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_ 137 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698