Disable-conversion-measurement-api.patch 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. From: uazo <uazo@users.noreply.github.com>
  2. Date: Mon, 15 Nov 2021 09:43:29 +0000
  3. Subject: Disable conversion measurement api
  4. Disable Conversion Measurement API by disabling the flag and removing
  5. support for the AttributionReporting provider. it also removes
  6. the handling of attributions via intents between apps.
  7. This patch enforces the deactivation by preventing the report from
  8. being sent and being saved to disk, although it is currently in uncalled code.
  9. ---
  10. .../flags/android/chrome_feature_list.cc | 2 +-
  11. .../embedder_support/origin_trials/features.cc | 3 ++-
  12. .../render_view_context_menu_base.cc | 3 ---
  13. .../aggregatable_report_sender.cc | 17 ++++++++---------
  14. .../attribution_report_network_sender.cc | 15 ++++++++-------
  15. .../attribution_storage_sql.cc | 2 +-
  16. content/browser/storage_partition_impl.cc | 7 +------
  17. content/public/browser/navigation_controller.cc | 1 -
  18. third_party/blink/common/features.cc | 2 +-
  19. .../platform/runtime_enabled_features.json5 | 9 ++++++++-
  20. 10 files changed, 30 insertions(+), 31 deletions(-)
  21. diff --git a/chrome/browser/flags/android/chrome_feature_list.cc b/chrome/browser/flags/android/chrome_feature_list.cc
  22. --- a/chrome/browser/flags/android/chrome_feature_list.cc
  23. +++ b/chrome/browser/flags/android/chrome_feature_list.cc
  24. @@ -442,7 +442,7 @@ const base::Feature kAppMenuMobileSiteOption{"AppMenuMobileSiteOption",
  25. base::FEATURE_DISABLED_BY_DEFAULT};
  26. const base::Feature kAppToWebAttribution{"AppToWebAttribution",
  27. - base::FEATURE_DISABLED_BY_DEFAULT};
  28. + base::FEATURE_DISABLED_BY_DEFAULT}; // guard this
  29. const base::Feature kBackgroundThreadPool{"BackgroundThreadPool",
  30. base::FEATURE_DISABLED_BY_DEFAULT};
  31. diff --git a/components/embedder_support/origin_trials/features.cc b/components/embedder_support/origin_trials/features.cc
  32. --- a/components/embedder_support/origin_trials/features.cc
  33. +++ b/components/embedder_support/origin_trials/features.cc
  34. @@ -17,8 +17,9 @@ const base::Feature kOriginTrialsSampleAPIThirdPartyAlternativeUsage{
  35. "OriginTrialsSampleAPIThirdPartyAlternativeUsage",
  36. base::FEATURE_ENABLED_BY_DEFAULT};
  37. +// When disabled, the API cannot be enabled by tokens.
  38. const base::Feature kConversionMeasurementAPIAlternativeUsage{
  39. "ConversionMeasurementAPIAlternativeUsage",
  40. - base::FEATURE_ENABLED_BY_DEFAULT};
  41. + base::FEATURE_DISABLED_BY_DEFAULT};
  42. } // namespace embedder_support
  43. diff --git a/components/renderer_context_menu/render_view_context_menu_base.cc b/components/renderer_context_menu/render_view_context_menu_base.cc
  44. --- a/components/renderer_context_menu/render_view_context_menu_base.cc
  45. +++ b/components/renderer_context_menu/render_view_context_menu_base.cc
  46. @@ -486,9 +486,6 @@ void RenderViewContextMenuBase::OpenURLWithExtraHeaders(
  47. open_url_params.source_site_instance = site_instance_;
  48. - if (disposition != WindowOpenDisposition::OFF_THE_RECORD)
  49. - open_url_params.impression = params_.impression;
  50. -
  51. source_web_contents_->OpenURL(open_url_params);
  52. }
  53. diff --git a/content/browser/aggregation_service/aggregatable_report_sender.cc b/content/browser/aggregation_service/aggregatable_report_sender.cc
  54. --- a/content/browser/aggregation_service/aggregatable_report_sender.cc
  55. +++ b/content/browser/aggregation_service/aggregatable_report_sender.cc
  56. @@ -137,19 +137,18 @@ void AggregatableReportSender::SendReport(const GURL& url,
  57. // Allow bodies of non-2xx responses to be returned.
  58. simple_url_loader_ptr->SetAllowHttpErrorResults(true);
  59. - // Unretained is safe because the URLLoader is owned by `this` and will be
  60. - // deleted before `this`.
  61. - simple_url_loader_ptr->DownloadHeadersOnly(
  62. - url_loader_factory_.get(),
  63. - base::BindOnce(&AggregatableReportSender::OnReportSent,
  64. - base::Unretained(this), std::move(it),
  65. - std::move(callback)));
  66. + // this is never called on Bromite but nothing would be sent if it were
  67. + OnReportSent(std::move(it), std::move(callback), nullptr);
  68. }
  69. void AggregatableReportSender::OnReportSent(
  70. UrlLoaderList::iterator it,
  71. ReportSentCallback callback,
  72. - scoped_refptr<net::HttpResponseHeaders> headers) {
  73. + scoped_refptr<net::HttpResponseHeaders> headers) { // disable in Bromite
  74. + if ((true)) {
  75. + std::move(callback).Run(RequestStatus::kOk);
  76. + return;
  77. + }
  78. RequestStatus status;
  79. absl::optional<int> http_response_code;
  80. @@ -189,4 +188,4 @@ void AggregatableReportSender::OnReportSent(
  81. std::move(callback).Run(status);
  82. }
  83. -} // namespace content
  84. \ No newline at end of file
  85. +} // namespace content
  86. diff --git a/content/browser/attribution_reporting/attribution_report_network_sender.cc b/content/browser/attribution_reporting/attribution_report_network_sender.cc
  87. --- a/content/browser/attribution_reporting/attribution_report_network_sender.cc
  88. +++ b/content/browser/attribution_reporting/attribution_report_network_sender.cc
  89. @@ -118,13 +118,8 @@ void AttributionReportNetworkSender::SendReport(
  90. network::SimpleURLLoader::RETRY_ON_NAME_NOT_RESOLVED;
  91. simple_url_loader_ptr->SetRetryOptions(/*max_retries=*/1, retry_mode);
  92. - // Unretained is safe because the URLLoader is owned by |this| and will be
  93. - // deleted before |this|.
  94. - simple_url_loader_ptr->DownloadHeadersOnly(
  95. - url_loader_factory_.get(),
  96. - base::BindOnce(&AttributionReportNetworkSender::OnReportSent,
  97. - base::Unretained(this), std::move(it), std::move(report),
  98. - is_debug_report, std::move(sent_callback)));
  99. + // this is never called on Bromite but nothing would be sent if it were
  100. + OnReportSent(std::move(it), report, is_debug_report, std::move(sent_callback), nullptr);
  101. }
  102. void AttributionReportNetworkSender::SetURLLoaderFactoryForTesting(
  103. @@ -138,6 +133,12 @@ void AttributionReportNetworkSender::OnReportSent(
  104. bool is_debug_report,
  105. ReportSentCallback sent_callback,
  106. scoped_refptr<net::HttpResponseHeaders> headers) {
  107. + if ((true)) {
  108. + std::move(sent_callback)
  109. + .Run(std::move(report),
  110. + SendResult(SendResult::Status::kSent, headers ? headers->response_code() : 200));
  111. + return;
  112. + }
  113. network::SimpleURLLoader* loader = it->get();
  114. // Consider a non-200 HTTP code as a non-internal error.
  115. diff --git a/content/browser/attribution_reporting/attribution_storage_sql.cc b/content/browser/attribution_reporting/attribution_storage_sql.cc
  116. --- a/content/browser/attribution_reporting/attribution_storage_sql.cc
  117. +++ b/content/browser/attribution_reporting/attribution_storage_sql.cc
  118. @@ -358,7 +358,7 @@ void AttributionStorageSql::RunInMemoryForTesting() {
  119. }
  120. // static
  121. -bool AttributionStorageSql::g_run_in_memory_ = false;
  122. +bool AttributionStorageSql::g_run_in_memory_ = true;
  123. AttributionStorageSql::AttributionStorageSql(
  124. const base::FilePath& path_to_database,
  125. diff --git a/content/browser/storage_partition_impl.cc b/content/browser/storage_partition_impl.cc
  126. --- a/content/browser/storage_partition_impl.cc
  127. +++ b/content/browser/storage_partition_impl.cc
  128. @@ -1304,12 +1304,7 @@ void StoragePartitionImpl::Initialize(
  129. bucket_manager_ = std::make_unique<BucketManager>(quota_manager_proxy);
  130. - // The Conversion Measurement API is not available in Incognito mode.
  131. - if (!is_in_memory() &&
  132. - base::FeatureList::IsEnabled(blink::features::kConversionMeasurement)) {
  133. - attribution_manager_ = std::make_unique<AttributionManagerImpl>(
  134. - this, path, special_storage_policy_);
  135. - }
  136. + // The Conversion Measurement API is not available in Bromite.
  137. if (base::FeatureList::IsEnabled(blink::features::kInterestGroupStorage)) {
  138. interest_group_manager_ = std::make_unique<InterestGroupManagerImpl>(
  139. diff --git a/content/public/browser/navigation_controller.cc b/content/public/browser/navigation_controller.cc
  140. --- a/content/public/browser/navigation_controller.cc
  141. +++ b/content/public/browser/navigation_controller.cc
  142. @@ -36,7 +36,6 @@ NavigationController::LoadURLParams::LoadURLParams(const OpenURLParams& input)
  143. blob_url_loader_factory(input.blob_url_loader_factory),
  144. href_translate(input.href_translate),
  145. reload_type(input.reload_type),
  146. - impression(input.impression),
  147. is_pdf(input.is_pdf) {
  148. #if DCHECK_IS_ON()
  149. DCHECK(input.Valid());
  150. diff --git a/third_party/blink/common/features.cc b/third_party/blink/common/features.cc
  151. --- a/third_party/blink/common/features.cc
  152. +++ b/third_party/blink/common/features.cc
  153. @@ -49,7 +49,7 @@ const base::Feature kCSSContainerQueries{"CSSContainerQueries",
  154. // Controls whether the Conversion Measurement API infrastructure is enabled.
  155. const base::Feature kConversionMeasurement{"ConversionMeasurement",
  156. - base::FEATURE_ENABLED_BY_DEFAULT};
  157. + base::FEATURE_DISABLED_BY_DEFAULT};
  158. // Controls whether LCP calculations should exclude low-entropy images. If
  159. // enabled, then the associated parameter sets the cutoff, expressed as the
  160. diff --git a/third_party/blink/renderer/platform/runtime_enabled_features.json5 b/third_party/blink/renderer/platform/runtime_enabled_features.json5
  161. --- a/third_party/blink/renderer/platform/runtime_enabled_features.json5
  162. +++ b/third_party/blink/renderer/platform/runtime_enabled_features.json5
  163. @@ -106,6 +106,13 @@
  164. },
  165. data: [
  166. + {
  167. + // disable by default features by marking as
  168. + // depends_on: ["DisabledForBromite"]
  169. + // to work is needed to remove "origin_trial_feature_name"
  170. + // and "origin_trial_allows_third_party"
  171. + name: "DisabledForBromite",
  172. + },
  173. {
  174. name: "AbortSignalThrowIfAborted",
  175. status: "stable",
  176. @@ -482,7 +489,7 @@
  177. },
  178. {
  179. name: "ConversionMeasurement",
  180. - status: "test",
  181. + depends_on: ["DisabledForBromite"],
  182. },
  183. {
  184. name: "CooperativeScheduling"
  185. --
  186. 2.25.1