1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Copyright (c) 2013 Intel Corporation. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
6 #ifndef XWALK_RUNTIME_BROWSER_RUNTIME_DOWNLOAD_MANAGER_DELEGATE_H_
7 #define XWALK_RUNTIME_BROWSER_RUNTIME_DOWNLOAD_MANAGER_DELEGATE_H_
9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h"
11 #include "content/public/browser/download_manager_delegate.h"
15 class RuntimeDownloadManagerDelegate
16 : public content::DownloadManagerDelegate,
17 public base::RefCountedThreadSafe<RuntimeDownloadManagerDelegate> {
19 RuntimeDownloadManagerDelegate();
21 void SetDownloadManager(content::DownloadManager* manager);
23 void Shutdown() override;
24 bool DetermineDownloadTarget(
25 content::DownloadItem* download,
26 const content::DownloadTargetCallback& callback) override;
27 bool ShouldOpenDownload(
28 content::DownloadItem* item,
29 const content::DownloadOpenDelayedCallback& callback) override;
30 void GetNextId(const content::DownloadIdCallback& callback) override;
32 // Inhibits prompting and sets the default download path.
33 void SetDownloadBehaviorForTesting(
34 const base::FilePath& default_download_path);
37 // To allow subclasses for testing.
38 virtual ~RuntimeDownloadManagerDelegate();
41 friend class base::RefCountedThreadSafe<RuntimeDownloadManagerDelegate>;
43 void GenerateFilename(uint32 download_id,
44 const content::DownloadTargetCallback& callback,
45 const base::FilePath& generated_name,
46 const base::FilePath& suggested_directory);
47 void OnDownloadPathGenerated(uint32 download_id,
48 const content::DownloadTargetCallback& callback,
49 const base::FilePath& suggested_path);
50 void ChooseDownloadPath(uint32 download_id,
51 const content::DownloadTargetCallback& callback,
52 const base::FilePath& suggested_path);
54 content::DownloadManager* download_manager_;
55 base::FilePath default_download_path_;
56 bool suppress_prompting_;
58 DISALLOW_COPY_AND_ASSIGN(RuntimeDownloadManagerDelegate);
63 #endif // XWALK_RUNTIME_BROWSER_RUNTIME_DOWNLOAD_MANAGER_DELEGATE_H_