OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ |
6 #define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ | 6 #define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ |
7 | 7 |
8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/time/default_clock.h" | 10 #include "base/time/default_clock.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 static const char* kRawScoreKey; | 24 static const char* kRawScoreKey; |
25 static const char* kPointsAddedTodayKey; | 25 static const char* kPointsAddedTodayKey; |
26 static const char* kLastEngagementTimeKey; | 26 static const char* kLastEngagementTimeKey; |
27 | 27 |
28 // The maximum number of points that are allowed. | 28 // The maximum number of points that are allowed. |
29 static const double kMaxPoints; | 29 static const double kMaxPoints; |
30 | 30 |
31 // The maximum number of points that can be accrued in one day. | 31 // The maximum number of points that can be accrued in one day. |
32 static const double kMaxPointsPerDay; | 32 static const double kMaxPointsPerDay; |
33 | 33 |
34 // The number of points given for a navigation. | 34 // The number of points given for user input (indicating time-on-site). |
35 static const double kNavigationPoints; | 35 static const double kUserInputPoints; |
36 | 36 |
37 // Decaying works by removing a portion of the score periodically. This | 37 // Decaying works by removing a portion of the score periodically. This |
38 // constant determines how often that happens. | 38 // constant determines how often that happens. |
39 static const int kDecayPeriodInDays; | 39 static const int kDecayPeriodInDays; |
40 | 40 |
41 // How much the score decays after every kDecayPeriodInDays. | 41 // How much the score decays after every kDecayPeriodInDays. |
42 static const double kDecayPoints; | 42 static const double kDecayPoints; |
43 | 43 |
44 // The SiteEngagementService does not take ownership of |clock|. It is the | 44 // The SiteEngagementService does not take ownership of |clock|. It is the |
45 // responsibility of the caller to make sure |clock| outlives this | 45 // responsibility of the caller to make sure |clock| outlives this |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 public SiteEngagementScoreProvider { | 107 public SiteEngagementScoreProvider { |
108 public: | 108 public: |
109 static SiteEngagementService* Get(Profile* profile); | 109 static SiteEngagementService* Get(Profile* profile); |
110 | 110 |
111 // Returns whether or not the SiteEngagementService is enabled. | 111 // Returns whether or not the SiteEngagementService is enabled. |
112 static bool IsEnabled(); | 112 static bool IsEnabled(); |
113 | 113 |
114 explicit SiteEngagementService(Profile* profile); | 114 explicit SiteEngagementService(Profile* profile); |
115 ~SiteEngagementService() override; | 115 ~SiteEngagementService() override; |
116 | 116 |
117 // Update the karma score of the origin matching |url| for user navigation. | 117 // Update the karma score of the origin matching |url| for time-on-site, based |
118 void HandleNavigation(const GURL& url); | 118 // on user input. |
| 119 void HandleUserInput(const GURL& url); |
119 | 120 |
120 // Overridden from SiteEngagementScoreProvider: | 121 // Overridden from SiteEngagementScoreProvider: |
121 int GetScore(const GURL& url) override; | 122 int GetScore(const GURL& url) override; |
122 int GetTotalEngagementPoints() override; | 123 int GetTotalEngagementPoints() override; |
123 | 124 |
124 private: | 125 private: |
125 Profile* profile_; | 126 Profile* profile_; |
126 | 127 |
127 // The clock used to vend times. | 128 // The clock used to vend times. |
128 base::DefaultClock clock_; | 129 base::DefaultClock clock_; |
129 | 130 |
130 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService); | 131 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService); |
131 }; | 132 }; |
132 | 133 |
133 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ | 134 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ |
OLD | NEW |