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

Side by Side Diff: chrome/browser/previews/previews_infobar_delegate.h

Issue 2875993002: Converging the two previews type enums (Closed)
Patch Set: header change Created 3 years, 7 months 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_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 "components/infobars/core/confirm_infobar_delegate.h" 10 #include "components/infobars/core/confirm_infobar_delegate.h"
11 #include "components/previews/core/previews_experiments.h"
11 12
12 namespace content { 13 namespace content {
13 class WebContents; 14 class WebContents;
14 } 15 }
15 16
16 // Shows an infobar that lets the user know that a preview page has been loaded, 17 // Shows an infobar that lets the user know that a preview page has been loaded,
17 // and gives the user a link to reload the original page. This infobar will only 18 // and gives the user a link to reload the original page. This infobar will only
18 // be shown once per page load. Records UMA data for user interactions with the 19 // be shown once per page load. Records UMA data for user interactions with the
19 // infobar. 20 // infobar.
20 class PreviewsInfoBarDelegate : public ConfirmInfoBarDelegate { 21 class PreviewsInfoBarDelegate : public ConfirmInfoBarDelegate {
21 public: 22 public:
22 // The type of the infobar. It controls the strings and what UMA data is
23 // recorded for the infobar.
24 // TODO(ryansturm): Combine PreviewsInfoBarType with previews::PreviewsType.
25 // crbug.com/704335
26 enum PreviewsInfoBarType {
27 LOFI, // Image placeholders (both server and client implementations).
28 LITE_PAGE, // Server-side page rewrite.
29 OFFLINE, // Offline copy of the page.
30 };
31
32 typedef base::Callback<void(bool opt_out)> OnDismissPreviewsInfobarCallback; 23 typedef base::Callback<void(bool opt_out)> OnDismissPreviewsInfobarCallback;
33 24
34 // Actions on the previews infobar. This enum must remain synchronized with 25 // Actions on the previews infobar. This enum must remain synchronized with
35 // the enum of the same name in metrics/histograms/histograms.xml. 26 // the enum of the same name in metrics/histograms/histograms.xml.
36 enum PreviewsInfoBarAction { 27 enum PreviewsInfoBarAction {
37 INFOBAR_SHOWN = 0, 28 INFOBAR_SHOWN = 0,
38 INFOBAR_LOAD_ORIGINAL_CLICKED = 1, 29 INFOBAR_LOAD_ORIGINAL_CLICKED = 1,
39 INFOBAR_DISMISSED_BY_USER = 2, 30 INFOBAR_DISMISSED_BY_USER = 2,
40 INFOBAR_DISMISSED_BY_NAVIGATION = 3, 31 INFOBAR_DISMISSED_BY_NAVIGATION = 3,
41 INFOBAR_DISMISSED_BY_RELOAD = 4, 32 INFOBAR_DISMISSED_BY_RELOAD = 4,
42 INFOBAR_DISMISSED_BY_TAB_CLOSURE = 5, 33 INFOBAR_DISMISSED_BY_TAB_CLOSURE = 5,
43 INFOBAR_INDEX_BOUNDARY 34 INFOBAR_INDEX_BOUNDARY
44 }; 35 };
45 36
46 ~PreviewsInfoBarDelegate() override; 37 ~PreviewsInfoBarDelegate() override;
47 38
48 // Creates a preview infobar and corresponding delegate and adds the infobar 39 // Creates a preview infobar and corresponding delegate and adds the infobar
49 // to InfoBarService. 40 // to InfoBarService.
50 static void Create( 41 static void Create(
51 content::WebContents* web_contents, 42 content::WebContents* web_contents,
52 PreviewsInfoBarType infobar_type, 43 previews::PreviewsType infobar_type,
53 bool is_data_saver_user, 44 bool is_data_saver_user,
54 const OnDismissPreviewsInfobarCallback& on_dismiss_callback); 45 const OnDismissPreviewsInfobarCallback& on_dismiss_callback);
55 46
56 // ConfirmInfoBarDelegate overrides: 47 // ConfirmInfoBarDelegate overrides:
57 base::string16 GetMessageText() const override; 48 base::string16 GetMessageText() const override;
58 base::string16 GetLinkText() const override; 49 base::string16 GetLinkText() const override;
59 50
60 base::string16 GetTimestampText() const; 51 base::string16 GetTimestampText() const;
61 52
62 private: 53 private:
63 PreviewsInfoBarDelegate( 54 PreviewsInfoBarDelegate(
64 content::WebContents* web_contents, 55 content::WebContents* web_contents,
65 PreviewsInfoBarType infobar_type, 56 previews::PreviewsType infobar_type,
66 bool is_data_saver_user, 57 bool is_data_saver_user,
67 const OnDismissPreviewsInfobarCallback& on_dismiss_callback); 58 const OnDismissPreviewsInfobarCallback& on_dismiss_callback);
68 59
69 // ConfirmInfoBarDelegate overrides: 60 // ConfirmInfoBarDelegate overrides:
70 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; 61 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override;
71 int GetIconId() const override; 62 int GetIconId() const override;
72 bool ShouldExpire(const NavigationDetails& details) const override; 63 bool ShouldExpire(const NavigationDetails& details) const override;
73 void InfoBarDismissed() override; 64 void InfoBarDismissed() override;
74 int GetButtons() const override; 65 int GetButtons() const override;
75 bool LinkClicked(WindowOpenDisposition disposition) override; 66 bool LinkClicked(WindowOpenDisposition disposition) override;
76 67
77 PreviewsInfoBarType infobar_type_; 68 previews::PreviewsType previews_type_;
megjablon 2017/05/11 23:49:45 Either rename these all to previews_type or keep a
RyanSturm 2017/05/15 16:23:08 Done.
78 mutable PreviewsInfoBarAction infobar_dismissed_action_; 69 mutable PreviewsInfoBarAction infobar_dismissed_action_;
79 70
80 const base::string16 message_text_; 71 const base::string16 message_text_;
81 72
82 OnDismissPreviewsInfobarCallback on_dismiss_callback_; 73 OnDismissPreviewsInfobarCallback on_dismiss_callback_;
83 74
84 DISALLOW_COPY_AND_ASSIGN(PreviewsInfoBarDelegate); 75 DISALLOW_COPY_AND_ASSIGN(PreviewsInfoBarDelegate);
85 }; 76 };
86 77
87 #endif // CHROME_BROWSER_PREVIEWS_PREVIEWS_INFOBAR_DELEGATE_H_ 78 #endif // CHROME_BROWSER_PREVIEWS_PREVIEWS_INFOBAR_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698