1 // Copyright 2013 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_SHELL_BROWSER_SHELL_DOWNLOAD_MANAGER_DELEGATE_H_
6 #define CONTENT_SHELL_BROWSER_SHELL_DOWNLOAD_MANAGER_DELEGATE_H_
8 #include "base/callback_forward.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/weak_ptr.h"
11 #include "content/public/browser/download_manager_delegate.h"
15 class DownloadManager
;
17 class ShellDownloadManagerDelegate
: public DownloadManagerDelegate
{
19 ShellDownloadManagerDelegate();
20 virtual ~ShellDownloadManagerDelegate();
22 void SetDownloadManager(DownloadManager
* manager
);
24 virtual void Shutdown() OVERRIDE
;
25 virtual bool DetermineDownloadTarget(
26 DownloadItem
* download
,
27 const DownloadTargetCallback
& callback
) OVERRIDE
;
28 virtual bool ShouldOpenDownload(
30 const DownloadOpenDelayedCallback
& callback
) OVERRIDE
;
31 virtual void GetNextId(const DownloadIdCallback
& callback
) OVERRIDE
;
33 // Inhibits prompting and sets the default download path.
34 void SetDownloadBehaviorForTesting(
35 const base::FilePath
& default_download_path
);
38 friend class base::RefCountedThreadSafe
<ShellDownloadManagerDelegate
>;
40 typedef base::Callback
<void(const base::FilePath
&)>
41 FilenameDeterminedCallback
;
43 static void GenerateFilename(const GURL
& url
,
44 const std::string
& content_disposition
,
45 const std::string
& suggested_filename
,
46 const std::string
& mime_type
,
47 const base::FilePath
& suggested_directory
,
48 const FilenameDeterminedCallback
& callback
);
49 void OnDownloadPathGenerated(uint32 download_id
,
50 const DownloadTargetCallback
& callback
,
51 const base::FilePath
& suggested_path
);
52 void ChooseDownloadPath(uint32 download_id
,
53 const DownloadTargetCallback
& callback
,
54 const base::FilePath
& suggested_path
);
56 DownloadManager
* download_manager_
;
57 base::FilePath default_download_path_
;
58 bool suppress_prompting_
;
59 base::WeakPtrFactory
<ShellDownloadManagerDelegate
> weak_ptr_factory_
;
61 DISALLOW_COPY_AND_ASSIGN(ShellDownloadManagerDelegate
);
64 } // namespace content
66 #endif // CONTENT_SHELL_BROWSER_SHELL_DOWNLOAD_MANAGER_DELEGATE_H_