#include "chrome/browser/background_sync/background_sync_delegate_impl.h"
#include "build/build_config.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/metrics/ukm_background_recorder_service.h"
#include "chrome/browser/profiles/keep_alive/profile_keep_alive_types.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/keep_alive_registry/keep_alive_registry.h"
#include "components/keep_alive_registry/keep_alive_types.h"
#include "components/site_engagement/content/site_engagement_service.h"
#include "components/webapps/common/web_app_id.h"
#include "content/public/browser/background_sync_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "url/origin.h"
#if BUILDFLAG(IS_ANDROID)
#include "chrome/browser/android/background_sync_launcher_android.h"
#endif
BackgroundSyncDelegateImpl::BackgroundSyncDelegateImpl(Profile* profile)
: … { … }
BackgroundSyncDelegateImpl::~BackgroundSyncDelegateImpl() = default;
#if !BUILDFLAG(IS_ANDROID)
BackgroundSyncDelegateImpl::BackgroundSyncEventKeepAliveImpl::
BackgroundSyncEventKeepAliveImpl(Profile* profile) { … }
BackgroundSyncDelegateImpl::BackgroundSyncEventKeepAliveImpl::
~BackgroundSyncEventKeepAliveImpl() = default;
std::unique_ptr<content::BackgroundSyncController::BackgroundSyncEventKeepAlive>
BackgroundSyncDelegateImpl::CreateBackgroundSyncEventKeepAlive() { … }
#endif
void BackgroundSyncDelegateImpl::GetUkmSourceId(
const url::Origin& origin,
base::OnceCallback<void(std::optional<ukm::SourceId>)> callback) { … }
void BackgroundSyncDelegateImpl::Shutdown() { … }
HostContentSettingsMap*
BackgroundSyncDelegateImpl::GetHostContentSettingsMap() { … }
bool BackgroundSyncDelegateImpl::IsProfileOffTheRecord() { … }
void BackgroundSyncDelegateImpl::NoteSuspendedPeriodicSyncOrigins(
std::set<url::Origin> suspended_origins) { … }
int BackgroundSyncDelegateImpl::GetSiteEngagementPenalty(const GURL& url) { … }
#if BUILDFLAG(IS_ANDROID)
void BackgroundSyncDelegateImpl::ScheduleBrowserWakeUpWithDelay(
blink::mojom::BackgroundSyncType sync_type,
base::TimeDelta delay) {
BackgroundSyncLauncherAndroid::ScheduleBrowserWakeUpWithDelay(sync_type,
delay);
}
void BackgroundSyncDelegateImpl::CancelBrowserWakeup(
blink::mojom::BackgroundSyncType sync_type) {
BackgroundSyncLauncherAndroid::CancelBrowserWakeup(sync_type);
}
bool BackgroundSyncDelegateImpl::ShouldDisableBackgroundSync() {
return BackgroundSyncLauncherAndroid::ShouldDisableBackgroundSync();
}
bool BackgroundSyncDelegateImpl::ShouldDisableAndroidNetworkDetection() {
return false;
}
#endif
void BackgroundSyncDelegateImpl::OnEngagementEvent(
content::WebContents* web_contents,
const GURL& url,
double score,
double old_score,
site_engagement::EngagementType engagement_type,
const std::optional<webapps::AppId>& app_id) { … }