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