| 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 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/metrics/field_trial.h" | 15 #include "base/metrics/field_trial.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/time/clock.h" | 17 #include "base/time/clock.h" |
| 18 #include "base/time/default_clock.h" | 18 #include "base/time/default_clock.h" |
| 19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 20 #include "base/values.h" | 20 #include "base/values.h" |
| 21 #include "chrome/browser/banners/app_banner_settings_helper.h" | 21 #include "chrome/browser/banners/app_banner_settings_helper.h" |
| 22 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 22 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 23 #include "chrome/browser/engagement/site_engagement_eviction_policy.h" | |
| 24 #include "chrome/browser/engagement/site_engagement_metrics.h" | 23 #include "chrome/browser/engagement/site_engagement_metrics.h" |
| 25 #include "chrome/browser/engagement/site_engagement_score.h" | 24 #include "chrome/browser/engagement/site_engagement_score.h" |
| 26 #include "chrome/browser/engagement/site_engagement_service_factory.h" | 25 #include "chrome/browser/engagement/site_engagement_service_factory.h" |
| 27 #include "chrome/browser/history/history_service_factory.h" | 26 #include "chrome/browser/history/history_service_factory.h" |
| 28 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
| 29 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 30 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 31 #include "components/content_settings/core/browser/host_content_settings_map.h" | 30 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 32 #include "components/content_settings/core/common/content_settings_pattern.h" | 31 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 33 #include "components/history/core/browser/history_service.h" | 32 #include "components/history/core/browser/history_service.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 double SiteEngagementService::GetMaxPoints() { | 83 double SiteEngagementService::GetMaxPoints() { |
| 85 return SiteEngagementScore::kMaxPoints; | 84 return SiteEngagementScore::kMaxPoints; |
| 86 } | 85 } |
| 87 | 86 |
| 88 // static | 87 // static |
| 89 bool SiteEngagementService::IsEnabled() { | 88 bool SiteEngagementService::IsEnabled() { |
| 90 // If the engagement service or any of its dependencies are force-enabled, | 89 // If the engagement service or any of its dependencies are force-enabled, |
| 91 // return true immediately. | 90 // return true immediately. |
| 92 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 91 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 93 switches::kEnableSiteEngagementService) || | 92 switches::kEnableSiteEngagementService) || |
| 94 SiteEngagementEvictionPolicy::IsEnabled() || | |
| 95 AppBannerSettingsHelper::ShouldUseSiteEngagementScore()) { | 93 AppBannerSettingsHelper::ShouldUseSiteEngagementScore()) { |
| 96 return true; | 94 return true; |
| 97 } | 95 } |
| 98 | 96 |
| 99 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 97 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 100 switches::kDisableSiteEngagementService)) { | 98 switches::kDisableSiteEngagementService)) { |
| 101 return false; | 99 return false; |
| 102 } | 100 } |
| 103 const std::string group_name = | 101 const std::string group_name = |
| 104 base::FieldTrialList::FindFullName(kEngagementParams); | 102 base::FieldTrialList::FindFullName(kEngagementParams); |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 if (!engagement_score.last_shortcut_launch_time().is_null() && | 616 if (!engagement_score.last_shortcut_launch_time().is_null() && |
| 619 engagement_score.last_shortcut_launch_time() > last_visit) { | 617 engagement_score.last_shortcut_launch_time() > last_visit) { |
| 620 engagement_score.set_last_shortcut_launch_time(last_visit); | 618 engagement_score.set_last_shortcut_launch_time(last_visit); |
| 621 } | 619 } |
| 622 | 620 |
| 623 engagement_score.Commit(); | 621 engagement_score.Commit(); |
| 624 } | 622 } |
| 625 | 623 |
| 626 SetLastEngagementTime(now); | 624 SetLastEngagementTime(now); |
| 627 } | 625 } |
| OLD | NEW |