Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 } |
| OLD | NEW |