Enable subresource redirects to all schemes with network service

Previously, subresource requests could not redirect to schemes
other than http/https/data with the network service. Now they can
redirect to all schemes, and have proper safety checks.

This gets rid of the RedirectChecker class and instead just checks
the redirect in WebRequestProxyingURLLoaderFactory if the request
is being proxied. The checks farther downstream will be skipped if
the request is proxied. This should be simpler, and avoids complicated
logic with the RedirectChecker that would have been necessary for
subresource redirects.

The bypass_redirect_checks bit is set if the request is being proxied
by WebRequestProxyingURLLoaderFactory. In that case, all redirect
checks will happen in WebRequestProxyingURLLoaderFactory, because the
webRequest API has special permissions for allowing redirects. For
subresource requests, the bypass_redirect_checks bit is set on the
URLLoaderFactoryBundleInfo that is sent to the renderer from
RenderFrameHostImpl. This is used in ResourceDispatcher to ignore
redirect checks if necessary.

Bug: 868545
Cq-Include-Trybots: luci.chromium.try:linux_mojo
Change-Id: Ib11bf81e5b4b1ec9fa1b8d9178467322df91b30c
Reviewed-on: https://chromium-review.googlesource.com/1157549
Reviewed-by: Kinuko Yasuda <[email protected]>
Reviewed-by: John Abd-El-Malek <[email protected]>
Commit-Queue: Clark DuVall <[email protected]>
Cr-Commit-Position: refs/heads/master@{#582174}
diff --git a/content/renderer/loader/url_loader_client_impl.h b/content/renderer/loader/url_loader_client_impl.h
index 6ede15c5..d4e4186e 100644
--- a/content/renderer/loader/url_loader_client_impl.h
+++ b/content/renderer/loader/url_loader_client_impl.h
@@ -37,7 +37,8 @@
  public:
   URLLoaderClientImpl(int request_id,
                       ResourceDispatcher* resource_dispatcher,
-                      scoped_refptr<base::SingleThreadTaskRunner> task_runner);
+                      scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+                      bool bypass_redirect_checks);
   ~URLLoaderClientImpl() override;
 
   // Sets |is_deferred_|. From now, the received messages are not dispatched
@@ -103,6 +104,7 @@
   int32_t accumulated_transfer_size_diff_during_deferred_ = 0;
   ResourceDispatcher* const resource_dispatcher_;
   scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+  bool bypass_redirect_checks_ = false;
 
   network::mojom::URLLoaderPtr url_loader_;
   mojo::Binding<network::mojom::URLLoaderClient> url_loader_client_binding_;