Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1199)

Unified Diff: chrome/browser/android/download_overwrite_infobar_delegate.h

Issue 580043002: [Android] Prompt with infobar on filename conflict (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: also handles use cases from ChromeDownloadDelegate Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..8da252f734e8d2346cb10bb9ff57141d9eaf53d2
--- /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"
+
+namespace content {
+class DownloadItem;
+}
+
+namespace chrome {
+namespace android {
+
+// A class to implement an infobar that asks if it is ok to overwrite an
Peter Kasting 2015/02/18 00:51:31 Nit: Remove "A class to implement"
Changwan Ryu 2015/02/18 07:15:02 Done.
+// 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, you can dismiss the infobar.
Peter Kasting 2015/02/18 00:51:31 Nit: "The user can dismiss the infobar to abort th
Changwan Ryu 2015/02/18 07:15:02 Done.
+//
+// Note that this infobar does not expire when the user navigates away.
Peter Kasting 2015/02/18 00:51:31 Nit: "when the user navigates away" -> "if the use
Changwan Ryu 2015/02/18 07:15:03 Done.
+class DownloadOverwriteInfoBarDelegate : public infobars::InfoBarDelegate {
+ public:
+ ~DownloadOverwriteInfoBarDelegate() override;
+
+ static infobars::InfoBar* Create(
Peter Kasting 2015/02/18 00:51:31 Looks like you don't use the return value, so retu
Changwan Ryu 2015/02/18 07:15:02 Done.
+ content::DownloadItem* download,
+ const base::FilePath& suggested_download_path,
+ const DownloadTargetDeterminerDelegate::FileSelectedCallback&
+ file_selected_callback);
+
+ // This is called when the user accepts overwriting.
+ bool AcceptOverwrite();
Peter Kasting 2015/02/18 00:51:31 Nit: Consider calling this OverwriteExistingFile()
Changwan Ryu 2015/02/18 07:15:03 Done.
+
+ static void CreateNewFileInternal(
Peter Kasting 2015/02/18 00:51:31 Nit: Add a comment explaining what this does, and
Changwan Ryu 2015/02/18 07:15:02 Done.
+ const base::FilePath& suggested_download_path,
+ const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback);
+
+ // This is called when the user chooses to create a new file.
+ bool CreateNewFile();
+
+ std::string GetFileName() const;
+ std::string GetDirName() const;
+ std::string GetDirFullPath() const;
+
+ // Implements InfoBarDelegate
Peter Kasting 2015/02/18 00:51:31 Nit: "infobars::InfoBarDelegate:"
Changwan Ryu 2015/02/18 07:15:02 Done.
+ void InfoBarDismissed() override;
Peter Kasting 2015/02/18 00:51:31 Nit: Swap the order of these two functions (to mat
Changwan Ryu 2015/02/18 07:15:03 Done.
+ bool ShouldExpire(const NavigationDetails& details) const override;
+
+ private:
+ DownloadOverwriteInfoBarDelegate(
+ content::DownloadItem* download,
+ const base::FilePath& suggested_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_

Powered by Google App Engine
This is Rietveld 408576698