Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3c236eb76d88039db9c48154fb0a98dcabaef667 |
| --- /dev/null |
| +++ b/chrome/browser/engagement/site_engagement_service.h |
| @@ -0,0 +1,52 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ |
| +#define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ |
| + |
| +#include <map> |
| + |
| +#include "base/macros.h" |
| +#include "components/keyed_service/core/keyed_service.h" |
| + |
| +class GURL; |
| +class Profile; |
| + |
| +// Stores and retrieves the engagement score of a origin. |
|
raymes
2015/04/16 01:13:55
nit: an origin
benwells
2015/04/16 05:15:27
Done.
|
| +// |
| +// An engagement score is a positive integer that represents how much a user has |
| +// engaged with a origin - the higher it is, the more engagement the user has |
|
raymes
2015/04/16 01:13:55
nit: an origin
benwells
2015/04/16 05:15:27
Done.
|
| +// had with this site recently. |
| +// |
| +// Positive user activity, such as visiting the origin often and adding it to |
| +// the homescreen, will increase the site engagement score. Negative activity, |
| +// such as rejecting permission prompts or not responding to notifications, will |
| +// decrease the site engagement score. |
| +class SiteEngagementService : public KeyedService { |
| + public: |
| + static SiteEngagementService* Get(Profile* profile); |
| + |
| + // Returns whether or not the SiteEngagementService is enabled. |
| + static bool IsEnabled(); |
| + |
| + explicit SiteEngagementService(Profile* profile); |
| + ~SiteEngagementService() override; |
| + |
| + // Update the karma score of the origin matching |url| for user navigation. |
| + void HandleNavigation(const GURL& url); |
| + |
| + // Returns a non-negative integer representing the engagement score of the |
| + // origin for this URL. |
| + int GetScore(const GURL& url); |
| + |
| + private: |
| + Profile* profile_; |
| + |
| + // Temporary non-persistent score database for testing. |
| + std::map<GURL, int> scores_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SiteEngagementService); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ |