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

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: addressed comments and added 'create new file' behavior Created 6 years, 1 month 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 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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698