OLD | NEW |
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" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 public content::DownloadManagerDelegate, | 47 public content::DownloadManagerDelegate, |
48 public content::NotificationObserver { | 48 public content::NotificationObserver { |
49 public: | 49 public: |
50 // Callback type used with ChooseDownloadPath(). The callback should be | 50 // Callback type used with ChooseDownloadPath(). The callback should be |
51 // invoked with the user-selected path as the argument. If the file selection | 51 // invoked with the user-selected path as the argument. If the file selection |
52 // was canceled, the argument should be the empty path. | 52 // was canceled, the argument should be the empty path. |
53 typedef base::Callback<void(const base::FilePath&)> FileSelectedCallback; | 53 typedef base::Callback<void(const base::FilePath&)> FileSelectedCallback; |
54 | 54 |
55 explicit ChromeDownloadManagerDelegate(Profile* profile); | 55 explicit ChromeDownloadManagerDelegate(Profile* profile); |
56 | 56 |
57 static void RegisterUserPrefs(PrefRegistrySyncable* registry); | |
58 | |
59 // Should be called before the first call to ShouldCompleteDownload() to | 57 // Should be called before the first call to ShouldCompleteDownload() to |
60 // disable SafeBrowsing checks for |item|. | 58 // disable SafeBrowsing checks for |item|. |
61 static void DisableSafeBrowsing(content::DownloadItem* item); | 59 static void DisableSafeBrowsing(content::DownloadItem* item); |
62 | 60 |
63 void SetDownloadManager(content::DownloadManager* dm); | 61 void SetDownloadManager(content::DownloadManager* dm); |
64 | 62 |
65 // content::DownloadManagerDelegate | 63 // content::DownloadManagerDelegate |
66 virtual void Shutdown() OVERRIDE; | 64 virtual void Shutdown() OVERRIDE; |
67 virtual content::DownloadId GetNextId() OVERRIDE; | 65 virtual content::DownloadId GetNextId() OVERRIDE; |
68 virtual bool DetermineDownloadTarget( | 66 virtual bool DetermineDownloadTarget( |
(...skipping 17 matching lines...) Expand all Loading... |
86 const base::FilePath& suggested_path, | 84 const base::FilePath& suggested_path, |
87 const base::FilePath::StringType& default_extension, | 85 const base::FilePath::StringType& default_extension, |
88 bool can_save_as_complete, | 86 bool can_save_as_complete, |
89 const content::SavePackagePathPickedCallback& callback) OVERRIDE; | 87 const content::SavePackagePathPickedCallback& callback) OVERRIDE; |
90 virtual void OpenDownload(content::DownloadItem* download) OVERRIDE; | 88 virtual void OpenDownload(content::DownloadItem* download) OVERRIDE; |
91 virtual void ShowDownloadInShell(content::DownloadItem* download) OVERRIDE; | 89 virtual void ShowDownloadInShell(content::DownloadItem* download) OVERRIDE; |
92 virtual void CheckForFileExistence( | 90 virtual void CheckForFileExistence( |
93 content::DownloadItem* download, | 91 content::DownloadItem* download, |
94 const content::CheckForFileExistenceCallback& callback) OVERRIDE; | 92 const content::CheckForFileExistenceCallback& callback) OVERRIDE; |
95 | 93 |
96 // Clears the last directory chosen by the user in response to a file chooser | |
97 // prompt. Called when clearing recent history. | |
98 void ClearLastDownloadPath(); | |
99 | |
100 DownloadPrefs* download_prefs() { return download_prefs_.get(); } | 94 DownloadPrefs* download_prefs() { return download_prefs_.get(); } |
101 | 95 |
102 protected: | 96 protected: |
103 // So that test classes can inherit from this for override purposes. | 97 // So that test classes can inherit from this for override purposes. |
104 virtual ~ChromeDownloadManagerDelegate(); | 98 virtual ~ChromeDownloadManagerDelegate(); |
105 | 99 |
106 // Returns the SafeBrowsing download protection service if it's | 100 // Returns the SafeBrowsing download protection service if it's |
107 // enabled. Returns NULL otherwise. Protected virtual for testing. | 101 // enabled. Returns NULL otherwise. Protected virtual for testing. |
108 virtual safe_browsing::DownloadProtectionService* | 102 virtual safe_browsing::DownloadProtectionService* |
109 GetDownloadProtectionService(); | 103 GetDownloadProtectionService(); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 | 229 |
236 // Maps from pending extension installations to DownloadItem IDs. | 230 // Maps from pending extension installations to DownloadItem IDs. |
237 typedef base::hash_map<extensions::CrxInstaller*, | 231 typedef base::hash_map<extensions::CrxInstaller*, |
238 content::DownloadOpenDelayedCallback> CrxInstallerMap; | 232 content::DownloadOpenDelayedCallback> CrxInstallerMap; |
239 CrxInstallerMap crx_installers_; | 233 CrxInstallerMap crx_installers_; |
240 | 234 |
241 CancelableRequestConsumer history_consumer_; | 235 CancelableRequestConsumer history_consumer_; |
242 | 236 |
243 content::NotificationRegistrar registrar_; | 237 content::NotificationRegistrar registrar_; |
244 | 238 |
245 // The directory most recently chosen by the user in response to a Save As | |
246 // dialog for a regular download. | |
247 base::FilePath last_download_path_; | |
248 | |
249 DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerDelegate); | 239 DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerDelegate); |
250 }; | 240 }; |
251 | 241 |
252 #endif // CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ | 242 #endif // CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ |
OLD | NEW |