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_PREVIEWS_PREVIEWS_INFOBAR_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_PREVIEWS_PREVIEWS_INFOBAR_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_PREVIEWS_PREVIEWS_INFOBAR_DELEGATE_H_ | 6 #define CHROME_BROWSER_PREVIEWS_PREVIEWS_INFOBAR_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | |
| 8 #include "components/infobars/core/confirm_infobar_delegate.h" | 9 #include "components/infobars/core/confirm_infobar_delegate.h" |
| 9 | 10 |
| 10 namespace content { | 11 namespace content { |
| 11 class WebContents; | 12 class WebContents; |
| 12 } | 13 } |
| 13 | 14 |
| 14 // Shows an infobar that lets the user know that a preview page has been loaded, | 15 // Shows an infobar that lets the user know that a preview page has been loaded, |
| 15 // and gives the user a link to reload the original page. This infobar will only | 16 // and gives the user a link to reload the original page. This infobar will only |
| 16 // be shown once per page load. Records UMA data for user interactions with the | 17 // be shown once per page load. Records UMA data for user interactions with the |
| 17 // infobar. | 18 // infobar. |
| 18 class PreviewsInfoBarDelegate : public ConfirmInfoBarDelegate { | 19 class PreviewsInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 19 public: | 20 public: |
| 20 // The type of the infobar. It controls the strings and what UMA data is | 21 // The type of the infobar. It controls the strings and what UMA data is |
| 21 // recorded for the infobar. | 22 // recorded for the infobar. |
| 22 enum PreviewsInfoBarType { | 23 enum PreviewsInfoBarType { |
| 23 LOFI, // Server-side image replacement. | 24 LOFI, // Server-side image replacement. |
| 24 LITE_PAGE, // Server-side page rewrite. | 25 LITE_PAGE, // Server-side page rewrite. |
| 25 OFFLINE, // Offline copy of the page. | 26 OFFLINE, // Offline copy of the page. |
| 26 }; | 27 }; |
| 27 | 28 |
| 29 typedef base::Callback<void(bool opt_out)> PreviewsUserLeavePreviewCallback; | |
|
megjablon
2016/11/09 00:19:11
Can we call this OnDismissPreviewsInfobarCallback?
RyanSturm
2016/11/09 18:47:13
Done.
| |
| 30 | |
| 28 // Actions on the previews infobar. This enum must remain synchronized with | 31 // Actions on the previews infobar. This enum must remain synchronized with |
| 29 // the enum of the same name in metrics/histograms/histograms.xml. | 32 // the enum of the same name in metrics/histograms/histograms.xml. |
| 30 enum PreviewsInfoBarAction { | 33 enum PreviewsInfoBarAction { |
| 31 INFOBAR_SHOWN = 0, | 34 INFOBAR_SHOWN = 0, |
| 32 INFOBAR_LOAD_ORIGINAL_CLICKED = 1, | 35 INFOBAR_LOAD_ORIGINAL_CLICKED = 1, |
| 33 INFOBAR_DISMISSED_BY_USER = 2, | 36 INFOBAR_DISMISSED_BY_USER = 2, |
| 34 INFOBAR_DISMISSED_BY_NAVIGATION = 3, | 37 INFOBAR_DISMISSED_BY_NAVIGATION = 3, |
| 35 INFOBAR_INDEX_BOUNDARY | 38 INFOBAR_INDEX_BOUNDARY |
| 36 }; | 39 }; |
| 37 | 40 |
| 38 ~PreviewsInfoBarDelegate() override; | 41 ~PreviewsInfoBarDelegate() override; |
| 39 | 42 |
| 40 // Creates a preview infobar and corresponding delegate and adds the infobar | 43 // Creates a preview infobar and corresponding delegate and adds the infobar |
| 41 // to InfoBarService. | 44 // to InfoBarService. |
| 42 static void Create(content::WebContents* web_contents, | 45 static void Create( |
| 43 PreviewsInfoBarType infobar_type); | 46 content::WebContents* web_contents, |
| 47 PreviewsInfoBarType infobar_type, | |
| 48 const PreviewsUserLeavePreviewCallback& user_leaving_preview_callback); | |
| 44 | 49 |
| 45 private: | 50 private: |
| 46 PreviewsInfoBarDelegate(content::WebContents* web_contents, | 51 PreviewsInfoBarDelegate( |
| 47 PreviewsInfoBarType infobar_type); | 52 content::WebContents* web_contents, |
| 53 PreviewsInfoBarType infobar_type, | |
| 54 const PreviewsUserLeavePreviewCallback& user_leaving_preview_callback); | |
| 48 | 55 |
| 49 // ConfirmInfoBarDelegate overrides: | 56 // ConfirmInfoBarDelegate overrides: |
| 50 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; | 57 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; |
| 51 int GetIconId() const override; | 58 int GetIconId() const override; |
| 52 bool ShouldExpire(const NavigationDetails& details) const override; | 59 bool ShouldExpire(const NavigationDetails& details) const override; |
| 53 void InfoBarDismissed() override; | 60 void InfoBarDismissed() override; |
| 54 base::string16 GetMessageText() const override; | 61 base::string16 GetMessageText() const override; |
| 55 int GetButtons() const override; | 62 int GetButtons() const override; |
| 56 base::string16 GetLinkText() const override; | 63 base::string16 GetLinkText() const override; |
| 57 bool LinkClicked(WindowOpenDisposition disposition) override; | 64 bool LinkClicked(WindowOpenDisposition disposition) override; |
| 58 | 65 |
| 59 PreviewsInfoBarType infobar_type_; | 66 PreviewsInfoBarType infobar_type_; |
| 60 | 67 |
| 68 PreviewsUserLeavePreviewCallback user_leaving_preview_callback_; | |
| 69 | |
| 61 DISALLOW_COPY_AND_ASSIGN(PreviewsInfoBarDelegate); | 70 DISALLOW_COPY_AND_ASSIGN(PreviewsInfoBarDelegate); |
| 62 }; | 71 }; |
| 63 | 72 |
| 64 #endif // CHROME_BROWSER_PREVIEWS_PREVIEWS_INFOBAR_DELEGATE_H_ | 73 #endif // CHROME_BROWSER_PREVIEWS_PREVIEWS_INFOBAR_DELEGATE_H_ |
| OLD | NEW |