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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 // This is the Chrome side helper for the download system. | 47 // This is the Chrome side helper for the download system. |
48 class ChromeDownloadManagerDelegate | 48 class ChromeDownloadManagerDelegate |
49 : public base::RefCountedThreadSafe<ChromeDownloadManagerDelegate>, | 49 : public base::RefCountedThreadSafe<ChromeDownloadManagerDelegate>, |
50 public content::DownloadManagerDelegate, | 50 public content::DownloadManagerDelegate, |
51 public content::NotificationObserver, | 51 public content::NotificationObserver, |
52 public DownloadTargetDeterminerDelegate { | 52 public DownloadTargetDeterminerDelegate { |
53 public: | 53 public: |
54 explicit ChromeDownloadManagerDelegate(Profile* profile); | 54 explicit ChromeDownloadManagerDelegate(Profile* profile); |
55 | 55 |
56 static void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry); | |
57 | |
58 // Should be called before the first call to ShouldCompleteDownload() to | 56 // Should be called before the first call to ShouldCompleteDownload() to |
59 // disable SafeBrowsing checks for |item|. | 57 // disable SafeBrowsing checks for |item|. |
60 static void DisableSafeBrowsing(content::DownloadItem* item); | 58 static void DisableSafeBrowsing(content::DownloadItem* item); |
61 | 59 |
62 void SetDownloadManager(content::DownloadManager* dm); | 60 void SetDownloadManager(content::DownloadManager* dm); |
63 | 61 |
64 // content::DownloadManagerDelegate | 62 // content::DownloadManagerDelegate |
65 virtual void Shutdown() OVERRIDE; | 63 virtual void Shutdown() OVERRIDE; |
66 virtual content::DownloadId GetNextId() OVERRIDE; | 64 virtual content::DownloadId GetNextId() OVERRIDE; |
67 virtual bool DetermineDownloadTarget( | 65 virtual bool DetermineDownloadTarget( |
(...skipping 17 matching lines...) Expand all Loading... |
85 const base::FilePath& suggested_path, | 83 const base::FilePath& suggested_path, |
86 const base::FilePath::StringType& default_extension, | 84 const base::FilePath::StringType& default_extension, |
87 bool can_save_as_complete, | 85 bool can_save_as_complete, |
88 const content::SavePackagePathPickedCallback& callback) OVERRIDE; | 86 const content::SavePackagePathPickedCallback& callback) OVERRIDE; |
89 virtual void OpenDownload(content::DownloadItem* download) OVERRIDE; | 87 virtual void OpenDownload(content::DownloadItem* download) OVERRIDE; |
90 virtual void ShowDownloadInShell(content::DownloadItem* download) OVERRIDE; | 88 virtual void ShowDownloadInShell(content::DownloadItem* download) OVERRIDE; |
91 virtual void CheckForFileExistence( | 89 virtual void CheckForFileExistence( |
92 content::DownloadItem* download, | 90 content::DownloadItem* download, |
93 const content::CheckForFileExistenceCallback& callback) OVERRIDE; | 91 const content::CheckForFileExistenceCallback& callback) OVERRIDE; |
94 | 92 |
95 // Clears the last directory chosen by the user in response to a file chooser | |
96 // prompt. Called when clearing recent history. | |
97 void ClearLastDownloadPath(); | |
98 | |
99 DownloadPrefs* download_prefs() { return download_prefs_.get(); } | 93 DownloadPrefs* download_prefs() { return download_prefs_.get(); } |
100 | 94 |
101 protected: | 95 protected: |
102 // So that test classes can inherit from this for override purposes. | 96 // So that test classes can inherit from this for override purposes. |
103 virtual ~ChromeDownloadManagerDelegate(); | 97 virtual ~ChromeDownloadManagerDelegate(); |
104 | 98 |
105 // So that test classes that inherit from this for override purposes | 99 // So that test classes that inherit from this for override purposes |
106 // can call back into the DownloadManager. | 100 // can call back into the DownloadManager. |
107 content::DownloadManager* download_manager_; | 101 content::DownloadManager* download_manager_; |
108 | 102 |
(...skipping 17 matching lines...) Expand all Loading... |
126 const FileSelectedCallback& callback) OVERRIDE; | 120 const FileSelectedCallback& callback) OVERRIDE; |
127 virtual void DetermineLocalPath( | 121 virtual void DetermineLocalPath( |
128 content::DownloadItem* download, | 122 content::DownloadItem* download, |
129 const base::FilePath& virtual_path, | 123 const base::FilePath& virtual_path, |
130 const LocalPathCallback& callback) OVERRIDE; | 124 const LocalPathCallback& callback) OVERRIDE; |
131 virtual void CheckDownloadUrl( | 125 virtual void CheckDownloadUrl( |
132 content::DownloadItem* download, | 126 content::DownloadItem* download, |
133 const base::FilePath& suggested_virtual_path, | 127 const base::FilePath& suggested_virtual_path, |
134 const CheckDownloadUrlCallback& callback) OVERRIDE; | 128 const CheckDownloadUrlCallback& callback) OVERRIDE; |
135 | 129 |
136 // Callback invoked by the DownloadFilePicker after PromptUserForDownloadPath. | |
137 void OnDownloadPathSelected( | |
138 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback, | |
139 const base::FilePath& virtual_path); | |
140 | |
141 private: | 130 private: |
142 friend class base::RefCountedThreadSafe<ChromeDownloadManagerDelegate>; | 131 friend class base::RefCountedThreadSafe<ChromeDownloadManagerDelegate>; |
143 | 132 |
144 // content::NotificationObserver implementation. | 133 // content::NotificationObserver implementation. |
145 virtual void Observe(int type, | 134 virtual void Observe(int type, |
146 const content::NotificationSource& source, | 135 const content::NotificationSource& source, |
147 const content::NotificationDetails& details) OVERRIDE; | 136 const content::NotificationDetails& details) OVERRIDE; |
148 | 137 |
149 // Callback function after the DownloadProtectionService completes. | 138 // Callback function after the DownloadProtectionService completes. |
150 void CheckClientDownloadDone( | 139 void CheckClientDownloadDone( |
(...skipping 12 matching lines...) Expand all Loading... |
163 int next_download_id_; | 152 int next_download_id_; |
164 scoped_ptr<DownloadPrefs> download_prefs_; | 153 scoped_ptr<DownloadPrefs> download_prefs_; |
165 | 154 |
166 // Maps from pending extension installations to DownloadItem IDs. | 155 // Maps from pending extension installations to DownloadItem IDs. |
167 typedef base::hash_map<extensions::CrxInstaller*, | 156 typedef base::hash_map<extensions::CrxInstaller*, |
168 content::DownloadOpenDelayedCallback> CrxInstallerMap; | 157 content::DownloadOpenDelayedCallback> CrxInstallerMap; |
169 CrxInstallerMap crx_installers_; | 158 CrxInstallerMap crx_installers_; |
170 | 159 |
171 content::NotificationRegistrar registrar_; | 160 content::NotificationRegistrar registrar_; |
172 | 161 |
173 // The directory most recently chosen by the user in response to a Save As | |
174 // dialog for a regular download. | |
175 base::FilePath last_download_path_; | |
176 | |
177 DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerDelegate); | 162 DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerDelegate); |
178 }; | 163 }; |
179 | 164 |
180 #endif // CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ | 165 #endif // CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ |
OLD | NEW |