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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 if (!origin.is_valid()) | 220 if (!origin.is_valid()) |
221 continue; | 221 continue; |
222 | 222 |
223 scoped_ptr<base::DictionaryValue> score_dict = | 223 scoped_ptr<base::DictionaryValue> score_dict = |
224 GetScoreDictForOrigin(settings_map, origin); | 224 GetScoreDictForOrigin(settings_map, origin); |
225 SiteEngagementScore score(&clock_, *score_dict); | 225 SiteEngagementScore score(&clock_, *score_dict); |
226 total_score += score.Score(); | 226 total_score += score.Score(); |
227 } | 227 } |
228 return total_score; | 228 return total_score; |
229 } | 229 } |
| 230 |
| 231 std::map<GURL, int> SiteEngagementService::GetScoreMap() { |
| 232 std::map<GURL, int> score_map; |
| 233 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap(); |
| 234 ContentSettingsForOneType engagement_settings; |
| 235 settings_map->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, |
| 236 std::string(), &engagement_settings); |
| 237 for (const auto& site : engagement_settings) { |
| 238 GURL origin(site.primary_pattern.ToString()); |
| 239 if (!origin.is_valid()) |
| 240 continue; |
| 241 |
| 242 scoped_ptr<base::DictionaryValue> score_dict = |
| 243 GetScoreDictForOrigin(settings_map, origin); |
| 244 SiteEngagementScore score(&clock_, *score_dict); |
| 245 score_map[origin] = score.Score(); |
| 246 } |
| 247 return score_map; |
| 248 } |
OLD | NEW |