OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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_OVERWRITE_INFOBAR_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_ANDROID_DOWNLOAD_OVERWRITE_INFOBAR_DELEGATE_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/files/file_path.h" |
| 10 #include "chrome/browser/download/download_target_determiner_delegate.h" |
| 11 #include "components/infobars/core/infobar_delegate.h" |
| 12 |
| 13 namespace content { |
| 14 class DownloadItem; |
| 15 } |
| 16 |
| 17 namespace chrome { |
| 18 namespace android { |
| 19 |
| 20 // A class to implement an infobar that asks if it is ok to overwrite an |
| 21 // existing file. Due to limited disk space on Android, two options are |
| 22 // presented to the user when downloading a file whose name conflicts with an |
| 23 // already present file: |
| 24 // |
| 25 // 1. Overwrite the file. |
| 26 // 2. Do not download. |
| 27 // |
| 28 // Also, you can close the infobar. |
| 29 class DownloadOverwriteInfoBarDelegate : public infobars::InfoBarDelegate { |
| 30 public: |
| 31 ~DownloadOverwriteInfoBarDelegate() override; |
| 32 |
| 33 static infobars::InfoBar* Create( |
| 34 content::DownloadItem* download, |
| 35 const base::FilePath& suggested_download_path, |
| 36 const DownloadTargetDeterminerDelegate::FileSelectedCallback& |
| 37 file_selected_callback); |
| 38 |
| 39 // This is called when the user accepts overwriting. |
| 40 bool AcceptOverwrite(); |
| 41 |
| 42 // This is called when the user chooses to create a new file. |
| 43 bool CreateNewFile(); |
| 44 |
| 45 std::string GetFileName() const; |
| 46 std::string GetDirName() const; |
| 47 std::string GetDirFullPath() const; |
| 48 |
| 49 // Implements InfoBarDelegate |
| 50 void InfoBarDismissed() override; |
| 51 |
| 52 private: |
| 53 DownloadOverwriteInfoBarDelegate( |
| 54 content::DownloadItem* download, |
| 55 const base::FilePath& suggested_path, |
| 56 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback); |
| 57 |
| 58 // The suggested download path from download target determiner. This is used |
| 59 // to show users the file name and the directory that will be used. |
| 60 base::FilePath suggested_download_path_; |
| 61 |
| 62 // A callback to download target determiner to notify that file selection |
| 63 // is made (or cancelled). |
| 64 DownloadTargetDeterminerDelegate::FileSelectedCallback |
| 65 file_selected_callback_; |
| 66 |
| 67 DISALLOW_COPY_AND_ASSIGN(DownloadOverwriteInfoBarDelegate); |
| 68 }; |
| 69 |
| 70 } // namespace android |
| 71 } // namespace chrome |
| 72 |
| 73 #endif // CHROME_BROWSER_ANDROID_DOWNLOAD_OVERWRITE_INFOBAR_DELEGATE_H_ |
OLD | NEW |