diff options
author | Torne (Richard Coles) <torne@google.com> | 2012-11-14 11:43:16 +0000 |
---|---|---|
committer | Torne (Richard Coles) <torne@google.com> | 2012-11-14 11:43:16 +0000 |
commit | 5821806d5e7f356e8fa4b058a389a808ea183019 (patch) | |
tree | e19f4793aac92e2c0d9a01087019a60d6657d838 /content/browser/download/download_item_impl_delegate.h | |
parent | 8e79a8efe247f109aafd917a69e8a392961b3687 (diff) | |
download | chromium_org-5821806d5e7f356e8fa4b058a389a808ea183019.tar.gz |
Merge from Chromium at DEPS revision r167172
This commit was generated by merge_to_master.py.
Change-Id: Ib8d56fd5ae39a2d7e8c91dcd76cc6d13f25f2aab
Diffstat (limited to 'content/browser/download/download_item_impl_delegate.h')
-rw-r--r-- | content/browser/download/download_item_impl_delegate.h | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/content/browser/download/download_item_impl_delegate.h b/content/browser/download/download_item_impl_delegate.h new file mode 100644 index 0000000000..323aa6b453 --- /dev/null +++ b/content/browser/download/download_item_impl_delegate.h @@ -0,0 +1,97 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_ +#define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_ + +#include "base/callback.h" +#include "base/file_path.h" +#include "content/common/content_export.h" +#include "content/public/browser/download_danger_type.h" +#include "content/public/browser/download_item.h" + +namespace content { +class DownloadItemImpl; +class BrowserContext; + +// Delegate for operations that a DownloadItemImpl can't do for itself. +// The base implementation of this class does nothing (returning false +// on predicates) so interfaces not of interest to a derived class may +// be left unimplemented. +class CONTENT_EXPORT DownloadItemImplDelegate { + public: + typedef base::Callback<void( + const FilePath&, // Target path + DownloadItem::TargetDisposition, // overwrite/uniquify target + DownloadDangerType, + const FilePath& // Intermediate file path + )> DownloadTargetCallback; + + // The boolean argument indicates whether or not the download was + // actually opened. + typedef base::Callback<void(bool)> ShouldOpenDownloadCallback; + + DownloadItemImplDelegate(); + virtual ~DownloadItemImplDelegate(); + + // Used for catching use-after-free errors. + void Attach(); + void Detach(); + + // Request determination of the download target from the delegate. + virtual void DetermineDownloadTarget( + DownloadItemImpl* download, const DownloadTargetCallback& callback); + + // Allows the delegate to delay completion of the download. This function + // will call the callback passed when the download is ready for completion. + // This may be done immediately, from within the routine itself, or it + // may be delayed. + // This routine should only be called once per download. + virtual void ReadyForDownloadCompletion( + DownloadItemImpl* download, + const base::Closure& complete_callback); + + // Allows the delegate to override the opening of a download. If it returns + // true then it's reponsible for opening the item. + virtual bool ShouldOpenDownload( + DownloadItemImpl* download, const ShouldOpenDownloadCallback& callback); + + // Tests if a file type should be opened automatically. + virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path); + + // Checks whether a downloaded file still exists and updates the + // file's state if the file is already removed. + // The check may or may not result in a later asynchronous call + // to OnDownloadedFileRemoved(). + virtual void CheckForFileRemoval(DownloadItemImpl* download_item); + + // For contextual issues like language and prefs. + virtual BrowserContext* GetBrowserContext() const; + + // Update the persistent store with our information. + virtual void UpdatePersistence(DownloadItemImpl* download); + + // Handle any delegate portions of a state change operation on the + // DownloadItem. + virtual void DownloadStopped(DownloadItemImpl* download); + virtual void DownloadCompleted(DownloadItemImpl* download); + virtual void DownloadOpened(DownloadItemImpl* download); + virtual void DownloadRemoved(DownloadItemImpl* download); + virtual void DownloadRenamedToIntermediateName( + DownloadItemImpl* download); + virtual void DownloadRenamedToFinalName(DownloadItemImpl* download); + + // Assert consistent state for delgate object at various transitions. + virtual void AssertStateConsistent(DownloadItemImpl* download) const; + + private: + // For "Outlives attached DownloadItemImpl" invariant assertion. + int count_; + + DISALLOW_COPY_AND_ASSIGN(DownloadItemImplDelegate); +}; + +} // namespace content + +#endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_ |