Add a factory method to create a FakeGCMS with a TestURLLoaderFactory.

This new factory method is meant to replace
BuildFakeGaiaCookieManagerServiceWithOptions in the cases where
create_fake_url_loader_factory_for_cookie_requests is set to true.

Callers of BuildFakeGaiaCookieManagerServiceWithOptions will be migrated
to use this new factory method in a future CL.

This is part of step 1a of the plan to eliminate FakeGCMS entirely:

https: //docs.google.com/document/d/1t0ZtuV7h-znzdItFgBW0aKPscAwWXIBuNZnNlEGgi7g/edit
Change-Id: Ia26dbe429743e30b86130106d3909a3320e4ba2d
Bug: 907782
Reviewed-on: https://chromium-review.googlesource.com/c/1412456
Reviewed-by: David Roger <droger@chromium.org>
Reviewed-by: Colin Blundell <blundell@chromium.org>
Commit-Queue: Lowell Manners <lowell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#623180}
diff --git a/chrome/browser/signin/fake_gaia_cookie_manager_service_builder.cc b/chrome/browser/signin/fake_gaia_cookie_manager_service_builder.cc
index d2ab6d9..3a3e5fa7e 100644
--- a/chrome/browser/signin/fake_gaia_cookie_manager_service_builder.cc
+++ b/chrome/browser/signin/fake_gaia_cookie_manager_service_builder.cc
@@ -10,6 +10,7 @@
 #include "components/keyed_service/core/keyed_service.h"
 #include "components/signin/core/browser/fake_gaia_cookie_manager_service.h"
 #include "components/signin/core/browser/profile_oauth2_token_service.h"
+#include "services/network/test/test_url_loader_factory.h"
 
 std::unique_ptr<KeyedService> BuildFakeGaiaCookieManagerService(
     content::BrowserContext* context) {
@@ -17,6 +18,16 @@
       /*create_fake_url_loader_factory_for_cookie_requests=*/false, context);
 }
 
+std::unique_ptr<KeyedService> BuildFakeGaiaCookieManagerServiceWithURLLoader(
+    network::TestURLLoaderFactory* test_url_loader_factory,
+    content::BrowserContext* context) {
+  Profile* profile = Profile::FromBrowserContext(context);
+  return std::make_unique<FakeGaiaCookieManagerService>(
+      ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
+      ChromeSigninClientFactory::GetForProfile(profile),
+      test_url_loader_factory);
+}
+
 std::unique_ptr<KeyedService> BuildFakeGaiaCookieManagerServiceWithOptions(
     bool create_fake_url_loader_factory_for_cookie_requests,
     content::BrowserContext* context) {
diff --git a/chrome/browser/signin/fake_gaia_cookie_manager_service_builder.h b/chrome/browser/signin/fake_gaia_cookie_manager_service_builder.h
index 89085cb..7644b0b 100644
--- a/chrome/browser/signin/fake_gaia_cookie_manager_service_builder.h
+++ b/chrome/browser/signin/fake_gaia_cookie_manager_service_builder.h
@@ -13,10 +13,21 @@
 class BrowserContext;
 }
 
+namespace network {
+class TestURLLoaderFactory;
+}
+
 // Helper functions to be used with KeyedService::SetTestingFactory().
 std::unique_ptr<KeyedService> BuildFakeGaiaCookieManagerService(
     content::BrowserContext* context);
 
+// Builds a FakeGaiaCookieManagerService which uses the provided
+// |test_url_loader_factory| for cookie-related requests.
+std::unique_ptr<KeyedService> BuildFakeGaiaCookieManagerServiceWithURLLoader(
+    network::TestURLLoaderFactory* test_url_loader_factory,
+    content::BrowserContext* context);
+
+// TODO(https://crbug.com/907782): Remove all references and delete this method.
 std::unique_ptr<KeyedService> BuildFakeGaiaCookieManagerServiceWithOptions(
     bool create_fake_url_loader_factory_for_cookie_requests,
     content::BrowserContext* context);