Disable-conversion-measurement-api.patch 10 KB

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