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, |
36 const DownloadTargetDeterminerDelegate::FileSelectedCallback& | 32 const DownloadTargetDeterminerDelegate::FileSelectedCallback& |
37 file_selected_callback); | 33 file_selected_callback); |
38 | 34 |
39 // content::DownloadItem::Observer | 35 // content::DownloadItem::Observer |
40 void OnDownloadDestroyed(content::DownloadItem* download_item) override; | 36 void OnDownloadDestroyed(content::DownloadItem* download_item) override; |
41 | 37 |
42 private: | 38 private: |
43 ChromeDownloadManagerOverwriteInfoBarDelegate( | 39 ChromeDuplicateDownloadInfoBarDelegate( |
44 content::DownloadItem* download_item, | 40 content::DownloadItem* download_item, |
45 const base::FilePath& suggested_path, | 41 const base::FilePath& file_path, |
46 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback); | 42 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback); |
47 | 43 |
48 // DownloadOverwriteInfoBarDelegate: | 44 // DownloadOverwriteInfoBarDelegate: |
49 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; | 45 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; |
50 bool OverwriteExistingFile() override; | 46 bool Accept() override; |
51 bool CreateNewFile() override; | 47 bool Cancel() override; |
52 std::string GetFileName() const override; | 48 std::string GetFilePath() const override; |
53 std::string GetDirName() const override; | |
54 std::string GetDirFullPath() const override; | |
55 void InfoBarDismissed() override; | 49 void InfoBarDismissed() override; |
| 50 bool IsOffTheRecord() const override; |
| 51 |
56 | 52 |
57 // The download item that is requesting the infobar. Could get deleted while | 53 // The download item that is requesting the infobar. Could get deleted while |
58 // the infobar is showing. | 54 // the infobar is showing. |
59 content::DownloadItem* download_item_; | 55 content::DownloadItem* download_item_; |
60 | 56 |
61 // The suggested download path from download target determiner. This is used | 57 // 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. | 58 // file name that will be used. |
63 base::FilePath suggested_download_path_; | 59 base::FilePath file_path_; |
| 60 |
| 61 // Whether the download is off the record. |
| 62 bool is_off_the_record_; |
64 | 63 |
65 // A callback to download target determiner to notify that file selection | 64 // A callback to download target determiner to notify that file selection |
66 // is made (or cancelled). | 65 // is made (or cancelled). |
67 DownloadTargetDeterminerDelegate::FileSelectedCallback | 66 DownloadTargetDeterminerDelegate::FileSelectedCallback |
68 file_selected_callback_; | 67 file_selected_callback_; |
69 | 68 |
70 DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerOverwriteInfoBarDelegate); | 69 DISALLOW_COPY_AND_ASSIGN(ChromeDuplicateDownloadInfoBarDelegate); |
71 }; | 70 }; |
72 | 71 |
73 } // namespace android | 72 } // namespace android |
74 } // namespace chrome | 73 } // namespace chrome |
75 | 74 |
76 #endif // CHROME_BROWSER_ANDROID_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_OVERWRITE_INF
OBAR_DELEGATE_H_ | 75 #endif // CHROME_BROWSER_ANDROID_DOWNLOAD_CHROME_DUPLICATE_DOWNLOAD_INFOBAR_DEL
EGATE_H_ |
OLD | NEW |