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

Side by Side Diff: chrome/browser/android/offline_pages/downloads/offline_page_infobar_delegate.h

Issue 2478583004: implementation for new duplicate download UI (Closed)
Patch Set: do null check on webcontents Created 4 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_DOWNLOADS_OFFLINE_PAGE_INFOBAR_DELE GATE_H_ 5 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_DOWNLOADS_OFFLINE_PAGE_INFOBAR_DELE GATE_H_
6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_DOWNLOADS_OFFLINE_PAGE_INFOBAR_DELE GATE_H_ 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_DOWNLOADS_OFFLINE_PAGE_INFOBAR_DELE GATE_H_
7 7
8 #include "base/callback_forward.h" 8 #include "base/callback.h"
9 #include "chrome/browser/android/download/download_overwrite_infobar_delegate.h" 9 #include "chrome/browser/android/download/duplicate_download_infobar_delegate.h"
10 #include "components/infobars/core/infobar_delegate.h" 10 #include "components/infobars/core/infobar_delegate.h"
11 #include "url/gurl.h" 11 #include "url/gurl.h"
12 12
13 namespace content { 13 namespace content {
14 class WebContents; 14 class WebContents;
15 } 15 }
16 16
17 namespace offline_pages { 17 namespace offline_pages {
18 18
19 // An InfoBarDelegate that appears when a user attempt to save offline pages for 19 // An InfoBarDelegate that appears when a user attempt to save offline pages for
20 // a URL that is already saved. This piggy-backs off the Download infobar, 20 // a URL that is already saved. This piggy-backs off the Download infobar,
21 // since the UI should be the same between Downloads and Offline Pages in this 21 // since the UI should be the same between Downloads and Offline Pages in this
22 // case. There are two actions: Create New, and Overwrite. Since Overwrite is 22 // case. There are two actions: Create New, and Overwrite. Since Overwrite is
23 // not straightforward for offline pages, the behavior is to delete ALL other 23 // not straightforward for offline pages, the behavior is to delete ALL other
24 // pages that are saved for the given URL, then save the newly requested page. 24 // pages that are saved for the given URL, then save the newly requested page.
25 class OfflinePageInfoBarDelegate 25 class OfflinePageInfoBarDelegate
26 : public chrome::android::DownloadOverwriteInfoBarDelegate { 26 : public chrome::android::DuplicateDownloadInfoBarDelegate {
27 public: 27 public:
28 enum class Action { CREATE_NEW, OVERWRITE };
29
30 // Creates an offline page infobar and a delegate and adds the infobar to the 28 // Creates an offline page infobar and a delegate and adds the infobar to the
31 // InfoBarService associated with |web_contents|. |page_name| is the name 29 // InfoBarService associated with |web_contents|. |page_name| is the name
32 // shown for this file in the infobar text. 30 // shown for this file in the infobar text.
33 static void Create(const base::Callback<void(Action)>& confirm_continuation, 31 static void Create(const base::Closure& confirm_continuation,
34 const std::string& downloads_label,
35 const GURL& page_to_download, 32 const GURL& page_to_download,
36 content::WebContents* web_contents); 33 content::WebContents* web_contents);
37 ~OfflinePageInfoBarDelegate() override; 34 ~OfflinePageInfoBarDelegate() override;
38 35
39 private: 36 private:
40 OfflinePageInfoBarDelegate( 37 OfflinePageInfoBarDelegate(
41 const base::Callback<void(Action)>& confirm_continuation, 38 const base::Closure& confirm_continuation,
42 const std::string& downloads_label, 39 const std::string& page_name,
43 const std::string& page_name); 40 const GURL& page_to_download);
44 41
45 // DownloadOverwriteInfoBarDelegate: 42 // DuplicateDownloadInfoBarDelegate:
46 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; 43 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override;
47 bool EqualsDelegate(InfoBarDelegate* delegate) const override; 44 bool EqualsDelegate(InfoBarDelegate* delegate) const override;
48 bool OverwriteExistingFile() override; 45 bool Accept() override;
49 bool CreateNewFile() override; 46 bool Cancel() override;
50 std::string GetFileName() const override; 47 std::string GetFilePath() const override;
51 std::string GetDirName() const override; 48 bool IsOfflinePage() const override;
52 std::string GetDirFullPath() const override; 49 std::string GetPageURL() const override;
53 bool ShouldExpire(const NavigationDetails& details) const override; 50 bool ShouldExpire(const NavigationDetails& details) const override;
54 OfflinePageInfoBarDelegate* AsOfflinePageInfoBarDelegate() override; 51 OfflinePageInfoBarDelegate* AsOfflinePageInfoBarDelegate() override;
55 52
56 // Continuation called when the user chooses to create a new file. 53 // Continuation called when the user chooses to create a new file.
57 base::Callback<void(Action)> confirm_continuation_; 54 base::Closure confirm_continuation_;
58 55
59 std::string downloads_label_;
60 std::string page_name_; 56 std::string page_name_;
57 GURL page_to_download_;
61 58
62 DISALLOW_COPY_AND_ASSIGN(OfflinePageInfoBarDelegate); 59 DISALLOW_COPY_AND_ASSIGN(OfflinePageInfoBarDelegate);
63 }; 60 };
64 61
65 } // namespace offline_pages 62 } // namespace offline_pages
66 63
67 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_DOWNLOADS_OFFLINE_PAGE_INFOBAR_D ELEGATE_H_ 64 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_DOWNLOADS_OFFLINE_PAGE_INFOBAR_D ELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698