Commit f3118cfa authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Replace remaining usages of GaiaCookieManagerServiceFactory::GetInstance in //chrome

This CL adds a common factory method named BuildChromeSigninClientWithURLLoader to
chrome/browser/signin/chrome_signin_client_test_util.cc|h to create a
ChromeSigninClient instance supplying the test's URLLoaderFactory to it.
This avoids GCMSFactory::GetInstance to be referenced from various places
for similar purposes.

In the end, there is no functionality change since GCMS fetches its
URLLoaderFactory instance from SigninClient when needed.

c/b/signin/gaia_cookie_manager_service_test_util.cc|h is removed.

This includes the following files:
- chrome/browser/ui/cocoa/test/cocoa_profile_test.mm
- chrome/browser/extensions/api/identity/identity_apitest.cc
- chrome/browser/ui/views/frame/test_with_browser_view.cc
- chrome/browser/metrics/ukm_browsertest.cc
- chrome/browser/sync/test/integration/secondary_account_helper.cc|h
- chrome/browser/sync/test/integration/single_client_secondary_account_sync_test.cc
- chrome/browser/sync/test/integration/single_cl

TBR=treib@chromium.org (Marc has reviewed //c/b/sync changes in CL_1466606
    that got reverted due to another problem).

BUG=930745

Change-Id: I4887f10f0a66b7c60d21bc7fd97f1b0d8f01a84b
Reviewed-on: https://chromium-review.googlesource.com/c/1471790Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Cr-Commit-Position: refs/heads/master@{#632384}
parent d36690db
......@@ -5403,8 +5403,8 @@ static_library("test_support") {
"search_engines/template_url_service_factory_test_util.h",
"search_engines/template_url_service_test_util.cc",
"search_engines/template_url_service_test_util.h",
"signin/gaia_cookie_manager_service_test_util.cc",
"signin/gaia_cookie_manager_service_test_util.h",
"signin/chrome_signin_client_test_util.cc",
"signin/chrome_signin_client_test_util.h",
"signin/identity_test_environment_profile_adaptor.cc",
"signin/identity_test_environment_profile_adaptor.h",
"signin/scoped_account_consistency.cc",
......
......@@ -33,8 +33,8 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/account_fetcher_service_factory.h"
#include "chrome/browser/signin/account_reconcilor_factory.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_factory.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_test_util.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/chrome_signin_client_test_util.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/identity_test_environment_profile_adaptor.h"
#include "chrome/browser/ui/browser.h"
......@@ -464,10 +464,9 @@ class IdentityTestWithSignin : public AsyncExtensionBrowserTest {
IdentityTestEnvironmentProfileAdaptor::
SetIdentityTestEnvironmentFactoriesOnBrowserContext(context);
GaiaCookieManagerServiceFactory::GetInstance()->SetTestingFactory(
context,
base::BindRepeating(&BuildGaiaCookieManagerServiceWithURLLoader,
&test_url_loader_factory_));
ChromeSigninClientFactory::GetInstance()->SetTestingFactory(
context, base::BindRepeating(&BuildChromeSigninClientWithURLLoader,
&test_url_loader_factory_));
// Ensure that AccountFetcherService is (1) created at all and (2) created
// early enough for it to observe the Profile initialization process and
......
......@@ -341,9 +341,8 @@ class UkmBrowserTestWithSyncTransport : public UkmBrowserTest {
// This is required to support (fake) secondary-account-signin (based on
// cookies) in tests. Without this, the real GaiaCookieManagerService would
// try talking to Google servers which of course wouldn't work in tests.
test_gaia_cookie_manager_factory_ =
secondary_account_helper::SetUpGaiaCookieManagerService(
&test_url_loader_factory_);
test_signin_client_factory_ =
secondary_account_helper::SetUpSigninClient(&test_url_loader_factory_);
UkmBrowserTest::SetUpInProcessBrowserTestFixture();
}
......@@ -357,8 +356,8 @@ class UkmBrowserTestWithSyncTransport : public UkmBrowserTest {
private:
base::test::ScopedFeatureList features_;
secondary_account_helper::ScopedGaiaCookieManagerServiceFactory
test_gaia_cookie_manager_factory_;
secondary_account_helper::ScopedSigninClientFactory
test_signin_client_factory_;
DISALLOW_COPY_AND_ASSIGN(UkmBrowserTestWithSyncTransport);
};
......
......@@ -2,28 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/signin/gaia_cookie_manager_service_test_util.h"
#include "chrome/browser/signin/chrome_signin_client_test_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/chrome_signin_client.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/signin/core/browser/gaia_cookie_manager_service.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/test/test_url_loader_factory.h"
std::unique_ptr<KeyedService> BuildGaiaCookieManagerServiceWithURLLoader(
std::unique_ptr<KeyedService> BuildChromeSigninClientWithURLLoader(
network::TestURLLoaderFactory* test_url_loader_factory,
content::BrowserContext* context) {
Profile* profile = Profile::FromBrowserContext(context);
return std::make_unique<GaiaCookieManagerService>(
ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
ChromeSigninClientFactory::GetForProfile(profile),
base::BindRepeating(
[](network::TestURLLoaderFactory* test_url_loader_factory)
-> scoped_refptr<network::SharedURLLoaderFactory> {
return test_url_loader_factory->GetSafeWeakWrapper();
},
test_url_loader_factory));
auto signin_client = std::make_unique<ChromeSigninClient>(profile);
signin_client->SetURLLoaderFactoryForTest(
test_url_loader_factory->GetSafeWeakWrapper());
return signin_client;
}
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SIGNIN_GAIA_COOKIE_MANAGER_SERVICE_TEST_UTIL_H_
#define CHROME_BROWSER_SIGNIN_GAIA_COOKIE_MANAGER_SERVICE_TEST_UTIL_H_
#ifndef CHROME_BROWSER_SIGNIN_CHROME_SIGNIN_CLIENT_TEST_UTIL_H_
#define CHROME_BROWSER_SIGNIN_CHROME_SIGNIN_CLIENT_TEST_UTIL_H_
#include <memory>
......@@ -17,10 +17,10 @@ namespace network {
class TestURLLoaderFactory;
}
// Creates a GaiaCookieManagerService using the supplied
// Creates a ChromeSigninClient using the supplied
// |test_url_loader_factory| and |context|.
std::unique_ptr<KeyedService> BuildGaiaCookieManagerServiceWithURLLoader(
std::unique_ptr<KeyedService> BuildChromeSigninClientWithURLLoader(
network::TestURLLoaderFactory* test_url_loader_factory,
content::BrowserContext* context);
#endif // CHROME_BROWSER_SIGNIN_GAIA_COOKIE_MANAGER_SERVICE_TEST_UTIL_H_
#endif // CHROME_BROWSER_SIGNIN_CHROME_SIGNIN_CLIENT_TEST_UTIL_H_
......@@ -9,7 +9,6 @@
#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_factory.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_test_util.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
......
......@@ -6,8 +6,8 @@
#include "base/bind.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_factory.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_test_util.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/chrome_signin_client_test_util.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "services/identity/public/cpp/identity_manager.h"
......@@ -29,14 +29,14 @@ namespace {
void OnWillCreateBrowserContextServices(
network::TestURLLoaderFactory* test_url_loader_factory,
content::BrowserContext* context) {
GaiaCookieManagerServiceFactory::GetInstance()->SetTestingFactory(
context, base::BindRepeating(&BuildGaiaCookieManagerServiceWithURLLoader,
ChromeSigninClientFactory::GetInstance()->SetTestingFactory(
context, base::BindRepeating(&BuildChromeSigninClientWithURLLoader,
test_url_loader_factory));
}
} // namespace
ScopedGaiaCookieManagerServiceFactory SetUpGaiaCookieManagerService(
ScopedSigninClientFactory SetUpSigninClient(
network::TestURLLoaderFactory* test_url_loader_factory) {
return BrowserContextDependencyManager::GetInstance()
->RegisterWillCreateBrowserContextServicesCallbackForTesting(
......
......@@ -23,15 +23,15 @@ class TestURLLoaderFactory;
namespace secondary_account_helper {
using ScopedGaiaCookieManagerServiceFactory = std::unique_ptr<
using ScopedSigninClientFactory = std::unique_ptr<
base::CallbackList<void(content::BrowserContext*)>::Subscription>;
// Sets up a factory to create a GaiaCookieManagerService which uses the
// Sets up a factory to create a SigninClient which uses the
// provided |test_url_loader_factory| for cookie-related requests. Meant to be
// called from SetUpInProcessBrowserTestFixture. The caller should hold on to
// the returned object for the duration of the test, e.g. store it in a member
// of the test fixture class.
ScopedGaiaCookieManagerServiceFactory SetUpGaiaCookieManagerService(
ScopedSigninClientFactory SetUpSigninClient(
network::TestURLLoaderFactory* test_url_loader_factory);
#if defined(OS_CHROMEOS)
......
......@@ -38,9 +38,8 @@ class SingleClientSecondaryAccountSyncTest : public SyncTest {
~SingleClientSecondaryAccountSyncTest() override {}
void SetUpInProcessBrowserTestFixture() override {
test_gaia_cookie_manager_factory_ =
secondary_account_helper::SetUpGaiaCookieManagerService(
&test_url_loader_factory_);
test_signin_client_factory_ =
secondary_account_helper::SetUpSigninClient(&test_url_loader_factory_);
}
void SetUpOnMainThread() override {
......@@ -55,8 +54,8 @@ class SingleClientSecondaryAccountSyncTest : public SyncTest {
private:
base::test::ScopedFeatureList features_;
secondary_account_helper::ScopedGaiaCookieManagerServiceFactory
test_gaia_cookie_manager_factory_;
secondary_account_helper::ScopedSigninClientFactory
test_signin_client_factory_;
DISALLOW_COPY_AND_ASSIGN(SingleClientSecondaryAccountSyncTest);
};
......
......@@ -1116,9 +1116,8 @@ class SingleClientWalletSecondaryAccountSyncTest
~SingleClientWalletSecondaryAccountSyncTest() override {}
void SetUpInProcessBrowserTestFixture() override {
test_gaia_cookie_manager_factory_ =
secondary_account_helper::SetUpGaiaCookieManagerService(
&test_url_loader_factory_);
test_signin_client_factory_ =
secondary_account_helper::SetUpSigninClient(&test_url_loader_factory_);
}
void SetUpOnMainThread() override {
......@@ -1131,8 +1130,8 @@ class SingleClientWalletSecondaryAccountSyncTest
Profile* profile() { return GetProfile(0); }
private:
secondary_account_helper::ScopedGaiaCookieManagerServiceFactory
test_gaia_cookie_manager_factory_;
secondary_account_helper::ScopedSigninClientFactory
test_signin_client_factory_;
DISALLOW_COPY_AND_ASSIGN(SingleClientWalletSecondaryAccountSyncTest);
};
......
......@@ -11,8 +11,8 @@
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_factory.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_test_util.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/chrome_signin_client_test_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_tabstrip.h"
......@@ -57,8 +57,8 @@ void CocoaProfileTest::SetUp() {
// Always fake out the Gaia service to avoid issuing network requests.
TestingProfile::TestingFactories testing_factories = {
{GaiaCookieManagerServiceFactory::GetInstance(),
base::BindRepeating(&BuildGaiaCookieManagerServiceWithURLLoader,
{ChromeSigninClientFactory::GetInstance(),
base::BindRepeating(&BuildChromeSigninClientWithURLLoader,
&test_url_loader_factory_)}};
profile_ = profile_manager_.CreateTestingProfile(
......
......@@ -15,8 +15,8 @@
#include "chrome/browser/search_engines/chrome_template_url_service_client.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_factory.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_test_util.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/chrome_signin_client_test_util.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/web_data_service_factory.h"
......@@ -115,7 +115,7 @@ BrowserWindow* TestWithBrowserView::CreateBrowserWindow() {
}
TestingProfile::TestingFactories TestWithBrowserView::GetTestingFactories() {
return {{GaiaCookieManagerServiceFactory::GetInstance(),
base::BindRepeating(&BuildGaiaCookieManagerServiceWithURLLoader,
return {{ChromeSigninClientFactory::GetInstance(),
base::BindRepeating(&BuildChromeSigninClientWithURLLoader,
test_url_loader_factory())}};
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment