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

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

Issue 2553013004: Remove the app banner navigation heuristic. (Closed)
Patch Set: Add comments 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 19 matching lines...) Expand all
45 // A Java counterpart will be generated for this enum. 43 // A Java counterpart will be generated for this enum.
46 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.banners 44 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.banners
47 enum LanguageOption { 45 enum LanguageOption {
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
53 // The various types of banner events recorded as timestamps in the app banner
54 // content setting per origin and package_name_or_start_url pair. This enum
55 // corresponds to the kBannerEventsKeys array.
55 // TODO(mariakhomenko): Rename events to reflect that they are used in more 56 // TODO(mariakhomenko): Rename events to reflect that they are used in more
56 // contexts now. 57 // contexts now.
57 enum AppBannerEvent { 58 enum AppBannerEvent {
59 // Records the first time that a site met the conditions to show a banner.
60 // Used for computing the MinutesFromFirstVisitToBannerShown metric.
58 APP_BANNER_EVENT_COULD_SHOW, 61 APP_BANNER_EVENT_COULD_SHOW,
62 // Records the latest time a banner was shown to the user. Used to suppress
63 // the banner from being shown too often.
59 APP_BANNER_EVENT_DID_SHOW, 64 APP_BANNER_EVENT_DID_SHOW,
65 // Records the latest time a banner was dismissed by the user. Used to
66 // suppress the banenr for some time if the user explicitly didn't want it.
60 APP_BANNER_EVENT_DID_BLOCK, 67 APP_BANNER_EVENT_DID_BLOCK,
68 // Records the latest time the user adds a site to the homescreen from a
69 // banner, or launched that site from homescreen. Used to ensure banenrs are
70 // not shown for sites which were added, and to determine if sites were
71 // launched recently.
61 APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, 72 APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN,
62 APP_BANNER_EVENT_NUM_EVENTS, 73 APP_BANNER_EVENT_NUM_EVENTS,
63 }; 74 };
64 75
65 enum AppBannerRapporMetric { 76 enum AppBannerRapporMetric {
66 WEB, 77 WEB,
67 NATIVE, 78 NATIVE,
68 }; 79 };
69 80
70 static const char kInstantAppsKey[]; 81 static const char kInstantAppsKey[];
71 82
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. 83 // The content setting basically records a simplified subset of history.
80 // For privacy reasons this needs to be cleared. The ClearHistoryForURLs 84 // For privacy reasons this needs to be cleared. The ClearHistoryForURLs
81 // function removes any information from the banner content settings for the 85 // function removes any information from the banner content settings for the
82 // given URls. 86 // given URls.
83 static void ClearHistoryForURLs(Profile* profile, 87 static void ClearHistoryForURLs(Profile* profile,
84 const std::set<GURL>& origin_urls); 88 const std::set<GURL>& origin_urls);
85 89
86 // Record a banner installation event, for either a WEB or NATIVE app. 90 // Record a banner installation event, for either a WEB or NATIVE app.
87 static void RecordBannerInstallEvent( 91 static void RecordBannerInstallEvent(
88 content::WebContents* web_contents, 92 content::WebContents* web_contents,
89 const std::string& package_name_or_start_url, 93 const std::string& package_name_or_start_url,
90 AppBannerRapporMetric rappor_metric); 94 AppBannerRapporMetric rappor_metric);
91 95
92 // Record a banner dismissal event, for either a WEB or NATIVE app. 96 // Record a banner dismissal event, for either a WEB or NATIVE app.
93 static void RecordBannerDismissEvent( 97 static void RecordBannerDismissEvent(
94 content::WebContents* web_contents, 98 content::WebContents* web_contents,
95 const std::string& package_name_or_start_url, 99 const std::string& package_name_or_start_url,
96 AppBannerRapporMetric rappor_metric); 100 AppBannerRapporMetric rappor_metric);
97 101
98 // Record a banner event. Should not be used for could show events, as they 102 // Record a banner event specified by |event|.
99 // require a transition type.
100 static void RecordBannerEvent(content::WebContents* web_contents, 103 static void RecordBannerEvent(content::WebContents* web_contents,
101 const GURL& origin_url, 104 const GURL& origin_url,
102 const std::string& package_name_or_start_url, 105 const std::string& package_name_or_start_url,
103 AppBannerEvent event, 106 AppBannerEvent event,
104 base::Time time); 107 base::Time time);
105 108
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 109 // Determine if the banner should be shown, given the recorded events for the
115 // supplied app. Returns an InstallableStatusCode indicated the reason why the 110 // 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. 111 // banner shouldn't be shown, or NO_ERROR_DETECTED if it should be shown.
117 static InstallableStatusCode ShouldShowBanner( 112 static InstallableStatusCode ShouldShowBanner(
118 content::WebContents* web_contents, 113 content::WebContents* web_contents,
119 const GURL& origin_url, 114 const GURL& origin_url,
120 const std::string& package_name_or_start_url, 115 const std::string& package_name_or_start_url,
121 base::Time time); 116 base::Time time);
122 117
123 // Gets the could have been shown events that are stored for the given package 118 // 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. 119 // 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( 120 static base::Time GetSingleBannerEvent(
134 content::WebContents* web_contents, 121 content::WebContents* web_contents,
135 const GURL& origin_url, 122 const GURL& origin_url,
136 const std::string& package_name_or_start_url, 123 const std::string& package_name_or_start_url,
137 AppBannerEvent event); 124 AppBannerEvent event);
138 125
139 // Returns true if |total_engagement| is sufficiently high to warrant 126 // Returns true if |total_engagement| is sufficiently high to warrant
140 // triggering a banner, or if the command-line flag to bypass engagement 127 // triggering a banner, or if the command-line flag to bypass engagement
141 // checking is true. 128 // checking is true.
142 static bool HasSufficientEngagement(double total_engagement); 129 static bool HasSufficientEngagement(double total_engagement);
(...skipping 12 matching lines...) Expand all
155 // already been added to homescreen. 142 // already been added to homescreen.
156 static bool WasLaunchedRecently(Profile* profile, 143 static bool WasLaunchedRecently(Profile* profile,
157 const GURL& origin_url, 144 const GURL& origin_url,
158 base::Time now); 145 base::Time now);
159 146
160 // Set the number of days which dismissing/ignoring the banner should prevent 147 // Set the number of days which dismissing/ignoring the banner should prevent
161 // a banner from showing. 148 // a banner from showing.
162 static void SetDaysAfterDismissAndIgnoreToTrigger(unsigned int dismiss_days, 149 static void SetDaysAfterDismissAndIgnoreToTrigger(unsigned int dismiss_days,
163 unsigned int ignore_days); 150 unsigned int ignore_days);
164 151
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. 152 // Set the total engagement weight required to trigger a banner.
176 static void SetTotalEngagementToTrigger(double total_engagement); 153 static void SetTotalEngagementToTrigger(double total_engagement);
177 154
178 // Resets the engagement weights, minimum minutes, and total engagement to 155 // Resets the engagement weights, minimum minutes, and total engagement to
179 // trigger to their default values. 156 // trigger to their default values.
180 static void SetDefaultParameters(); 157 static void SetDefaultParameters();
181 158
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. 159 // Updates all values from field trial.
187 static void UpdateFromFieldTrial(); 160 static void UpdateFromFieldTrial();
188 161
189 // Queries variations to determine which language option should be used for 162 // Queries variations to determine which language option should be used for
190 // app banners and add to homescreen. 163 // app banners and add to homescreen.
191 static LanguageOption GetHomescreenLanguageOption(); 164 static LanguageOption GetHomescreenLanguageOption();
192 165
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: 166 private:
198 DISALLOW_IMPLICIT_CONSTRUCTORS(AppBannerSettingsHelper); 167 DISALLOW_IMPLICIT_CONSTRUCTORS(AppBannerSettingsHelper);
199 }; 168 };
200 169
201 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_ 170 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_SETTINGS_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/banners/app_banner_manager_browsertest.cc ('k') | chrome/browser/banners/app_banner_settings_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698