Enable AsyncNavigationIntercept on Android

This CL also removes delaying navigation failures waiting for the
async task to complete. The navigation is being cancelled by another
part of the stack, so it makes sense to respect that decision and not
call out an intent after the fact. Additionally, navigation simulator
test infrastructure doesn't really handle delayed failures at the
moment :)

Bug: 793053
Change-Id: Ic5c57be5d07d1e8bde77b6be4d661c66c7449943
Reviewed-on: https://chromium-review.googlesource.com/c/1455686
Reviewed-by: Ilya Sherman <isherman@chromium.org>
Reviewed-by: Nate Fischer <ntfschr@chromium.org>
Commit-Queue: Charlie Harrison <csharrison@chromium.org>
Cr-Commit-Position: refs/heads/master@{#631033}
diff --git a/components/navigation_interception/intercept_navigation_throttle.cc b/components/navigation_interception/intercept_navigation_throttle.cc
index 2b2b89e..2010540 100644
--- a/components/navigation_interception/intercept_navigation_throttle.cc
+++ b/components/navigation_interception/intercept_navigation_throttle.cc
@@ -9,14 +9,16 @@
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/time/time.h"
 #include "base/timer/elapsed_timer.h"
+#include "build/build_config.h"
 #include "content/public/browser/browser_thread.h"
 #include "content/public/browser/navigation_handle.h"
 #include "url/gurl.h"
 
 namespace navigation_interception {
 
+// Note: this feature is a no-op on non-Android platforms.
 const base::Feature InterceptNavigationThrottle::kAsyncCheck{
-    "AsyncNavigationIntercept", base::FEATURE_DISABLED_BY_DEFAULT};
+    "AsyncNavigationIntercept", base::FEATURE_ENABLED_BY_DEFAULT};
 
 InterceptNavigationThrottle::InterceptNavigationThrottle(
     content::NavigationHandle* navigation_handle,
@@ -49,21 +51,7 @@
 }
 
 content::NavigationThrottle::ThrottleCheckResult
-InterceptNavigationThrottle::WillFailRequest() {
-  return WillFinish();
-}
-
-content::NavigationThrottle::ThrottleCheckResult
 InterceptNavigationThrottle::WillProcessResponse() {
-  return WillFinish();
-}
-
-const char* InterceptNavigationThrottle::GetNameForLogging() {
-  return "InterceptNavigationThrottle";
-}
-
-content::NavigationThrottle::ThrottleCheckResult
-InterceptNavigationThrottle::WillFinish() {
   DCHECK(!deferring_);
   if (should_ignore_)
     return content::NavigationThrottle::CANCEL_AND_IGNORE;
@@ -76,6 +64,10 @@
   return content::NavigationThrottle::PROCEED;
 }
 
+const char* InterceptNavigationThrottle::GetNameForLogging() {
+  return "InterceptNavigationThrottle";
+}
+
 content::NavigationThrottle::ThrottleCheckResult
 InterceptNavigationThrottle::CheckIfShouldIgnoreNavigation(bool is_redirect) {
   if (ShouldCheckAsynchronously()) {
@@ -120,14 +112,19 @@
 
 bool InterceptNavigationThrottle::ShouldCheckAsynchronously() const {
   // Do not apply the async optimization for:
+  // - Non-Android platforms (where the check is always fast)
   // - POST navigations, to ensure we aren't violating idempotency.
   // - Subframe navigations, which aren't observed on Android, and should be
   //   fast on other platforms.
   // - non-http/s URLs, which are more likely to be intercepted.
+#if defined(OS_ANDROID)
   return navigation_handle()->IsInMainFrame() &&
          !navigation_handle()->IsPost() &&
          navigation_handle()->GetURL().SchemeIsHTTPOrHTTPS() &&
          base::FeatureList::IsEnabled(kAsyncCheck);
+#else
+  return false;
+#endif
 }
 
 NavigationParams InterceptNavigationThrottle::GetNavigationParams(
diff --git a/components/navigation_interception/intercept_navigation_throttle.h b/components/navigation_interception/intercept_navigation_throttle.h
index 0b154bc..ba12086 100644
--- a/components/navigation_interception/intercept_navigation_throttle.h
+++ b/components/navigation_interception/intercept_navigation_throttle.h
@@ -41,14 +41,10 @@
   // content::NavigationThrottle implementation:
   ThrottleCheckResult WillStartRequest() override;
   ThrottleCheckResult WillRedirectRequest() override;
-  ThrottleCheckResult WillFailRequest() override;
   ThrottleCheckResult WillProcessResponse() override;
   const char* GetNameForLogging() override;
 
  private:
-  // To be called on either WillFailRequest or WillProcessResponse.
-  ThrottleCheckResult WillFinish();
-
   ThrottleCheckResult CheckIfShouldIgnoreNavigation(bool is_redirect);
   void RunCheckAsync(const NavigationParams& params);
 
diff --git a/testing/variations/fieldtrial_testing_config.json b/testing/variations/fieldtrial_testing_config.json
index 3c0af49..b6e23e2 100644
--- a/testing/variations/fieldtrial_testing_config.json
+++ b/testing/variations/fieldtrial_testing_config.json
@@ -555,21 +555,6 @@
             ]
         }
     ],
-    "AsyncNavigationIntercept": [
-        {
-            "platforms": [
-                "android"
-            ],
-            "experiments": [
-                {
-                    "name": "Enabled",
-                    "enable_features": [
-                        "AsyncNavigationIntercept"
-                    ]
-                }
-            ]
-        }
-    ],
     "AudioService": [
         {
             "platforms": [