Chromium Code Reviews| Index: chrome/browser/android/download_overwrite_infobar_delegate.h |
| diff --git a/chrome/browser/android/download_overwrite_infobar_delegate.h b/chrome/browser/android/download_overwrite_infobar_delegate.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9cecb5ea61ab513231d33006d243cf369ddaaa8a |
| --- /dev/null |
| +++ b/chrome/browser/android/download_overwrite_infobar_delegate.h |
| @@ -0,0 +1,80 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_ANDROID_DOWNLOAD_OVERWRITE_INFOBAR_DELEGATE_H_ |
| +#define CHROME_BROWSER_ANDROID_DOWNLOAD_OVERWRITE_INFOBAR_DELEGATE_H_ |
| + |
| +#include "base/callback.h" |
| +#include "base/files/file_path.h" |
| +#include "chrome/browser/download/download_target_determiner_delegate.h" |
| +#include "components/infobars/core/infobar_delegate.h" |
| + |
| +class InfoBarService; |
| + |
| +namespace chrome { |
| +namespace android { |
| + |
| +// An infobar that asks if it is ok to overwrite an |
| +// existing file. Due to limited disk space on Android, two options are |
| +// presented to the user when downloading a file whose name conflicts with an |
| +// already present file: |
| +// |
| +// 1. Overwrite the file. |
| +// 2. Create a new file. |
| +// |
| +// Also, the user can dismiss the infobar to abort the download. |
| +// |
| +// Note that this infobar does not expire if the user subsequently navigates, |
| +// since such navigations won't automatically cancel the underlying download. |
| +class DownloadOverwriteInfoBarDelegate : public infobars::InfoBarDelegate { |
| + public: |
| + ~DownloadOverwriteInfoBarDelegate() override; |
| + |
| + static void Create( |
| + InfoBarService* infobar_service, |
| + const base::FilePath& suggested_download_path, |
| + const DownloadTargetDeterminerDelegate::FileSelectedCallback& |
| + file_selected_callback); |
| + |
| + // This is called when the user chooses to overwrite the existing file. |
| + void OverwriteExistingFile(); |
| + |
| + // This is called when the user chooses to create a new file. |
| + void CreateNewFile(); |
| + |
| + std::string GetFileName() const; |
| + std::string GetDirName() const; |
| + 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.
|
| + |
| + private: |
| + DownloadOverwriteInfoBarDelegate( |
| + const base::FilePath& suggested_path, |
| + const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback); |
| + |
| + // 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.
|
| + bool ShouldExpire(const NavigationDetails& details) const override; |
| + void InfoBarDismissed() override; |
| + |
| + // 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.
|
| + // done, call |callback| in the UI thread. |
| + static void CreateNewFileInternal( |
| + const base::FilePath& suggested_download_path, |
| + const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback); |
| + |
| + // The suggested download path from download target determiner. This is used |
| + // to show users the file name and the directory that will be used. |
| + base::FilePath suggested_download_path_; |
| + |
| + // A callback to download target determiner to notify that file selection |
| + // is made (or cancelled). |
| + DownloadTargetDeterminerDelegate::FileSelectedCallback |
| + file_selected_callback_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(DownloadOverwriteInfoBarDelegate); |
| +}; |
| + |
| +} // namespace android |
| +} // namespace chrome |
| + |
| +#endif // CHROME_BROWSER_ANDROID_DOWNLOAD_OVERWRITE_INFOBAR_DELEGATE_H_ |