OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_score.h" | 5 #include "chrome/browser/engagement/site_engagement_score.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 double SiteEngagementScore::GetScore() const { | 217 double SiteEngagementScore::GetScore() const { |
218 return std::min(DecayedScore() + BonusScore(), kMaxPoints); | 218 return std::min(DecayedScore() + BonusScore(), kMaxPoints); |
219 } | 219 } |
220 | 220 |
221 void SiteEngagementScore::Commit() { | 221 void SiteEngagementScore::Commit() { |
222 if (!UpdateScoreDict(score_dict_.get())) | 222 if (!UpdateScoreDict(score_dict_.get())) |
223 return; | 223 return; |
224 | 224 |
225 settings_map_->SetWebsiteSettingDefaultScope( | 225 settings_map_->SetWebsiteSettingDefaultScope( |
226 origin_, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), | 226 origin_, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
227 score_dict_.release()); | 227 std::move(score_dict_)); |
228 } | 228 } |
229 | 229 |
230 bool SiteEngagementScore::MaxPointsPerDayAdded() const { | 230 bool SiteEngagementScore::MaxPointsPerDayAdded() const { |
231 if (!last_engagement_time_.is_null() && | 231 if (!last_engagement_time_.is_null() && |
232 clock_->Now().LocalMidnight() != last_engagement_time_.LocalMidnight()) { | 232 clock_->Now().LocalMidnight() != last_engagement_time_.LocalMidnight()) { |
233 return false; | 233 return false; |
234 } | 234 } |
235 | 235 |
236 return points_added_today_ == GetMaxPointsPerDay(); | 236 return points_added_today_ == GetMaxPointsPerDay(); |
237 } | 237 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 param_values[HIDDEN_MEDIA_POINTS] = 0.01; | 335 param_values[HIDDEN_MEDIA_POINTS] = 0.01; |
336 param_values[WEB_APP_INSTALLED_POINTS] = 5; | 336 param_values[WEB_APP_INSTALLED_POINTS] = 5; |
337 param_values[BOOTSTRAP_POINTS] = 8; | 337 param_values[BOOTSTRAP_POINTS] = 8; |
338 param_values[MEDIUM_ENGAGEMENT_BOUNDARY] = 5; | 338 param_values[MEDIUM_ENGAGEMENT_BOUNDARY] = 5; |
339 param_values[HIGH_ENGAGEMENT_BOUNDARY] = 50; | 339 param_values[HIGH_ENGAGEMENT_BOUNDARY] = 50; |
340 | 340 |
341 // This is set to zero to avoid interference with tests and is set when | 341 // This is set to zero to avoid interference with tests and is set when |
342 // testing this functionality. | 342 // testing this functionality. |
343 param_values[FIRST_DAILY_ENGAGEMENT] = 0; | 343 param_values[FIRST_DAILY_ENGAGEMENT] = 0; |
344 } | 344 } |
OLD | NEW |