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

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

Issue 1207383006: Add GetTotalEngagementPoints to SiteEngagementService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address_comments Created 5 years, 6 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.cc
diff --git a/chrome/browser/engagement/site_engagement_service.cc b/chrome/browser/engagement/site_engagement_service.cc
index 2885fbfc99fce5ca781d3de6d15448270fbb09da..f803c3fc895a1fe152ba44dc768c0bc6998eb8cb 100644
--- a/chrome/browser/engagement/site_engagement_service.cc
+++ b/chrome/browser/engagement/site_engagement_service.cc
@@ -32,7 +32,7 @@ bool DoublesConsideredDifferent(double value1, double value2, double delta) {
return abs_difference > delta;
}
-scoped_ptr<base::DictionaryValue> GetOriginDict(
+scoped_ptr<base::DictionaryValue> GetScoreDictForOrigin(
HostContentSettingsMap* settings,
const GURL& origin_url) {
if (!settings)
@@ -168,7 +168,8 @@ SiteEngagementService::~SiteEngagementService() {
void SiteEngagementService::HandleNavigation(const GURL& url) {
HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap();
- scoped_ptr<base::DictionaryValue> settings = GetOriginDict(settings_map, url);
+ scoped_ptr<base::DictionaryValue> settings =
raymes 2015/07/06 02:50:51 nit here and below: score_dict =
calamity 2015/07/07 02:47:25 Done.
+ GetScoreDictForOrigin(settings_map, url);
SiteEngagementScore score(&clock_, *settings);
score.AddPoints(SiteEngagementScore::kNavigationPoints);
@@ -186,9 +187,27 @@ void SiteEngagementService::HandleNavigation(const GURL& url) {
int SiteEngagementService::GetScore(const GURL& url) {
HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap();
- scoped_ptr<base::DictionaryValue> settings = GetOriginDict(settings_map, url);
+ scoped_ptr<base::DictionaryValue> settings =
+ GetScoreDictForOrigin(settings_map, url);
SiteEngagementScore score(&clock_, *settings);
return score.Score();
}
+int SiteEngagementService::GetTotalEngagementPoints() {
+ HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap();
+ ContentSettingsForOneType engagement_settings;
+ settings_map->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT,
+ std::string(), &engagement_settings);
+ int total_score = 0;
+ for (const auto& site : engagement_settings) {
+ GURL origin(site.primary_pattern.ToString());
+ DCHECK(origin.is_valid());
raymes 2015/07/06 02:50:51 hmm I think because this is coming from disk we re
calamity 2015/07/07 02:47:25 Done.
+
+ scoped_ptr<base::DictionaryValue> settings =
+ GetScoreDictForOrigin(settings_map, origin);
+ SiteEngagementScore score(&clock_, *settings);
+ total_score += score.Score();
+ }
+ return total_score;
+}

Powered by Google App Engine
This is Rietveld 408576698