Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 } | 114 } |
| 115 | 115 |
| 116 } // namespace | 116 } // namespace |
| 117 | 117 |
| 118 const double SiteEngagementScore::kMaxPoints = 100; | 118 const double SiteEngagementScore::kMaxPoints = 100; |
| 119 double SiteEngagementScore::param_values[] = { | 119 double SiteEngagementScore::param_values[] = { |
| 120 5, // MAX_POINTS_PER_DAY | 120 5, // MAX_POINTS_PER_DAY |
| 121 7, // DECAY_PERIOD_IN_DAYS | 121 7, // DECAY_PERIOD_IN_DAYS |
| 122 5, // DECAY_POINTS | 122 5, // DECAY_POINTS |
| 123 0.5, // NAVIGATION_POINTS | 123 0.5, // NAVIGATION_POINTS |
| 124 0.05, // USER_INPUT_POINTS | 124 0.2, // USER_INPUT_POINTS |
| 125 0.02, // VISIBLE_MEDIA_POINTS | 125 0.02, // VISIBLE_MEDIA_POINTS |
| 126 0.01, // HIDDEN_MEDIA_POINTS | 126 0.01, // HIDDEN_MEDIA_POINTS |
| 127 5, // WEB_APP_INSTALLED_POINTS | 127 5, // WEB_APP_INSTALLED_POINTS |
| 128 0.5, // FIRST_DAILY_ENGAGEMENT | 128 0.5, // FIRST_DAILY_ENGAGEMENT |
| 129 }; | 129 }; |
| 130 | 130 |
| 131 const char* SiteEngagementScore::kRawScoreKey = "rawScore"; | 131 const char* SiteEngagementScore::kRawScoreKey = "rawScore"; |
| 132 const char* SiteEngagementScore::kPointsAddedTodayKey = "pointsAddedToday"; | 132 const char* SiteEngagementScore::kPointsAddedTodayKey = "pointsAddedToday"; |
| 133 const char* SiteEngagementScore::kLastEngagementTimeKey = "lastEngagementTime"; | 133 const char* SiteEngagementScore::kLastEngagementTimeKey = "lastEngagementTime"; |
| 134 const char* SiteEngagementScore::kLastShortcutLaunchTimeKey = | 134 const char* SiteEngagementScore::kLastShortcutLaunchTimeKey = |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 318 | 318 |
| 319 double SiteEngagementScore::BonusScore() const { | 319 double SiteEngagementScore::BonusScore() const { |
| 320 int days_since_shortcut_launch = | 320 int days_since_shortcut_launch = |
| 321 (clock_->Now() - last_shortcut_launch_time_).InDays(); | 321 (clock_->Now() - last_shortcut_launch_time_).InDays(); |
| 322 if (days_since_shortcut_launch <= kMaxDaysSinceShortcutLaunch) | 322 if (days_since_shortcut_launch <= kMaxDaysSinceShortcutLaunch) |
| 323 return GetWebAppInstalledPoints(); | 323 return GetWebAppInstalledPoints(); |
| 324 | 324 |
| 325 return 0; | 325 return 0; |
| 326 } | 326 } |
| 327 | 327 |
| 328 void SiteEngagementScore::DisableFirstDailyEngagementBonusForTesting() { | 328 void SiteEngagementScore::SetParamValuesForTesting() { |
| 329 param_values[MAX_POINTS_PER_DAY] = 5; | |
| 330 param_values[DECAY_PERIOD_IN_DAYS] = 7; | |
| 331 param_values[DECAY_POINTS] = 5; | |
| 332 param_values[NAVIGATION_POINTS] = 0.5; | |
| 333 param_values[USER_INPUT_POINTS] = 0.05; | |
| 334 param_values[VISIBLE_MEDIA_POINTS] = 0.02; | |
| 335 param_values[HIDDEN_MEDIA_POINTS] = 0.01; | |
| 336 param_values[WEB_APP_INSTALLED_POINTS] = 5; | |
| 329 param_values[FIRST_DAILY_ENGAGEMENT] = 0; | 337 param_values[FIRST_DAILY_ENGAGEMENT] = 0; |
|
dominickn
2016/01/25 03:04:57
Nit: add a comment pointing out that first daily e
calamity
2016/01/27 03:47:22
Done.
| |
| 330 } | 338 } |
| 331 | 339 |
| 332 const char SiteEngagementService::kEngagementParams[] = "SiteEngagement"; | 340 const char SiteEngagementService::kEngagementParams[] = "SiteEngagement"; |
| 333 | 341 |
| 334 // static | 342 // static |
| 335 SiteEngagementService* SiteEngagementService::Get(Profile* profile) { | 343 SiteEngagementService* SiteEngagementService::Get(Profile* profile) { |
| 336 return SiteEngagementServiceFactory::GetForProfile(profile); | 344 return SiteEngagementServiceFactory::GetForProfile(profile); |
| 337 } | 345 } |
| 338 | 346 |
| 339 // static | 347 // static |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 655 HostContentSettingsMapFactory::GetForProfile(profile_); | 663 HostContentSettingsMapFactory::GetForProfile(profile_); |
| 656 for (const auto& origin_to_count : origin_counts) { | 664 for (const auto& origin_to_count : origin_counts) { |
| 657 if (origin_to_count.second != 0) | 665 if (origin_to_count.second != 0) |
| 658 continue; | 666 continue; |
| 659 | 667 |
| 660 settings_map->SetWebsiteSettingDefaultScope( | 668 settings_map->SetWebsiteSettingDefaultScope( |
| 661 origin_to_count.first, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, | 669 origin_to_count.first, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, |
| 662 std::string(), nullptr); | 670 std::string(), nullptr); |
| 663 } | 671 } |
| 664 } | 672 } |
| OLD | NEW |