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

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

Issue 11574006: Implement chrome.downloads.onDeterminingFilename() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: @r177662 Created 7 years, 11 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 CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ 5 #ifndef CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_
6 #define CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ 6 #define CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/hash_tables.h" 9 #include "base/hash_tables.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/common/cancelable_request.h" 12 #include "chrome/browser/common/cancelable_request.h"
13 #include "chrome/browser/download/download_path_reservation_tracker.h" 13 #include "chrome/browser/download/download_path_reservation_tracker.h"
14 #include "chrome/browser/safe_browsing/download_protection_service.h" 14 #include "chrome/browser/safe_browsing/download_protection_service.h"
15 #include "content/public/browser/download_danger_type.h" 15 #include "content/public/browser/download_danger_type.h"
16 #include "content/public/browser/download_item.h" 16 #include "content/public/browser/download_item.h"
17 #include "content/public/browser/download_manager_delegate.h" 17 #include "content/public/browser/download_manager_delegate.h"
18 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
20 20
21 class DownloadPrefs; 21 class DownloadPrefs;
22 class ExtensionDownloadsEventRouter;
23 class Profile; 22 class Profile;
24 23
25 namespace content { 24 namespace content {
26 class DownloadManager; 25 class DownloadManager;
27 } 26 }
28 27
29 namespace extensions { 28 namespace extensions {
30 class CrxInstaller; 29 class CrxInstaller;
31 } 30 }
32 31
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 const FilePath& suggested_path, 128 const FilePath& suggested_path,
130 const FileSelectedCallback& callback); 129 const FileSelectedCallback& callback);
131 130
132 // So that test classes that inherit from this for override purposes 131 // So that test classes that inherit from this for override purposes
133 // can call back into the DownloadManager. 132 // can call back into the DownloadManager.
134 scoped_refptr<content::DownloadManager> download_manager_; 133 scoped_refptr<content::DownloadManager> download_manager_;
135 134
136 private: 135 private:
137 friend class base::RefCountedThreadSafe<ChromeDownloadManagerDelegate>; 136 friend class base::RefCountedThreadSafe<ChromeDownloadManagerDelegate>;
138 137
138 struct ContinueFilenameDeterminationInfo;
139
139 // content::NotificationObserver implementation. 140 // content::NotificationObserver implementation.
140 virtual void Observe(int type, 141 virtual void Observe(int type,
141 const content::NotificationSource& source, 142 const content::NotificationSource& source,
142 const content::NotificationDetails& details) OVERRIDE; 143 const content::NotificationDetails& details) OVERRIDE;
143 144
144 // Callback function after url is checked with safebrowsing service. 145 // Callback function after url is checked with safebrowsing service.
145 void CheckDownloadUrlDone( 146 void CheckDownloadUrlDone(
146 int32 download_id, 147 int32 download_id,
147 const content::DownloadTargetCallback& callback, 148 const content::DownloadTargetCallback& callback,
148 safe_browsing::DownloadProtectionService::DownloadCheckResult result); 149 safe_browsing::DownloadProtectionService::DownloadCheckResult result);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 // download identified by |download_id| with the |target_path|, target 188 // download identified by |download_id| with the |target_path|, target
188 // disposition and |danger_type|. 189 // disposition and |danger_type|.
189 void OnPathReservationAvailable( 190 void OnPathReservationAvailable(
190 int32 download_id, 191 int32 download_id,
191 const content::DownloadTargetCallback& callback, 192 const content::DownloadTargetCallback& callback,
192 bool should_prompt, 193 bool should_prompt,
193 content::DownloadDangerType danger_type, 194 content::DownloadDangerType danger_type,
194 const FilePath& reserved_path, 195 const FilePath& reserved_path,
195 bool reserved_path_verified); 196 bool reserved_path_verified);
196 197
198 // When an extension opts to change a download's target filename, this
199 // sanitizes it before continuing with the filename determination process.
200 void OnExtensionsChangingFilename(
201 const ContinueFilenameDeterminationInfo& continue_info,
202 const FilePath& changed_filename,
203 bool overwrite);
204
205 // When extensions either opt not to change a download's target filename, or
206 // the changed filename has been sanitized, this method continues with the
207 // filename determination process, optionally prompting the user to manually
208 // set the filename.
209 void OnExtensionsDeterminedFilename(
210 const ContinueFilenameDeterminationInfo& continue_info,
211 const FilePath& suggested_path,
212 bool is_forced_path);
213
197 // Called on the UI thread once the final target path is available. 214 // Called on the UI thread once the final target path is available.
198 void OnTargetPathDetermined( 215 void OnTargetPathDetermined(
199 int32 download_id, 216 int32 download_id,
200 const content::DownloadTargetCallback& callback, 217 const content::DownloadTargetCallback& callback,
201 content::DownloadItem::TargetDisposition disposition, 218 content::DownloadItem::TargetDisposition disposition,
202 content::DownloadDangerType danger_type, 219 content::DownloadDangerType danger_type,
203 const FilePath& target_path); 220 const FilePath& target_path);
204 221
205 // Check policy of whether we should open this download with a web intents 222 // Check policy of whether we should open this download with a web intents
206 // dispatch. 223 // dispatch.
(...skipping 16 matching lines...) Expand all
223 240
224 // Maps from pending extension installations to DownloadItem IDs. 241 // Maps from pending extension installations to DownloadItem IDs.
225 typedef base::hash_map<extensions::CrxInstaller*, 242 typedef base::hash_map<extensions::CrxInstaller*,
226 content::DownloadOpenDelayedCallback> CrxInstallerMap; 243 content::DownloadOpenDelayedCallback> CrxInstallerMap;
227 CrxInstallerMap crx_installers_; 244 CrxInstallerMap crx_installers_;
228 245
229 CancelableRequestConsumer history_consumer_; 246 CancelableRequestConsumer history_consumer_;
230 247
231 content::NotificationRegistrar registrar_; 248 content::NotificationRegistrar registrar_;
232 249
233 // On Android, GET downloads are not handled by the DownloadManager.
234 // Once we have extensions on android, we probably need the EventRouter
235 // in ContentViewDownloadDelegate which knows about both GET and POST
236 // downloads.
237 #if !defined(OS_ANDROID)
238 // The ExtensionDownloadsEventRouter dispatches download creation, change, and
239 // erase events to extensions. Like ChromeDownloadManagerDelegate, it's a
240 // chrome-level concept and its lifetime should match DownloadManager. There
241 // should be a separate EDER for on-record and off-record managers.
242 // There does not appear to be a separate ExtensionSystem for on-record and
243 // off-record profiles, so ExtensionSystem cannot own the EDER.
244 scoped_ptr<ExtensionDownloadsEventRouter> extension_event_router_;
245 #endif
246
247 // The directory most recently chosen by the user in response to a Save As 250 // The directory most recently chosen by the user in response to a Save As
248 // dialog for a regular download. 251 // dialog for a regular download.
249 FilePath last_download_path_; 252 FilePath last_download_path_;
250 253
251 DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerDelegate); 254 DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerDelegate);
252 }; 255 };
253 256
254 #endif // CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ 257 #endif // CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698