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") { ...@@ -5403,8 +5403,8 @@ static_library("test_support") {
"search_engines/template_url_service_factory_test_util.h", "search_engines/template_url_service_factory_test_util.h",
"search_engines/template_url_service_test_util.cc", "search_engines/template_url_service_test_util.cc",
"search_engines/template_url_service_test_util.h", "search_engines/template_url_service_test_util.h",
"signin/gaia_cookie_manager_service_test_util.cc", "signin/chrome_signin_client_test_util.cc",
"signin/gaia_cookie_manager_service_test_util.h", "signin/chrome_signin_client_test_util.h",
"signin/identity_test_environment_profile_adaptor.cc", "signin/identity_test_environment_profile_adaptor.cc",
"signin/identity_test_environment_profile_adaptor.h", "signin/identity_test_environment_profile_adaptor.h",
"signin/scoped_account_consistency.cc", "signin/scoped_account_consistency.cc",
......
...@@ -33,8 +33,8 @@ ...@@ -33,8 +33,8 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/account_fetcher_service_factory.h" #include "chrome/browser/signin/account_fetcher_service_factory.h"
#include "chrome/browser/signin/account_reconcilor_factory.h" #include "chrome/browser/signin/account_reconcilor_factory.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_factory.h" #include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_test_util.h" #include "chrome/browser/signin/chrome_signin_client_test_util.h"
#include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/identity_test_environment_profile_adaptor.h" #include "chrome/browser/signin/identity_test_environment_profile_adaptor.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
...@@ -464,9 +464,8 @@ class IdentityTestWithSignin : public AsyncExtensionBrowserTest { ...@@ -464,9 +464,8 @@ class IdentityTestWithSignin : public AsyncExtensionBrowserTest {
IdentityTestEnvironmentProfileAdaptor:: IdentityTestEnvironmentProfileAdaptor::
SetIdentityTestEnvironmentFactoriesOnBrowserContext(context); SetIdentityTestEnvironmentFactoriesOnBrowserContext(context);
GaiaCookieManagerServiceFactory::GetInstance()->SetTestingFactory( ChromeSigninClientFactory::GetInstance()->SetTestingFactory(
context, context, base::BindRepeating(&BuildChromeSigninClientWithURLLoader,
base::BindRepeating(&BuildGaiaCookieManagerServiceWithURLLoader,
&test_url_loader_factory_)); &test_url_loader_factory_));
// Ensure that AccountFetcherService is (1) created at all and (2) created // Ensure that AccountFetcherService is (1) created at all and (2) created
......
...@@ -341,9 +341,8 @@ class UkmBrowserTestWithSyncTransport : public UkmBrowserTest { ...@@ -341,9 +341,8 @@ class UkmBrowserTestWithSyncTransport : public UkmBrowserTest {
// This is required to support (fake) secondary-account-signin (based on // This is required to support (fake) secondary-account-signin (based on
// cookies) in tests. Without this, the real GaiaCookieManagerService would // cookies) in tests. Without this, the real GaiaCookieManagerService would
// try talking to Google servers which of course wouldn't work in tests. // try talking to Google servers which of course wouldn't work in tests.
test_gaia_cookie_manager_factory_ = test_signin_client_factory_ =
secondary_account_helper::SetUpGaiaCookieManagerService( secondary_account_helper::SetUpSigninClient(&test_url_loader_factory_);
&test_url_loader_factory_);
UkmBrowserTest::SetUpInProcessBrowserTestFixture(); UkmBrowserTest::SetUpInProcessBrowserTestFixture();
} }
...@@ -357,8 +356,8 @@ class UkmBrowserTestWithSyncTransport : public UkmBrowserTest { ...@@ -357,8 +356,8 @@ class UkmBrowserTestWithSyncTransport : public UkmBrowserTest {
private: private:
base::test::ScopedFeatureList features_; base::test::ScopedFeatureList features_;
secondary_account_helper::ScopedGaiaCookieManagerServiceFactory secondary_account_helper::ScopedSigninClientFactory
test_gaia_cookie_manager_factory_; test_signin_client_factory_;
DISALLOW_COPY_AND_ASSIGN(UkmBrowserTestWithSyncTransport); DISALLOW_COPY_AND_ASSIGN(UkmBrowserTestWithSyncTransport);
}; };
......
...@@ -2,28 +2,20 @@ ...@@ -2,28 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // 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/profiles/profile.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h" #include "chrome/browser/signin/chrome_signin_client.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "components/keyed_service/core/keyed_service.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/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/test/test_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, network::TestURLLoaderFactory* test_url_loader_factory,
content::BrowserContext* context) { content::BrowserContext* context) {
Profile* profile = Profile::FromBrowserContext(context); Profile* profile = Profile::FromBrowserContext(context);
return std::make_unique<GaiaCookieManagerService>( auto signin_client = std::make_unique<ChromeSigninClient>(profile);
ProfileOAuth2TokenServiceFactory::GetForProfile(profile), signin_client->SetURLLoaderFactoryForTest(
ChromeSigninClientFactory::GetForProfile(profile), test_url_loader_factory->GetSafeWeakWrapper());
base::BindRepeating( return signin_client;
[](network::TestURLLoaderFactory* test_url_loader_factory)
-> scoped_refptr<network::SharedURLLoaderFactory> {
return test_url_loader_factory->GetSafeWeakWrapper();
},
test_url_loader_factory));
} }
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_SIGNIN_GAIA_COOKIE_MANAGER_SERVICE_TEST_UTIL_H_ #ifndef CHROME_BROWSER_SIGNIN_CHROME_SIGNIN_CLIENT_TEST_UTIL_H_
#define CHROME_BROWSER_SIGNIN_GAIA_COOKIE_MANAGER_SERVICE_TEST_UTIL_H_ #define CHROME_BROWSER_SIGNIN_CHROME_SIGNIN_CLIENT_TEST_UTIL_H_
#include <memory> #include <memory>
...@@ -17,10 +17,10 @@ namespace network { ...@@ -17,10 +17,10 @@ namespace network {
class TestURLLoaderFactory; class TestURLLoaderFactory;
} }
// Creates a GaiaCookieManagerService using the supplied // Creates a ChromeSigninClient using the supplied
// |test_url_loader_factory| and |context|. // |test_url_loader_factory| and |context|.
std::unique_ptr<KeyedService> BuildGaiaCookieManagerServiceWithURLLoader( std::unique_ptr<KeyedService> BuildChromeSigninClientWithURLLoader(
network::TestURLLoaderFactory* test_url_loader_factory, network::TestURLLoaderFactory* test_url_loader_factory,
content::BrowserContext* context); 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 @@ ...@@ -9,7 +9,6 @@
#include "chrome/browser/signin/account_tracker_service_factory.h" #include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/chrome_signin_client_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_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/identity_manager_factory.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_manager_factory.h"
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
#include "base/bind.h" #include "base/bind.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_factory.h" #include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_test_util.h" #include "chrome/browser/signin/chrome_signin_client_test_util.h"
#include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/signin/identity_manager_factory.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "services/identity/public/cpp/identity_manager.h" #include "services/identity/public/cpp/identity_manager.h"
...@@ -29,14 +29,14 @@ namespace { ...@@ -29,14 +29,14 @@ namespace {
void OnWillCreateBrowserContextServices( void OnWillCreateBrowserContextServices(
network::TestURLLoaderFactory* test_url_loader_factory, network::TestURLLoaderFactory* test_url_loader_factory,
content::BrowserContext* context) { content::BrowserContext* context) {
GaiaCookieManagerServiceFactory::GetInstance()->SetTestingFactory( ChromeSigninClientFactory::GetInstance()->SetTestingFactory(
context, base::BindRepeating(&BuildGaiaCookieManagerServiceWithURLLoader, context, base::BindRepeating(&BuildChromeSigninClientWithURLLoader,
test_url_loader_factory)); test_url_loader_factory));
} }
} // namespace } // namespace
ScopedGaiaCookieManagerServiceFactory SetUpGaiaCookieManagerService( ScopedSigninClientFactory SetUpSigninClient(
network::TestURLLoaderFactory* test_url_loader_factory) { network::TestURLLoaderFactory* test_url_loader_factory) {
return BrowserContextDependencyManager::GetInstance() return BrowserContextDependencyManager::GetInstance()
->RegisterWillCreateBrowserContextServicesCallbackForTesting( ->RegisterWillCreateBrowserContextServicesCallbackForTesting(
......
...@@ -23,15 +23,15 @@ class TestURLLoaderFactory; ...@@ -23,15 +23,15 @@ class TestURLLoaderFactory;
namespace secondary_account_helper { namespace secondary_account_helper {
using ScopedGaiaCookieManagerServiceFactory = std::unique_ptr< using ScopedSigninClientFactory = std::unique_ptr<
base::CallbackList<void(content::BrowserContext*)>::Subscription>; 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 // provided |test_url_loader_factory| for cookie-related requests. Meant to be
// called from SetUpInProcessBrowserTestFixture. The caller should hold on to // 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 // the returned object for the duration of the test, e.g. store it in a member
// of the test fixture class. // of the test fixture class.
ScopedGaiaCookieManagerServiceFactory SetUpGaiaCookieManagerService( ScopedSigninClientFactory SetUpSigninClient(
network::TestURLLoaderFactory* test_url_loader_factory); network::TestURLLoaderFactory* test_url_loader_factory);
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
......
...@@ -38,9 +38,8 @@ class SingleClientSecondaryAccountSyncTest : public SyncTest { ...@@ -38,9 +38,8 @@ class SingleClientSecondaryAccountSyncTest : public SyncTest {
~SingleClientSecondaryAccountSyncTest() override {} ~SingleClientSecondaryAccountSyncTest() override {}
void SetUpInProcessBrowserTestFixture() override { void SetUpInProcessBrowserTestFixture() override {
test_gaia_cookie_manager_factory_ = test_signin_client_factory_ =
secondary_account_helper::SetUpGaiaCookieManagerService( secondary_account_helper::SetUpSigninClient(&test_url_loader_factory_);
&test_url_loader_factory_);
} }
void SetUpOnMainThread() override { void SetUpOnMainThread() override {
...@@ -55,8 +54,8 @@ class SingleClientSecondaryAccountSyncTest : public SyncTest { ...@@ -55,8 +54,8 @@ class SingleClientSecondaryAccountSyncTest : public SyncTest {
private: private:
base::test::ScopedFeatureList features_; base::test::ScopedFeatureList features_;
secondary_account_helper::ScopedGaiaCookieManagerServiceFactory secondary_account_helper::ScopedSigninClientFactory
test_gaia_cookie_manager_factory_; test_signin_client_factory_;
DISALLOW_COPY_AND_ASSIGN(SingleClientSecondaryAccountSyncTest); DISALLOW_COPY_AND_ASSIGN(SingleClientSecondaryAccountSyncTest);
}; };
......
...@@ -1116,9 +1116,8 @@ class SingleClientWalletSecondaryAccountSyncTest ...@@ -1116,9 +1116,8 @@ class SingleClientWalletSecondaryAccountSyncTest
~SingleClientWalletSecondaryAccountSyncTest() override {} ~SingleClientWalletSecondaryAccountSyncTest() override {}
void SetUpInProcessBrowserTestFixture() override { void SetUpInProcessBrowserTestFixture() override {
test_gaia_cookie_manager_factory_ = test_signin_client_factory_ =
secondary_account_helper::SetUpGaiaCookieManagerService( secondary_account_helper::SetUpSigninClient(&test_url_loader_factory_);
&test_url_loader_factory_);
} }
void SetUpOnMainThread() override { void SetUpOnMainThread() override {
...@@ -1131,8 +1130,8 @@ class SingleClientWalletSecondaryAccountSyncTest ...@@ -1131,8 +1130,8 @@ class SingleClientWalletSecondaryAccountSyncTest
Profile* profile() { return GetProfile(0); } Profile* profile() { return GetProfile(0); }
private: private:
secondary_account_helper::ScopedGaiaCookieManagerServiceFactory secondary_account_helper::ScopedSigninClientFactory
test_gaia_cookie_manager_factory_; test_signin_client_factory_;
DISALLOW_COPY_AND_ASSIGN(SingleClientWalletSecondaryAccountSyncTest); DISALLOW_COPY_AND_ASSIGN(SingleClientWalletSecondaryAccountSyncTest);
}; };
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
#include "chrome/browser/bookmarks/bookmark_model_factory.h" #include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/search_engines/template_url_service_factory.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/chrome_signin_client_factory.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_test_util.h" #include "chrome/browser/signin/chrome_signin_client_test_util.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_tabstrip.h"
...@@ -57,8 +57,8 @@ void CocoaProfileTest::SetUp() { ...@@ -57,8 +57,8 @@ void CocoaProfileTest::SetUp() {
// Always fake out the Gaia service to avoid issuing network requests. // Always fake out the Gaia service to avoid issuing network requests.
TestingProfile::TestingFactories testing_factories = { TestingProfile::TestingFactories testing_factories = {
{GaiaCookieManagerServiceFactory::GetInstance(), {ChromeSigninClientFactory::GetInstance(),
base::BindRepeating(&BuildGaiaCookieManagerServiceWithURLLoader, base::BindRepeating(&BuildChromeSigninClientWithURLLoader,
&test_url_loader_factory_)}}; &test_url_loader_factory_)}};
profile_ = profile_manager_.CreateTestingProfile( profile_ = profile_manager_.CreateTestingProfile(
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
#include "chrome/browser/search_engines/chrome_template_url_service_client.h" #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/template_url_service_factory.h"
#include "chrome/browser/search_engines/ui_thread_search_terms_data.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/chrome_signin_client_factory.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_test_util.h" #include "chrome/browser/signin/chrome_signin_client_test_util.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/web_data_service_factory.h" #include "chrome/browser/web_data_service_factory.h"
...@@ -115,7 +115,7 @@ BrowserWindow* TestWithBrowserView::CreateBrowserWindow() { ...@@ -115,7 +115,7 @@ BrowserWindow* TestWithBrowserView::CreateBrowserWindow() {
} }
TestingProfile::TestingFactories TestWithBrowserView::GetTestingFactories() { TestingProfile::TestingFactories TestWithBrowserView::GetTestingFactories() {
return {{GaiaCookieManagerServiceFactory::GetInstance(), return {{ChromeSigninClientFactory::GetInstance(),
base::BindRepeating(&BuildGaiaCookieManagerServiceWithURLLoader, base::BindRepeating(&BuildChromeSigninClientWithURLLoader,
test_url_loader_factory())}}; 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