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

Unified Diff: content/public/browser/download_manager_delegate.h

Issue 10704052: Download filename determination refactor (3/3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: content/public/browser/download_manager_delegate.h
diff --git a/content/public/browser/download_manager_delegate.h b/content/public/browser/download_manager_delegate.h
index a977ce01eac79ae40c4a6add80ac560dcb619af6..cfaad6d8962ad97310ffc3a14b3a1c3f37592e25 100644
--- a/content/public/browser/download_manager_delegate.h
+++ b/content/public/browser/download_manager_delegate.h
@@ -11,12 +11,13 @@
#include "base/logging.h"
#include "base/time.h"
#include "content/common/content_export.h"
+#include "content/public/browser/download_danger_type.h"
+#include "content/public/browser/download_item.h"
#include "content/public/browser/save_page_type.h"
namespace content {
class DownloadId;
-class DownloadItem;
class WebContents;
// Called by SavePackage when it creates a DownloadItem.
@@ -32,6 +33,18 @@ typedef base::Callback<void(const FilePath&,
const SavePackageDownloadCreatedCallback&)>
SavePackagePathPickedCallback;
+// Called with the results of DetermineDownloadTarget(). If the delegate decides
+// to cancel the download, then |target_path| should be set to an empty path. If
+// |target_path| is non-empty, then |intermediate_path| is required to be
+// non-empty and specify the path to the intermediate file (which could be the
+// same as |target_path|). Both |target_path| and |intermediate_path| are
+// expected to in the same directory.
+typedef base::Callback<void(
+ const FilePath& target_path,
+ content::DownloadItem::TargetDisposition disposition,
+ content::DownloadDangerType danger_type,
+ const FilePath& intermediate_path)> DownloadTargetCallback;
+
// Browser's download manager: manages all downloads and destination view.
class CONTENT_EXPORT DownloadManagerDelegate {
public:
@@ -41,23 +54,21 @@ class CONTENT_EXPORT DownloadManagerDelegate {
// Returns a new DownloadId.
virtual DownloadId GetNextId();
- // Notifies the delegate that a download is starting. The delegate can return
- // false to delay the start of the download, in which case it should call
- // DownloadManager::RestartDownload when it's ready.
- virtual bool ShouldStartDownload(int32 download_id);
-
- // Asks the user for the path for a download. The delegate calls
- // DownloadManager::FileSelected or DownloadManager::FileSelectionCanceled to
- // give the answer.
- virtual void ChooseDownloadPath(DownloadItem* item) {}
-
- // Allows the embedder to set an intermediate name for the download until it's
- // complete. The return value is the intermediate path to use. If the embedder
- // doesn't want to set an intermediate path, it should return
- // item.GetTargetFilePath(). If there's already a file at the returned path,
- // it will not be overwritten. Instead the path will be uniquified by adding a
- // suffix to the filename.
- virtual FilePath GetIntermediatePath(const DownloadItem& item);
+ // Called to notify the delegate that a new download |item| requires a
+ // download target to be determined. The delegate should return |true| if it
+ // will determine the target information and will invoke |callback|. The
+ // callback may be invoked directly (synchronously). If this function returns
+ // |false|, the download manager will continue the download using a default
+ // target path.
+ //
+ // The state of the |item| shouldn't be modified during the process of
+ // filename determination save for external data (GetExternalData() /
+ // SetExternalData()).
+ //
+ // If the download should be canceled, |callback| should be invoked with an
+ // empty |target_path| argument.
+ virtual bool DetermineDownloadTarget(DownloadItem* item,
+ const DownloadTargetCallback& callback);
// Called when the download system wants to alert a WebContents that a
// download has started, but the TabConetnts has gone away. This lets an

Powered by Google App Engine
This is Rietveld 408576698