diff --git a/components/background_fetch/background_fetch_delegate_base.cc b/components/background_fetch/background_fetch_delegate_base.cc index 2cd4b82fe874..d4ecd4e5e29a 100644 --- a/components/background_fetch/background_fetch_delegate_base.cc +++ b/components/background_fetch/background_fetch_delegate_base.cc @@ -114,6 +114,7 @@ void BackgroundFetchDelegateBase::DownloadUrl( job_details->MarkJobAsStarted(); } + params.request_params.initiator = job_details->fetch_description->origin; params.request_params.isolation_info = job_details->fetch_description->isolation_info; diff --git a/components/download/content/internal/download_driver_impl.cc b/components/download/content/internal/download_driver_impl.cc index 0428af0294a0..97e96659ff3c 100644 --- a/components/download/content/internal/download_driver_impl.cc +++ b/components/download/content/internal/download_driver_impl.cc @@ -229,6 +229,10 @@ void DownloadDriverImpl::Start( } download_url_params->set_update_first_party_url_on_redirect( request_params.update_first_party_url_on_redirect); + if (request_params.initiator) { + download_url_params->set_initiator( + request_params.initiator.value()); + } download_manager_coordinator_->DownloadUrl(std::move(download_url_params)); } diff --git a/components/download/public/background_service/download_params.h b/components/download/public/background_service/download_params.h index 8d539cbe3cb9..b5ca05c0c652 100644 --- a/components/download/public/background_service/download_params.h +++ b/components/download/public/background_service/download_params.h @@ -18,6 +18,7 @@ #include "net/traffic_annotation/network_traffic_annotation.h" #include "services/network/public/mojom/fetch_api.mojom-shared.h" #include "url/gurl.h" +#include "url/origin.h" namespace download { @@ -135,6 +136,8 @@ struct COMPONENT_EXPORT(COMPONENTS_DOWNLOAD_PUBLIC_BACKGROUND_SERVICE) // considered a main frame navigation. However, this is not true for // background fetch. bool update_first_party_url_on_redirect = true; + + std::optional initiator; }; // The parameters that describe a download request made to the DownloadService.