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 "base/callback.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "components/infobars/core/confirm_infobar_delegate.h" | 11 #include "components/infobars/core/confirm_infobar_delegate.h" |
12 #include "components/previews/core/previews_experiments.h" | 12 #include "components/previews/core/previews_experiments.h" |
13 | 13 |
14 class PreviewsInfoBarTabHelper; | |
15 | |
14 namespace content { | 16 namespace content { |
15 class WebContents; | 17 class WebContents; |
16 } | 18 } |
17 | 19 |
18 // Shows an infobar that lets the user know that a preview page has been loaded, | 20 // Shows an infobar that lets the user know that a preview page has been loaded, |
19 // and gives the user a link to reload the original page. This infobar will only | 21 // and gives the user a link to reload the original page. This infobar will only |
20 // be shown once per page load. Records UMA data for user interactions with the | 22 // be shown once per page load. Records UMA data for user interactions with the |
21 // infobar. | 23 // infobar. |
22 class PreviewsInfoBarDelegate : public ConfirmInfoBarDelegate { | 24 class PreviewsInfoBarDelegate : public ConfirmInfoBarDelegate { |
23 public: | 25 public: |
(...skipping 12 matching lines...) Expand all Loading... | |
36 }; | 38 }; |
37 | 39 |
38 // Values of the UMA Previews.InfoBarTimestamp histogram. This enum must | 40 // Values of the UMA Previews.InfoBarTimestamp histogram. This enum must |
39 // remain synchronized with the enum of the same name in | 41 // remain synchronized with the enum of the same name in |
40 // metrics/histograms/histograms.xml. | 42 // metrics/histograms/histograms.xml. |
41 enum PreviewsInfoBarTimestamp { | 43 enum PreviewsInfoBarTimestamp { |
42 TIMESTAMP_SHOWN = 0, | 44 TIMESTAMP_SHOWN = 0, |
43 TIMESTAMP_NOT_SHOWN_PREVIEW_NOT_STALE = 1, | 45 TIMESTAMP_NOT_SHOWN_PREVIEW_NOT_STALE = 1, |
44 TIMESTAMP_NOT_SHOWN_STALENESS_NEGATIVE = 2, | 46 TIMESTAMP_NOT_SHOWN_STALENESS_NEGATIVE = 2, |
45 TIMESTAMP_NOT_SHOWN_STALENESS_GREATER_THAN_MAX = 3, | 47 TIMESTAMP_NOT_SHOWN_STALENESS_GREATER_THAN_MAX = 3, |
48 TIMESTAMP_UPDATED_NOW_SHOWN = 4, | |
46 TIMESTAMP_INDEX_BOUNDARY | 49 TIMESTAMP_INDEX_BOUNDARY |
47 }; | 50 }; |
48 | 51 |
49 ~PreviewsInfoBarDelegate() override; | 52 ~PreviewsInfoBarDelegate() override; |
50 | 53 |
51 // Creates a preview infobar and corresponding delegate and adds the infobar | 54 // Creates a preview infobar and corresponding delegate and adds the infobar |
52 // to InfoBarService. | 55 // to InfoBarService. |
53 static void Create( | 56 static void Create( |
54 content::WebContents* web_contents, | 57 content::WebContents* web_contents, |
55 previews::PreviewsType previews_type, | 58 previews::PreviewsType previews_type, |
56 base::Time previews_freshness, | 59 base::Time previews_freshness, |
57 bool is_data_saver_user, | 60 bool is_data_saver_user, |
61 bool is_reload, | |
58 const OnDismissPreviewsInfobarCallback& on_dismiss_callback); | 62 const OnDismissPreviewsInfobarCallback& on_dismiss_callback); |
59 | 63 |
60 // ConfirmInfoBarDelegate overrides: | 64 // ConfirmInfoBarDelegate overrides: |
61 int GetIconId() const override; | 65 int GetIconId() const override; |
62 base::string16 GetMessageText() const override; | 66 base::string16 GetMessageText() const override; |
63 base::string16 GetLinkText() const override; | 67 base::string16 GetLinkText() const override; |
64 | 68 |
65 base::string16 GetTimestampText() const; | 69 base::string16 GetTimestampText() const; |
66 | 70 |
67 private: | 71 private: |
68 PreviewsInfoBarDelegate( | 72 PreviewsInfoBarDelegate( |
69 content::WebContents* web_contents, | 73 PreviewsInfoBarTabHelper* infobar_tab_helper, |
70 previews::PreviewsType previews_type, | 74 previews::PreviewsType previews_type, |
71 base::Time previews_freshness, | 75 base::Time previews_freshness, |
72 bool is_data_saver_user, | 76 bool is_data_saver_user, |
77 bool is_reload, | |
73 const OnDismissPreviewsInfobarCallback& on_dismiss_callback); | 78 const OnDismissPreviewsInfobarCallback& on_dismiss_callback); |
74 | 79 |
75 // ConfirmInfoBarDelegate overrides: | 80 // ConfirmInfoBarDelegate overrides: |
76 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; | 81 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; |
77 bool ShouldExpire(const NavigationDetails& details) const override; | 82 bool ShouldExpire(const NavigationDetails& details) const override; |
78 void InfoBarDismissed() override; | 83 void InfoBarDismissed() override; |
79 int GetButtons() const override; | 84 int GetButtons() const override; |
80 bool LinkClicked(WindowOpenDisposition disposition) override; | 85 bool LinkClicked(WindowOpenDisposition disposition) override; |
81 | 86 |
87 PreviewsInfoBarTabHelper* infobar_tab_helper_; | |
tbansal1
2017/06/23 23:13:31
Is this guaranteed to be non-null? May be add a co
megjablon
2017/06/23 23:39:24
Added a check in GetTimestampText instead. With th
| |
82 previews::PreviewsType previews_type_; | 88 previews::PreviewsType previews_type_; |
83 // The time at which the preview associated with this infobar was created. A | 89 // The time at which the preview associated with this infobar was created. A |
84 // value of zero means that the creation time is unknown. | 90 // value of zero means that the creation time is unknown. |
85 const base::Time previews_freshness_; | 91 const base::Time previews_freshness_; |
92 const bool is_reload_; | |
86 mutable PreviewsInfoBarAction infobar_dismissed_action_; | 93 mutable PreviewsInfoBarAction infobar_dismissed_action_; |
87 | 94 |
88 const base::string16 message_text_; | 95 const base::string16 message_text_; |
89 | 96 |
90 OnDismissPreviewsInfobarCallback on_dismiss_callback_; | 97 OnDismissPreviewsInfobarCallback on_dismiss_callback_; |
91 | 98 |
92 DISALLOW_COPY_AND_ASSIGN(PreviewsInfoBarDelegate); | 99 DISALLOW_COPY_AND_ASSIGN(PreviewsInfoBarDelegate); |
93 }; | 100 }; |
94 | 101 |
95 #endif // CHROME_BROWSER_PREVIEWS_PREVIEWS_INFOBAR_DELEGATE_H_ | 102 #endif // CHROME_BROWSER_PREVIEWS_PREVIEWS_INFOBAR_DELEGATE_H_ |
OLD | NEW |