#include "chrome/browser/ui/user_education/recent_session_policy.h"
#include <optional>
#include "base/dcheck_is_on.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_functions.h"
#include "base/time/time.h"
#include "chrome/browser/user_education/browser_feature_promo_storage_service.h"
#include "chrome/browser/user_education/user_education_service.h"
namespace {
constexpr int kMaxRecords = …;
base::Time GetEndOfDay(base::Time time) { … }
std::optional<int> CountActiveDays(const RecentSessionData& recent_sessions,
base::Time last_day,
int num_days) { … }
std::optional<int> ValueOrNull(int value) { … }
}
bool RecentSessionPolicyImpl::Constraint::ShouldSkipRecording(
const RecentSessionData& recent_sessions) const { … }
bool RecentSessionPolicyImpl::DailyConstraint::ShouldSkipRecording(
const RecentSessionData& recent_sessions) const { … }
std::optional<int> RecentSessionPolicyImpl::SessionCountConstraint::GetCount(
const RecentSessionData& recent_sessions) const { … }
std::optional<int> RecentSessionPolicyImpl::ActiveDaysConstraint::GetCount(
const RecentSessionData& recent_sessions) const { … }
std::optional<int> RecentSessionPolicyImpl::ActiveWeeksConstraint::GetCount(
const RecentSessionData& recent_sessions) const { … }
RecentSessionPolicyImpl::ConstraintInfo::ConstraintInfo() = default;
RecentSessionPolicyImpl::ConstraintInfo::ConstraintInfo(
std::unique_ptr<Constraint> constraint_,
std::string histogram_name_,
std::optional<int> histogram_max_,
std::optional<int> low_usage_max_)
: … { … }
RecentSessionPolicyImpl::ConstraintInfo::ConstraintInfo(
ConstraintInfo&&) noexcept = default;
RecentSessionPolicyImpl::ConstraintInfo&
RecentSessionPolicyImpl::ConstraintInfo::operator=(ConstraintInfo&&) noexcept =
default;
RecentSessionPolicyImpl::ConstraintInfo::~ConstraintInfo() = default;
RecentSessionPolicyImpl::RecentSessionPolicyImpl(ConstraintInfos constraints)
: … { … }
RecentSessionPolicyImpl::~RecentSessionPolicyImpl() = default;
void RecentSessionPolicyImpl::RecordRecentUsageMetrics(
const RecentSessionData& recent_sessions) { … }
bool RecentSessionPolicyImpl::ShouldEnableLowUsagePromoMode(
const RecentSessionData& recent_sessions) const { … }
RecentSessionPolicyImpl::ConstraintInfos
RecentSessionPolicyImpl::GetDefaultConstraints() { … }