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 350d30a934855a90f559122d691434087003c1fa..cb1d47ba7f877d253888d564c6b0893bb84f5731 100644 |
--- a/chrome/browser/engagement/site_engagement_service.h |
+++ b/chrome/browser/engagement/site_engagement_service.h |
@@ -19,6 +19,7 @@ |
#include "chrome/browser/engagement/site_engagement_observer.h" |
#include "components/history/core/browser/history_service_observer.h" |
#include "components/keyed_service/core/keyed_service.h" |
+#include "third_party/WebKit/public/platform/site_engagement.mojom.h" |
#include "ui/base/page_transition_types.h" |
namespace base { |
@@ -75,14 +76,6 @@ class SiteEngagementService : public KeyedService, |
// the service of them. |
class Helper; |
- enum EngagementLevel { |
- ENGAGEMENT_LEVEL_NONE, |
- ENGAGEMENT_LEVEL_LOW, |
- ENGAGEMENT_LEVEL_MEDIUM, |
- ENGAGEMENT_LEVEL_HIGH, |
- ENGAGEMENT_LEVEL_MAX, |
- }; |
- |
// The name of the site engagement variation field trial. |
static const char kEngagementParams[]; |
@@ -113,7 +106,7 @@ class SiteEngagementService : public KeyedService, |
~SiteEngagementService() override; |
// Returns the engagement level of |url|. |
- EngagementLevel GetEngagementLevel(const GURL& url) const; |
+ blink::mojom::EngagementLevel GetEngagementLevel(const GURL& url) const; |
// Returns a map of all stored origins and their engagement scores. |
std::map<GURL, double> GetScoreMap() const; |
@@ -124,7 +117,8 @@ class SiteEngagementService : public KeyedService, |
bool IsBootstrapped() const; |
// Returns whether |url| has at least the given |level| of engagement. |
- bool IsEngagementAtLeast(const GURL& url, EngagementLevel level) const; |
+ bool IsEngagementAtLeast(const GURL& url, |
+ blink::mojom::EngagementLevel level) const; |
// Resets the engagement score |url| to |score|, clearing daily limits. |
void ResetScoreForURL(const GURL& url, double score); |
@@ -133,6 +127,9 @@ class SiteEngagementService : public KeyedService, |
// clock_->Now(). |
void SetLastShortcutLaunchTime(const GURL& url); |
+ void HelperCreated(SiteEngagementService::Helper* helper); |
+ void HelperDeleted(SiteEngagementService::Helper* helper); |
+ |
// Overridden from SiteEngagementScoreProvider. |
double GetScore(const GURL& url) const override; |
double GetTotalEngagementPoints() const override; |
@@ -231,6 +228,11 @@ class SiteEngagementService : public KeyedService, |
void HandleUserInput(content::WebContents* web_contents, |
SiteEngagementMetrics::EngagementType type); |
+ // Called if |url| changes to |level| engagement, and informs every Helper of |
+ // the change. |
+ void SendLevelChangeToHelpers(const GURL& url, |
+ blink::mojom::EngagementLevel level); |
+ |
// Returns true if the last engagement increasing event seen by the site |
// engagement service was sufficiently long ago that we need to reset all |
// scores to be relative to now. This ensures that users who do not use the |
@@ -277,6 +279,9 @@ class SiteEngagementService : public KeyedService, |
// upload. |
base::Time last_metrics_time_; |
+ // All helpers currently attached to a WebContents. |
+ std::set<SiteEngagementService::Helper*> helpers_; |
+ |
// A list of observers. When any origin registers an engagement-increasing |
// event, each observer's OnEngagementIncreased method will be called. |
base::ObserverList<SiteEngagementObserver> observer_list_; |