#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/site_engagement/content/site_engagement_score.h"
#include <algorithm>
#include <cmath>
#include <utility>
#include "base/metrics/field_trial_params.h"
#include "base/no_destructor.h"
#include "base/strings/string_number_conversions.h"
#include "base/time/clock.h"
#include "base/time/time.h"
#include "base/values.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/content_settings/core/common/content_settings_utils.h"
#include "components/site_engagement/content/engagement_type.h"
#include "components/site_engagement/content/site_engagement_metrics.h"
#include "third_party/blink/public/mojom/site_engagement/site_engagement.mojom.h"
namespace site_engagement {
namespace {
const double kScoreDelta = …;
const double kTimeDelta = …;
const int kMaxDaysSinceShortcutLaunch = …;
bool DoublesConsideredDifferent(double value1, double value2, double delta) { … }
base::Value::Dict GetSiteEngagementScoreDictForSettings(
const HostContentSettingsMap* settings,
const GURL& origin_url) { … }
}
const double SiteEngagementScore::kMaxPoints = …;
const char SiteEngagementScore::kRawScoreKey[] = …;
const char SiteEngagementScore::kPointsAddedTodayKey[] = …;
const char SiteEngagementScore::kLastEngagementTimeKey[] = …;
const char SiteEngagementScore::kLastShortcutLaunchTimeKey[] = …;
SiteEngagementScore::ParamValues& SiteEngagementScore::GetParamValues() { … }
double SiteEngagementScore::GetMaxPointsPerDay() { … }
double SiteEngagementScore::GetDecayPeriodInHours() { … }
double SiteEngagementScore::GetDecayPoints() { … }
double SiteEngagementScore::GetDecayProportion() { … }
double SiteEngagementScore::GetScoreCleanupThreshold() { … }
double SiteEngagementScore::GetNavigationPoints() { … }
double SiteEngagementScore::GetUserInputPoints() { … }
double SiteEngagementScore::GetVisibleMediaPoints() { … }
double SiteEngagementScore::GetHiddenMediaPoints() { … }
double SiteEngagementScore::GetWebAppInstalledPoints() { … }
double SiteEngagementScore::GetFirstDailyEngagementPoints() { … }
double SiteEngagementScore::GetBootstrapPoints() { … }
double SiteEngagementScore::GetMediumEngagementBoundary() { … }
double SiteEngagementScore::GetHighEngagementBoundary() { … }
double SiteEngagementScore::GetMaxDecaysPerScore() { … }
double SiteEngagementScore::GetLastEngagementGracePeriodInHours() { … }
double SiteEngagementScore::GetNotificationInteractionPoints() { … }
void SiteEngagementScore::SetParamValuesForTesting() { … }
void SiteEngagementScore::UpdateFromVariations(const char* param_name) { … }
SiteEngagementScore::SiteEngagementScore(base::Clock* clock,
const GURL& origin,
HostContentSettingsMap* settings)
: … { … }
SiteEngagementScore::SiteEngagementScore(SiteEngagementScore&& other) = default;
SiteEngagementScore::~SiteEngagementScore() { … }
SiteEngagementScore& SiteEngagementScore::operator=(
SiteEngagementScore&& other) = default;
void SiteEngagementScore::AddPoints(double points) { … }
double SiteEngagementScore::GetTotalScore() const { … }
mojom::SiteEngagementDetails SiteEngagementScore::GetDetails() const { … }
void SiteEngagementScore::Commit() { … }
blink::mojom::EngagementLevel SiteEngagementScore::GetEngagementLevel() const { … }
bool SiteEngagementScore::MaxPointsPerDayAdded() const { … }
void SiteEngagementScore::Reset(double points,
const base::Time last_engagement_time) { … }
void SiteEngagementScore::SetLastEngagementTime(const base::Time& time) { … }
bool SiteEngagementScore::UpdateScoreDict(base::Value::Dict& score_dict) { … }
SiteEngagementScore::SiteEngagementScore(
base::Clock* clock,
const GURL& origin,
std::optional<base::Value::Dict> score_dict)
: … { … }
double SiteEngagementScore::DecayedScore() const { … }
double SiteEngagementScore::BonusIfShortcutLaunched() const { … }
}