#include "chrome/browser/media/media_engagement_service.h"
#include <functional>
#include <vector>
#include "base/functional/bind.h"
#include "base/time/clock.h"
#include "base/time/default_clock.h"
#include "base/time/time.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/media/media_engagement_contents_observer.h"
#include "chrome/browser/media/media_engagement_score.h"
#include "chrome/browser/media/media_engagement_service_factory.h"
#include "chrome/browser/preloading/prefetch/no_state_prefetch/chrome_no_state_prefetch_contents_delegate.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/history/core/browser/history_service.h"
#include "components/no_state_prefetch/browser/no_state_prefetch_contents.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/web_contents.h"
#include "media/base/media_switches.h"
#include "url/origin.h"
namespace {
static const int kSchemaVersion = …;
static const int kSchemaVersionAddingExpiration = …;
enum class MediaEngagementClearReason { … };
bool MediaEngagementFilterAdapter(
const url::Origin& predicate,
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern) { … }
bool MediaEngagementTimeFilterAdapter(
MediaEngagementService* service,
base::Time delete_begin,
base::Time delete_end,
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern) { … }
}
bool MediaEngagementService::IsEnabled() { … }
MediaEngagementService* MediaEngagementService::Get(Profile* profile) { … }
void MediaEngagementService::CreateWebContentsObserver(
content::WebContents* web_contents) { … }
void MediaEngagementService::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) { … }
MediaEngagementService::MediaEngagementService(Profile* profile)
: … { … }
MediaEngagementService::MediaEngagementService(Profile* profile,
base::Clock* clock)
: … { … }
MediaEngagementService::~MediaEngagementService() = default;
int MediaEngagementService::GetSchemaVersion() const { … }
void MediaEngagementService::SetSchemaVersion(int version) { … }
void MediaEngagementService::ClearDataBetweenTime(
const base::Time& delete_begin,
const base::Time& delete_end) { … }
void MediaEngagementService::Shutdown() { … }
void MediaEngagementService::OnHistoryDeletions(
history::HistoryService* history_service,
const history::DeletionInfo& deletion_info) { … }
void MediaEngagementService::RemoveOriginsWithNoVisits(
const std::set<url::Origin>& deleted_origins,
const history::OriginCountAndLastVisitMap& origin_data) { … }
void MediaEngagementService::Clear(const url::Origin& origin) { … }
double MediaEngagementService::GetEngagementScore(
const url::Origin& origin) const { … }
bool MediaEngagementService::HasHighEngagement(
const url::Origin& origin) const { … }
std::map<url::Origin, double> MediaEngagementService::GetScoreMapForTesting()
const { … }
void MediaEngagementService::RecordVisit(const url::Origin& origin) { … }
std::vector<media::mojom::MediaEngagementScoreDetailsPtr>
MediaEngagementService::GetAllScoreDetails() const { … }
MediaEngagementScore MediaEngagementService::CreateEngagementScore(
const url::Origin& origin) const { … }
MediaEngagementContentsObserver* MediaEngagementService::GetContentsObserverFor(
content::WebContents* web_contents) const { … }
void MediaEngagementService::SetHistoryServiceForTesting(
history::HistoryService* history) { … }
Profile* MediaEngagementService::profile() const { … }
bool MediaEngagementService::ShouldRecordEngagement(
const url::Origin& origin) const { … }
std::vector<MediaEngagementScore> MediaEngagementService::GetAllStoredScores()
const { … }