Update ASan/Android runtime and setup script to LLVM r200682.
[chromium-blink-merge.git] / content / browser / download / download_item_impl_delegate.h
blob72e079b89630673cae049b706f29db81480f8fef
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_
8 #include "base/callback.h"
9 #include "base/files/file_path.h"
10 #include "content/common/content_export.h"
11 #include "content/public/browser/download_danger_type.h"
12 #include "content/public/browser/download_item.h"
13 #include "content/public/browser/download_url_parameters.h"
15 namespace content {
16 class DownloadItemImpl;
17 class BrowserContext;
19 // Delegate for operations that a DownloadItemImpl can't do for itself.
20 // The base implementation of this class does nothing (returning false
21 // on predicates) so interfaces not of interest to a derived class may
22 // be left unimplemented.
23 class CONTENT_EXPORT DownloadItemImplDelegate {
24 public:
25 typedef base::Callback<void(
26 const base::FilePath&, // Target path
27 DownloadItem::TargetDisposition, // overwrite/uniquify target
28 DownloadDangerType,
29 const base::FilePath& // Intermediate file path
30 )> DownloadTargetCallback;
32 // The boolean argument indicates whether or not the download was
33 // actually opened.
34 typedef base::Callback<void(bool)> ShouldOpenDownloadCallback;
36 DownloadItemImplDelegate();
37 virtual ~DownloadItemImplDelegate();
39 // Used for catching use-after-free errors.
40 void Attach();
41 void Detach();
43 // Request determination of the download target from the delegate.
44 virtual void DetermineDownloadTarget(
45 DownloadItemImpl* download, const DownloadTargetCallback& callback);
47 // Allows the delegate to delay completion of the download. This function
48 // will either return true (if the download may complete now) or will return
49 // false and call the provided callback at some future point. This function
50 // may be called repeatedly.
51 virtual bool ShouldCompleteDownload(
52 DownloadItemImpl* download,
53 const base::Closure& complete_callback);
55 // Allows the delegate to override the opening of a download. If it returns
56 // true then it's reponsible for opening the item.
57 virtual bool ShouldOpenDownload(
58 DownloadItemImpl* download, const ShouldOpenDownloadCallback& callback);
60 // Tests if a file type should be opened automatically.
61 virtual bool ShouldOpenFileBasedOnExtension(const base::FilePath& path);
63 // Checks whether a downloaded file still exists and updates the
64 // file's state if the file is already removed.
65 // The check may or may not result in a later asynchronous call
66 // to OnDownloadedFileRemoved().
67 virtual void CheckForFileRemoval(DownloadItemImpl* download_item);
69 // Called when an interrupted download is resumed.
70 virtual void ResumeInterruptedDownload(
71 scoped_ptr<content::DownloadUrlParameters> params,
72 uint32 id);
74 // For contextual issues like language and prefs.
75 virtual BrowserContext* GetBrowserContext() const;
77 // Update the persistent store with our information.
78 virtual void UpdatePersistence(DownloadItemImpl* download);
80 // Opens the file associated with this download.
81 virtual void OpenDownload(DownloadItemImpl* download);
83 // Shows the download via the OS shell.
84 virtual void ShowDownloadInShell(DownloadItemImpl* download);
86 // Handle any delegate portions of a state change operation on the
87 // DownloadItem.
88 virtual void DownloadRemoved(DownloadItemImpl* download);
90 // Assert consistent state for delgate object at various transitions.
91 virtual void AssertStateConsistent(DownloadItemImpl* download) const;
93 private:
94 // For "Outlives attached DownloadItemImpl" invariant assertion.
95 int count_;
97 DISALLOW_COPY_AND_ASSIGN(DownloadItemImplDelegate);
100 } // namespace content
102 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_