OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_ANDROID_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_OVERWRITE_INFOBA
R_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_DOWNLOAD_CHROME_DUPLICATE_DOWNLOAD_INFOBAR_DELEGA
TE_H_ |
6 #define CHROME_BROWSER_ANDROID_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_OVERWRITE_INFOBA
R_DELEGATE_H_ | 6 #define CHROME_BROWSER_ANDROID_DOWNLOAD_CHROME_DUPLICATE_DOWNLOAD_INFOBAR_DELEGA
TE_H_ |
7 | 7 |
8 #include "base/android/scoped_java_ref.h" | |
9 #include "base/callback.h" | 8 #include "base/callback.h" |
10 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
11 #include "base/macros.h" | 10 #include "base/macros.h" |
12 #include "chrome/browser/android/download/download_overwrite_infobar_delegate.h" | 11 #include "chrome/browser/android/download/duplicate_download_infobar_delegate.h" |
13 #include "chrome/browser/download/download_path_reservation_tracker.h" | |
14 #include "chrome/browser/download/download_target_determiner_delegate.h" | 12 #include "chrome/browser/download/download_target_determiner_delegate.h" |
15 #include "components/infobars/core/infobar_delegate.h" | 13 #include "components/infobars/core/infobar_delegate.h" |
16 #include "content/public/browser/download_item.h" | 14 #include "content/public/browser/download_item.h" |
17 | 15 |
18 using base::android::ScopedJavaGlobalRef; | |
19 | |
20 class InfoBarService; | 16 class InfoBarService; |
21 | 17 |
22 namespace chrome { | 18 namespace chrome { |
23 namespace android { | 19 namespace android { |
24 | 20 |
25 // An infobar delegate that starts from the given file path. | 21 // An infobar delegate that starts from the given file path. |
26 class ChromeDownloadManagerOverwriteInfoBarDelegate | 22 class ChromeDuplicateDownloadInfoBarDelegate |
27 : public DownloadOverwriteInfoBarDelegate, | 23 : public DuplicateDownloadInfoBarDelegate, |
28 public content::DownloadItem::Observer { | 24 public content::DownloadItem::Observer { |
29 public: | 25 public: |
30 ~ChromeDownloadManagerOverwriteInfoBarDelegate() override; | 26 ~ChromeDuplicateDownloadInfoBarDelegate() override; |
31 | 27 |
32 static void Create( | 28 static void Create( |
33 InfoBarService* infobar_service, | 29 InfoBarService* infobar_service, |
34 content::DownloadItem* download_item, | 30 content::DownloadItem* download_item, |
35 const base::FilePath& suggested_download_path, | 31 const base::FilePath& file_path, |
| 32 bool is_off_the_record, |
36 const DownloadTargetDeterminerDelegate::FileSelectedCallback& | 33 const DownloadTargetDeterminerDelegate::FileSelectedCallback& |
37 file_selected_callback); | 34 file_selected_callback); |
38 | 35 |
39 // content::DownloadItem::Observer | 36 // content::DownloadItem::Observer |
40 void OnDownloadDestroyed(content::DownloadItem* download_item) override; | 37 void OnDownloadDestroyed(content::DownloadItem* download_item) override; |
41 | 38 |
42 private: | 39 private: |
43 ChromeDownloadManagerOverwriteInfoBarDelegate( | 40 ChromeDuplicateDownloadInfoBarDelegate( |
44 content::DownloadItem* download_item, | 41 content::DownloadItem* download_item, |
45 const base::FilePath& suggested_path, | 42 const base::FilePath& file_path, |
| 43 bool is_off_the_record, |
46 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback); | 44 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback); |
47 | 45 |
48 // DownloadOverwriteInfoBarDelegate: | 46 // DownloadOverwriteInfoBarDelegate: |
49 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; | 47 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; |
50 bool OverwriteExistingFile() override; | 48 bool Accept() override; |
51 bool CreateNewFile() override; | 49 bool Cancel() override; |
52 std::string GetFileName() const override; | 50 std::string GetFilePath() const override; |
53 std::string GetDirName() const override; | |
54 std::string GetDirFullPath() const override; | |
55 void InfoBarDismissed() override; | 51 void InfoBarDismissed() override; |
| 52 bool IsOffTheRecord() const override; |
| 53 |
56 | 54 |
57 // The download item that is requesting the infobar. Could get deleted while | 55 // The download item that is requesting the infobar. Could get deleted while |
58 // the infobar is showing. | 56 // the infobar is showing. |
59 content::DownloadItem* download_item_; | 57 content::DownloadItem* download_item_; |
60 | 58 |
61 // The suggested download path from download target determiner. This is used | 59 // The target file path to be downloaded. This is used to show users the |
62 // to show users the file name and the directory that will be used. | 60 // file name that will be used. |
63 base::FilePath suggested_download_path_; | 61 base::FilePath file_path_; |
| 62 |
| 63 // Whether the download is off the record. |
| 64 bool is_off_the_record_; |
64 | 65 |
65 // A callback to download target determiner to notify that file selection | 66 // A callback to download target determiner to notify that file selection |
66 // is made (or cancelled). | 67 // is made (or cancelled). |
67 DownloadTargetDeterminerDelegate::FileSelectedCallback | 68 DownloadTargetDeterminerDelegate::FileSelectedCallback |
68 file_selected_callback_; | 69 file_selected_callback_; |
69 | 70 |
70 DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerOverwriteInfoBarDelegate); | 71 DISALLOW_COPY_AND_ASSIGN(ChromeDuplicateDownloadInfoBarDelegate); |
71 }; | 72 }; |
72 | 73 |
73 } // namespace android | 74 } // namespace android |
74 } // namespace chrome | 75 } // namespace chrome |
75 | 76 |
76 #endif // CHROME_BROWSER_ANDROID_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_OVERWRITE_INF
OBAR_DELEGATE_H_ | 77 #endif // CHROME_BROWSER_ANDROID_DOWNLOAD_CHROME_DUPLICATE_DOWNLOAD_INFOBAR_DEL
EGATE_H_ |
OLD | NEW |