Commit 3f9b3e12 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Sync: don't expose SigninManager from SyncService

As a first (baby) step of removing the old signin APIs from Sync.

Bug: 825190
Change-Id: I1554c96c54555083f06963a72d2c38248afeb960
Reviewed-on: https://chromium-review.googlesource.com/978186Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546065}
parent bc09d4d5
...@@ -281,8 +281,8 @@ bool ProfileSyncServiceHarness::RestartSyncService() { ...@@ -281,8 +281,8 @@ bool ProfileSyncServiceHarness::RestartSyncService() {
void ProfileSyncServiceHarness::SignoutSyncService() { void ProfileSyncServiceHarness::SignoutSyncService() {
DCHECK(!username_.empty()); DCHECK(!username_.empty());
service()->GoogleSignedOut(service()->signin()->GetAuthenticatedAccountId(), service()->GoogleSignedOut(
username_); service()->GetAuthenticatedAccountInfo().account_id, username_);
} }
bool ProfileSyncServiceHarness::AwaitMutualSyncCycleCompletion( bool ProfileSyncServiceHarness::AwaitMutualSyncCycleCompletion(
......
...@@ -428,7 +428,8 @@ IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, ...@@ -428,7 +428,8 @@ IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest,
// want to block here and not create the HistogramTester below until we know // want to block here and not create the HistogramTester below until we know
// the cookie jar stats have been updated. // the cookie jar stats have been updated.
UpdateCookieJarAccountsAndWait( UpdateCookieJarAccountsAndWait(
{GetClient(0)->service()->signin()->GetAuthenticatedAccountId()}, false); {GetClient(0)->service()->GetAuthenticatedAccountInfo().account_id},
false);
{ {
HistogramTester histogram_tester; HistogramTester histogram_tester;
......
...@@ -336,14 +336,14 @@ void ProfileSyncService::StartSyncingWithServer() { ...@@ -336,14 +336,14 @@ void ProfileSyncService::StartSyncingWithServer() {
void ProfileSyncService::RegisterAuthNotifications() { void ProfileSyncService::RegisterAuthNotifications() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
oauth2_token_service_->AddObserver(this); oauth2_token_service_->AddObserver(this);
if (signin()) if (signin_)
signin()->AddObserver(this); signin_->GetOriginal()->AddObserver(this);
} }
void ProfileSyncService::UnregisterAuthNotifications() { void ProfileSyncService::UnregisterAuthNotifications() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
if (signin()) if (signin_)
signin()->RemoveObserver(this); signin_->GetOriginal()->RemoveObserver(this);
if (oauth2_token_service_) if (oauth2_token_service_)
oauth2_token_service_->RemoveObserver(this); oauth2_token_service_->RemoveObserver(this);
} }
......
...@@ -783,6 +783,7 @@ static_library("test_support_driver") { ...@@ -783,6 +783,7 @@ static_library("test_support_driver") {
deps = [ deps = [
":sync", ":sync",
":test_support_engine", ":test_support_engine",
"//components/signin/core/browser:account_info",
"//components/sync_preferences:test_support", "//components/sync_preferences:test_support",
"//components/version_info", "//components/version_info",
"//google_apis", "//google_apis",
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/values.h" #include "base/values.h"
#include "components/signin/core/browser/signin_manager_base.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "components/sync/driver/sync_service.h" #include "components/sync/driver/sync_service.h"
#include "components/sync/engine/cycle/sync_cycle_snapshot.h" #include "components/sync/engine/cycle/sync_cycle_snapshot.h"
...@@ -245,11 +244,8 @@ std::string GetConnectionStatus(const SyncService::SyncTokenStatus& status) { ...@@ -245,11 +244,8 @@ std::string GetConnectionStatus(const SyncService::SyncTokenStatus& status) {
std::unique_ptr<base::DictionaryValue> ConstructAboutInformation_DEPRECATED( std::unique_ptr<base::DictionaryValue> ConstructAboutInformation_DEPRECATED(
SyncService* service, SyncService* service,
version_info::Channel channel) { version_info::Channel channel) {
AccountInfo primary_account_info; return ConstructAboutInformation(
if (service->signin()) service, service->GetAuthenticatedAccountInfo(), channel);
primary_account_info = service->signin()->GetAuthenticatedAccountInfo();
return ConstructAboutInformation(service, primary_account_info, channel);
} }
// This function both defines the structure of the message to be returned and // This function both defines the structure of the message to be returned and
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "components/sync/driver/fake_sync_service.h" #include "components/sync/driver/fake_sync_service.h"
#include "base/values.h" #include "base/values.h"
#include "components/signin/core/browser/account_info.h"
#include "components/sync/driver/data_type_controller.h" #include "components/sync/driver/data_type_controller.h"
#include "components/sync/syncable/base_transaction.h" #include "components/sync/syncable/base_transaction.h"
#include "components/sync/syncable/user_share.h" #include "components/sync/syncable/user_share.h"
...@@ -204,8 +205,8 @@ base::WeakPtr<JsController> FakeSyncService::GetJsController() { ...@@ -204,8 +205,8 @@ base::WeakPtr<JsController> FakeSyncService::GetJsController() {
void FakeSyncService::GetAllNodes( void FakeSyncService::GetAllNodes(
const base::Callback<void(std::unique_ptr<base::ListValue>)>& callback) {} const base::Callback<void(std::unique_ptr<base::ListValue>)>& callback) {}
SigninManagerBase* FakeSyncService::signin() const { AccountInfo FakeSyncService::GetAuthenticatedAccountInfo() const {
return nullptr; return AccountInfo();
} }
GlobalIdMapper* FakeSyncService::GetGlobalIdMapper() const { GlobalIdMapper* FakeSyncService::GetGlobalIdMapper() const {
......
...@@ -88,7 +88,7 @@ class FakeSyncService : public SyncService { ...@@ -88,7 +88,7 @@ class FakeSyncService : public SyncService {
base::WeakPtr<JsController> GetJsController() override; base::WeakPtr<JsController> GetJsController() override;
void GetAllNodes(const base::Callback<void(std::unique_ptr<base::ListValue>)>& void GetAllNodes(const base::Callback<void(std::unique_ptr<base::ListValue>)>&
callback) override; callback) override;
SigninManagerBase* signin() const override; AccountInfo GetAuthenticatedAccountInfo() const override;
GlobalIdMapper* GetGlobalIdMapper() const override; GlobalIdMapper* GetGlobalIdMapper() const override;
// DataTypeEncryptionHandler implementation. // DataTypeEncryptionHandler implementation.
......
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
#include "components/sync/engine/connection_status.h" #include "components/sync/engine/connection_status.h"
#include "google_apis/gaia/google_service_auth_error.h" #include "google_apis/gaia/google_service_auth_error.h"
struct AccountInfo;
class GoogleServiceAuthError; class GoogleServiceAuthError;
class SigninManagerBase;
namespace sync_sessions { namespace sync_sessions {
class OpenTabsUIDelegate; class OpenTabsUIDelegate;
...@@ -350,9 +350,8 @@ class SyncService : public DataTypeEncryptionHandler, public KeyedService { ...@@ -350,9 +350,8 @@ class SyncService : public DataTypeEncryptionHandler, public KeyedService {
const base::Callback<void(std::unique_ptr<base::ListValue>)>& const base::Callback<void(std::unique_ptr<base::ListValue>)>&
callback) = 0; callback) = 0;
// Non-owning pointer to sign in logic that can be used to fetch information // Information about the currently signed in user.
// about the currently signed in user. virtual AccountInfo GetAuthenticatedAccountInfo() const = 0;
virtual SigninManagerBase* signin() const = 0;
virtual GlobalIdMapper* GetGlobalIdMapper() const = 0; virtual GlobalIdMapper* GetGlobalIdMapper() const = 0;
......
...@@ -7,12 +7,13 @@ ...@@ -7,12 +7,13 @@
#include <utility> #include <utility>
#include "base/bind.h" #include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/syslog_logging.h" #include "base/syslog_logging.h"
#include "components/invalidation/public/invalidation_service.h" #include "components/invalidation/public/invalidation_service.h"
#include "components/signin/core/browser/account_info.h"
#include "components/signin/core/browser/signin_manager_base.h"
#include "components/sync/base/report_unrecoverable_error.h" #include "components/sync/base/report_unrecoverable_error.h"
#include "components/sync/device_info/local_device_info_provider.h" #include "components/sync/device_info/local_device_info_provider.h"
#include "components/sync/driver/sync_driver_switches.h" #include "components/sync/driver/sync_driver_switches.h"
...@@ -82,9 +83,10 @@ bool SyncServiceBase::HasObserver(const SyncServiceObserver* observer) const { ...@@ -82,9 +83,10 @@ bool SyncServiceBase::HasObserver(const SyncServiceObserver* observer) const {
return observers_.HasObserver(observer); return observers_.HasObserver(observer);
} }
SigninManagerBase* SyncServiceBase::signin() const { AccountInfo SyncServiceBase::GetAuthenticatedAccountInfo() const {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
return signin_ ? signin_->GetOriginal() : nullptr; return signin_ ? signin_->GetOriginal()->GetAuthenticatedAccountInfo()
: AccountInfo();
} }
// static // static
......
...@@ -47,7 +47,7 @@ class SyncServiceBase : public SyncService, public SyncEngineHost { ...@@ -47,7 +47,7 @@ class SyncServiceBase : public SyncService, public SyncEngineHost {
void AddObserver(SyncServiceObserver* observer) override; void AddObserver(SyncServiceObserver* observer) override;
void RemoveObserver(SyncServiceObserver* observer) override; void RemoveObserver(SyncServiceObserver* observer) override;
bool HasObserver(const SyncServiceObserver* observer) const override; bool HasObserver(const SyncServiceObserver* observer) const override;
SigninManagerBase* signin() const override; AccountInfo GetAuthenticatedAccountInfo() const override;
// Given base path (path to profile) formats path to "Sync Data" folder where // Given base path (path to profile) formats path to "Sync Data" folder where
// sync engine stores directory database. // sync engine stores directory database.
......
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