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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
| 11 #include <string> |
| 12 #include <vector> |
11 | 13 |
12 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
13 #include "base/containers/hash_tables.h" | 15 #include "base/containers/hash_tables.h" |
14 #include "base/macros.h" | 16 #include "base/macros.h" |
15 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
16 #include "chrome/browser/download/download_path_reservation_tracker.h" | 18 #include "chrome/browser/download/download_path_reservation_tracker.h" |
17 #include "chrome/browser/download/download_target_determiner_delegate.h" | 19 #include "chrome/browser/download/download_target_determiner_delegate.h" |
18 #include "chrome/browser/download/download_target_info.h" | 20 #include "chrome/browser/download/download_target_info.h" |
19 #include "chrome/browser/safe_browsing/download_protection_service.h" | 21 #include "chrome/browser/safe_browsing/download_protection_service.h" |
20 #include "content/public/browser/download_danger_type.h" | 22 #include "content/public/browser/download_danger_type.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 const base::FilePath::StringType& default_extension, | 79 const base::FilePath::StringType& default_extension, |
78 bool can_save_as_complete, | 80 bool can_save_as_complete, |
79 const content::SavePackagePathPickedCallback& callback) override; | 81 const content::SavePackagePathPickedCallback& callback) override; |
80 void SanitizeSavePackageResourceName(base::FilePath* filename) override; | 82 void SanitizeSavePackageResourceName(base::FilePath* filename) override; |
81 void OpenDownload(content::DownloadItem* download) override; | 83 void OpenDownload(content::DownloadItem* download) override; |
82 void ShowDownloadInShell(content::DownloadItem* download) override; | 84 void ShowDownloadInShell(content::DownloadItem* download) override; |
83 void CheckForFileExistence( | 85 void CheckForFileExistence( |
84 content::DownloadItem* download, | 86 content::DownloadItem* download, |
85 const content::CheckForFileExistenceCallback& callback) override; | 87 const content::CheckForFileExistenceCallback& callback) override; |
86 std::string ApplicationClientIdForFileScanning() const override; | 88 std::string ApplicationClientIdForFileScanning() const override; |
| 89 bool ShouldBlockAllDownloads() const override; |
87 | 90 |
88 // Opens a download using the platform handler. DownloadItem::OpenDownload, | 91 // Opens a download using the platform handler. DownloadItem::OpenDownload, |
89 // which ends up being handled by OpenDownload(), will open a download in the | 92 // which ends up being handled by OpenDownload(), will open a download in the |
90 // browser if doing so is preferred. | 93 // browser if doing so is preferred. |
91 void OpenDownloadUsingPlatformHandler(content::DownloadItem* download); | 94 void OpenDownloadUsingPlatformHandler(content::DownloadItem* download); |
92 | 95 |
93 DownloadPrefs* download_prefs() { return download_prefs_.get(); } | 96 DownloadPrefs* download_prefs() { return download_prefs_.get(); } |
94 | 97 |
95 protected: | 98 protected: |
96 // So that test classes that inherit from this for override purposes | 99 // So that test classes that inherit from this for override purposes |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 void ReturnNextId(const content::DownloadIdCallback& callback); | 153 void ReturnNextId(const content::DownloadIdCallback& callback); |
151 | 154 |
152 void OnDownloadTargetDetermined( | 155 void OnDownloadTargetDetermined( |
153 int32_t download_id, | 156 int32_t download_id, |
154 const content::DownloadTargetCallback& callback, | 157 const content::DownloadTargetCallback& callback, |
155 std::unique_ptr<DownloadTargetInfo> target_info); | 158 std::unique_ptr<DownloadTargetInfo> target_info); |
156 | 159 |
157 // Returns true if |path| should open in the browser. | 160 // Returns true if |path| should open in the browser. |
158 bool IsOpenInBrowserPreferreredForFile(const base::FilePath& path); | 161 bool IsOpenInBrowserPreferreredForFile(const base::FilePath& path); |
159 | 162 |
| 163 // Return true if the downloaded file should be blocked on on the current pref |
| 164 // and |danger_type|. |
| 165 bool ShouldBlockFile(content::DownloadDangerType danger_type) const; |
| 166 |
160 Profile* profile_; | 167 Profile* profile_; |
161 uint32_t next_download_id_; | 168 uint32_t next_download_id_; |
162 IdCallbackVector id_callbacks_; | 169 IdCallbackVector id_callbacks_; |
163 std::unique_ptr<DownloadPrefs> download_prefs_; | 170 std::unique_ptr<DownloadPrefs> download_prefs_; |
164 | 171 |
165 #if BUILDFLAG(ENABLE_EXTENSIONS) | 172 #if BUILDFLAG(ENABLE_EXTENSIONS) |
166 // Maps from pending extension installations to DownloadItem IDs. | 173 // Maps from pending extension installations to DownloadItem IDs. |
167 typedef base::hash_map<extensions::CrxInstaller*, | 174 typedef base::hash_map<extensions::CrxInstaller*, |
168 content::DownloadOpenDelayedCallback> CrxInstallerMap; | 175 content::DownloadOpenDelayedCallback> CrxInstallerMap; |
169 CrxInstallerMap crx_installers_; | 176 CrxInstallerMap crx_installers_; |
170 #endif | 177 #endif |
171 | 178 |
172 content::NotificationRegistrar registrar_; | 179 content::NotificationRegistrar registrar_; |
173 | 180 |
174 base::WeakPtrFactory<ChromeDownloadManagerDelegate> weak_ptr_factory_; | 181 base::WeakPtrFactory<ChromeDownloadManagerDelegate> weak_ptr_factory_; |
175 | 182 |
176 DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerDelegate); | 183 DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerDelegate); |
177 }; | 184 }; |
178 | 185 |
179 #endif // CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ | 186 #endif // CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ |
OLD | NEW |