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

Side by Side Diff: chrome/browser/engagement/site_engagement_score.h

Issue 2748103011: Grant origins engagement for having interactions on their notifications. (Closed)
Patch Set: Unfriend Created 3 years, 9 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_ENGAGEMENT_SITE_ENGAGEMENT_SCORE_H_ 5 #ifndef CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SCORE_H_
6 #define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SCORE_H_ 6 #define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SCORE_H_
7 7
8 #include <array> 8 #include <array>
9 #include <memory> 9 #include <memory>
10 10
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // the max decay period, i.e. the maximum duration permitted for 77 // the max decay period, i.e. the maximum duration permitted for
78 // (clock_->Now() - score.last_engagement_time()). 78 // (clock_->Now() - score.last_engagement_time()).
79 MAX_DECAYS_PER_SCORE, 79 MAX_DECAYS_PER_SCORE,
80 80
81 // If a SiteEngagamentScore has not been accessed or updated for a period 81 // If a SiteEngagamentScore has not been accessed or updated for a period
82 // longer than the max decay period + LAST_ENGAGEMENT_GRACE_PERIOD_IN_HOURS 82 // longer than the max decay period + LAST_ENGAGEMENT_GRACE_PERIOD_IN_HOURS
83 // (see above), its last engagement time will be reset to be max decay 83 // (see above), its last engagement time will be reset to be max decay
84 // period prior to clock_->Now(). 84 // period prior to clock_->Now().
85 LAST_ENGAGEMENT_GRACE_PERIOD_IN_HOURS, 85 LAST_ENGAGEMENT_GRACE_PERIOD_IN_HOURS,
86 86
87 // THe number of points given for having notification permission granted. 87 // The number of points given for having notification permission granted.
88 NOTIFICATION_PERMISSION_POINTS, 88 NOTIFICATION_PERMISSION_POINTS,
89 89
90 // The number of points given for interacting with a displayed notification.
91 NOTIFICATION_INTERACTION_POINTS,
92
90 MAX_VARIATION 93 MAX_VARIATION
91 }; 94 };
92 95
93 // The maximum number of points that are allowed. 96 // The maximum number of points that are allowed.
94 static const double kMaxPoints; 97 static const double kMaxPoints;
95 98
96 static double GetMaxPointsPerDay(); 99 static double GetMaxPointsPerDay();
97 static double GetDecayPeriodInHours(); 100 static double GetDecayPeriodInHours();
98 static double GetDecayPoints(); 101 static double GetDecayPoints();
99 static double GetDecayProportion(); 102 static double GetDecayProportion();
100 static double GetScoreCleanupThreshold(); 103 static double GetScoreCleanupThreshold();
101 static double GetNavigationPoints(); 104 static double GetNavigationPoints();
102 static double GetUserInputPoints(); 105 static double GetUserInputPoints();
103 static double GetVisibleMediaPoints(); 106 static double GetVisibleMediaPoints();
104 static double GetHiddenMediaPoints(); 107 static double GetHiddenMediaPoints();
105 static double GetWebAppInstalledPoints(); 108 static double GetWebAppInstalledPoints();
106 static double GetFirstDailyEngagementPoints(); 109 static double GetFirstDailyEngagementPoints();
107 static double GetBootstrapPoints(); 110 static double GetBootstrapPoints();
108 static double GetMediumEngagementBoundary(); 111 static double GetMediumEngagementBoundary();
109 static double GetHighEngagementBoundary(); 112 static double GetHighEngagementBoundary();
110 static double GetMaxDecaysPerScore(); 113 static double GetMaxDecaysPerScore();
111 static double GetLastEngagementGracePeriodInHours(); 114 static double GetLastEngagementGracePeriodInHours();
112 static double GetNotificationPermissionPoints(); 115 static double GetNotificationPermissionPoints();
116 static double GetNotificationInteractionPoints();
117
118 // Sets fixed parameter values for testing site engagement. Ensure that any
119 // newly added parameters receive a fixed value here.
120 static void SetParamValuesForTesting();
113 121
114 // Update the default engagement settings via variations. 122 // Update the default engagement settings via variations.
115 static void UpdateFromVariations(const char* param_name); 123 static void UpdateFromVariations(const char* param_name);
116 124
117 // The SiteEngagementScore does not take ownership of |clock|. It is the 125 // The SiteEngagementScore does not take ownership of |clock|. It is the
118 // responsibility of the caller to make sure |clock| outlives this 126 // responsibility of the caller to make sure |clock| outlives this
119 // SiteEngagementScore. 127 // SiteEngagementScore.
120 SiteEngagementScore(base::Clock* clock, 128 SiteEngagementScore(base::Clock* clock,
121 const GURL& origin, 129 const GURL& origin,
122 HostContentSettingsMap* settings); 130 HostContentSettingsMap* settings);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 166 }
159 void set_last_engagement_time(const base::Time& time) { 167 void set_last_engagement_time(const base::Time& time) {
160 last_engagement_time_ = time; 168 last_engagement_time_ = time;
161 } 169 }
162 170
163 private: 171 private:
164 FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, FirstDailyEngagementBonus); 172 FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, FirstDailyEngagementBonus);
165 FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, PartiallyEmptyDictionary); 173 FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, PartiallyEmptyDictionary);
166 FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, PopulatedDictionary); 174 FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, PopulatedDictionary);
167 FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, Reset); 175 FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, Reset);
168 friend class ChromePluginServiceFilterTest;
169 friend class ImportantSitesUtil;
170 friend class ImportantSitesUtilTest;
171 friend class PushMessagingBrowserTest;
172 friend class SiteEngagementHelperTest;
173 friend class SiteEngagementScoreTest; 176 friend class SiteEngagementScoreTest;
174 friend class SiteEngagementServiceTest; 177 friend class SiteEngagementServiceTest;
175 178
176 using ParamValues = std::array<std::pair<std::string, double>, MAX_VARIATION>; 179 using ParamValues = std::array<std::pair<std::string, double>, MAX_VARIATION>;
177 180
178 // Array holding the values corresponding to each item in Variation array. 181 // Array holding the values corresponding to each item in Variation array.
179 static ParamValues& GetParamValues(); 182 static ParamValues& GetParamValues();
180 static ParamValues BuildParamValues(); 183 static ParamValues BuildParamValues();
181 184
182 // Keys used in the content settings dictionary. 185 // Keys used in the content settings dictionary.
183 static const char* kRawScoreKey; 186 static const char* kRawScoreKey;
184 static const char* kPointsAddedTodayKey; 187 static const char* kPointsAddedTodayKey;
185 static const char* kLastEngagementTimeKey; 188 static const char* kLastEngagementTimeKey;
186 static const char* kLastShortcutLaunchTimeKey; 189 static const char* kLastShortcutLaunchTimeKey;
187 190
188 // This version of the constructor is used in unit tests. 191 // This version of the constructor is used in unit tests.
189 SiteEngagementScore(base::Clock* clock, 192 SiteEngagementScore(base::Clock* clock,
190 const GURL& origin, 193 const GURL& origin,
191 std::unique_ptr<base::DictionaryValue> score_dict); 194 std::unique_ptr<base::DictionaryValue> score_dict);
192 195
193 // Determine the score, accounting for any decay. 196 // Determine the score, accounting for any decay.
194 double DecayedScore() const; 197 double DecayedScore() const;
195 198
196 // Determine any score bonus from having installed shortcuts. 199 // Determine any score bonus from having installed shortcuts.
197 double BonusScore() const; 200 double BonusScore() const;
198 201
199 // Sets fixed parameter values for testing site engagement. Ensure that any
200 // newly added parameters receive a fixed value here.
201 static void SetParamValuesForTesting();
202
203 // Updates the content settings dictionary |score_dict| with the current score 202 // Updates the content settings dictionary |score_dict| with the current score
204 // fields. Returns true if |score_dict| changed, otherwise return false. 203 // fields. Returns true if |score_dict| changed, otherwise return false.
205 bool UpdateScoreDict(base::DictionaryValue* score_dict); 204 bool UpdateScoreDict(base::DictionaryValue* score_dict);
206 205
207 // The clock used to vend times. Enables time travelling in tests. Owned by 206 // The clock used to vend times. Enables time travelling in tests. Owned by
208 // the SiteEngagementService. 207 // the SiteEngagementService.
209 base::Clock* clock_; 208 base::Clock* clock_;
210 209
211 // |raw_score_| is the score before any decay is applied. 210 // |raw_score_| is the score before any decay is applied.
212 double raw_score_; 211 double raw_score_;
(...skipping 17 matching lines...) Expand all
230 // The origin this score represents. 229 // The origin this score represents.
231 GURL origin_; 230 GURL origin_;
232 231
233 // The settings to write this score to when Commit() is called. 232 // The settings to write this score to when Commit() is called.
234 HostContentSettingsMap* settings_map_; 233 HostContentSettingsMap* settings_map_;
235 234
236 DISALLOW_COPY_AND_ASSIGN(SiteEngagementScore); 235 DISALLOW_COPY_AND_ASSIGN(SiteEngagementScore);
237 }; 236 };
238 237
239 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SCORE_H_ 238 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SCORE_H_
OLDNEW
« no previous file with comments | « chrome/browser/engagement/site_engagement_observer.h ('k') | chrome/browser/engagement/site_engagement_score.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698