OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_DOWNLOAD_TARGET_DETERMINER_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_H_ |
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_H_ |
7 | 7 |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 }; | 132 }; |
133 | 133 |
134 // Construct a DownloadTargetDeterminer object. Constraints on the arguments | 134 // Construct a DownloadTargetDeterminer object. Constraints on the arguments |
135 // are as per Start() above. | 135 // are as per Start() above. |
136 DownloadTargetDeterminer(content::DownloadItem* download, | 136 DownloadTargetDeterminer(content::DownloadItem* download, |
137 const base::FilePath& initial_virtual_path, | 137 const base::FilePath& initial_virtual_path, |
138 DownloadPrefs* download_prefs, | 138 DownloadPrefs* download_prefs, |
139 DownloadTargetDeterminerDelegate* delegate, | 139 DownloadTargetDeterminerDelegate* delegate, |
140 const CompletionCallback& callback); | 140 const CompletionCallback& callback); |
141 | 141 |
142 virtual ~DownloadTargetDeterminer(); | 142 ~DownloadTargetDeterminer() override; |
143 | 143 |
144 // Invoke each successive handler until a handler returns QUIT_DOLOOP or | 144 // Invoke each successive handler until a handler returns QUIT_DOLOOP or |
145 // COMPLETE. Note that as a result, this object might be deleted. So |this| | 145 // COMPLETE. Note that as a result, this object might be deleted. So |this| |
146 // should not be accessed after calling DoLoop(). | 146 // should not be accessed after calling DoLoop(). |
147 void DoLoop(); | 147 void DoLoop(); |
148 | 148 |
149 // === Main workflow === | 149 // === Main workflow === |
150 | 150 |
151 // Generates an initial target path. This target is based only on the state of | 151 // Generates an initial target path. This target is based only on the state of |
152 // the download item. | 152 // the download item. |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 // operation. | 288 // operation. |
289 bool HasPromptedForPath() const; | 289 bool HasPromptedForPath() const; |
290 | 290 |
291 // Returns true if this download should show the "dangerous file" warning. | 291 // Returns true if this download should show the "dangerous file" warning. |
292 // Various factors are considered, such as the type of the file, whether a | 292 // Various factors are considered, such as the type of the file, whether a |
293 // user action initiated the download, and whether the user has explicitly | 293 // user action initiated the download, and whether the user has explicitly |
294 // marked the file type as "auto open". Protected virtual for testing. | 294 // marked the file type as "auto open". Protected virtual for testing. |
295 bool IsDangerousFile(PriorVisitsToReferrer visits); | 295 bool IsDangerousFile(PriorVisitsToReferrer visits); |
296 | 296 |
297 // content::DownloadItem::Observer | 297 // content::DownloadItem::Observer |
298 virtual void OnDownloadDestroyed(content::DownloadItem* download) override; | 298 void OnDownloadDestroyed(content::DownloadItem* download) override; |
299 | 299 |
300 // state | 300 // state |
301 State next_state_; | 301 State next_state_; |
302 bool should_prompt_; | 302 bool should_prompt_; |
303 bool should_notify_extensions_; | 303 bool should_notify_extensions_; |
304 bool create_target_directory_; | 304 bool create_target_directory_; |
305 DownloadPathReservationTracker::FilenameConflictAction conflict_action_; | 305 DownloadPathReservationTracker::FilenameConflictAction conflict_action_; |
306 content::DownloadDangerType danger_type_; | 306 content::DownloadDangerType danger_type_; |
307 bool is_dangerous_file_; // See DownloadTargetInfo::is_dangerous_file | 307 bool is_dangerous_file_; // See DownloadTargetInfo::is_dangerous_file |
308 base::FilePath virtual_path_; | 308 base::FilePath virtual_path_; |
309 base::FilePath local_path_; | 309 base::FilePath local_path_; |
310 base::FilePath intermediate_path_; | 310 base::FilePath intermediate_path_; |
311 std::string mime_type_; | 311 std::string mime_type_; |
312 bool is_filetype_handled_safely_; | 312 bool is_filetype_handled_safely_; |
313 | 313 |
314 content::DownloadItem* download_; | 314 content::DownloadItem* download_; |
315 const bool is_resumption_; | 315 const bool is_resumption_; |
316 DownloadPrefs* download_prefs_; | 316 DownloadPrefs* download_prefs_; |
317 DownloadTargetDeterminerDelegate* delegate_; | 317 DownloadTargetDeterminerDelegate* delegate_; |
318 CompletionCallback completion_callback_; | 318 CompletionCallback completion_callback_; |
319 base::CancelableTaskTracker history_tracker_; | 319 base::CancelableTaskTracker history_tracker_; |
320 | 320 |
321 base::WeakPtrFactory<DownloadTargetDeterminer> weak_ptr_factory_; | 321 base::WeakPtrFactory<DownloadTargetDeterminer> weak_ptr_factory_; |
322 | 322 |
323 DISALLOW_COPY_AND_ASSIGN(DownloadTargetDeterminer); | 323 DISALLOW_COPY_AND_ASSIGN(DownloadTargetDeterminer); |
324 }; | 324 }; |
325 | 325 |
326 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_H_ | 326 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_H_ |
OLD | NEW |