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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_
6 #define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_
10 #include "base/macros.h"
11 #include "components/keyed_service/core/keyed_service.h"
16 // Stores and retrieves the engagement score of an origin.
18 // An engagement score is a positive integer that represents how much a user has
19 // engaged with an origin - the higher it is, the more engagement the user has
20 // had with this site recently.
22 // Positive user activity, such as visiting the origin often and adding it to
23 // the homescreen, will increase the site engagement score. Negative activity,
24 // such as rejecting permission prompts or not responding to notifications, will
25 // decrease the site engagement score.
26 class SiteEngagementService
: public KeyedService
{
28 static SiteEngagementService
* Get(Profile
* profile
);
30 // Returns whether or not the SiteEngagementService is enabled.
31 static bool IsEnabled();
33 explicit SiteEngagementService(Profile
* profile
);
34 ~SiteEngagementService() override
;
36 // Update the karma score of the origin matching |url| for user navigation.
37 void HandleNavigation(const GURL
& url
);
39 // Returns a non-negative integer representing the engagement score of the
40 // origin for this URL.
41 int GetScore(const GURL
& url
);
46 // Temporary non-persistent score database for testing.
47 std::map
<GURL
, int> scores_
;
49 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService
);
52 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_