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

Side by Side 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 unified diff | Download patch
OLDNEW
(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 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
Peter Kasting 2015/02/18 00:51:31 Nit: Remove "A class to implement"
Changwan Ryu 2015/02/18 07:15:02 Done.
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. Create a new file.
27 //
28 // 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.
29 //
30 // 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.
31 class DownloadOverwriteInfoBarDelegate : public infobars::InfoBarDelegate {
32 public:
33 ~DownloadOverwriteInfoBarDelegate() override;
34
35 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.
36 content::DownloadItem* download,
37 const base::FilePath& suggested_download_path,
38 const DownloadTargetDeterminerDelegate::FileSelectedCallback&
39 file_selected_callback);
40
41 // This is called when the user accepts overwriting.
42 bool AcceptOverwrite();
Peter Kasting 2015/02/18 00:51:31 Nit: Consider calling this OverwriteExistingFile()
Changwan Ryu 2015/02/18 07:15:03 Done.
43
44 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.
45 const base::FilePath& suggested_download_path,
46 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback);
47
48 // This is called when the user chooses to create a new file.
49 bool CreateNewFile();
50
51 std::string GetFileName() const;
52 std::string GetDirName() const;
53 std::string GetDirFullPath() const;
54
55 // Implements InfoBarDelegate
Peter Kasting 2015/02/18 00:51:31 Nit: "infobars::InfoBarDelegate:"
Changwan Ryu 2015/02/18 07:15:02 Done.
56 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.
57 bool ShouldExpire(const NavigationDetails& details) const override;
58
59 private:
60 DownloadOverwriteInfoBarDelegate(
61 content::DownloadItem* download,
62 const base::FilePath& suggested_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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698