Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_forward.h" |
| 9 #include "chrome/browser/android/download/download_overwrite_infobar_delegate.h" | 9 #include "chrome/browser/android/download/download_overwrite_infobar_delegate.h" |
| 10 #include "components/infobars/core/infobar_delegate.h" | 10 #include "components/infobars/core/infobar_delegate.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 class WebContents; | 13 class WebContents; |
| 14 } | 14 } |
| 15 | 15 |
| 16 namespace offline_pages { | 16 namespace offline_pages { |
| 17 | 17 |
| 18 class OfflinePageInfoBarDelegate | 18 class OfflinePageInfoBarDelegate |
| 19 : public chrome::android::DownloadOverwriteInfoBarDelegate { | 19 : public chrome::android::DownloadOverwriteInfoBarDelegate { |
| 20 public: | 20 public: |
| 21 enum class Action { CONFIRM, OVERWRITE }; | |
|
fgorski
2016/10/10 18:08:21
s/CONFIRM/CREATE_NEW/
Logically both are confirma
| |
| 22 | |
| 21 // Creates an offline page infobar and a delegate and adds the infobar to the | 23 // Creates an offline page infobar and a delegate and adds the infobar to the |
| 22 // InfoBarService associated with |web_contents|. |page_name| is the name | 24 // InfoBarService associated with |web_contents|. |page_name| is the name |
| 23 // shown for this file in the infobar text. | 25 // shown for this file in the infobar text. |
| 24 static void Create(const base::Closure& confirm_continuation, | 26 static void Create(const base::Callback<void(Action)>& confirm_continuation, |
| 27 const std::string& downloads_label, | |
| 25 const std::string& page_name, | 28 const std::string& page_name, |
| 26 content::WebContents* web_contents); | 29 content::WebContents* web_contents); |
| 27 ~OfflinePageInfoBarDelegate() override; | 30 ~OfflinePageInfoBarDelegate() override; |
| 28 | 31 |
| 29 private: | 32 private: |
| 30 OfflinePageInfoBarDelegate(const base::Closure& confirm_continuation, | 33 OfflinePageInfoBarDelegate( |
| 31 const std::string& page_name); | 34 const base::Callback<void(Action)>& confirm_continuation, |
| 35 const std::string& downloads_label, | |
| 36 const std::string& page_name); | |
| 32 | 37 |
| 33 // DownloadOverwriteInfoBarDelegate: | 38 // DownloadOverwriteInfoBarDelegate: |
| 34 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; | 39 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; |
| 35 bool EqualsDelegate(InfoBarDelegate* delegate) const override; | 40 bool EqualsDelegate(InfoBarDelegate* delegate) const override; |
| 36 bool OverwriteExistingFile() override; | 41 bool OverwriteExistingFile() override; |
| 37 bool CreateNewFile() override; | 42 bool CreateNewFile() override; |
| 38 std::string GetFileName() const override; | 43 std::string GetFileName() const override; |
| 39 std::string GetDirName() const override; | 44 std::string GetDirName() const override; |
| 40 std::string GetDirFullPath() const override; | 45 std::string GetDirFullPath() const override; |
| 41 bool ShouldExpire(const NavigationDetails& details) const override; | 46 bool ShouldExpire(const NavigationDetails& details) const override; |
| 42 OfflinePageInfoBarDelegate* AsOfflinePageInfoBarDelegate() override; | 47 OfflinePageInfoBarDelegate* AsOfflinePageInfoBarDelegate() override; |
| 43 | 48 |
| 44 // Continuation called when the user chooses to create a new file. | 49 // Continuation called when the user chooses to create a new file. |
| 45 base::Closure confirm_continuation_; | 50 base::Callback<void(Action)> confirm_continuation_; |
| 46 | 51 |
| 52 std::string downloads_label_; | |
| 47 std::string page_name_; | 53 std::string page_name_; |
| 48 | 54 |
| 49 DISALLOW_COPY_AND_ASSIGN(OfflinePageInfoBarDelegate); | 55 DISALLOW_COPY_AND_ASSIGN(OfflinePageInfoBarDelegate); |
| 50 }; | 56 }; |
| 51 | 57 |
| 52 } // namespace offline_pages | 58 } // namespace offline_pages |
| 53 | 59 |
| 54 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_DOWNLOADS_OFFLINE_PAGE_INFOBAR_D ELEGATE_H_ | 60 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_DOWNLOADS_OFFLINE_PAGE_INFOBAR_D ELEGATE_H_ |
| OLD | NEW |