| Index: chrome/browser/engagement/site_engagement_service.h
|
| diff --git a/chrome/browser/engagement/site_engagement_service.h b/chrome/browser/engagement/site_engagement_service.h
|
| index 60644a4a4e3f504721d10a8a2e0666eb635dac34..8f2ae0289d1337c71c09719a8869767d4a0b3996 100644
|
| --- a/chrome/browser/engagement/site_engagement_service.h
|
| +++ b/chrome/browser/engagement/site_engagement_service.h
|
| @@ -10,6 +10,7 @@
|
| #include "base/time/default_clock.h"
|
| #include "base/time/time.h"
|
| #include "components/keyed_service/core/keyed_service.h"
|
| +#include "ui/base/page_transition_types.h"
|
|
|
| namespace base {
|
| class DictionaryValue;
|
| @@ -31,9 +32,12 @@ class SiteEngagementScore {
|
| // The maximum number of points that can be accrued in one day.
|
| static const double kMaxPointsPerDay;
|
|
|
| - // The number of points given for a navigation.
|
| + // The number of points given for navigations.
|
| static const double kNavigationPoints;
|
|
|
| + // The number of points given for user input (indicating time-on-site).
|
| + static const double kUserInputPoints;
|
| +
|
| // Decaying works by removing a portion of the score periodically. This
|
| // constant determines how often that happens.
|
| static const int kDecayPeriodInDays;
|
| @@ -87,10 +91,10 @@ class SiteEngagementScoreProvider {
|
| public:
|
| // Returns a non-negative integer representing the engagement score of the
|
| // origin for this URL.
|
| - virtual int GetScore(const GURL& url) = 0;
|
| + virtual double GetScore(const GURL& url) = 0;
|
|
|
| // Returns the sum of engagement points awarded to all sites.
|
| - virtual int GetTotalEngagementPoints() = 0;
|
| + virtual double GetTotalEngagementPoints() = 0;
|
| };
|
|
|
| // Stores and retrieves the engagement score of an origin.
|
| @@ -114,14 +118,20 @@ class SiteEngagementService : public KeyedService,
|
| explicit SiteEngagementService(Profile* profile);
|
| ~SiteEngagementService() override;
|
|
|
| - // Update the karma score of the origin matching |url| for user navigation.
|
| - void HandleNavigation(const GURL& url);
|
| + // Update the karma score of the origin matching |url| for navigation.
|
| + void HandleNavigation(const GURL& url, ui::PageTransition transition);
|
| +
|
| + // Update the karma score of the origin matching |url| for time-on-site, based
|
| + // on user input.
|
| + void HandleUserInput(const GURL& url);
|
|
|
| // Overridden from SiteEngagementScoreProvider:
|
| - int GetScore(const GURL& url) override;
|
| - int GetTotalEngagementPoints() override;
|
| + double GetScore(const GURL& url) override;
|
| + double GetTotalEngagementPoints() override;
|
|
|
| private:
|
| + void AddPoints(const GURL& url, double points);
|
| +
|
| Profile* profile_;
|
|
|
| // The clock used to vend times.
|
|
|