#include "chrome/browser/background_fetch/background_fetch_delegate_impl.h"
#include <utility>
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/notreached.h"
#include "base/strings/string_util.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "chrome/browser/download/background_download_service_factory.h"
#include "chrome/browser/metrics/ukm_background_recorder_service.h"
#include "chrome/browser/offline_items_collection/offline_content_aggregator_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_key.h"
#include "components/background_fetch/job_details.h"
#include "components/download/public/background_service/background_download_service.h"
#include "components/download/public/common/download_features.h"
#include "components/offline_items_collection/core/offline_content_aggregator.h"
#include "components/offline_items_collection/core/offline_item.h"
#include "content/public/browser/background_fetch_description.h"
#include "content/public/browser/browser_thread.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "url/origin.h"
namespace {
constexpr char kBackgroundFetchNamespacePrefix[] = …;
}
BackgroundFetchDelegateImpl::BackgroundFetchDelegateImpl(Profile* profile)
: … { … }
BackgroundFetchDelegateImpl::~BackgroundFetchDelegateImpl() { … }
void BackgroundFetchDelegateImpl::MarkJobComplete(const std::string& job_id) { … }
void BackgroundFetchDelegateImpl::UpdateUI(
const std::string& job_id,
const std::optional<std::string>& title,
const std::optional<SkBitmap>& icon) { … }
void BackgroundFetchDelegateImpl::OpenItem(
const offline_items_collection::OpenParams& open_params,
const offline_items_collection::ContentId& id) { … }
void BackgroundFetchDelegateImpl::RemoveItem(
const offline_items_collection::ContentId& id) { … }
void BackgroundFetchDelegateImpl::CancelDownload(
const offline_items_collection::ContentId& id) { … }
void BackgroundFetchDelegateImpl::PauseDownload(
const offline_items_collection::ContentId& id) { … }
void BackgroundFetchDelegateImpl::ResumeDownload(
const offline_items_collection::ContentId& id) { … }
void BackgroundFetchDelegateImpl::GetItemById(
const offline_items_collection::ContentId& id,
SingleItemCallback callback) { … }
void BackgroundFetchDelegateImpl::GetAllItems(MultipleItemCallback callback) { … }
void BackgroundFetchDelegateImpl::GetVisualsForItem(
const offline_items_collection::ContentId& id,
GetVisualsOptions options,
VisualsCallback callback) { … }
void BackgroundFetchDelegateImpl::GetShareInfoForItem(
const offline_items_collection::ContentId& id,
ShareCallback callback) { … }
void BackgroundFetchDelegateImpl::RenameItem(
const offline_items_collection::ContentId& id,
const std::string& name,
RenameCallback callback) { … }
download::BackgroundDownloadService*
BackgroundFetchDelegateImpl::GetDownloadService() { … }
void BackgroundFetchDelegateImpl::OnJobDetailsCreated(
const std::string& job_id) { … }
void BackgroundFetchDelegateImpl::DoShowUi(const std::string& job_id) { … }
void BackgroundFetchDelegateImpl::DoUpdateUi(const std::string& job_id) { … }
void BackgroundFetchDelegateImpl::DoCleanUpUi(const std::string& job_id) { … }
void BackgroundFetchDelegateImpl::UpdateOfflineItem(const std::string& job_id) { … }
void BackgroundFetchDelegateImpl::
RecordBackgroundFetchDeletingRegistrationUkmEvent(
const url::Origin& origin,
bool user_initiated_abort) { … }
void BackgroundFetchDelegateImpl::DidGetBackgroundSourceId(
bool user_initiated_abort,
std::optional<ukm::SourceId> source_id) { … }
BackgroundFetchDelegateImpl::UiState::UiState() = default;
BackgroundFetchDelegateImpl::UiState::~UiState() = default;