s13n: Replace use of AccountTrackerService in advanced_protection_status_manager.cc/h

As a step to use IdentityManager, this CL makes AdvancedProtectionStatusManager implement
IdentityManager::Observer instead of AccountTrackerService::Observer.
Besides, AccountTrackerService::SetIsAdvancedProtectionAccount is also replaced by
AccountMutator::UpdateAccountInfo

Bug: 922761, 922762
Change-Id: Ia223d792f745e4d0057eb1426389645ec9083aee
Reviewed-on: https://chromium-review.googlesource.com/c/1426503
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Reviewed-by: Varun Khaneja <vakh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#625486}
diff --git a/chrome/browser/safe_browsing/advanced_protection_status_manager.cc b/chrome/browser/safe_browsing/advanced_protection_status_manager.cc
index 70ec786..5ac2654 100644
--- a/chrome/browser/safe_browsing/advanced_protection_status_manager.cc
+++ b/chrome/browser/safe_browsing/advanced_protection_status_manager.cc
@@ -8,7 +8,6 @@
 #include "base/metrics/histogram_macros.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/safe_browsing/advanced_protection_status_manager_factory.h"
-#include "chrome/browser/signin/account_tracker_service_factory.h"
 #include "chrome/browser/signin/identity_manager_factory.h"
 #include "components/prefs/pref_service.h"
 #include "components/safe_browsing/common/safe_browsing_prefs.h"
@@ -16,6 +15,7 @@
 #include "content/public/browser/browser_thread.h"
 #include "google_apis/gaia/gaia_constants.h"
 #include "google_apis/gaia/oauth2_id_token_decoder.h"
+#include "services/identity/public/cpp/accounts_mutator.h"
 #include "services/identity/public/cpp/primary_account_access_token_fetcher.h"
 
 using content::BrowserThread;
@@ -38,7 +38,6 @@
     : profile_(profile),
       identity_manager_(nullptr),
       access_token_fetcher_(nullptr),
-      account_tracker_service_(nullptr),
       is_under_advanced_protection_(false),
       minimum_delay_(kMinimumRefreshDelay) {
   DCHECK_CURRENTLY_ON(BrowserThread::UI);
@@ -51,8 +50,6 @@
 
 void AdvancedProtectionStatusManager::Initialize() {
   identity_manager_ = IdentityManagerFactory::GetForProfile(profile_);
-  account_tracker_service_ =
-      AccountTrackerServiceFactory::GetForProfile(profile_);
   SubscribeToSigninEvents();
 }
 
@@ -88,12 +85,10 @@
 AdvancedProtectionStatusManager::~AdvancedProtectionStatusManager() {}
 
 void AdvancedProtectionStatusManager::SubscribeToSigninEvents() {
-  AccountTrackerServiceFactory::GetForProfile(profile_)->AddObserver(this);
   IdentityManagerFactory::GetForProfile(profile_)->AddObserver(this);
 }
 
 void AdvancedProtectionStatusManager::UnsubscribeFromSigninEvents() {
-  AccountTrackerServiceFactory::GetForProfile(profile_)->RemoveObserver(this);
   IdentityManagerFactory::GetForProfile(profile_)->RemoveObserver(this);
 }
 
@@ -117,7 +112,7 @@
   }
 }
 
-void AdvancedProtectionStatusManager::OnAccountRemoved(
+void AdvancedProtectionStatusManager::OnAccountRemovedWithInfo(
     const AccountInfo& info) {
   if (profile_->IsOffTheRecord())
     return;
@@ -267,8 +262,9 @@
   // This also triggers |OnAccountUpdated()|.
   if (is_under_advanced_protection_ !=
       service_flags.is_under_advanced_protection) {
-    account_tracker_service_->SetIsAdvancedProtectionAccount(
-        GetPrimaryAccountId(), service_flags.is_under_advanced_protection);
+    identity_manager_->GetAccountsMutator()->UpdateAccountInfo(
+        GetPrimaryAccountId(), false,
+        service_flags.is_under_advanced_protection);
   } else if (service_flags.is_under_advanced_protection) {
     OnAdvancedProtectionEnabled();
   } else {
@@ -281,7 +277,6 @@
     const base::TimeDelta& min_delay)
     : profile_(profile),
       identity_manager_(nullptr),
-      account_tracker_service_(nullptr),
       is_under_advanced_protection_(false),
       minimum_delay_(min_delay) {
   if (profile_->IsOffTheRecord())
diff --git a/chrome/browser/safe_browsing/advanced_protection_status_manager.h b/chrome/browser/safe_browsing/advanced_protection_status_manager.h
index e4285a1..abaf42f 100644
--- a/chrome/browser/safe_browsing/advanced_protection_status_manager.h
+++ b/chrome/browser/safe_browsing/advanced_protection_status_manager.h
@@ -7,7 +7,7 @@
 
 #include "base/timer/timer.h"
 #include "components/keyed_service/core/keyed_service.h"
-#include "components/signin/core/browser/account_tracker_service.h"
+#include "components/signin/core/browser/account_info.h"
 #include "services/identity/public/cpp/access_token_info.h"
 #include "services/identity/public/cpp/identity_manager.h"
 
@@ -27,7 +27,6 @@
 // of its original profile.
 class AdvancedProtectionStatusManager
     : public KeyedService,
-      public AccountTrackerService::Observer,
       public identity::IdentityManager::Observer {
  public:
   explicit AdvancedProtectionStatusManager(Profile* profile);
@@ -82,13 +81,11 @@
   // Subscribes from sign-in events.
   void UnsubscribeFromSigninEvents();
 
-  // AccountTrackerService::Observer implementations.
-  void OnAccountUpdated(const AccountInfo& info) override;
-  void OnAccountRemoved(const AccountInfo& info) override;
-
   // IdentityManager::Observer implementations.
   void OnPrimaryAccountSet(const AccountInfo& account_info) override;
   void OnPrimaryAccountCleared(const AccountInfo& account_info) override;
+  void OnAccountUpdated(const AccountInfo& info) override;
+  void OnAccountRemovedWithInfo(const AccountInfo& info) override;
 
   void OnAdvancedProtectionEnabled();