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" |
11 #include "base/time/clock.h" | 11 #include "base/time/clock.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 13 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
14 #include "chrome/browser/engagement/site_engagement_eviction_policy.h" | |
14 #include "chrome/browser/engagement/site_engagement_helper.h" | 15 #include "chrome/browser/engagement/site_engagement_helper.h" |
15 #include "chrome/browser/engagement/site_engagement_service_factory.h" | 16 #include "chrome/browser/engagement/site_engagement_service_factory.h" |
16 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
17 #include "components/content_settings/core/browser/host_content_settings_map.h" | 18 #include "components/content_settings/core/browser/host_content_settings_map.h" |
18 #include "components/content_settings/core/common/content_settings_pattern.h" | 19 #include "components/content_settings/core/common/content_settings_pattern.h" |
19 #include "url/gurl.h" | 20 #include "url/gurl.h" |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 // Delta within which to consider scores equal. | 24 // Delta within which to consider scores equal. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 } | 151 } |
151 | 152 |
152 // static | 153 // static |
153 SiteEngagementService* SiteEngagementService::Get(Profile* profile) { | 154 SiteEngagementService* SiteEngagementService::Get(Profile* profile) { |
154 return SiteEngagementServiceFactory::GetForProfile(profile); | 155 return SiteEngagementServiceFactory::GetForProfile(profile); |
155 } | 156 } |
156 | 157 |
157 // static | 158 // static |
158 bool SiteEngagementService::IsEnabled() { | 159 bool SiteEngagementService::IsEnabled() { |
159 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 160 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
160 switches::kEnableSiteEngagementService); | 161 switches::kEnableSiteEngagementService) || |
raymes
2015/09/24 01:55:30
Hmm - should we just get rid of this switch? Do yo
calamity
2015/10/26 03:01:57
We definitely want this switch around for experime
| |
162 SiteEngagementEvictionPolicy::IsEnabled(); | |
161 } | 163 } |
162 | 164 |
163 SiteEngagementService::SiteEngagementService(Profile* profile) | 165 SiteEngagementService::SiteEngagementService(Profile* profile) |
164 : profile_(profile) { | 166 : profile_(profile) { |
165 } | 167 } |
166 | 168 |
167 SiteEngagementService::~SiteEngagementService() { | 169 SiteEngagementService::~SiteEngagementService() { |
168 } | 170 } |
169 | 171 |
170 void SiteEngagementService::HandleNavigation(const GURL& url) { | 172 void SiteEngagementService::HandleNavigation(const GURL& url) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 if (!origin.is_valid()) | 211 if (!origin.is_valid()) |
210 continue; | 212 continue; |
211 | 213 |
212 scoped_ptr<base::DictionaryValue> score_dict = | 214 scoped_ptr<base::DictionaryValue> score_dict = |
213 GetScoreDictForOrigin(settings_map, origin); | 215 GetScoreDictForOrigin(settings_map, origin); |
214 SiteEngagementScore score(&clock_, *score_dict); | 216 SiteEngagementScore score(&clock_, *score_dict); |
215 total_score += score.Score(); | 217 total_score += score.Score(); |
216 } | 218 } |
217 return total_score; | 219 return total_score; |
218 } | 220 } |
OLD | NEW |