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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 if (!origin.is_valid()) | 209 if (!origin.is_valid()) |
210 continue; | 210 continue; |
211 | 211 |
212 scoped_ptr<base::DictionaryValue> score_dict = | 212 scoped_ptr<base::DictionaryValue> score_dict = |
213 GetScoreDictForOrigin(settings_map, origin); | 213 GetScoreDictForOrigin(settings_map, origin); |
214 SiteEngagementScore score(&clock_, *score_dict); | 214 SiteEngagementScore score(&clock_, *score_dict); |
215 total_score += score.Score(); | 215 total_score += score.Score(); |
216 } | 216 } |
217 return total_score; | 217 return total_score; |
218 } | 218 } |
| 219 |
| 220 std::map<GURL, int> SiteEngagementService::GetScoreMap() { |
| 221 std::map<GURL, int> score_map; |
| 222 HostContentSettingsMap* settings_map = |
| 223 HostContentSettingsMapFactory::GetForProfile(profile_); |
| 224 ContentSettingsForOneType engagement_settings; |
| 225 settings_map->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, |
| 226 std::string(), &engagement_settings); |
| 227 for (const auto& site : engagement_settings) { |
| 228 GURL origin(site.primary_pattern.ToString()); |
| 229 if (!origin.is_valid()) |
| 230 continue; |
| 231 |
| 232 scoped_ptr<base::DictionaryValue> score_dict = |
| 233 GetScoreDictForOrigin(settings_map, origin); |
| 234 SiteEngagementScore score(&clock_, *score_dict); |
| 235 score_map[origin] = score.Score(); |
| 236 } |
| 237 return score_map; |
| 238 } |
OLD | NEW |