| 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_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 Loading... |
| 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. |
| 88 NOTIFICATION_PERMISSION_POINTS, |
| 89 |
| 87 MAX_VARIATION | 90 MAX_VARIATION |
| 88 }; | 91 }; |
| 89 | 92 |
| 90 // The maximum number of points that are allowed. | 93 // The maximum number of points that are allowed. |
| 91 static const double kMaxPoints; | 94 static const double kMaxPoints; |
| 92 | 95 |
| 93 static double GetMaxPointsPerDay(); | 96 static double GetMaxPointsPerDay(); |
| 94 static double GetDecayPeriodInHours(); | 97 static double GetDecayPeriodInHours(); |
| 95 static double GetDecayPoints(); | 98 static double GetDecayPoints(); |
| 96 static double GetDecayProportion(); | 99 static double GetDecayProportion(); |
| 97 static double GetScoreCleanupThreshold(); | 100 static double GetScoreCleanupThreshold(); |
| 98 static double GetNavigationPoints(); | 101 static double GetNavigationPoints(); |
| 99 static double GetUserInputPoints(); | 102 static double GetUserInputPoints(); |
| 100 static double GetVisibleMediaPoints(); | 103 static double GetVisibleMediaPoints(); |
| 101 static double GetHiddenMediaPoints(); | 104 static double GetHiddenMediaPoints(); |
| 102 static double GetWebAppInstalledPoints(); | 105 static double GetWebAppInstalledPoints(); |
| 103 static double GetFirstDailyEngagementPoints(); | 106 static double GetFirstDailyEngagementPoints(); |
| 104 static double GetBootstrapPoints(); | 107 static double GetBootstrapPoints(); |
| 105 static double GetMediumEngagementBoundary(); | 108 static double GetMediumEngagementBoundary(); |
| 106 static double GetHighEngagementBoundary(); | 109 static double GetHighEngagementBoundary(); |
| 107 static double GetMaxDecaysPerScore(); | 110 static double GetMaxDecaysPerScore(); |
| 108 static double GetLastEngagementGracePeriodInHours(); | 111 static double GetLastEngagementGracePeriodInHours(); |
| 112 static double GetNotificationPermissionPoints(); |
| 109 | 113 |
| 110 // Update the default engagement settings via variations. | 114 // Update the default engagement settings via variations. |
| 111 static void UpdateFromVariations(const char* param_name); | 115 static void UpdateFromVariations(const char* param_name); |
| 112 | 116 |
| 113 // The SiteEngagementScore does not take ownership of |clock|. It is the | 117 // The SiteEngagementScore does not take ownership of |clock|. It is the |
| 114 // responsibility of the caller to make sure |clock| outlives this | 118 // responsibility of the caller to make sure |clock| outlives this |
| 115 // SiteEngagementScore. | 119 // SiteEngagementScore. |
| 116 SiteEngagementScore(base::Clock* clock, | 120 SiteEngagementScore(base::Clock* clock, |
| 117 const GURL& origin, | 121 const GURL& origin, |
| 118 HostContentSettingsMap* settings); | 122 HostContentSettingsMap* settings); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 } | 161 } |
| 158 | 162 |
| 159 private: | 163 private: |
| 160 FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, FirstDailyEngagementBonus); | 164 FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, FirstDailyEngagementBonus); |
| 161 FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, PartiallyEmptyDictionary); | 165 FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, PartiallyEmptyDictionary); |
| 162 FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, PopulatedDictionary); | 166 FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, PopulatedDictionary); |
| 163 FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, Reset); | 167 FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, Reset); |
| 164 friend class ChromePluginServiceFilterTest; | 168 friend class ChromePluginServiceFilterTest; |
| 165 friend class ImportantSitesUtil; | 169 friend class ImportantSitesUtil; |
| 166 friend class ImportantSitesUtilTest; | 170 friend class ImportantSitesUtilTest; |
| 171 friend class PushMessagingBrowserTest; |
| 167 friend class SiteEngagementHelperTest; | 172 friend class SiteEngagementHelperTest; |
| 168 friend class SiteEngagementScoreTest; | 173 friend class SiteEngagementScoreTest; |
| 169 friend class SiteEngagementServiceTest; | 174 friend class SiteEngagementServiceTest; |
| 170 | 175 |
| 171 using ParamValues = std::array<std::pair<std::string, double>, MAX_VARIATION>; | 176 using ParamValues = std::array<std::pair<std::string, double>, MAX_VARIATION>; |
| 172 | 177 |
| 173 // Array holding the values corresponding to each item in Variation array. | 178 // Array holding the values corresponding to each item in Variation array. |
| 174 static ParamValues& GetParamValues(); | 179 static ParamValues& GetParamValues(); |
| 175 static ParamValues BuildParamValues(); | 180 static ParamValues BuildParamValues(); |
| 176 | 181 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 // The origin this score represents. | 230 // The origin this score represents. |
| 226 GURL origin_; | 231 GURL origin_; |
| 227 | 232 |
| 228 // The settings to write this score to when Commit() is called. | 233 // The settings to write this score to when Commit() is called. |
| 229 HostContentSettingsMap* settings_map_; | 234 HostContentSettingsMap* settings_map_; |
| 230 | 235 |
| 231 DISALLOW_COPY_AND_ASSIGN(SiteEngagementScore); | 236 DISALLOW_COPY_AND_ASSIGN(SiteEngagementScore); |
| 232 }; | 237 }; |
| 233 | 238 |
| 234 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SCORE_H_ | 239 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SCORE_H_ |
| OLD | NEW |