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

Side by Side Diff: chrome/browser/engagement/site_engagement_service.cc

Issue 1338603002: Implement a site engagement score based on time-on-site. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile unit tests Created 5 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/engagement/site_engagement_service.h" 5 #include "chrome/browser/engagement/site_engagement_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 switches::kEnableSiteEngagementService); 160 switches::kEnableSiteEngagementService);
161 } 161 }
162 162
163 SiteEngagementService::SiteEngagementService(Profile* profile) 163 SiteEngagementService::SiteEngagementService(Profile* profile)
164 : profile_(profile) { 164 : profile_(profile) {
165 } 165 }
166 166
167 SiteEngagementService::~SiteEngagementService() { 167 SiteEngagementService::~SiteEngagementService() {
168 } 168 }
169 169
170 void SiteEngagementService::HandleNavigation(const GURL& url) { 170 void SiteEngagementService::HandleUserInput(const GURL& url) {
171 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap(); 171 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap();
172 scoped_ptr<base::DictionaryValue> score_dict = 172 scoped_ptr<base::DictionaryValue> score_dict =
173 GetScoreDictForOrigin(settings_map, url); 173 GetScoreDictForOrigin(settings_map, url);
174 SiteEngagementScore score(&clock_, *score_dict); 174 SiteEngagementScore score(&clock_, *score_dict);
175 175
176 score.AddPoints(SiteEngagementScore::kNavigationPoints); 176 score.AddPoints(SiteEngagementScore::kNavigationPoints);
calamity 2015/09/11 07:19:56 This constant name needs to change. kUserInputPoin
dominickn 2015/09/11 08:03:38 Done.
177 if (score.UpdateScoreDict(score_dict.get())) { 177 if (score.UpdateScoreDict(score_dict.get())) {
178 ContentSettingsPattern pattern( 178 ContentSettingsPattern pattern(
179 ContentSettingsPattern::FromURLNoWildcard(url)); 179 ContentSettingsPattern::FromURLNoWildcard(url));
180 if (!pattern.IsValid()) 180 if (!pattern.IsValid())
181 return; 181 return;
182 182
183 settings_map->SetWebsiteSetting(pattern, ContentSettingsPattern::Wildcard(), 183 settings_map->SetWebsiteSetting(pattern, ContentSettingsPattern::Wildcard(),
184 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, 184 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT,
185 std::string(), score_dict.release()); 185 std::string(), score_dict.release());
186 } 186 }
(...skipping 19 matching lines...) Expand all
206 if (!origin.is_valid()) 206 if (!origin.is_valid())
207 continue; 207 continue;
208 208
209 scoped_ptr<base::DictionaryValue> score_dict = 209 scoped_ptr<base::DictionaryValue> score_dict =
210 GetScoreDictForOrigin(settings_map, origin); 210 GetScoreDictForOrigin(settings_map, origin);
211 SiteEngagementScore score(&clock_, *score_dict); 211 SiteEngagementScore score(&clock_, *score_dict);
212 total_score += score.Score(); 212 total_score += score.Score();
213 } 213 }
214 return total_score; 214 return total_score;
215 } 215 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698