Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(527)

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

Issue 10704052: Download filename determination refactor (3/3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with r148594 to and resolve conflicts with r148576 Created 8 years, 4 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/file_path.h" 24 #include "base/file_path.h"
25 #include "base/string16.h" 25 #include "base/string16.h"
26 #include "content/public/browser/download_danger_type.h" 26 #include "content/public/browser/download_danger_type.h"
27 #include "content/public/browser/download_interrupt_reasons.h" 27 #include "content/public/browser/download_interrupt_reasons.h"
28 #include "content/public/common/page_transition_types.h" 28 #include "content/public/common/page_transition_types.h"
29 29
30 class DownloadFileManager;
31 class FilePath; 30 class FilePath;
32 class GURL; 31 class GURL;
33 struct DownloadCreateInfo; 32 struct DownloadCreateInfo;
34 33
35 namespace base { 34 namespace base {
36 class Time; 35 class Time;
37 class TimeDelta; 36 class TimeDelta;
38 } 37 }
39 38
40 namespace content { 39 namespace content {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 virtual const FilePath& GetFullPath() const = 0; 213 virtual const FilePath& GetFullPath() const = 0;
215 214
216 // Target path of an in-progress download. We may be downloading to a 215 // Target path of an in-progress download. We may be downloading to a
217 // temporary or intermediate file (specified by |current_path_|. Once the 216 // temporary or intermediate file (specified by |current_path_|. Once the
218 // download completes, we will rename the file to |target_path_|. 217 // download completes, we will rename the file to |target_path_|.
219 virtual const FilePath& GetTargetFilePath() const = 0; 218 virtual const FilePath& GetTargetFilePath() const = 0;
220 219
221 // Get the target disposition. 220 // Get the target disposition.
222 virtual TargetDisposition GetTargetDisposition() const = 0; 221 virtual TargetDisposition GetTargetDisposition() const = 0;
223 222
224 // Called when the target path has been determined. |target_path| is the
225 // suggested target path. |disposition| indicates how the target path should
226 // be used (see TargetDisposition). |danger_type| is the danger level of
227 // |target_path| as determined by the caller. If |disposition| is
228 // TARGET_DISPOSITION_PROMPT, then OnTargetPathSelected() should be called
229 // subsequently with the user's selected target path.
230 virtual void OnTargetPathDetermined(
231 const FilePath& target_path,
232 TargetDisposition disposition,
233 content::DownloadDangerType danger_type) = 0;
234
235 // This method should be called if and only if OnTargetPathDetermined() was
236 // called previously with disposition set to TARGET_DISPOSITION_PROMPT.
237 // |target_path| is the path that the user selected after being prompted for a
238 // target path.
239 virtual void OnTargetPathSelected(const FilePath& target_path) = 0;
240
241 // Called if a check of the download contents was performed and the results of 223 // Called if a check of the download contents was performed and the results of
242 // the test are available. This should only be called after AllDataSaved() is 224 // the test are available. This should only be called after AllDataSaved() is
243 // true. 225 // true.
244 virtual void OnContentCheckCompleted(DownloadDangerType danger_type) = 0; 226 virtual void OnContentCheckCompleted(DownloadDangerType danger_type) = 0;
245 227
246 virtual void OnIntermediatePathDetermined(DownloadFileManager* file_manager,
247 const FilePath& path) = 0;
248
249 virtual bool IsPersisted() const = 0; 228 virtual bool IsPersisted() const = 0;
250 229
251 // Accessors 230 // Accessors
252 virtual const std::string& GetHash() const = 0; 231 virtual const std::string& GetHash() const = 0;
253 virtual DownloadState GetState() const = 0; 232 virtual DownloadState GetState() const = 0;
254 virtual const GURL& GetURL() const = 0; 233 virtual const GURL& GetURL() const = 0;
255 virtual const std::vector<GURL>& GetUrlChain() const = 0; 234 virtual const std::vector<GURL>& GetUrlChain() const = 0;
256 virtual const GURL& GetOriginalUrl() const = 0; 235 virtual const GURL& GetOriginalUrl() const = 0;
257 virtual const GURL& GetReferrerUrl() const = 0; 236 virtual const GURL& GetReferrerUrl() const = 0;
258 virtual std::string GetSuggestedFilename() const = 0; 237 virtual std::string GetSuggestedFilename() const = 0;
(...skipping 16 matching lines...) Expand all
275 virtual bool GetFileExternallyRemoved() const = 0; 254 virtual bool GetFileExternallyRemoved() const = 0;
276 virtual SafetyState GetSafetyState() const = 0; 255 virtual SafetyState GetSafetyState() const = 0;
277 // Why |safety_state_| is not SAFE. 256 // Why |safety_state_| is not SAFE.
278 virtual DownloadDangerType GetDangerType() const = 0; 257 virtual DownloadDangerType GetDangerType() const = 0;
279 virtual bool IsDangerous() const = 0; 258 virtual bool IsDangerous() const = 0;
280 259
281 virtual bool GetAutoOpened() = 0; 260 virtual bool GetAutoOpened() = 0;
282 virtual FilePath GetTargetName() const = 0; 261 virtual FilePath GetTargetName() const = 0;
283 virtual const FilePath& GetForcedFilePath() const = 0; 262 virtual const FilePath& GetForcedFilePath() const = 0;
284 virtual bool HasUserGesture() const = 0; 263 virtual bool HasUserGesture() const = 0;
285 virtual content::PageTransition GetTransitionType() const = 0; 264 virtual PageTransition GetTransitionType() const = 0;
286 virtual bool IsOtr() const = 0; 265 virtual bool IsOtr() const = 0;
287 virtual bool IsTemporary() const = 0; 266 virtual bool IsTemporary() const = 0;
288 virtual void SetIsTemporary(bool temporary) = 0; 267 virtual void SetIsTemporary(bool temporary) = 0;
289 virtual void SetOpened(bool opened) = 0; 268 virtual void SetOpened(bool opened) = 0;
290 virtual bool GetOpened() const = 0; 269 virtual bool GetOpened() const = 0;
291 270
292 virtual const std::string& GetLastModifiedTime() const = 0; 271 virtual const std::string& GetLastModifiedTime() const = 0;
293 virtual const std::string& GetETag() const = 0; 272 virtual const std::string& GetETag() const = 0;
294 273
295 virtual DownloadInterruptReason GetLastReason() const = 0; 274 virtual DownloadInterruptReason GetLastReason() const = 0;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 virtual void SetExternalData(const void* key, ExternalData* data) = 0; 308 virtual void SetExternalData(const void* key, ExternalData* data) = 0;
330 309
331 virtual std::string DebugString(bool verbose) const = 0; 310 virtual std::string DebugString(bool verbose) const = 0;
332 311
333 virtual void MockDownloadOpenForTesting() = 0; 312 virtual void MockDownloadOpenForTesting() = 0;
334 }; 313 };
335 314
336 } // namespace content 315 } // namespace content
337 316
338 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ 317 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_
OLDNEW
« no previous file with comments | « content/browser/download/download_manager_impl_unittest.cc ('k') | content/public/browser/download_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698