Commit 35af51e3 authored by Mario Sanchez Prada's avatar Mario Sanchez Prada Committed by Commit Bot

Convert PeopleHandler to IdentityManager::Observer

Reimplement callbacks GoogleSigninSucceeded and GoogleSignedOut as
OnPrimaryAccountSet and OnPrimaryAccountCleared, from IdentityManager.

Bug: 887461
Change-Id: I6a0f5758b8c07f21a8b06b4993a9f58528ee7c7e
Reviewed-on: https://chromium-review.googlesource.com/c/1261637
Commit-Queue: Mario Sanchez Prada <mario@igalia.com>
Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603044}
parent c63fdd71
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "chrome/browser/profiles/profile_metrics.h" #include "chrome/browser/profiles/profile_metrics.h"
#include "chrome/browser/profiles/profile_window.h" #include "chrome/browser/profiles/profile_window.h"
#include "chrome/browser/signin/chrome_signin_helper.h" #include "chrome/browser/signin/chrome_signin_helper.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_error_controller_factory.h" #include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_manager_factory.h"
...@@ -220,7 +221,7 @@ const char PeopleHandler::kPassphraseFailedPageStatus[] = "passphraseFailed"; ...@@ -220,7 +221,7 @@ const char PeopleHandler::kPassphraseFailedPageStatus[] = "passphraseFailed";
PeopleHandler::PeopleHandler(Profile* profile) PeopleHandler::PeopleHandler(Profile* profile)
: profile_(profile), : profile_(profile),
configuring_sync_(false), configuring_sync_(false),
signin_observer_(this), identity_manager_observer_(this),
#if BUILDFLAG(ENABLE_DICE_SUPPORT) #if BUILDFLAG(ENABLE_DICE_SUPPORT)
sync_service_observer_(this), sync_service_observer_(this),
account_tracker_observer_(this) { account_tracker_observer_(this) {
...@@ -310,10 +311,10 @@ void PeopleHandler::OnJavascriptAllowed() { ...@@ -310,10 +311,10 @@ void PeopleHandler::OnJavascriptAllowed() {
prefs::kSigninAllowed, prefs::kSigninAllowed,
base::Bind(&PeopleHandler::UpdateSyncStatus, base::Unretained(this))); base::Bind(&PeopleHandler::UpdateSyncStatus, base::Unretained(this)));
SigninManagerBase* signin_manager( identity::IdentityManager* identity_manager(
SigninManagerFactory::GetInstance()->GetForProfile(profile_)); IdentityManagerFactory::GetInstance()->GetForProfile(profile_));
if (signin_manager) if (identity_manager)
signin_observer_.Add(signin_manager); identity_manager_observer_.Add(identity_manager);
// This is intentionally not using GetSyncService(), to go around the // This is intentionally not using GetSyncService(), to go around the
// Profile::IsSyncAllowed() check. // Profile::IsSyncAllowed() check.
...@@ -332,7 +333,7 @@ void PeopleHandler::OnJavascriptAllowed() { ...@@ -332,7 +333,7 @@ void PeopleHandler::OnJavascriptAllowed() {
void PeopleHandler::OnJavascriptDisallowed() { void PeopleHandler::OnJavascriptDisallowed() {
profile_pref_registrar_.RemoveAll(); profile_pref_registrar_.RemoveAll();
signin_observer_.RemoveAll(); identity_manager_observer_.RemoveAll();
sync_service_observer_.RemoveAll(); sync_service_observer_.RemoveAll();
#if BUILDFLAG(ENABLE_DICE_SUPPORT) #if BUILDFLAG(ENABLE_DICE_SUPPORT)
account_tracker_observer_.RemoveAll(); account_tracker_observer_.RemoveAll();
...@@ -923,13 +924,13 @@ void PeopleHandler::CloseUI() { ...@@ -923,13 +924,13 @@ void PeopleHandler::CloseUI() {
FireWebUIListener("page-status-changed", base::Value(kDonePageStatus)); FireWebUIListener("page-status-changed", base::Value(kDonePageStatus));
} }
void PeopleHandler::GoogleSigninSucceeded(const std::string& /* account_id */, void PeopleHandler::OnPrimaryAccountSet(
const std::string& /* username */) { const AccountInfo& primary_account_info) {
UpdateSyncStatus(); UpdateSyncStatus();
} }
void PeopleHandler::GoogleSignedOut(const std::string& /* account_id */, void PeopleHandler::OnPrimaryAccountCleared(
const std::string& /* username */) { const AccountInfo& previous_primary_account_info) {
UpdateSyncStatus(); UpdateSyncStatus();
} }
......
...@@ -21,15 +21,14 @@ ...@@ -21,15 +21,14 @@
#include "chrome/browser/ui/webui/signin/login_ui_service.h" #include "chrome/browser/ui/webui/signin/login_ui_service.h"
#include "components/prefs/pref_change_registrar.h" #include "components/prefs/pref_change_registrar.h"
#include "components/signin/core/browser/signin_buildflags.h" #include "components/signin/core/browser/signin_buildflags.h"
#include "components/signin/core/browser/signin_manager_base.h"
#include "components/sync/driver/sync_service_observer.h" #include "components/sync/driver/sync_service_observer.h"
#include "services/identity/public/cpp/identity_manager.h"
#if BUILDFLAG(ENABLE_DICE_SUPPORT) #if BUILDFLAG(ENABLE_DICE_SUPPORT)
#include "components/signin/core/browser/account_tracker_service.h" #include "components/signin/core/browser/account_tracker_service.h"
#endif #endif
class LoginUIService; class LoginUIService;
class SigninManagerBase;
namespace browser_sync { namespace browser_sync {
class ProfileSyncService; class ProfileSyncService;
...@@ -50,7 +49,7 @@ class SyncSetupInProgressHandle; ...@@ -50,7 +49,7 @@ class SyncSetupInProgressHandle;
namespace settings { namespace settings {
class PeopleHandler : public SettingsPageUIHandler, class PeopleHandler : public SettingsPageUIHandler,
public SigninManagerBase::Observer, public identity::IdentityManager::Observer,
public SyncStartupTracker::Observer, public SyncStartupTracker::Observer,
#if BUILDFLAG(ENABLE_DICE_SUPPORT) #if BUILDFLAG(ENABLE_DICE_SUPPORT)
public AccountTrackerService::Observer, public AccountTrackerService::Observer,
...@@ -136,11 +135,10 @@ class PeopleHandler : public SettingsPageUIHandler, ...@@ -136,11 +135,10 @@ class PeopleHandler : public SettingsPageUIHandler,
// LoginUIService::LoginUI implementation. // LoginUIService::LoginUI implementation.
void FocusUI() override; void FocusUI() override;
// SigninManagerBase::Observer implementation. // IdentityManager::Observer implementation.
void GoogleSigninSucceeded(const std::string& account_id, void OnPrimaryAccountSet(const AccountInfo& primary_account_info) override;
const std::string& username) override; void OnPrimaryAccountCleared(
void GoogleSignedOut(const std::string& account_id, const AccountInfo& previous_primary_account_info) override;
const std::string& username) override;
// syncer::SyncServiceObserver implementation. // syncer::SyncServiceObserver implementation.
void OnStateChanged(syncer::SyncService* sync) override; void OnStateChanged(syncer::SyncService* sync) override;
...@@ -258,7 +256,8 @@ class PeopleHandler : public SettingsPageUIHandler, ...@@ -258,7 +256,8 @@ class PeopleHandler : public SettingsPageUIHandler,
PrefChangeRegistrar profile_pref_registrar_; PrefChangeRegistrar profile_pref_registrar_;
// Manages observer lifetimes. // Manages observer lifetimes.
ScopedObserver<SigninManagerBase, PeopleHandler> signin_observer_; ScopedObserver<identity::IdentityManager, PeopleHandler>
identity_manager_observer_;
ScopedObserver<browser_sync::ProfileSyncService, PeopleHandler> ScopedObserver<browser_sync::ProfileSyncService, PeopleHandler>
sync_service_observer_; sync_service_observer_;
......
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