Files
cromite/build/patches/Disable-conversion-measurement-api.patch
T

235 lines
11 KiB
Diff

From: uazo <uazo@users.noreply.github.com>
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.
Original License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html
License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html
---
.../embedder_support/origin_trials/features.cc | 8 ++++----
.../render_view_context_menu_base.cc | 3 ---
.../aggregatable_report_sender.cc | 15 +++++++--------
.../attribution_reporting/attribution_host.cc | 1 +
.../attribution_report_network_sender.cc | 9 +++++++++
.../attribution_storage_sql.cc | 8 +++++---
content/browser/storage_partition_impl.cc | 7 +------
content/public/browser/navigation_controller.cc | 1 -
content/renderer/render_thread_impl.cc | 2 +-
third_party/blink/common/features.cc | 8 ++++----
.../platform/runtime_enabled_features.json5 | 7 +++++++
11 files changed, 39 insertions(+), 30 deletions(-)
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
@@ -14,11 +14,11 @@ namespace embedder_support {
// Users from control group will have the feature disabled, excluding them
// from the origin trial.
BASE_FEATURE(kOriginTrialsSampleAPIThirdPartyAlternativeUsage,
- "OriginTrialsSampleAPIThirdPartyAlternativeUsage",
- base::FEATURE_ENABLED_BY_DEFAULT);
+ "OriginTrialsSampleAPIThirdPartyAlternativeUsage", // must be disabled
+ base::FEATURE_DISABLED_BY_DEFAULT); // in Bromite
BASE_FEATURE(kConversionMeasurementAPIAlternativeUsage,
- "ConversionMeasurementAPIAlternativeUsage",
- base::FEATURE_ENABLED_BY_DEFAULT);
+ "ConversionMeasurementAPIAlternativeUsage", // must be disabled
+ base::FEATURE_DISABLED_BY_DEFAULT); // in Bromite
} // 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
@@ -507,9 +507,6 @@ RenderViewContextMenuBase::GetOpenURLParamsWithExtraHeaders(
open_url_params.source_site_instance = site_instance_;
- if (disposition != WindowOpenDisposition::OFF_THE_RECORD)
- open_url_params.impression = params_.impression;
-
return 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
@@ -136,19 +136,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<net::HttpResponseHeaders> headers) {
+ scoped_refptr<net::HttpResponseHeaders> headers) { // disable in Bromite
+ if ((true)) {
+ std::move(callback).Run(RequestStatus::kOk);
+ return;
+ }
RequestStatus status;
absl::optional<int> http_response_code;
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
@@ -189,6 +189,7 @@ void AttributionHost::DidRedirectNavigation(
return;
}
+ if ((true)) return;
AttributionManager* attribution_manager =
AttributionManager::FromWebContents(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
@@ -83,6 +83,9 @@ void AttributionReportNetworkSender::SendReport(GURL url,
const std::string& body,
net::HttpRequestHeaders headers,
UrlLoaderCallback callback) {
+ // this is never called on Bromite but nothing would be sent if it were
+ if ((true)) return;
+
auto resource_request = std::make_unique<network::ResourceRequest>();
resource_request->url = std::move(url);
resource_request->headers = std::move(headers);
@@ -154,6 +157,12 @@ void AttributionReportNetworkSender::OnReportSent(
ReportSentCallback sent_callback,
UrlLoaderList::iterator it,
scoped_refptr<net::HttpResponseHeaders> 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
@@ -438,6 +438,8 @@ base::FilePath DatabasePath(const base::FilePath& user_data_directory) {
return user_data_directory.Append(kDatabasePath);
}
+bool g_run_in_memory = true;
+
} // namespace
// static
@@ -449,9 +451,9 @@ bool AttributionStorageSql::DeleteStorageForTesting(
AttributionStorageSql::AttributionStorageSql(
const base::FilePath& user_data_directory,
std::unique_ptr<AttributionStorageDelegate> delegate)
- : path_to_database_(user_data_directory.empty()
- ? base::FilePath()
- : DatabasePath(user_data_directory)),
+ : path_to_database_(user_data_directory.empty() || g_run_in_memory
+ ? base::FilePath()
+ : DatabasePath(user_data_directory)),
delegate_(std::move(delegate)),
rate_limit_table_(delegate_.get()) {
DCHECK(delegate_);
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
@@ -1339,12 +1339,7 @@ void StoragePartitionImpl::Initialize(
bucket_manager_ = std::make_unique<BucketManager>(this);
- // 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<AttributionManagerImpl>(
- this, path, special_storage_policy_);
- }
+ // The Conversion Measurement API is not available in Bromite.
if (base::FeatureList::IsEnabled(blink::features::kInterestGroupStorage)) {
// Auction worklets on non-Android use dedicated processes; on Android due
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
@@ -40,7 +40,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/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -1853,7 +1853,7 @@ RenderThreadImpl::GetOsSupportForAttributionReporting() {
void RenderThreadImpl::SetOsSupportForAttributionReporting(
attribution_reporting::mojom::OsSupport attribution_os_support) {
- attribution_os_support_ = attribution_os_support;
+ attribution_os_support_ = attribution_reporting::mojom::OsSupport::kDisabled;
}
std::unique_ptr<CodecFactory> RenderThreadImpl::CreateMediaCodecFactory(
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
@@ -29,8 +29,8 @@ BASE_FEATURE(kAnonymousIframeOriginTrial,
// Gate access to Attribution Reporting cross app and web APIs that allow
// registering with a native attribution API.
BASE_FEATURE(kAttributionReportingCrossAppWeb,
- "AttributionReportingCrossAppWeb",
- base::FEATURE_DISABLED_BY_DEFAULT);
+ "AttributionReportingCrossAppWeb", // must be disabled
+ base::FEATURE_DISABLED_BY_DEFAULT); // in bromite
// Apply lazy-loading to ad frames which have embeds likely impacting Core Web
// Vitals.
@@ -128,8 +128,8 @@ BASE_FEATURE(kBlockingDownloadsInAdFrameWithoutUserActivation,
// Controls whether the Conversion Measurement API infrastructure is enabled.
BASE_FEATURE(kConversionMeasurement,
- "ConversionMeasurement",
- base::FEATURE_ENABLED_BY_DEFAULT);
+ "ConversionMeasurement", // must be disabled
+ base::FEATURE_DISABLED_BY_DEFAULT); // in Bromite
// 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
@@ -203,6 +203,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: "AbortSignalAny",
status: "experimental",
--
2.25.1