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

Side by Side Diff: chrome/browser/banners/app_banner_settings_helper.h

Issue 2553013004: Remove the app banner navigation heuristic. (Closed)
Patch Set: Rebase Created 4 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_BANNERS_APP_BANNER_SETTINGS_HELPER_H_ 5 #ifndef CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_
6 #define CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_ 6 #define CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector>
11 10
12 #include "base/macros.h" 11 #include "base/macros.h"
13 #include "base/time/time.h" 12 #include "base/time/time.h"
14 #include "chrome/browser/installable/installable_logging.h" 13 #include "chrome/browser/installable/installable_logging.h"
15 #include "ui/base/page_transition_types.h"
16 14
17 namespace content { 15 namespace content {
18 class WebContents; 16 class WebContents;
19 } // namespace content 17 } // namespace content
20 18
21 class GURL; 19 class GURL;
22 class Profile; 20 class Profile;
23 21
24 // Utility class to record banner events for the given package or start url. 22 // Utility class to record banner events for the given package or start url.
25 // 23 //
(...skipping 22 matching lines...) Expand all
48 LANGUAGE_OPTION_DEFAULT = 0, 46 LANGUAGE_OPTION_DEFAULT = 0,
49 LANGUAGE_OPTION_MIN = LANGUAGE_OPTION_DEFAULT, 47 LANGUAGE_OPTION_MIN = LANGUAGE_OPTION_DEFAULT,
50 LANGUAGE_OPTION_ADD = 1, 48 LANGUAGE_OPTION_ADD = 1,
51 LANGUAGE_OPTION_INSTALL = 2, 49 LANGUAGE_OPTION_INSTALL = 2,
52 LANGUAGE_OPTION_MAX = LANGUAGE_OPTION_INSTALL, 50 LANGUAGE_OPTION_MAX = LANGUAGE_OPTION_INSTALL,
53 }; 51 };
54 52
55 // TODO(mariakhomenko): Rename events to reflect that they are used in more 53 // TODO(mariakhomenko): Rename events to reflect that they are used in more
56 // contexts now. 54 // contexts now.
57 enum AppBannerEvent { 55 enum AppBannerEvent {
58 APP_BANNER_EVENT_COULD_SHOW, 56 APP_BANNER_EVENT_COULD_SHOW,
benwells 2016/12/09 04:55:05 Should this be renamed to something like "FIRST_CO
dominickn 2016/12/09 05:27:28 I thought about that. The upside of not changing t
benwells 2016/12/09 05:44:55 Right now it's really not clear what this data is.
dominickn 2016/12/12 02:23:14 Done.
59 APP_BANNER_EVENT_DID_SHOW, 57 APP_BANNER_EVENT_DID_SHOW,
60 APP_BANNER_EVENT_DID_BLOCK, 58 APP_BANNER_EVENT_DID_BLOCK,
61 APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, 59 APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN,
62 APP_BANNER_EVENT_NUM_EVENTS, 60 APP_BANNER_EVENT_NUM_EVENTS,
63 }; 61 };
64 62
65 enum AppBannerRapporMetric { 63 enum AppBannerRapporMetric {
66 WEB, 64 WEB,
67 NATIVE, 65 NATIVE,
68 }; 66 };
69 67
70 static const char kInstantAppsKey[]; 68 static const char kInstantAppsKey[];
71 69
72 // BannerEvents record the time that a site was accessed, along with an
73 // engagement weight representing the importance of the access.
74 struct BannerEvent {
75 base::Time time;
76 double engagement;
77 };
78
79 // The content setting basically records a simplified subset of history. 70 // The content setting basically records a simplified subset of history.
80 // For privacy reasons this needs to be cleared. The ClearHistoryForURLs 71 // For privacy reasons this needs to be cleared. The ClearHistoryForURLs
81 // function removes any information from the banner content settings for the 72 // function removes any information from the banner content settings for the
82 // given URls. 73 // given URls.
83 static void ClearHistoryForURLs(Profile* profile, 74 static void ClearHistoryForURLs(Profile* profile,
84 const std::set<GURL>& origin_urls); 75 const std::set<GURL>& origin_urls);
85 76
86 // Record a banner installation event, for either a WEB or NATIVE app. 77 // Record a banner installation event, for either a WEB or NATIVE app.
87 static void RecordBannerInstallEvent( 78 static void RecordBannerInstallEvent(
88 content::WebContents* web_contents, 79 content::WebContents* web_contents,
89 const std::string& package_name_or_start_url, 80 const std::string& package_name_or_start_url,
90 AppBannerRapporMetric rappor_metric); 81 AppBannerRapporMetric rappor_metric);
91 82
92 // Record a banner dismissal event, for either a WEB or NATIVE app. 83 // Record a banner dismissal event, for either a WEB or NATIVE app.
93 static void RecordBannerDismissEvent( 84 static void RecordBannerDismissEvent(
94 content::WebContents* web_contents, 85 content::WebContents* web_contents,
95 const std::string& package_name_or_start_url, 86 const std::string& package_name_or_start_url,
96 AppBannerRapporMetric rappor_metric); 87 AppBannerRapporMetric rappor_metric);
97 88
98 // Record a banner event. Should not be used for could show events, as they 89 // Record a banner event specified by |event|.
99 // require a transition type.
100 static void RecordBannerEvent(content::WebContents* web_contents, 90 static void RecordBannerEvent(content::WebContents* web_contents,
101 const GURL& origin_url, 91 const GURL& origin_url,
102 const std::string& package_name_or_start_url, 92 const std::string& package_name_or_start_url,
103 AppBannerEvent event, 93 AppBannerEvent event,
104 base::Time time); 94 base::Time time);
105 95
106 // Record a banner could show event, with a specified transition type.
107 static void RecordBannerCouldShowEvent(
108 content::WebContents* web_contents,
109 const GURL& origin_url,
110 const std::string& package_name_or_start_url,
111 base::Time time,
112 ui::PageTransition transition_type);
113
114 // Determine if the banner should be shown, given the recorded events for the 96 // Determine if the banner should be shown, given the recorded events for the
115 // supplied app. Returns an InstallableStatusCode indicated the reason why the 97 // supplied app. Returns an InstallableStatusCode indicated the reason why the
116 // banner shouldn't be shown, or NO_ERROR_DETECTED if it should be shown. 98 // banner shouldn't be shown, or NO_ERROR_DETECTED if it should be shown.
117 static InstallableStatusCode ShouldShowBanner( 99 static InstallableStatusCode ShouldShowBanner(
118 content::WebContents* web_contents, 100 content::WebContents* web_contents,
119 const GURL& origin_url, 101 const GURL& origin_url,
120 const std::string& package_name_or_start_url, 102 const std::string& package_name_or_start_url,
121 base::Time time); 103 base::Time time);
122 104
123 // Gets the could have been shown events that are stored for the given package 105 // Get the time that |event| was recorded, or a null time if it has not yet
124 // or start url. This is only exposed for testing. 106 // been recorded. Exposed for testing.
125 static std::vector<BannerEvent> GetCouldShowBannerEvents(
126 content::WebContents* web_contents,
127 const GURL& origin_url,
128 const std::string& package_name_or_start_url);
129
130 // Get the recorded event for an event type that only records the last event.
131 // Should not be used with APP_BANNER_EVENT_COULD_SHOW. This is only exposed
132 // for testing.
133 static base::Time GetSingleBannerEvent( 107 static base::Time GetSingleBannerEvent(
134 content::WebContents* web_contents, 108 content::WebContents* web_contents,
135 const GURL& origin_url, 109 const GURL& origin_url,
136 const std::string& package_name_or_start_url, 110 const std::string& package_name_or_start_url,
137 AppBannerEvent event); 111 AppBannerEvent event);
138 112
139 // Returns true if |total_engagement| is sufficiently high to warrant 113 // Returns true if |total_engagement| is sufficiently high to warrant
140 // triggering a banner, or if the command-line flag to bypass engagement 114 // triggering a banner, or if the command-line flag to bypass engagement
141 // checking is true. 115 // checking is true.
142 static bool HasSufficientEngagement(double total_engagement); 116 static bool HasSufficientEngagement(double total_engagement);
(...skipping 12 matching lines...) Expand all
155 // already been added to homescreen. 129 // already been added to homescreen.
156 static bool WasLaunchedRecently(Profile* profile, 130 static bool WasLaunchedRecently(Profile* profile,
157 const GURL& origin_url, 131 const GURL& origin_url,
158 base::Time now); 132 base::Time now);
159 133
160 // Set the number of days which dismissing/ignoring the banner should prevent 134 // Set the number of days which dismissing/ignoring the banner should prevent
161 // a banner from showing. 135 // a banner from showing.
162 static void SetDaysAfterDismissAndIgnoreToTrigger(unsigned int dismiss_days, 136 static void SetDaysAfterDismissAndIgnoreToTrigger(unsigned int dismiss_days,
163 unsigned int ignore_days); 137 unsigned int ignore_days);
164 138
165 // Set the engagement weights assigned to direct and indirect navigations.
166 static void SetEngagementWeights(double direct_engagement,
167 double indirect_engagement);
168
169 // Set the minimum number of minutes between banner visits that will
170 // trigger a could show banner event. This must be less than the
171 // number of minutes in a day, and evenly divide the number of minutes
172 // in a day.
173 static void SetMinimumMinutesBetweenVisits(unsigned int minutes);
174
175 // Set the total engagement weight required to trigger a banner. 139 // Set the total engagement weight required to trigger a banner.
176 static void SetTotalEngagementToTrigger(double total_engagement); 140 static void SetTotalEngagementToTrigger(double total_engagement);
177 141
178 // Resets the engagement weights, minimum minutes, and total engagement to 142 // Resets the engagement weights, minimum minutes, and total engagement to
179 // trigger to their default values. 143 // trigger to their default values.
180 static void SetDefaultParameters(); 144 static void SetDefaultParameters();
181 145
182 // Bucket a given time to the given resolution in local time.
183 static base::Time BucketTimeToResolution(base::Time time,
184 unsigned int minutes);
185
186 // Updates all values from field trial. 146 // Updates all values from field trial.
187 static void UpdateFromFieldTrial(); 147 static void UpdateFromFieldTrial();
188 148
189 // Queries variations to determine which language option should be used for 149 // Queries variations to determine which language option should be used for
190 // app banners and add to homescreen. 150 // app banners and add to homescreen.
191 static LanguageOption GetHomescreenLanguageOption(); 151 static LanguageOption GetHomescreenLanguageOption();
192 152
193 // Returns true if the app banner trigger condition should use the site
194 // engagement score instead of the navigation-based heuristic.
195 static bool ShouldUseSiteEngagementScore();
196
197 private: 153 private:
198 DISALLOW_IMPLICIT_CONSTRUCTORS(AppBannerSettingsHelper); 154 DISALLOW_IMPLICIT_CONSTRUCTORS(AppBannerSettingsHelper);
199 }; 155 };
200 156
201 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_ 157 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698