[iOS] Focus the WKWebView on page load

When BVC is checking if it should register the keyboard commands, if it
doesn't find any first responder it is setting the WebView as first
responder. This allows the WebView to respond to the keyboard commands,
for example when using space to scroll the page.
This CL moves this check to the page load because we only need it once
to make sure the WebView gets it.

TEST=The support of the external keyboard could be affected, for the
WebView shortcuts and for the Chrome shortcuts too.

Bug: 949118
Change-Id: Ib4ddacbbf665c5d069638bdd20963c48c042ab38
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1564072
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: Mike Dougherty <michaeldo@chromium.org>
Reviewed-by: Eugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#651185}
diff --git a/ios/chrome/browser/ui/browser_view/browser_view_controller.mm b/ios/chrome/browser/ui/browser_view/browser_view_controller.mm
index f75365b..a42e98c 100644
--- a/ios/chrome/browser/ui/browser_view/browser_view_controller.mm
+++ b/ios/chrome/browser/ui/browser_view/browser_view_controller.mm
@@ -1483,13 +1483,6 @@
   if (_voiceSearchController && _voiceSearchController->IsVisible())
     return NO;
 
-  // If there is no first responder, try to make the webview the first
-  // responder.
-  if (!GetFirstResponder()) {
-    if (self.currentWebState)
-      [self.currentWebState->GetWebViewProxy() becomeFirstResponder];
-  }
-
   return YES;
 }
 
@@ -3525,6 +3518,11 @@
         self.view.window.traitCollection.horizontalSizeClass;
     [SizeClassRecorder pageLoadedWithHorizontalSizeClass:sizeClass];
   }
+
+  // If there is no first responder, try to make the webview the first
+  // responder to have it answer keyboard commands (e.g. space bar to scroll).
+  if (!GetFirstResponder() && self.currentWebState)
+    [self.currentWebState->GetWebViewProxy() becomeFirstResponder];
 }
 
 #pragma mark - OmniboxPopupPresenterDelegate methods.