| 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" |
| 16 #include "base/gtest_prod_util.h" |
| 14 #include "base/macros.h" | 17 #include "base/macros.h" |
| 15 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 16 #include "chrome/browser/download/download_path_reservation_tracker.h" | 19 #include "chrome/browser/download/download_path_reservation_tracker.h" |
| 17 #include "chrome/browser/download/download_target_determiner_delegate.h" | 20 #include "chrome/browser/download/download_target_determiner_delegate.h" |
| 18 #include "chrome/browser/download/download_target_info.h" | 21 #include "chrome/browser/download/download_target_info.h" |
| 19 #include "chrome/browser/safe_browsing/download_protection_service.h" | 22 #include "chrome/browser/safe_browsing/download_protection_service.h" |
| 20 #include "content/public/browser/download_danger_type.h" | 23 #include "content/public/browser/download_danger_type.h" |
| 21 #include "content/public/browser/download_item.h" | 24 #include "content/public/browser/download_item.h" |
| 22 #include "content/public/browser/download_manager_delegate.h" | 25 #include "content/public/browser/download_manager_delegate.h" |
| 23 #include "content/public/browser/notification_observer.h" | 26 #include "content/public/browser/notification_observer.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 std::string ApplicationClientIdForFileScanning() const override; | 92 std::string ApplicationClientIdForFileScanning() const override; |
| 90 | 93 |
| 91 // Opens a download using the platform handler. DownloadItem::OpenDownload, | 94 // Opens a download using the platform handler. DownloadItem::OpenDownload, |
| 92 // which ends up being handled by OpenDownload(), will open a download in the | 95 // which ends up being handled by OpenDownload(), will open a download in the |
| 93 // browser if doing so is preferred. | 96 // browser if doing so is preferred. |
| 94 void OpenDownloadUsingPlatformHandler(content::DownloadItem* download); | 97 void OpenDownloadUsingPlatformHandler(content::DownloadItem* download); |
| 95 | 98 |
| 96 DownloadPrefs* download_prefs() { return download_prefs_.get(); } | 99 DownloadPrefs* download_prefs() { return download_prefs_.get(); } |
| 97 | 100 |
| 98 protected: | 101 protected: |
| 99 // So that test classes that inherit from this for override purposes | |
| 100 // can call back into the DownloadManager. | |
| 101 content::DownloadManager* download_manager_; | |
| 102 | |
| 103 virtual safe_browsing::DownloadProtectionService* | 102 virtual safe_browsing::DownloadProtectionService* |
| 104 GetDownloadProtectionService(); | 103 GetDownloadProtectionService(); |
| 105 | 104 |
| 106 // DownloadTargetDeterminerDelegate. Protected for testing. | 105 // DownloadTargetDeterminerDelegate. Protected for testing. |
| 107 void NotifyExtensions(content::DownloadItem* download, | 106 void NotifyExtensions(content::DownloadItem* download, |
| 108 const base::FilePath& suggested_virtual_path, | 107 const base::FilePath& suggested_virtual_path, |
| 109 const NotifyExtensionsCallback& callback) override; | 108 const NotifyExtensionsCallback& callback) override; |
| 110 void ReserveVirtualPath( | 109 void ReserveVirtualPath( |
| 111 content::DownloadItem* download, | 110 content::DownloadItem* download, |
| 112 const base::FilePath& virtual_path, | 111 const base::FilePath& virtual_path, |
| 113 bool create_directory, | 112 bool create_directory, |
| 114 DownloadPathReservationTracker::FilenameConflictAction conflict_action, | 113 DownloadPathReservationTracker::FilenameConflictAction conflict_action, |
| 115 const ReservedPathCallback& callback) override; | 114 const ReservedPathCallback& callback) override; |
| 116 void PromptUserForDownloadPath(content::DownloadItem* download, | 115 void RequestConfirmation(content::DownloadItem* download, |
| 117 const base::FilePath& suggested_virtual_path, | 116 const base::FilePath& suggested_virtual_path, |
| 118 const FileSelectedCallback& callback) override; | 117 DownloadConfirmationReason reason, |
| 118 const FileSelectedCallback& callback) override; |
| 119 void DetermineLocalPath(content::DownloadItem* download, | 119 void DetermineLocalPath(content::DownloadItem* download, |
| 120 const base::FilePath& virtual_path, | 120 const base::FilePath& virtual_path, |
| 121 const LocalPathCallback& callback) override; | 121 const LocalPathCallback& callback) override; |
| 122 void CheckDownloadUrl(content::DownloadItem* download, | 122 void CheckDownloadUrl(content::DownloadItem* download, |
| 123 const base::FilePath& suggested_virtual_path, | 123 const base::FilePath& suggested_virtual_path, |
| 124 const CheckDownloadUrlCallback& callback) override; | 124 const CheckDownloadUrlCallback& callback) override; |
| 125 void GetFileMimeType(const base::FilePath& path, | 125 void GetFileMimeType(const base::FilePath& path, |
| 126 const GetFileMimeTypeCallback& callback) override; | 126 const GetFileMimeTypeCallback& callback) override; |
| 127 | 127 |
| 128 // So that test classes that inherit from this for override purposes |
| 129 // can call back into the DownloadManager. |
| 130 content::DownloadManager* download_manager_; |
| 131 |
| 128 private: | 132 private: |
| 129 friend class base::RefCountedThreadSafe<ChromeDownloadManagerDelegate>; | 133 friend class base::RefCountedThreadSafe<ChromeDownloadManagerDelegate>; |
| 134 FRIEND_TEST_ALL_PREFIXES(ChromeDownloadManagerDelegateTest, |
| 135 RequestConfirmation_Android); |
| 130 | 136 |
| 131 typedef std::vector<content::DownloadIdCallback> IdCallbackVector; | 137 typedef std::vector<content::DownloadIdCallback> IdCallbackVector; |
| 132 | 138 |
| 133 // content::NotificationObserver implementation. | 139 // content::NotificationObserver implementation. |
| 134 void Observe(int type, | 140 void Observe(int type, |
| 135 const content::NotificationSource& source, | 141 const content::NotificationSource& source, |
| 136 const content::NotificationDetails& details) override; | 142 const content::NotificationDetails& details) override; |
| 137 | 143 |
| 138 // Callback function after the DownloadProtectionService completes. | 144 // Callback function after the DownloadProtectionService completes. |
| 139 void CheckClientDownloadDone( | 145 void CheckClientDownloadDone( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 #endif | 179 #endif |
| 174 | 180 |
| 175 content::NotificationRegistrar registrar_; | 181 content::NotificationRegistrar registrar_; |
| 176 | 182 |
| 177 base::WeakPtrFactory<ChromeDownloadManagerDelegate> weak_ptr_factory_; | 183 base::WeakPtrFactory<ChromeDownloadManagerDelegate> weak_ptr_factory_; |
| 178 | 184 |
| 179 DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerDelegate); | 185 DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerDelegate); |
| 180 }; | 186 }; |
| 181 | 187 |
| 182 #endif // CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ | 188 #endif // CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ |
| OLD | NEW |