| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 std::unique_ptr<base::Value> value = settings->GetWebsiteSetting( | 51 std::unique_ptr<base::Value> value = settings->GetWebsiteSetting( |
| 52 origin_url, origin_url, CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, | 52 origin_url, origin_url, CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, |
| 53 std::string(), NULL); | 53 std::string(), NULL); |
| 54 if (!value.get() && fallback_settings) { | 54 if (!value.get() && fallback_settings) { |
| 55 value = fallback_settings->GetWebsiteSetting( | 55 value = fallback_settings->GetWebsiteSetting( |
| 56 origin_url, origin_url, CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, | 56 origin_url, origin_url, CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, |
| 57 std::string(), NULL); | 57 std::string(), NULL); |
| 58 } | 58 } |
| 59 | 59 |
| 60 if (!value.get()) | 60 if (!value.get()) |
| 61 return base::WrapUnique(new base::DictionaryValue()); | 61 return base::MakeUnique<base::DictionaryValue>(); |
| 62 | 62 |
| 63 if (!value->IsType(base::Value::TYPE_DICTIONARY)) | 63 if (!value->IsType(base::Value::TYPE_DICTIONARY)) |
| 64 return base::WrapUnique(new base::DictionaryValue()); | 64 return base::MakeUnique<base::DictionaryValue>(); |
| 65 | 65 |
| 66 return base::WrapUnique(static_cast<base::DictionaryValue*>(value.release())); | 66 return base::WrapUnique(static_cast<base::DictionaryValue*>(value.release())); |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace | 69 } // namespace |
| 70 | 70 |
| 71 const double SiteEngagementScore::kMaxPoints = 100; | 71 const double SiteEngagementScore::kMaxPoints = 100; |
| 72 | 72 |
| 73 const char* SiteEngagementScore::kRawScoreKey = "rawScore"; | 73 const char* SiteEngagementScore::kRawScoreKey = "rawScore"; |
| 74 const char* SiteEngagementScore::kPointsAddedTodayKey = "pointsAddedToday"; | 74 const char* SiteEngagementScore::kPointsAddedTodayKey = "pointsAddedToday"; |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 GetParamValues()[HIGH_ENGAGEMENT_BOUNDARY].second = 50; | 372 GetParamValues()[HIGH_ENGAGEMENT_BOUNDARY].second = 50; |
| 373 GetParamValues()[MAX_DECAYS_PER_SCORE].second = 1; | 373 GetParamValues()[MAX_DECAYS_PER_SCORE].second = 1; |
| 374 GetParamValues()[LAST_ENGAGEMENT_GRACE_PERIOD_IN_HOURS].second = 72; | 374 GetParamValues()[LAST_ENGAGEMENT_GRACE_PERIOD_IN_HOURS].second = 72; |
| 375 | 375 |
| 376 // This is set to values that avoid interference with tests and are set when | 376 // This is set to values that avoid interference with tests and are set when |
| 377 // testing these features. | 377 // testing these features. |
| 378 GetParamValues()[FIRST_DAILY_ENGAGEMENT].second = 0; | 378 GetParamValues()[FIRST_DAILY_ENGAGEMENT].second = 0; |
| 379 GetParamValues()[DECAY_PROPORTION].second = 1; | 379 GetParamValues()[DECAY_PROPORTION].second = 1; |
| 380 GetParamValues()[SCORE_CLEANUP_THRESHOLD].second = 0; | 380 GetParamValues()[SCORE_CLEANUP_THRESHOLD].second = 0; |
| 381 } | 381 } |
| OLD | NEW |