Proxy browser requests through WebRequest API

This enables browser-initiated requests to be proxied through the
WebRequest API when the Network Service is enabled. Note that this
only applies to requests made on via a profile's context, not the
system context.

This mirrors the behavior in the non-Network Service path today.

Bug: 841002
Test: see buildbot filter changes
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_mojo
Change-Id: I1830959e1ba089974c546d933b4a6b51fb038779
Reviewed-on: https://chromium-review.googlesource.com/1083952
Commit-Queue: Ken Rockot <[email protected]>
Reviewed-by: Karan Bhatia <[email protected]>
Reviewed-by: John Abd-El-Malek <[email protected]>
Cr-Commit-Position: refs/heads/master@{#564937}
diff --git a/content/browser/loader/navigation_url_loader_impl.cc b/content/browser/loader/navigation_url_loader_impl.cc
index 33738ef..8b3a42ed 100644
--- a/content/browser/loader/navigation_url_loader_impl.cc
+++ b/content/browser/loader/navigation_url_loader_impl.cc
@@ -1336,8 +1336,8 @@
     network::mojom::URLLoaderFactoryPtrInfo factory_info;
     auto factory_request = mojo::MakeRequest(&factory_info);
     bool use_proxy = GetContentClient()->browser()->WillCreateURLLoaderFactory(
-        frame_tree_node->current_frame_host(), true /* is_navigation */,
-        &factory_request);
+        partition->browser_context(), frame_tree_node->current_frame_host(),
+        true /* is_navigation */, &factory_request);
     if (RenderFrameDevToolsAgentHost::WillCreateURLLoaderFactory(
             frame_tree_node->current_frame_host(), true, false,
             &factory_request)) {
@@ -1463,9 +1463,10 @@
   }
   FrameTreeNode* frame_tree_node =
       FrameTreeNode::GloballyFindByID(frame_tree_node_id);
+  auto* frame = frame_tree_node->current_frame_host();
   GetContentClient()->browser()->WillCreateURLLoaderFactory(
-      frame_tree_node->current_frame_host(), true /* is_navigation */,
-      &factory);
+      frame->GetSiteInstance()->GetBrowserContext(), frame,
+      true /* is_navigation */, &factory);
   it->second->Clone(std::move(factory));
 }