Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1087)

Unified Diff: chrome/browser/engagement/site_engagement_service.h

Issue 1077063002: Implement a basic Site Engagement Score service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Feedback Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..bc150af79a96cae3655751194fd27b8330d4080f
--- /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 an origin.
+//
+// An engagement score is a positive integer that represents how much a user has
+// engaged with an origin - the higher it is, the more engagement the user has
+// 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_
« no previous file with comments | « chrome/browser/engagement/site_engagement_helper.cc ('k') | chrome/browser/engagement/site_engagement_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698