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

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

Issue 1316043003: Add chrome://site-engagement WebUI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@navigation_smarter
Patch Set: address_comments 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698