Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Side by Side Diff: content/public/browser/download_item.h

Issue 14947007: [Downloads] Allow acquiring dangerous download file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with r201622 Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // Each download is represented by a DownloadItem, and all DownloadItems 5 // Each download is represented by a DownloadItem, and all DownloadItems
6 // are owned by the DownloadManager which maintains a global list of all 6 // are owned by the DownloadManager which maintains a global list of all
7 // downloads. DownloadItems are created when a user initiates a download, 7 // downloads. DownloadItems are created when a user initiates a download,
8 // and exist for the duration of the browser life time. 8 // and exist for the duration of the browser life time.
9 // 9 //
10 // Download observers: 10 // Download observers:
11 // DownloadItem::Observer: 11 // DownloadItem::Observer:
12 // - allows observers to receive notifications about one download from start 12 // - allows observers to receive notifications about one download from start
13 // to completion 13 // to completion
14 // Use AddObserver() / RemoveObserver() on the appropriate download object to 14 // Use AddObserver() / RemoveObserver() on the appropriate download object to
15 // receive state updates. 15 // receive state updates.
16 16
17 #ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ 17 #ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_
18 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ 18 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_
19 19
20 #include <map> 20 #include <map>
21 #include <string> 21 #include <string>
22 #include <vector> 22 #include <vector>
23 23
24 #include "base/callback_forward.h"
24 #include "base/files/file_path.h" 25 #include "base/files/file_path.h"
25 #include "base/string16.h" 26 #include "base/string16.h"
26 #include "base/supports_user_data.h" 27 #include "base/supports_user_data.h"
27 #include "content/public/browser/download_danger_type.h" 28 #include "content/public/browser/download_danger_type.h"
28 #include "content/public/browser/download_interrupt_reasons.h" 29 #include "content/public/browser/download_interrupt_reasons.h"
29 #include "content/public/common/page_transition_types.h" 30 #include "content/public/common/page_transition_types.h"
30 31
31 class GURL; 32 class GURL;
32 33
33 namespace base { 34 namespace base {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 }; 75 };
75 76
76 // How the final target path should be used. 77 // How the final target path should be used.
77 enum TargetDisposition { 78 enum TargetDisposition {
78 TARGET_DISPOSITION_OVERWRITE, // Overwrite if the target already exists. 79 TARGET_DISPOSITION_OVERWRITE, // Overwrite if the target already exists.
79 TARGET_DISPOSITION_PROMPT // Prompt the user for the actual 80 TARGET_DISPOSITION_PROMPT // Prompt the user for the actual
80 // target. Implies 81 // target. Implies
81 // TARGET_DISPOSITION_OVERWRITE. 82 // TARGET_DISPOSITION_OVERWRITE.
82 }; 83 };
83 84
85 // Callback used with AcquireFileAndDeleteDownload().
86 typedef base::Callback<void(const base::FilePath&)> AcquireFileCallback;
87
84 static const char kEmptyFileHash[]; 88 static const char kEmptyFileHash[];
85 89
86 // Interface that observers of a particular download must implement in order 90 // Interface that observers of a particular download must implement in order
87 // to receive updates to the download's status. 91 // to receive updates to the download's status.
88 class CONTENT_EXPORT Observer { 92 class CONTENT_EXPORT Observer {
89 public: 93 public:
90 virtual void OnDownloadUpdated(DownloadItem* download) {} 94 virtual void OnDownloadUpdated(DownloadItem* download) {}
91 virtual void OnDownloadOpened(DownloadItem* download) {} 95 virtual void OnDownloadOpened(DownloadItem* download) {}
92 virtual void OnDownloadRemoved(DownloadItem* download) {} 96 virtual void OnDownloadRemoved(DownloadItem* download) {}
93 97
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // exit to prevent this crash. This may result in a difference between the 133 // exit to prevent this crash. This may result in a difference between the
130 // downloaded file's size on disk, and what the history system's last record 134 // downloaded file's size on disk, and what the history system's last record
131 // of it is. At worst, we'll end up re-downloading a small portion of the file 135 // of it is. At worst, we'll end up re-downloading a small portion of the file
132 // when resuming a download (assuming the server supports byte ranges). 136 // when resuming a download (assuming the server supports byte ranges).
133 virtual void Cancel(bool user_cancel) = 0; 137 virtual void Cancel(bool user_cancel) = 0;
134 138
135 // Deletes the file from disk and removes the download from the views and 139 // Deletes the file from disk and removes the download from the views and
136 // history. 140 // history.
137 virtual void Delete(DeleteReason reason) = 0; 141 virtual void Delete(DeleteReason reason) = 0;
138 142
143 // Acquires the download file and deletes the download. Equivalent to calling
144 // |Delete(DELETE_DUE_TO_USER_DISCARD)| with the exception that the download
145 // file isn't deleted. The path to the file is passed to the |callback|. If
146 // the downloaded file is not available, then returned path will be empty.
147 virtual void AcquireFileAndDeleteDownload(
Randy Smith (Not in Mondays) 2013/05/23 13:56:43 What do you think of naming this in some fashion t
asanka 2013/05/23 15:53:31 How about this?: - ValidateDangerousDownload() - S
148 const AcquireFileCallback& callback) = 0;
149
139 // Removes the download from the views and history. 150 // Removes the download from the views and history.
140 virtual void Remove() = 0; 151 virtual void Remove() = 0;
141 152
142 // Open the file associated with this download. If the download is 153 // Open the file associated with this download. If the download is
143 // still in progress, marks the download to be opened when it is complete. 154 // still in progress, marks the download to be opened when it is complete.
144 virtual void OpenDownload() = 0; 155 virtual void OpenDownload() = 0;
145 156
146 // Show the download via the OS shell. 157 // Show the download via the OS shell.
147 virtual void ShowDownloadInShell() = 0; 158 virtual void ShowDownloadInShell() = 0;
148 159
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 // return |name|. Has no effect on the final target filename. 331 // return |name|. Has no effect on the final target filename.
321 virtual void SetDisplayName(const base::FilePath& name) = 0; 332 virtual void SetDisplayName(const base::FilePath& name) = 0;
322 333
323 // Debug/testing ------------------------------------------------------------- 334 // Debug/testing -------------------------------------------------------------
324 virtual std::string DebugString(bool verbose) const = 0; 335 virtual std::string DebugString(bool verbose) const = 0;
325 }; 336 };
326 337
327 } // namespace content 338 } // namespace content
328 339
329 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ 340 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698