From: uazo Date: Mon, 15 Nov 2021 09:43:29 +0000 Subject: Disable conversion measurement api Disable Conversion Measurement API by disabling the flag and removing support for the AttributionReporting provider. it also removes the handling of attributions via intents between apps. This patch enforces the deactivation by preventing the report from being sent and being saved to disk, although it is currently in uncalled code. --- .../flags/android/chrome_feature_list.cc | 2 +- .../embedder_support/origin_trials/features.cc | 3 ++- .../render_view_context_menu_base.cc | 3 --- .../aggregatable_report_sender.cc | 17 ++++++++--------- .../attribution_reporting/attribution_host.cc | 1 + .../attribution_report_network_sender.cc | 15 ++++++++------- .../attribution_storage_sql.cc | 2 +- content/browser/storage_partition_impl.cc | 7 +------ content/public/browser/navigation_controller.cc | 1 - third_party/blink/common/features.cc | 2 +- .../platform/runtime_enabled_features.json5 | 9 ++++++++- 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/chrome/browser/flags/android/chrome_feature_list.cc b/chrome/browser/flags/android/chrome_feature_list.cc --- a/chrome/browser/flags/android/chrome_feature_list.cc +++ b/chrome/browser/flags/android/chrome_feature_list.cc @@ -442,7 +442,7 @@ const base::Feature kAppMenuMobileSiteOption{"AppMenuMobileSiteOption", base::FEATURE_DISABLED_BY_DEFAULT}; const base::Feature kAppToWebAttribution{"AppToWebAttribution", - base::FEATURE_DISABLED_BY_DEFAULT}; + base::FEATURE_DISABLED_BY_DEFAULT}; // guard this const base::Feature kBackgroundThreadPool{"BackgroundThreadPool", base::FEATURE_DISABLED_BY_DEFAULT}; diff --git a/components/embedder_support/origin_trials/features.cc b/components/embedder_support/origin_trials/features.cc --- a/components/embedder_support/origin_trials/features.cc +++ b/components/embedder_support/origin_trials/features.cc @@ -17,8 +17,9 @@ const base::Feature kOriginTrialsSampleAPIThirdPartyAlternativeUsage{ "OriginTrialsSampleAPIThirdPartyAlternativeUsage", base::FEATURE_ENABLED_BY_DEFAULT}; +// When disabled, the API cannot be enabled by tokens. const base::Feature kConversionMeasurementAPIAlternativeUsage{ "ConversionMeasurementAPIAlternativeUsage", - base::FEATURE_ENABLED_BY_DEFAULT}; + base::FEATURE_DISABLED_BY_DEFAULT}; } // namespace embedder_support diff --git a/components/renderer_context_menu/render_view_context_menu_base.cc b/components/renderer_context_menu/render_view_context_menu_base.cc --- a/components/renderer_context_menu/render_view_context_menu_base.cc +++ b/components/renderer_context_menu/render_view_context_menu_base.cc @@ -486,9 +486,6 @@ void RenderViewContextMenuBase::OpenURLWithExtraHeaders( open_url_params.source_site_instance = site_instance_; - if (disposition != WindowOpenDisposition::OFF_THE_RECORD) - open_url_params.impression = params_.impression; - source_web_contents_->OpenURL(open_url_params); } diff --git a/content/browser/aggregation_service/aggregatable_report_sender.cc b/content/browser/aggregation_service/aggregatable_report_sender.cc --- a/content/browser/aggregation_service/aggregatable_report_sender.cc +++ b/content/browser/aggregation_service/aggregatable_report_sender.cc @@ -137,19 +137,18 @@ void AggregatableReportSender::SendReport(const GURL& url, // Allow bodies of non-2xx responses to be returned. simple_url_loader_ptr->SetAllowHttpErrorResults(true); - // Unretained is safe because the URLLoader is owned by `this` and will be - // deleted before `this`. - simple_url_loader_ptr->DownloadHeadersOnly( - url_loader_factory_.get(), - base::BindOnce(&AggregatableReportSender::OnReportSent, - base::Unretained(this), std::move(it), - std::move(callback))); + // this is never called on Bromite but nothing would be sent if it were + OnReportSent(std::move(it), std::move(callback), nullptr); } void AggregatableReportSender::OnReportSent( UrlLoaderList::iterator it, ReportSentCallback callback, - scoped_refptr headers) { + scoped_refptr headers) { // disable in Bromite + if ((true)) { + std::move(callback).Run(RequestStatus::kOk); + return; + } RequestStatus status; absl::optional http_response_code; @@ -189,4 +188,4 @@ void AggregatableReportSender::OnReportSent( std::move(callback).Run(status); } -} // namespace content \ No newline at end of file +} // namespace content diff --git a/content/browser/attribution_reporting/attribution_host.cc b/content/browser/attribution_reporting/attribution_host.cc --- a/content/browser/attribution_reporting/attribution_host.cc +++ b/content/browser/attribution_reporting/attribution_host.cc @@ -141,6 +141,7 @@ void AttributionHost::DidFinishNavigation(NavigationHandle* navigation_handle) { return; } + if ((true)) return; AttributionManager* attribution_manager = attribution_manager_provider_->GetManager(web_contents()); if (!attribution_manager) { diff --git a/content/browser/attribution_reporting/attribution_report_network_sender.cc b/content/browser/attribution_reporting/attribution_report_network_sender.cc --- a/content/browser/attribution_reporting/attribution_report_network_sender.cc +++ b/content/browser/attribution_reporting/attribution_report_network_sender.cc @@ -118,13 +118,8 @@ void AttributionReportNetworkSender::SendReport( network::SimpleURLLoader::RETRY_ON_NAME_NOT_RESOLVED; simple_url_loader_ptr->SetRetryOptions(/*max_retries=*/1, retry_mode); - // Unretained is safe because the URLLoader is owned by |this| and will be - // deleted before |this|. - simple_url_loader_ptr->DownloadHeadersOnly( - url_loader_factory_.get(), - base::BindOnce(&AttributionReportNetworkSender::OnReportSent, - base::Unretained(this), std::move(it), std::move(report), - is_debug_report, std::move(sent_callback))); + // this is never called on Bromite but nothing would be sent if it were + OnReportSent(std::move(it), report, is_debug_report, std::move(sent_callback), nullptr); } void AttributionReportNetworkSender::SetURLLoaderFactoryForTesting( @@ -138,6 +133,12 @@ void AttributionReportNetworkSender::OnReportSent( bool is_debug_report, ReportSentCallback sent_callback, scoped_refptr headers) { + if ((true)) { + std::move(sent_callback) + .Run(std::move(report), + SendResult(SendResult::Status::kSent, headers ? headers->response_code() : 200)); + return; + } network::SimpleURLLoader* loader = it->get(); // Consider a non-200 HTTP code as a non-internal error. diff --git a/content/browser/attribution_reporting/attribution_storage_sql.cc b/content/browser/attribution_reporting/attribution_storage_sql.cc --- a/content/browser/attribution_reporting/attribution_storage_sql.cc +++ b/content/browser/attribution_reporting/attribution_storage_sql.cc @@ -358,7 +358,7 @@ void AttributionStorageSql::RunInMemoryForTesting() { } // static -bool AttributionStorageSql::g_run_in_memory_ = false; +bool AttributionStorageSql::g_run_in_memory_ = true; AttributionStorageSql::AttributionStorageSql( const base::FilePath& path_to_database, diff --git a/content/browser/storage_partition_impl.cc b/content/browser/storage_partition_impl.cc --- a/content/browser/storage_partition_impl.cc +++ b/content/browser/storage_partition_impl.cc @@ -1304,12 +1304,7 @@ void StoragePartitionImpl::Initialize( bucket_manager_ = std::make_unique(quota_manager_proxy); - // The Conversion Measurement API is not available in Incognito mode. - if (!is_in_memory() && - base::FeatureList::IsEnabled(blink::features::kConversionMeasurement)) { - attribution_manager_ = std::make_unique( - this, path, special_storage_policy_); - } + // The Conversion Measurement API is not available in Bromite. if (base::FeatureList::IsEnabled(blink::features::kInterestGroupStorage)) { interest_group_manager_ = std::make_unique( diff --git a/content/public/browser/navigation_controller.cc b/content/public/browser/navigation_controller.cc --- a/content/public/browser/navigation_controller.cc +++ b/content/public/browser/navigation_controller.cc @@ -36,7 +36,6 @@ NavigationController::LoadURLParams::LoadURLParams(const OpenURLParams& input) blob_url_loader_factory(input.blob_url_loader_factory), href_translate(input.href_translate), reload_type(input.reload_type), - impression(input.impression), is_pdf(input.is_pdf) { #if DCHECK_IS_ON() DCHECK(input.Valid()); diff --git a/third_party/blink/common/features.cc b/third_party/blink/common/features.cc --- a/third_party/blink/common/features.cc +++ b/third_party/blink/common/features.cc @@ -49,7 +49,7 @@ const base::Feature kCSSContainerQueries{"CSSContainerQueries", // Controls whether the Conversion Measurement API infrastructure is enabled. const base::Feature kConversionMeasurement{"ConversionMeasurement", - base::FEATURE_ENABLED_BY_DEFAULT}; + base::FEATURE_DISABLED_BY_DEFAULT}; // Controls whether LCP calculations should exclude low-entropy images. If // enabled, then the associated parameter sets the cutoff, expressed as the diff --git a/third_party/blink/renderer/platform/runtime_enabled_features.json5 b/third_party/blink/renderer/platform/runtime_enabled_features.json5 --- a/third_party/blink/renderer/platform/runtime_enabled_features.json5 +++ b/third_party/blink/renderer/platform/runtime_enabled_features.json5 @@ -106,6 +106,13 @@ }, data: [ + { + // disable by default features by marking as + // depends_on: ["DisabledForBromite"] + // to work is needed to remove "origin_trial_feature_name" + // and "origin_trial_allows_third_party" + name: "DisabledForBromite", + }, { name: "AbortSignalThrowIfAborted", status: "stable", @@ -482,7 +489,7 @@ }, { name: "ConversionMeasurement", - status: "test", + depends_on: ["DisabledForBromite"], }, { name: "CooperativeScheduling" -- 2.25.1