Rework canary checks for the Chrome prefetching proxy.

1) Remove code for deprecated HTTP filter probing. Only DNS and TLS
   filter probing is still supported.
2) Make canary checks do a simple DNS resolution, instead of an HTTP
   GET request.
3) Make canary checks as soon as we send a non-decoy P4 request to make
   sure the check is cached by the time we try to use the request.
4) Remove AvailabilityProber class and replace it with
   PrefetchProxyCanaryChecker. The former class was more general and
   supported other clients (like the HTTP filter probe and the Previews
   probe). It however had high complexity due to unnecessary features
   for the new DNS checks. Since the new DNS checks are quick and low
   overhead, there is no need to cache state so aggressively (storing in
   prefs) or to monitor device changes to make checks before they're
   required. We can simply run the check if necessary at the time we
   send the prefetch.

Bug: 1135778
Change-Id: Ie949e51562cbb7a25226ff5b870fbfaf22c8673d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3266544
Reviewed-by: Marc Treib <[email protected]>
Reviewed-by: Christian Dullweber <[email protected]>
Reviewed-by: Tarun Bansal <[email protected]>
Reviewed-by: Robert Ogden <[email protected]>
Reviewed-by: Max Curran <[email protected]>
Commit-Queue: Simon Pelchat <[email protected]>
Cr-Commit-Position: refs/heads/main@{#948997}
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index ee9b03a..c54e06e 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -15,7 +15,6 @@
 #include "chrome/browser/accessibility/accessibility_labels_service.h"
 #include "chrome/browser/accessibility/accessibility_ui.h"
 #include "chrome/browser/accessibility/invert_bubble_prefs.h"
-#include "chrome/browser/availability/availability_prober.h"
 #include "chrome/browser/browser_process_impl.h"
 #include "chrome/browser/chrome_content_browser_client.h"
 #include "chrome/browser/component_updater/component_updater_prefs.h"
@@ -670,6 +669,14 @@
 // Deprecated 11/2021.
 const char kWasPreviouslySetUpPrefName[] = "android_sms.was_previously_set_up";
 
+// Deprecated 12/2021.
+const char kAvailabilityProberOriginCheck[] =
+    "Availability.Prober.cache.IsolatedPrerenderOriginCheck";
+const char kAvailabilityProberTLSCanaryCheck[] =
+    "Availability.Prober.cache.IsolatedPrerenderTLSCanaryCheck";
+const char kAvailabilityProberDNSCanaryCheck[] =
+    "Availability.Prober.cache.IsolatedPrerenderDNSCanaryCheck";
+
 // Register local state used only for migration (clearing or moving to a new
 // key).
 void RegisterLocalStatePrefsForMigration(PrefRegistrySimple* registry) {
@@ -860,6 +867,10 @@
 
   registry->RegisterBooleanPref(kAppCacheForceEnabled, false);
   registry->RegisterBooleanPref(kWasPreviouslySetUpPrefName, false);
+
+  registry->RegisterDictionaryPref(kAvailabilityProberOriginCheck);
+  registry->RegisterDictionaryPref(kAvailabilityProberTLSCanaryCheck);
+  registry->RegisterDictionaryPref(kAvailabilityProberDNSCanaryCheck);
 }
 
 }  // namespace
@@ -1103,7 +1114,6 @@
   AccessibilityLabelsService::RegisterProfilePrefs(registry);
   AccessibilityUIMessageHandler::RegisterProfilePrefs(registry);
   AnnouncementNotificationService::RegisterProfilePrefs(registry);
-  AvailabilityProber::RegisterProfilePrefs(registry);
   autofill::prefs::RegisterProfilePrefs(registry);
   browsing_data::prefs::RegisterBrowserUserPrefs(registry);
   certificate_transparency::prefs::RegisterPrefs(registry);
@@ -1712,6 +1722,11 @@
   syncer::ClearObsoleteKeystoreBootstrapTokenPref(profile_prefs);
   profile_prefs->ClearPref(kWasPreviouslySetUpPrefName);
 
+  // Added 12/2021.
+  profile_prefs->ClearPref(kAvailabilityProberOriginCheck);
+  profile_prefs->ClearPref(kAvailabilityProberTLSCanaryCheck);
+  profile_prefs->ClearPref(kAvailabilityProberDNSCanaryCheck);
+
   // Please don't delete the following line. It is used by PRESUBMIT.py.
   // END_MIGRATE_OBSOLETE_PROFILE_PREFS
 }