Disable-conversion-measurement-api.patch 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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. chrome/android/java/AndroidManifest.xml | 8 --------
  11. .../AttributionIntentHandlerFactory.java | 9 +--------
  12. .../flags/android/chrome_feature_list.cc | 2 +-
  13. .../embedder_support/origin_trials/features.cc | 3 ++-
  14. .../render_view_context_menu_base.cc | 3 ---
  15. .../browser/android/navigation_handle_proxy.cc | 10 ----------
  16. .../attribution_reporting/attribution_host.cc | 8 --------
  17. .../attribution_reporting/attribution_host.h | 3 ---
  18. .../attribution_host_utils.cc | 6 ++++++
  19. .../attribution_network_sender_impl.cc | 17 ++++++++++-------
  20. .../attribution_storage_sql.cc | 2 +-
  21. .../navigation_controller_android.cc | 16 ----------------
  22. content/browser/storage_partition_impl.cc | 7 +------
  23. .../browser/AttributionReporterImpl.java | 4 ----
  24. content/public/browser/navigation_controller.cc | 1 -
  25. third_party/blink/common/features.cc | 2 +-
  26. .../platform/runtime_enabled_features.json5 | 13 +++++++++----
  27. 17 files changed, 32 insertions(+), 82 deletions(-)
  28. diff --git a/chrome/android/java/AndroidManifest.xml b/chrome/android/java/AndroidManifest.xml
  29. --- a/chrome/android/java/AndroidManifest.xml
  30. +++ b/chrome/android/java/AndroidManifest.xml
  31. @@ -1276,14 +1276,6 @@ by a child template that "extends" this file.
  32. android:readPermission="android.permission.GLOBAL_SEARCH" />
  33. </provider>
  34. - <!-- Provider for App to Web impression attribution.
  35. - TODO(https://crbug.com/1210171): Gate this provider behind a custom permission? -->
  36. - <provider android:name="org.chromium.chrome.browser.attribution_reporting.AttributionReportingProvider"
  37. - android:authorities="{{ manifest_package }}.AttributionReporting"
  38. - android:exported="true"
  39. - tools:ignore="ExportedContentProvider">
  40. - </provider>
  41. -
  42. {% block base_application_definitions %}
  43. {% endblock %}
  44. {% block extra_application_definitions_for_test %}
  45. diff --git a/chrome/browser/attribution_reporting/android/internal/java/src/org/chromium/chrome/browser/attribution_reporting/AttributionIntentHandlerFactory.java b/chrome/browser/attribution_reporting/android/internal/java/src/org/chromium/chrome/browser/attribution_reporting/AttributionIntentHandlerFactory.java
  46. --- a/chrome/browser/attribution_reporting/android/internal/java/src/org/chromium/chrome/browser/attribution_reporting/AttributionIntentHandlerFactory.java
  47. +++ b/chrome/browser/attribution_reporting/android/internal/java/src/org/chromium/chrome/browser/attribution_reporting/AttributionIntentHandlerFactory.java
  48. @@ -26,14 +26,7 @@ public class AttributionIntentHandlerFactory {
  49. * @return an AttributionIntentHandler instance.
  50. */
  51. public static AttributionIntentHandler getInstance() {
  52. - if (CachedFeatureFlags.isEnabled(ChromeFeatureList.APP_TO_WEB_ATTRIBUTION)) {
  53. - if (sIntentHandler == null) {
  54. - sIntentHandler = new AttributionIntentHandlerImpl(sValidator);
  55. - }
  56. - return sIntentHandler;
  57. - } else {
  58. - return new NoopAttributionIntentHandler();
  59. - }
  60. + return new NoopAttributionIntentHandler();
  61. }
  62. public static void setInputEventValidatorForTesting(Predicate<InputEvent> validator) {
  63. diff --git a/chrome/browser/flags/android/chrome_feature_list.cc b/chrome/browser/flags/android/chrome_feature_list.cc
  64. --- a/chrome/browser/flags/android/chrome_feature_list.cc
  65. +++ b/chrome/browser/flags/android/chrome_feature_list.cc
  66. @@ -426,7 +426,7 @@ const base::Feature kAppMenuMobileSiteOption{"AppMenuMobileSiteOption",
  67. base::FEATURE_DISABLED_BY_DEFAULT};
  68. const base::Feature kAppToWebAttribution{"AppToWebAttribution",
  69. - base::FEATURE_DISABLED_BY_DEFAULT};
  70. + base::FEATURE_DISABLED_BY_DEFAULT}; // guard this
  71. const base::Feature kBackgroundThreadPool{"BackgroundThreadPool",
  72. base::FEATURE_DISABLED_BY_DEFAULT};
  73. diff --git a/components/embedder_support/origin_trials/features.cc b/components/embedder_support/origin_trials/features.cc
  74. --- a/components/embedder_support/origin_trials/features.cc
  75. +++ b/components/embedder_support/origin_trials/features.cc
  76. @@ -17,8 +17,9 @@ const base::Feature kOriginTrialsSampleAPIThirdPartyAlternativeUsage{
  77. "OriginTrialsSampleAPIThirdPartyAlternativeUsage",
  78. base::FEATURE_ENABLED_BY_DEFAULT};
  79. +// When disabled, the API cannot be enabled by tokens.
  80. const base::Feature kConversionMeasurementAPIAlternativeUsage{
  81. "ConversionMeasurementAPIAlternativeUsage",
  82. - base::FEATURE_ENABLED_BY_DEFAULT};
  83. + base::FEATURE_DISABLED_BY_DEFAULT};
  84. } // namespace embedder_support
  85. diff --git a/components/renderer_context_menu/render_view_context_menu_base.cc b/components/renderer_context_menu/render_view_context_menu_base.cc
  86. --- a/components/renderer_context_menu/render_view_context_menu_base.cc
  87. +++ b/components/renderer_context_menu/render_view_context_menu_base.cc
  88. @@ -484,9 +484,6 @@ void RenderViewContextMenuBase::OpenURLWithExtraHeaders(
  89. open_url_params.source_site_instance = site_instance_;
  90. - if (disposition != WindowOpenDisposition::OFF_THE_RECORD)
  91. - open_url_params.impression = params_.impression;
  92. -
  93. source_web_contents_->OpenURL(open_url_params);
  94. }
  95. diff --git a/content/browser/android/navigation_handle_proxy.cc b/content/browser/android/navigation_handle_proxy.cc
  96. --- a/content/browser/android/navigation_handle_proxy.cc
  97. +++ b/content/browser/android/navigation_handle_proxy.cc
  98. @@ -30,16 +30,6 @@ NavigationHandleProxy::NavigationHandleProxy(
  99. base::android::ScopedJavaLocalRef<jobject> impression_byte_buffer = nullptr;
  100. // Scoped to out-live the java call as this uses a DirectByteBuffer.
  101. - std::vector<uint8_t> byte_vector;
  102. - if (cpp_navigation_handle_->GetImpression()) {
  103. - blink::mojom::ImpressionPtr impression =
  104. - AttributionHost::MojoImpressionFromImpression(
  105. - *cpp_navigation_handle_->GetImpression());
  106. - byte_vector = blink::mojom::Impression::Serialize(&impression);
  107. - impression_byte_buffer = base::android::ScopedJavaLocalRef<jobject>(
  108. - env, env->NewDirectByteBuffer(byte_vector.data(), byte_vector.size()));
  109. - base::android::CheckException(env);
  110. - }
  111. java_navigation_handle_ = Java_NavigationHandle_Constructor(
  112. env, reinterpret_cast<jlong>(this),
  113. url::GURLAndroid::FromNativeGURL(env, cpp_navigation_handle_->GetURL()),
  114. diff --git a/content/browser/attribution_reporting/attribution_host.cc b/content/browser/attribution_reporting/attribution_host.cc
  115. --- a/content/browser/attribution_reporting/attribution_host.cc
  116. +++ b/content/browser/attribution_reporting/attribution_host.cc
  117. @@ -417,14 +417,6 @@ void AttributionHost::BindReceiver(
  118. conversion_host->receivers_.Bind(rfh, std::move(receiver));
  119. }
  120. -// static
  121. -blink::mojom::ImpressionPtr AttributionHost::MojoImpressionFromImpression(
  122. - const blink::Impression& impression) {
  123. - return blink::mojom::Impression::New(
  124. - impression.conversion_destination, impression.reporting_origin,
  125. - impression.impression_data, impression.expiry, impression.priority);
  126. -}
  127. -
  128. // static
  129. void AttributionHost::SetReceiverImplForTesting(AttributionHost* impl) {
  130. g_receiver_for_testing = impl;
  131. diff --git a/content/browser/attribution_reporting/attribution_host.h b/content/browser/attribution_reporting/attribution_host.h
  132. --- a/content/browser/attribution_reporting/attribution_host.h
  133. +++ b/content/browser/attribution_reporting/attribution_host.h
  134. @@ -58,9 +58,6 @@ class CONTENT_EXPORT AttributionHost
  135. const url::Origin& impression_origin,
  136. const blink::Impression& impression);
  137. - static blink::mojom::ImpressionPtr MojoImpressionFromImpression(
  138. - const blink::Impression& impression) WARN_UNUSED_RESULT;
  139. -
  140. // Overrides the target object to bind |receiver| to in BindReceiver().
  141. static void SetReceiverImplForTesting(AttributionHost* impl);
  142. diff --git a/content/browser/attribution_reporting/attribution_host_utils.cc b/content/browser/attribution_reporting/attribution_host_utils.cc
  143. --- a/content/browser/attribution_reporting/attribution_host_utils.cc
  144. +++ b/content/browser/attribution_reporting/attribution_host_utils.cc
  145. @@ -19,6 +19,8 @@
  146. #include "url/gurl.h"
  147. #include "url/origin.h"
  148. +// will change in attribution_host_utils.cc
  149. +
  150. namespace content {
  151. namespace attribution_host_utils {
  152. @@ -79,6 +81,10 @@ absl::optional<blink::Impression> ParseImpressionFromApp(
  153. // Java API should have rejected these already.
  154. DCHECK(!source_event_id.empty() && !destination.empty());
  155. + // no impression from app
  156. + if ((true))
  157. + return absl::nullopt;
  158. +
  159. blink::Impression impression;
  160. if (!base::StringToUint64(source_event_id, &impression.impression_data))
  161. return absl::nullopt;
  162. diff --git a/content/browser/attribution_reporting/attribution_network_sender_impl.cc b/content/browser/attribution_reporting/attribution_network_sender_impl.cc
  163. --- a/content/browser/attribution_reporting/attribution_network_sender_impl.cc
  164. +++ b/content/browser/attribution_reporting/attribution_network_sender_impl.cc
  165. @@ -146,13 +146,9 @@ void AttributionNetworkSenderImpl::SendReport(
  166. LogMetricsOnReportSend(report);
  167. - // Unretained is safe because the URLLoader is owned by |this| and will be
  168. - // deleted before |this|.
  169. - simple_url_loader_ptr->DownloadHeadersOnly(
  170. - url_loader_factory_.get(),
  171. - base::BindOnce(&AttributionNetworkSenderImpl::OnReportSent,
  172. - base::Unretained(this), std::move(it), std::move(report),
  173. - std::move(sent_callback)));
  174. + // this code is never called but if it were, nothing would be sent
  175. + OnReportSent(std::move(it), std::move(report), std::move(sent_callback),
  176. + nullptr);
  177. }
  178. void AttributionNetworkSenderImpl::SetURLLoaderFactoryForTesting(
  179. @@ -165,6 +161,13 @@ void AttributionNetworkSenderImpl::OnReportSent(
  180. AttributionReport report,
  181. ReportSentCallback sent_callback,
  182. scoped_refptr<net::HttpResponseHeaders> headers) {
  183. + if ((true)) {
  184. + std::move(sent_callback)
  185. + .Run(SentReportInfo(std::move(report),
  186. + SentReportInfo::Status::kSent,
  187. + /*response_code*/200));
  188. + return;
  189. + }
  190. network::SimpleURLLoader* loader = it->get();
  191. // Consider a non-200 HTTP code as a non-internal error.
  192. diff --git a/content/browser/attribution_reporting/attribution_storage_sql.cc b/content/browser/attribution_reporting/attribution_storage_sql.cc
  193. --- a/content/browser/attribution_reporting/attribution_storage_sql.cc
  194. +++ b/content/browser/attribution_reporting/attribution_storage_sql.cc
  195. @@ -239,7 +239,7 @@ void AttributionStorageSql::RunInMemoryForTesting() {
  196. }
  197. // static
  198. -bool AttributionStorageSql::g_run_in_memory_ = false;
  199. +bool AttributionStorageSql::g_run_in_memory_ = true;
  200. AttributionStorageSql::AttributionStorageSql(
  201. const base::FilePath& path_to_database,
  202. diff --git a/content/browser/renderer_host/navigation_controller_android.cc b/content/browser/renderer_host/navigation_controller_android.cc
  203. --- a/content/browser/renderer_host/navigation_controller_android.cc
  204. +++ b/content/browser/renderer_host/navigation_controller_android.cc
  205. @@ -318,22 +318,6 @@ void NavigationControllerAndroid::LoadUrl(
  206. if (input_start != 0)
  207. params.input_start = base::TimeTicks::FromUptimeMillis(input_start);
  208. - if (source_package_name) {
  209. - DCHECK(!params.initiator_origin);
  210. - // At the moment, source package name is only used for attribution.
  211. - DCHECK(attribution_source_event_id);
  212. - params.initiator_origin = OriginFromAndroidPackageName(
  213. - ConvertJavaStringToUTF8(env, source_package_name));
  214. -
  215. - params.impression = attribution_host_utils::ParseImpressionFromApp(
  216. - ConvertJavaStringToUTF8(env, attribution_source_event_id),
  217. - ConvertJavaStringToUTF8(env, attribution_destination),
  218. - attribution_report_to
  219. - ? ConvertJavaStringToUTF8(env, attribution_report_to)
  220. - : "",
  221. - attribution_expiry);
  222. - }
  223. -
  224. params.override_user_agent = static_cast<NavigationController::UserAgentOverrideOption>(
  225. user_agent_override_option);
  226. diff --git a/content/browser/storage_partition_impl.cc b/content/browser/storage_partition_impl.cc
  227. --- a/content/browser/storage_partition_impl.cc
  228. +++ b/content/browser/storage_partition_impl.cc
  229. @@ -1299,12 +1299,7 @@ void StoragePartitionImpl::Initialize(
  230. bucket_context_ = base::MakeRefCounted<BucketContext>();
  231. bucket_context_->Initialize();
  232. - // The Conversion Measurement API is not available in Incognito mode.
  233. - if (!is_in_memory() &&
  234. - base::FeatureList::IsEnabled(blink::features::kConversionMeasurement)) {
  235. - conversion_manager_ = std::make_unique<ConversionManagerImpl>(
  236. - this, path, special_storage_policy_);
  237. - }
  238. + // The Conversion Measurement API is not available in Bromite.
  239. if (base::FeatureList::IsEnabled(blink::features::kInterestGroupStorage)) {
  240. interest_group_manager_ = std::make_unique<InterestGroupManager>(
  241. diff --git a/content/public/android/java/src/org/chromium/content/browser/AttributionReporterImpl.java b/content/public/android/java/src/org/chromium/content/browser/AttributionReporterImpl.java
  242. --- a/content/public/android/java/src/org/chromium/content/browser/AttributionReporterImpl.java
  243. +++ b/content/public/android/java/src/org/chromium/content/browser/AttributionReporterImpl.java
  244. @@ -22,8 +22,6 @@ public class AttributionReporterImpl extends AttributionReporter {
  245. public void reportAttributionForCurrentNavigation(WebContents webContents,
  246. String sourcePackageName, String sourceEventId, String destination, String reportTo,
  247. long expiry) {
  248. - AttributionReporterImplJni.get().reportAttributionForCurrentNavigation(
  249. - webContents, sourcePackageName, sourceEventId, destination, reportTo, expiry);
  250. }
  251. /**
  252. @@ -32,8 +30,6 @@ public class AttributionReporterImpl extends AttributionReporter {
  253. @Override
  254. public void reportAppImpression(BrowserContextHandle browserContext, String sourcePackageName,
  255. String sourceEventId, String destination, String reportTo, long expiry) {
  256. - AttributionReporterImplJni.get().reportAppImpression(
  257. - browserContext, sourcePackageName, sourceEventId, destination, reportTo, expiry);
  258. }
  259. @NativeMethods
  260. diff --git a/content/public/browser/navigation_controller.cc b/content/public/browser/navigation_controller.cc
  261. --- a/content/public/browser/navigation_controller.cc
  262. +++ b/content/public/browser/navigation_controller.cc
  263. @@ -36,7 +36,6 @@ NavigationController::LoadURLParams::LoadURLParams(const OpenURLParams& input)
  264. blob_url_loader_factory(input.blob_url_loader_factory),
  265. href_translate(input.href_translate),
  266. reload_type(input.reload_type),
  267. - impression(input.impression),
  268. is_pdf(input.is_pdf) {
  269. #if DCHECK_IS_ON()
  270. DCHECK(input.Valid());
  271. diff --git a/third_party/blink/common/features.cc b/third_party/blink/common/features.cc
  272. --- a/third_party/blink/common/features.cc
  273. +++ b/third_party/blink/common/features.cc
  274. @@ -37,7 +37,7 @@ const base::Feature kCSSContainerQueries{"CSSContainerQueries",
  275. // Controls whether the Conversion Measurement API infrastructure is enabled.
  276. const base::Feature kConversionMeasurement{"ConversionMeasurement",
  277. - base::FEATURE_ENABLED_BY_DEFAULT};
  278. + base::FEATURE_DISABLED_BY_DEFAULT};
  279. const base::Feature kGMSCoreEmoji{"GMSCoreEmoji",
  280. base::FEATURE_DISABLED_BY_DEFAULT};
  281. diff --git a/third_party/blink/renderer/platform/runtime_enabled_features.json5 b/third_party/blink/renderer/platform/runtime_enabled_features.json5
  282. --- a/third_party/blink/renderer/platform/runtime_enabled_features.json5
  283. +++ b/third_party/blink/renderer/platform/runtime_enabled_features.json5
  284. @@ -106,6 +106,13 @@
  285. },
  286. data: [
  287. + {
  288. + // disable by default features by marking as
  289. + // depends_on: ["DisabledForBromite"]
  290. + // to work is needed to remove "origin_trial_feature_name"
  291. + // and "origin_trial_allows_third_party"
  292. + name: "DisabledForBromite",
  293. + },
  294. {
  295. name: "Accelerated2dCanvas",
  296. settable_from_internals: true,
  297. @@ -474,13 +481,11 @@
  298. },
  299. {
  300. name: "ConversionMeasurement",
  301. - origin_trial_feature_name: "ConversionMeasurement",
  302. - origin_trial_allows_third_party: true,
  303. - status: "experimental",
  304. + depends_on: ["DisabledForBromite"],
  305. },
  306. {
  307. name: "ConversionMeasurementEventSources",
  308. - status: "test",
  309. + depends_on: ["DisabledForBromite"],
  310. },
  311. {
  312. name: "CooperativeScheduling"
  313. --
  314. 2.20.1