| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 std::string ApplicationClientIdForFileScanning() const override; | 89 std::string ApplicationClientIdForFileScanning() 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 | |
| 97 // can call back into the DownloadManager. | |
| 98 content::DownloadManager* download_manager_; | |
| 99 | |
| 100 virtual safe_browsing::DownloadProtectionService* | 99 virtual safe_browsing::DownloadProtectionService* |
| 101 GetDownloadProtectionService(); | 100 GetDownloadProtectionService(); |
| 102 | 101 |
| 103 // DownloadTargetDeterminerDelegate. Protected for testing. | 102 // DownloadTargetDeterminerDelegate. Protected for testing. |
| 104 void NotifyExtensions(content::DownloadItem* download, | 103 void NotifyExtensions(content::DownloadItem* download, |
| 105 const base::FilePath& suggested_virtual_path, | 104 const base::FilePath& suggested_virtual_path, |
| 106 const NotifyExtensionsCallback& callback) override; | 105 const NotifyExtensionsCallback& callback) override; |
| 107 void ReserveVirtualPath( | 106 void ReserveVirtualPath( |
| 108 content::DownloadItem* download, | 107 content::DownloadItem* download, |
| 109 const base::FilePath& virtual_path, | 108 const base::FilePath& virtual_path, |
| 110 bool create_directory, | 109 bool create_directory, |
| 111 DownloadPathReservationTracker::FilenameConflictAction conflict_action, | 110 DownloadPathReservationTracker::FilenameConflictAction conflict_action, |
| 112 const ReservedPathCallback& callback) override; | 111 const ReservedPathCallback& callback) override; |
| 113 void PromptUserForDownloadPath(content::DownloadItem* download, | 112 void RequestConfirmation(content::DownloadItem* download, |
| 114 const base::FilePath& suggested_virtual_path, | 113 const base::FilePath& suggested_virtual_path, |
| 115 const FileSelectedCallback& callback) override; | 114 DownloadConfirmationReason reason, |
| 115 const ConfirmationCallback& callback) override; |
| 116 void DetermineLocalPath(content::DownloadItem* download, | 116 void DetermineLocalPath(content::DownloadItem* download, |
| 117 const base::FilePath& virtual_path, | 117 const base::FilePath& virtual_path, |
| 118 const LocalPathCallback& callback) override; | 118 const LocalPathCallback& callback) override; |
| 119 void CheckDownloadUrl(content::DownloadItem* download, | 119 void CheckDownloadUrl(content::DownloadItem* download, |
| 120 const base::FilePath& suggested_virtual_path, | 120 const base::FilePath& suggested_virtual_path, |
| 121 const CheckDownloadUrlCallback& callback) override; | 121 const CheckDownloadUrlCallback& callback) override; |
| 122 void GetFileMimeType(const base::FilePath& path, | 122 void GetFileMimeType(const base::FilePath& path, |
| 123 const GetFileMimeTypeCallback& callback) override; | 123 const GetFileMimeTypeCallback& callback) override; |
| 124 | 124 |
| 125 // So that test classes that inherit from this for override purposes |
| 126 // can call back into the DownloadManager. |
| 127 content::DownloadManager* download_manager_; |
| 128 |
| 125 private: | 129 private: |
| 126 friend class base::RefCountedThreadSafe<ChromeDownloadManagerDelegate>; | 130 friend class base::RefCountedThreadSafe<ChromeDownloadManagerDelegate>; |
| 131 FRIEND_TEST_ALL_PREFIXES(ChromeDownloadManagerDelegateTest, |
| 132 RequestConfirmation_Android); |
| 127 | 133 |
| 128 typedef std::vector<content::DownloadIdCallback> IdCallbackVector; | 134 typedef std::vector<content::DownloadIdCallback> IdCallbackVector; |
| 129 | 135 |
| 130 // content::NotificationObserver implementation. | 136 // content::NotificationObserver implementation. |
| 131 void Observe(int type, | 137 void Observe(int type, |
| 132 const content::NotificationSource& source, | 138 const content::NotificationSource& source, |
| 133 const content::NotificationDetails& details) override; | 139 const content::NotificationDetails& details) override; |
| 134 | 140 |
| 135 // Callback function after the DownloadProtectionService completes. | 141 // Callback function after the DownloadProtectionService completes. |
| 136 void CheckClientDownloadDone( | 142 void CheckClientDownloadDone( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 #endif | 176 #endif |
| 171 | 177 |
| 172 content::NotificationRegistrar registrar_; | 178 content::NotificationRegistrar registrar_; |
| 173 | 179 |
| 174 base::WeakPtrFactory<ChromeDownloadManagerDelegate> weak_ptr_factory_; | 180 base::WeakPtrFactory<ChromeDownloadManagerDelegate> weak_ptr_factory_; |
| 175 | 181 |
| 176 DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerDelegate); | 182 DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerDelegate); |
| 177 }; | 183 }; |
| 178 | 184 |
| 179 #endif // CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ | 185 #endif // CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ |
| OLD | NEW |