Chromium Code Reviews| 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_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 class InfoBarService; | |
| 14 | |
| 15 namespace chrome { | |
| 16 namespace android { | |
| 17 | |
| 18 // An infobar that asks if it is ok to overwrite an | |
| 19 // existing file. Due to limited disk space on Android, two options are | |
| 20 // presented to the user when downloading a file whose name conflicts with an | |
| 21 // already present file: | |
| 22 // | |
| 23 // 1. Overwrite the file. | |
| 24 // 2. Create a new file. | |
| 25 // | |
| 26 // Also, the user can dismiss the infobar to abort the download. | |
| 27 // | |
| 28 // Note that this infobar does not expire if the user subsequently navigates, | |
| 29 // since such navigations won't automatically cancel the underlying download. | |
| 30 class DownloadOverwriteInfoBarDelegate : public infobars::InfoBarDelegate { | |
| 31 public: | |
| 32 ~DownloadOverwriteInfoBarDelegate() override; | |
| 33 | |
| 34 static void Create( | |
| 35 InfoBarService* infobar_service, | |
| 36 const base::FilePath& suggested_download_path, | |
| 37 const DownloadTargetDeterminerDelegate::FileSelectedCallback& | |
| 38 file_selected_callback); | |
| 39 | |
| 40 // This is called when the user chooses to overwrite the existing file. | |
| 41 void OverwriteExistingFile(); | |
| 42 | |
| 43 // This is called when the user chooses to create a new file. | |
| 44 void CreateNewFile(); | |
| 45 | |
| 46 std::string GetFileName() const; | |
| 47 std::string GetDirName() const; | |
| 48 std::string GetDirFullPath() const; | |
|
Peter Kasting
2015/02/18 21:32:28
Instead of these three out-of-line accessors, just
Changwan Ryu
2015/02/19 07:41:15
Done.
| |
| 49 | |
| 50 private: | |
| 51 DownloadOverwriteInfoBarDelegate( | |
| 52 const base::FilePath& suggested_path, | |
| 53 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback); | |
| 54 | |
| 55 // Implements infobars::InfoBarDelegate | |
|
Peter Kasting
2015/02/18 21:32:28
Nit: Remove "Implements " and add trailing colon
Changwan Ryu
2015/02/19 07:41:15
Done.
| |
| 56 bool ShouldExpire(const NavigationDetails& details) const override; | |
| 57 void InfoBarDismissed() override; | |
| 58 | |
| 59 // Create a new file in content::BrowserThread::FILE thread, and when it's | |
|
Peter Kasting
2015/02/18 21:32:28
Nit: Use descriptive ("creates") verbs, not impera
Changwan Ryu
2015/02/19 07:41:15
Done.
| |
| 60 // done, call |callback| in the UI thread. | |
| 61 static void CreateNewFileInternal( | |
| 62 const base::FilePath& suggested_download_path, | |
| 63 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback); | |
| 64 | |
| 65 // The suggested download path from download target determiner. This is used | |
| 66 // to show users the file name and the directory that will be used. | |
| 67 base::FilePath suggested_download_path_; | |
| 68 | |
| 69 // A callback to download target determiner to notify that file selection | |
| 70 // is made (or cancelled). | |
| 71 DownloadTargetDeterminerDelegate::FileSelectedCallback | |
| 72 file_selected_callback_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(DownloadOverwriteInfoBarDelegate); | |
| 75 }; | |
| 76 | |
| 77 } // namespace android | |
| 78 } // namespace chrome | |
| 79 | |
| 80 #endif // CHROME_BROWSER_ANDROID_DOWNLOAD_OVERWRITE_INFOBAR_DELEGATE_H_ | |
| OLD | NEW |