Addressed review feedback; fixed CI issues

This commit is contained in:
AlexeyBarabash
2020-12-17 00:53:07 +02:00
parent 2ff7d8a15f
commit 79468a8638
11 changed files with 69 additions and 122 deletions
@@ -9,7 +9,6 @@
#include "base/files/file_path.h"
#include "brave/components/signin/public/identity_manager/brave_identity_manager.h"
#include "brave/components/signin/public/identity_manager/brave_identity_manager_builder.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/image_fetcher/image_decoder_impl.h"
@@ -31,7 +30,7 @@
BraveIdentityManagerFactory::BraveIdentityManagerFactory()
: IdentityManagerFactory() {}
BraveIdentityManagerFactory::~BraveIdentityManagerFactory() = default;
BraveIdentityManagerFactory::~BraveIdentityManagerFactory() {}
// static
signin::BraveIdentityManager* BraveIdentityManagerFactory::GetForProfile(
@@ -0,0 +1,20 @@
/* Copyright (c) 2020 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef BRAVE_CHROMIUM_SRC_CHROME_BROWSER_SIGNIN_IDENTITY_MANAGER_FACTORY_H_
#define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_SIGNIN_IDENTITY_MANAGER_FACTORY_H_
class BraveIdentityManagerFactory;
#define BRAVE_IDENTITY_MANAGER_FACTORY_H_ \
private: \
friend class BraveIdentityManagerFactory; \
friend struct base::DefaultSingletonTraits<BraveIdentityManagerFactory>;
#include "../../../../../chrome/browser/signin/identity_manager_factory.h"
#undef BRAVE_IDENTITY_MANAGER_FACTORY_H_
#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_SIGNIN_IDENTITY_MANAGER_FACTORY_H_
@@ -16,10 +16,6 @@
std::make_unique<syncer::BraveProfileSyncServiceDelegate>( \
DeviceInfoSyncServiceFactory::GetForProfile(profile)));
// Excluding src/chrome/browser/signin/identity_manager_factory.h, but this is
// OK, because we are including brave_identity_manager_factory.h
#define CHROME_BROWSER_SIGNIN_IDENTITY_MANAGER_FACTORY_H_
#include "../../../../../chrome/browser/sync/profile_sync_service_factory.cc"
#undef BRAVE_BUILD_SERVICE_INSTANCE_FOR
@@ -7,83 +7,26 @@
#include "brave/components/signin/internal/identity_manager/brave_primary_account_mutator_impl.h"
#include "brave/components/signin/public/identity_manager/brave_identity_manager.h"
#include "brave/components/signin/public/identity_manager/brave_identity_manager_builder.h"
namespace signin {
namespace {
IdentityManager::InitParameters BuildBraveIdentityManagerInitParameters(
IdentityManagerBuildParams* params) {
std::unique_ptr<AccountTrackerService> account_tracker_service =
BuildAccountTrackerService(params->pref_service, params->profile_path);
std::unique_ptr<ProfileOAuth2TokenService> token_service =
BuildProfileOAuth2TokenService(
params->pref_service, account_tracker_service.get(),
params->network_connection_tracker, params->account_consistency,
#if defined(OS_CHROMEOS)
params->account_manager, params->is_regular_profile,
#endif
#if !defined(OS_ANDROID)
params->delete_signin_cookies_on_exit, params->token_web_data,
#endif
#if defined(OS_IOS)
std::move(params->device_accounts_provider),
#endif
#if defined(OS_WIN)
params->reauth_callback,
#endif
params->signin_client);
auto gaia_cookie_manager_service = std::make_unique<GaiaCookieManagerService>(
token_service.get(), params->signin_client);
std::unique_ptr<PrimaryAccountManager> primary_account_manager =
BuildPrimaryAccountManager(params->signin_client,
params->account_consistency,
account_tracker_service.get(),
token_service.get(), params->local_state);
IdentityManager::InitParameters init_params;
IdentityManager::InitParameters init_params =
BuildIdentityManagerInitParameters(params);
init_params.primary_account_mutator =
std::make_unique<BravePrimaryAccountMutatorImpl>(
account_tracker_service.get(), primary_account_manager.get(),
params->pref_service);
init_params.accounts_mutator =
BuildAccountsMutator(params->pref_service, account_tracker_service.get(),
token_service.get(), primary_account_manager.get());
init_params.accounts_cookie_mutator =
std::make_unique<AccountsCookieMutatorImpl>(
params->signin_client, token_service.get(),
gaia_cookie_manager_service.get(), account_tracker_service.get());
init_params.diagnostics_provider = std::make_unique<DiagnosticsProviderImpl>(
token_service.get(), gaia_cookie_manager_service.get());
init_params.account_fetcher_service = BuildAccountFetcherService(
params->signin_client, token_service.get(), account_tracker_service.get(),
std::move(params->image_decoder));
#if defined(OS_IOS) || defined(OS_ANDROID)
init_params.device_accounts_synchronizer =
std::make_unique<DeviceAccountsSynchronizerImpl>(
token_service->GetDelegate());
#endif
init_params.account_tracker_service = std::move(account_tracker_service);
init_params.gaia_cookie_manager_service =
std::move(gaia_cookie_manager_service);
init_params.primary_account_manager = std::move(primary_account_manager);
init_params.token_service = std::move(token_service);
#if defined(OS_CHROMEOS)
init_params.chromeos_account_manager = params->account_manager;
#endif
init_params.account_tracker_service.get(),
init_params.primary_account_manager.get(), params->pref_service);
return init_params;
}
} // namespace
std::unique_ptr<BraveIdentityManager> BuildBraveIdentityManager(
IdentityManagerBuildParams* params) {
return std::make_unique<BraveIdentityManager>(
@@ -0,0 +1,27 @@
/* Copyright (c) 2020 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at https://mozilla.org/MPL/2.0/. */
#ifndef BRAVE_CHROMIUM_SRC_COMPONENTS_SIGNIN_PUBLIC_IDENTITY_MANAGER_IDENTITY_MANAGER_BUILDER_H_
#define BRAVE_CHROMIUM_SRC_COMPONENTS_SIGNIN_PUBLIC_IDENTITY_MANAGER_IDENTITY_MANAGER_BUILDER_H_
#include <memory>
#include "components/signin/public/identity_manager/identity_manager.h"
namespace signin {
class BraveIdentityManager;
struct IdentityManagerBuildParams;
// Builds an IdentityManager instance from the supplied embedder-level
// dependencies.
std::unique_ptr<BraveIdentityManager> BuildBraveIdentityManager(
IdentityManagerBuildParams* params);
} // namespace signin
#include "../../../../../../components/signin/public/identity_manager/identity_manager_builder.h"
#endif // BRAVE_CHROMIUM_SRC_COMPONENTS_SIGNIN_PUBLIC_IDENTITY_MANAGER_IDENTITY_MANAGER_BUILDER_H_
@@ -21,7 +21,6 @@ class BraveSyncAuthManager;
#include "../../../../../components/sync/driver/sync_auth_manager.h"
#undef BRAVE_SYNC_AUTH_MANAGER_H_
#undef RequestAccessToken
#undef DetermineAccountToUse
#endif // BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_DRIVER_SYNC_AUTH_MANAGER_H_
@@ -26,7 +26,7 @@ bool BravePrimaryAccountMutatorImpl::ClearPrimaryAccount(
ClearAccountsAction action,
signin_metrics::ProfileSignout source_metric,
signin_metrics::SignoutDelete delete_metric) {
return false;
return true;
}
#endif
@@ -11,7 +11,6 @@ source_set("identity_manager") {
sources = [
"brave_identity_manager.cc",
"brave_identity_manager.h",
"brave_identity_manager_builder.h",
]
public_deps = [
@@ -1,33 +0,0 @@
/* Copyright (c) 2020 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef BRAVE_COMPONENTS_SIGNIN_PUBLIC_IDENTITY_MANAGER_BRAVE_IDENTITY_MANAGER_BUILDER_H_
#define BRAVE_COMPONENTS_SIGNIN_PUBLIC_IDENTITY_MANAGER_BRAVE_IDENTITY_MANAGER_BUILDER_H_
#include <memory>
#include "components/signin/public/identity_manager/identity_manager.h"
// To avoid the code duplication, implementation is done in
// chromium_src/components/signin/public/identity_manager/identity_manager_builder.cc
namespace signin {
enum class AccountConsistencyMethod;
class BraveIdentityManager;
struct IdentityManagerBuildParams;
// Builds all required dependencies to initialize the IdentityManager instance.
IdentityManager::InitParameters BuildBraveIdentityManagerInitParameters(
IdentityManagerBuildParams* params);
// Builds an IdentityManager instance from the supplied embedder-level
// dependencies.
std::unique_ptr<BraveIdentityManager> BuildBraveIdentityManager(
IdentityManagerBuildParams* params);
} // namespace signin
#endif // BRAVE_COMPONENTS_SIGNIN_PUBLIC_IDENTITY_MANAGER_BRAVE_IDENTITY_MANAGER_BUILDER_H_
@@ -93,21 +93,6 @@ class BraveProfileSyncServiceTest : public testing::Test {
brave_sync::Prefs* brave_sync_prefs() { return &brave_sync_prefs_; }
void UpdateCredentials() {
profile_sync_service_bundle_.identity_test_env()
->SetRefreshTokenForPrimaryAccount();
}
void FastForwardUntilNoTasksRemain() {
task_environment_.FastForwardUntilNoTasksRemain();
}
DataTypeManagerMock* SetUpDataTypeManagerMock() {
auto data_type_manager = std::make_unique<NiceMock<DataTypeManagerMock>>();
DataTypeManagerMock* data_type_manager_raw = data_type_manager.get();
ON_CALL(*component_factory(), CreateDataTypeManager)
.WillByDefault(Return(ByMove(std::move(data_type_manager))));
return data_type_manager_raw;
}
SyncPrefs* sync_prefs() { return &sync_prefs_; }
BraveProfileSyncService* brave_sync_service() { return sync_service_.get(); }
@@ -0,0 +1,12 @@
diff --git a/chrome/browser/signin/identity_manager_factory.h b/chrome/browser/signin/identity_manager_factory.h
index 57d8f7caedfb91d0a7bef5febd390d2df3497e29..ceeb6a1fddaf5c0f2df3a038cc199fcf77144c0e 100644
--- a/chrome/browser/signin/identity_manager_factory.h
+++ b/chrome/browser/signin/identity_manager_factory.h
@@ -52,6 +52,7 @@ class IdentityManagerFactory : public BrowserContextKeyedServiceFactory {
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
+ BRAVE_IDENTITY_MANAGER_FACTORY_H_
private:
friend struct base::DefaultSingletonTraits<IdentityManagerFactory>;