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

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

Issue 10915180: Make DownloadHistory observe manager, items (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: @r165669 Created 8 years, 1 month 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 "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/download/download_history.h"
14 #include "chrome/browser/download/download_path_reservation_tracker.h"
13 #include "chrome/browser/safe_browsing/download_protection_service.h" 15 #include "chrome/browser/safe_browsing/download_protection_service.h"
14 #include "chrome/browser/download/download_path_reservation_tracker.h"
15 #include "content/public/browser/download_danger_type.h" 16 #include "content/public/browser/download_danger_type.h"
16 #include "content/public/browser/download_item.h" 17 #include "content/public/browser/download_item.h"
17 #include "content/public/browser/download_manager_delegate.h" 18 #include "content/public/browser/download_manager_delegate.h"
18 #include "content/public/browser/notification_observer.h" 19 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h" 20 #include "content/public/browser/notification_registrar.h"
20 21
21 class DownloadHistory; 22 class DownloadHistory;
22 class DownloadPrefs; 23 class DownloadPrefs;
23 class ExtensionDownloadsEventRouter; 24 class ExtensionDownloadsEventRouter;
24 class Profile; 25 class Profile;
(...skipping 25 matching lines...) Expand all
50 public: 51 public:
51 // Callback type used with ChooseDownloadPath(). The callback should be 52 // Callback type used with ChooseDownloadPath(). The callback should be
52 // invoked with the user-selected path as the argument. If the file selection 53 // invoked with the user-selected path as the argument. If the file selection
53 // was canceled, the argument should be the empty path. 54 // was canceled, the argument should be the empty path.
54 typedef base::Callback<void(const FilePath&)> FileSelectedCallback; 55 typedef base::Callback<void(const FilePath&)> FileSelectedCallback;
55 56
56 explicit ChromeDownloadManagerDelegate(Profile* profile); 57 explicit ChromeDownloadManagerDelegate(Profile* profile);
57 58
58 void SetDownloadManager(content::DownloadManager* dm); 59 void SetDownloadManager(content::DownloadManager* dm);
59 60
60 // Should be called before the call to ShouldCompleteDownload() to 61 // Add/Remove Observers of DownloadHistory events.
62 void AddHistoryObserver(DownloadHistory::Observer* observer);
63 void RemoveHistoryObserver(DownloadHistory::Observer* observer);
Randy Smith (Not in Mondays) 2012/11/02 23:31:25 These appear to only be used by tests. Any reason
benjhayden 2012/11/06 20:01:14 Exposed DownloadService::GetDownloadHistory(). LMK
Randy Smith (Not in Mondays) 2012/11/07 21:10:29 Nope, I think that'll do it--you correctly divined
benjhayden 2012/11/08 18:57:03 Done.
64
65 // Should be called before the first call to ShouldCompleteDownload() to
61 // disable SafeBrowsing checks for |item|. 66 // disable SafeBrowsing checks for |item|.
62 static void DisableSafeBrowsing(content::DownloadItem* item); 67 static void DisableSafeBrowsing(content::DownloadItem* item);
63 68
64 // content::DownloadManagerDelegate 69 // content::DownloadManagerDelegate
65 virtual void Shutdown() OVERRIDE; 70 virtual void Shutdown() OVERRIDE;
66 virtual content::DownloadId GetNextId() OVERRIDE; 71 virtual content::DownloadId GetNextId() OVERRIDE;
67 virtual bool DetermineDownloadTarget( 72 virtual bool DetermineDownloadTarget(
68 content::DownloadItem* item, 73 content::DownloadItem* item,
69 const content::DownloadTargetCallback& callback) OVERRIDE; 74 const content::DownloadTargetCallback& callback) OVERRIDE;
70 virtual content::WebContents* 75 virtual content::WebContents*
71 GetAlternativeWebContentsToNotifyForDownload() OVERRIDE; 76 GetAlternativeWebContentsToNotifyForDownload() OVERRIDE;
72 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path) OVERRIDE; 77 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path) OVERRIDE;
73 virtual bool ShouldCompleteDownload( 78 virtual bool ShouldCompleteDownload(
74 content::DownloadItem* item, 79 content::DownloadItem* item,
75 const base::Closure& complete_callback) OVERRIDE; 80 const base::Closure& complete_callback) OVERRIDE;
76 virtual bool ShouldOpenDownload(content::DownloadItem* item) OVERRIDE; 81 virtual bool ShouldOpenDownload(content::DownloadItem* item) OVERRIDE;
77 virtual bool GenerateFileHash() OVERRIDE; 82 virtual bool GenerateFileHash() OVERRIDE;
78 virtual void AddItemToPersistentStore(content::DownloadItem* item) OVERRIDE;
79 virtual void UpdateItemInPersistentStore(
80 content::DownloadItem* item) OVERRIDE;
81 virtual void UpdatePathForItemInPersistentStore(
82 content::DownloadItem* item,
83 const FilePath& new_path) OVERRIDE;
84 virtual void RemoveItemFromPersistentStore(
85 content::DownloadItem* item) OVERRIDE;
86 virtual void RemoveItemsFromPersistentStoreBetween(
87 base::Time remove_begin,
88 base::Time remove_end) OVERRIDE;
89 virtual void GetSaveDir(content::BrowserContext* browser_context, 83 virtual void GetSaveDir(content::BrowserContext* browser_context,
90 FilePath* website_save_dir, 84 FilePath* website_save_dir,
91 FilePath* download_save_dir, 85 FilePath* download_save_dir,
92 bool* skip_dir_check) OVERRIDE; 86 bool* skip_dir_check) OVERRIDE;
93 virtual void ChooseSavePath( 87 virtual void ChooseSavePath(
94 content::WebContents* web_contents, 88 content::WebContents* web_contents,
95 const FilePath& suggested_path, 89 const FilePath& suggested_path,
96 const FilePath::StringType& default_extension, 90 const FilePath::StringType& default_extension,
97 bool can_save_as_complete, 91 bool can_save_as_complete,
98 const content::SavePackagePathPickedCallback& callback) OVERRIDE; 92 const content::SavePackagePathPickedCallback& callback) OVERRIDE;
99 93
100 // Clears the last directory chosen by the user in response to a file chooser 94 // Clears the last directory chosen by the user in response to a file chooser
101 // prompt. Called when clearing recent history. 95 // prompt. Called when clearing recent history.
102 void ClearLastDownloadPath(); 96 void ClearLastDownloadPath();
103 97
104 DownloadPrefs* download_prefs() { return download_prefs_.get(); } 98 DownloadPrefs* download_prefs() { return download_prefs_.get(); }
105 DownloadHistory* download_history() { return download_history_.get(); }
106 99
107 protected: 100 protected:
108 // So that test classes can inherit from this for override purposes. 101 // So that test classes can inherit from this for override purposes.
109 virtual ~ChromeDownloadManagerDelegate(); 102 virtual ~ChromeDownloadManagerDelegate();
110 103
111 // Returns the SafeBrowsing download protection service if it's 104 // Returns the SafeBrowsing download protection service if it's
112 // enabled. Returns NULL otherwise. Protected virtual for testing. 105 // enabled. Returns NULL otherwise. Protected virtual for testing.
113 virtual safe_browsing::DownloadProtectionService* 106 virtual safe_browsing::DownloadProtectionService*
114 GetDownloadProtectionService(); 107 GetDownloadProtectionService();
115 108
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 bool reserved_path_verified); 199 bool reserved_path_verified);
207 200
208 // Called on the UI thread once the final target path is available. 201 // Called on the UI thread once the final target path is available.
209 void OnTargetPathDetermined( 202 void OnTargetPathDetermined(
210 int32 download_id, 203 int32 download_id,
211 const content::DownloadTargetCallback& callback, 204 const content::DownloadTargetCallback& callback,
212 content::DownloadItem::TargetDisposition disposition, 205 content::DownloadItem::TargetDisposition disposition,
213 content::DownloadDangerType danger_type, 206 content::DownloadDangerType danger_type,
214 const FilePath& target_path); 207 const FilePath& target_path);
215 208
216 // Callback from history system.
217 void OnItemAddedToPersistentStore(int32 download_id, int64 db_handle);
218
219 // Check policy of whether we should open this download with a web intents 209 // Check policy of whether we should open this download with a web intents
220 // dispatch. 210 // dispatch.
221 bool ShouldOpenWithWebIntents(const content::DownloadItem* item); 211 bool ShouldOpenWithWebIntents(const content::DownloadItem* item);
222 212
223 // Open the given item with a web intent dispatch. 213 // Open the given item with a web intent dispatch.
224 void OpenWithWebIntent(const content::DownloadItem* item); 214 void OpenWithWebIntent(const content::DownloadItem* item);
225 215
226 // Internal gateways for ShouldCompleteDownload(). 216 // Internal gateways for ShouldCompleteDownload().
227 bool IsDownloadReadyForCompletion( 217 bool IsDownloadReadyForCompletion(
228 content::DownloadItem* item, 218 content::DownloadItem* item,
(...skipping 28 matching lines...) Expand all
257 #endif 247 #endif
258 248
259 // The directory most recently chosen by the user in response to a Save As 249 // The directory most recently chosen by the user in response to a Save As
260 // dialog for a regular download. 250 // dialog for a regular download.
261 FilePath last_download_path_; 251 FilePath last_download_path_;
262 252
263 DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerDelegate); 253 DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerDelegate);
264 }; 254 };
265 255
266 #endif // CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ 256 #endif // CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/download/chrome_download_manager_delegate.cc » ('j') | chrome/browser/download/download_history.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698