[GCM] Use PO2TS directly rather than via ProfileIdentityProvider

To complete the elimination of usage of
ProfileIdentityProvider in //components/gcm_driver, this CL replaces
usage of ProfileIdentityProvider in (GCM)AccountTracker to obtain the
Oauth2TokenService with direct usage of the ProfileOAuth2TokenService
instance that is backing the ProfileIdentityProvider instance. This CL
is a step on the road to eventually using IdentityManager in
//components/gcm_driver.

The CL is completely straightforward.

Full design doc here:
https://docs.google.com/document/d/1OmNrIiMDkF7eOYVB4RIiDvY7pQz3zUrOf-D4TVwdRQA/edit?ts=5aa6b936#

TBR=rockot@chromium.org, zea@chromium.org

Bug: 809923
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I4a8c443851b0d4bc660656f528d0cd5a32a62bc6
Reviewed-on: https://chromium-review.googlesource.com/1046969
Commit-Queue: Colin Blundell <blundell@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560535}
diff --git a/chrome/browser/extensions/extension_gcm_app_handler_unittest.cc b/chrome/browser/extensions/extension_gcm_app_handler_unittest.cc
index 142e791..696ff1b 100644
--- a/chrome/browser/extensions/extension_gcm_app_handler_unittest.cc
+++ b/chrome/browser/extensions/extension_gcm_app_handler_unittest.cc
@@ -35,7 +35,6 @@
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
 #include "chrome/browser/signin/signin_manager_factory.h"
-#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
 #include "chrome/common/channel_info.h"
 #include "chrome/common/chrome_paths.h"
 #include "chrome/test/base/testing_profile.h"
@@ -213,11 +212,7 @@
         chrome::GetChannel(),
         gcm::GetProductCategoryForSubtypes(profile->GetPrefs()),
         SigninManagerFactory::GetForProfile(profile),
-        std::unique_ptr<ProfileIdentityProvider>(new ProfileIdentityProvider(
-            SigninManagerFactory::GetForProfile(profile),
-            ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
-            LoginUIServiceFactory::GetShowLoginPopupCallbackForProfile(
-                profile))),
+        ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
         base::WrapUnique(new gcm::FakeGCMClientFactory(ui_thread, io_thread)),
         ui_thread, io_thread, blocking_task_runner);
   }
diff --git a/chrome/browser/gcm/gcm_profile_service_factory.cc b/chrome/browser/gcm/gcm_profile_service_factory.cc
index 3834f7c..4cddd295 100644
--- a/chrome/browser/gcm/gcm_profile_service_factory.cc
+++ b/chrome/browser/gcm/gcm_profile_service_factory.cc
@@ -15,13 +15,11 @@
 #include "components/gcm_driver/gcm_profile_service.h"
 #include "components/keyed_service/content/browser_context_dependency_manager.h"
 #include "components/offline_pages/buildflags/buildflags.h"
-#include "components/signin/core/browser/profile_identity_provider.h"
 #include "components/signin/core/browser/signin_manager.h"
 #include "content/public/browser/browser_thread.h"
 
 #if !defined(OS_ANDROID)
 #include "chrome/browser/gcm/gcm_product_util.h"
-#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
 #include "chrome/common/channel_info.h"
 #include "components/gcm_driver/gcm_client_factory.h"
 #endif
@@ -58,9 +56,6 @@
         BrowserContextDependencyManager::GetInstance()) {
   DependsOn(SigninManagerFactory::GetInstance());
   DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
-#if !defined(OS_ANDROID)
-  DependsOn(LoginUIServiceFactory::GetInstance());
-#endif
 #if BUILDFLAG(ENABLE_OFFLINE_PAGES)
   DependsOn(offline_pages::PrefetchServiceFactory::GetInstance());
 #endif  // BUILDFLAG(ENABLE_OFFLINE_PAGES)
@@ -88,10 +83,7 @@
       chrome::GetChannel(),
       gcm::GetProductCategoryForSubtypes(profile->GetPrefs()),
       SigninManagerFactory::GetForProfile(profile),
-      std::unique_ptr<ProfileIdentityProvider>(new ProfileIdentityProvider(
-          SigninManagerFactory::GetForProfile(profile),
-          ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
-          LoginUIServiceFactory::GetShowLoginPopupCallbackForProfile(profile))),
+      ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
       std::unique_ptr<GCMClientFactory>(new GCMClientFactory),
       content::BrowserThread::GetTaskRunnerForThread(
           content::BrowserThread::UI),
diff --git a/chrome/browser/gcm/gcm_profile_service_unittest.cc b/chrome/browser/gcm/gcm_profile_service_unittest.cc
index 8a39cf87..0715006 100644
--- a/chrome/browser/gcm/gcm_profile_service_unittest.cc
+++ b/chrome/browser/gcm/gcm_profile_service_unittest.cc
@@ -17,7 +17,6 @@
 #include "chrome/browser/gcm/gcm_profile_service_factory.h"
 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
 #include "chrome/browser/signin/signin_manager_factory.h"
-#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
 #include "chrome/common/channel_info.h"
 #include "chrome/test/base/testing_profile.h"
 #include "components/gcm_driver/gcm_profile_service.h"
@@ -55,10 +54,7 @@
       chrome::GetChannel(),
       gcm::GetProductCategoryForSubtypes(profile->GetPrefs()),
       SigninManagerFactory::GetForProfile(profile),
-      std::unique_ptr<ProfileIdentityProvider>(new ProfileIdentityProvider(
-          SigninManagerFactory::GetForProfile(profile),
-          ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
-          LoginUIServiceFactory::GetShowLoginPopupCallbackForProfile(profile))),
+      ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
       std::unique_ptr<gcm::GCMClientFactory>(new gcm::FakeGCMClientFactory(
           content::BrowserThread::GetTaskRunnerForThread(
               content::BrowserThread::UI),
diff --git a/components/gcm_driver/account_tracker.cc b/components/gcm_driver/account_tracker.cc
index f2e6dca..1649c51 100644
--- a/components/gcm_driver/account_tracker.cc
+++ b/components/gcm_driver/account_tracker.cc
@@ -8,20 +8,21 @@
 #include "base/memory/ptr_util.h"
 #include "base/stl_util.h"
 #include "base/trace_event/trace_event.h"
+#include "components/signin/core/browser/profile_oauth2_token_service.h"
 #include "net/url_request/url_request_context_getter.h"
 
 namespace gcm {
 
 AccountTracker::AccountTracker(
     SigninManagerBase* signin_manager,
-    IdentityProvider* identity_provider,
+    ProfileOAuth2TokenService* token_service,
     net::URLRequestContextGetter* request_context_getter)
     : signin_manager_(signin_manager),
-      identity_provider_(identity_provider),
+      token_service_(token_service),
       request_context_getter_(request_context_getter),
       shutdown_called_(false) {
   signin_manager_->AddObserver(this);
-  identity_provider_->GetTokenService()->AddObserver(this);
+  token_service_->AddObserver(this);
 }
 
 AccountTracker::~AccountTracker() {
@@ -31,7 +32,7 @@
 void AccountTracker::Shutdown() {
   shutdown_called_ = true;
   user_info_requests_.clear();
-  identity_provider_->GetTokenService()->RemoveObserver(this);
+  token_service_->RemoveObserver(this);
   signin_manager_->RemoveObserver(this);
 }
 
@@ -95,8 +96,7 @@
                                            const std::string& username) {
   TRACE_EVENT0("identity", "AccountTracker::GoogleSigninSucceeded");
 
-  std::vector<std::string> accounts =
-      identity_provider_->GetTokenService()->GetAccounts();
+  std::vector<std::string> accounts = token_service_->GetAccounts();
 
   DVLOG(1) << "LOGIN " << accounts.size() << " accounts available.";
 
@@ -186,9 +186,8 @@
   }
 
   DVLOG(1) << "StartFetching " << account_key;
-  AccountIdFetcher* fetcher =
-      new AccountIdFetcher(identity_provider_->GetTokenService(),
-                           request_context_getter_.get(), this, account_key);
+  AccountIdFetcher* fetcher = new AccountIdFetcher(
+      token_service_, request_context_getter_.get(), this, account_key);
   user_info_requests_[account_key] = base::WrapUnique(fetcher);
   fetcher->Start();
 }
diff --git a/components/gcm_driver/account_tracker.h b/components/gcm_driver/account_tracker.h
index a80de25..23ed00b 100644
--- a/components/gcm_driver/account_tracker.h
+++ b/components/gcm_driver/account_tracker.h
@@ -13,10 +13,10 @@
 #include "base/observer_list.h"
 #include "components/signin/core/browser/signin_manager.h"
 #include "google_apis/gaia/gaia_oauth_client.h"
-#include "google_apis/gaia/identity_provider.h"
 #include "google_apis/gaia/oauth2_token_service.h"
 
 class GoogleServiceAuthError;
+class ProfileOAuth2TokenService;
 
 namespace net {
 class URLRequestContextGetter;
@@ -45,7 +45,7 @@
                        public SigninManagerBase::Observer {
  public:
   AccountTracker(SigninManagerBase* signin_manager,
-                 IdentityProvider* identity_provider,
+                 ProfileOAuth2TokenService* token_service,
                  net::URLRequestContextGetter* request_context_getter);
   ~AccountTracker() override;
 
@@ -82,8 +82,6 @@
   // Sets the state of an account. Does not fire notifications.
   void SetAccountStateForTest(AccountIds ids, bool is_signed_in);
 
-  IdentityProvider* identity_provider() { return identity_provider_; }
-
   // Indicates if all user information has been fetched. If the result is false,
   // there are still unfinished fetchers.
   virtual bool IsAllUserInfoFetched() const;
@@ -110,7 +108,7 @@
   void DeleteFetcher(AccountIdFetcher* fetcher);
 
   SigninManagerBase* signin_manager_;
-  IdentityProvider* identity_provider_;
+  ProfileOAuth2TokenService* token_service_;
   scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
   std::map<std::string, std::unique_ptr<AccountIdFetcher>> user_info_requests_;
   std::map<std::string, AccountState> accounts_;
diff --git a/components/gcm_driver/account_tracker_unittest.cc b/components/gcm_driver/account_tracker_unittest.cc
index dc1f994..2740805d 100644
--- a/components/gcm_driver/account_tracker_unittest.cc
+++ b/components/gcm_driver/account_tracker_unittest.cc
@@ -15,7 +15,6 @@
 #include "components/signin/core/browser/fake_signin_manager.h"
 #include "components/signin/core/browser/test_signin_client.h"
 #include "components/sync_preferences/testing_pref_service_syncable.h"
-#include "google_apis/gaia/fake_identity_provider.h"
 #include "google_apis/gaia/fake_oauth2_token_service.h"
 #include "google_apis/gaia/gaia_oauth_client.h"
 #include "net/http/http_status_code.h"
@@ -270,11 +269,8 @@
     SigninManagerBase::RegisterPrefs(pref_service_.registry());
     account_tracker_service_.Initialize(test_signin_client_.get());
 
-    fake_identity_provider_.reset(
-        new FakeIdentityProvider(fake_oauth2_token_service_.get()));
-
     account_tracker_.reset(new AccountTracker(
-        fake_signin_manager_.get(), fake_identity_provider_.get(),
+        fake_signin_manager_.get(), fake_oauth2_token_service_.get(),
         new net::TestURLRequestContextGetter(message_loop_.task_runner())));
     account_tracker_->AddObserver(&observer_);
   }
@@ -358,16 +354,7 @@
     observer()->Clear();
   }
 
-  std::string active_account_id() {
-    return identity_provider()->GetActiveAccountId();
-  }
-
  private:
-  FakeIdentityProvider* identity_provider() {
-    return static_cast<FakeIdentityProvider*>(
-        account_tracker_->identity_provider());
-  }
-
   base::MessageLoopForIO message_loop_;  // net:: stuff needs IO message loop.
   net::TestURLFetcherFactory test_fetcher_factory_;
   sync_preferences::TestingPrefServiceSyncable pref_service_;
@@ -375,7 +362,6 @@
   std::unique_ptr<TestSigninClient> test_signin_client_;
   std::unique_ptr<SigninManagerForTest> fake_signin_manager_;
   std::unique_ptr<FakeProfileOAuth2TokenService> fake_oauth2_token_service_;
-  std::unique_ptr<FakeIdentityProvider> fake_identity_provider_;
 
   std::unique_ptr<AccountTracker> account_tracker_;
   AccountTrackerObserver observer_;
diff --git a/components/gcm_driver/gcm_account_tracker.cc b/components/gcm_driver/gcm_account_tracker.cc
index 58e9426..ca9bb46 100644
--- a/components/gcm_driver/gcm_account_tracker.cc
+++ b/components/gcm_driver/gcm_account_tracker.cc
@@ -15,6 +15,7 @@
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/time/time.h"
 #include "components/gcm_driver/gcm_driver.h"
+#include "components/signin/core/browser/profile_oauth2_token_service.h"
 #include "google_apis/gaia/google_service_auth_error.h"
 #include "net/base/ip_endpoint.h"
 
@@ -46,9 +47,11 @@
 
 GCMAccountTracker::GCMAccountTracker(
     std::unique_ptr<AccountTracker> account_tracker,
+    ProfileOAuth2TokenService* token_service,
     GCMDriver* driver)
     : OAuth2TokenService::Consumer(kGCMAccountTrackerName),
       account_tracker_(account_tracker.release()),
+      token_service_(token_service),
       driver_(driver),
       shutdown_called_(false),
       reporting_weak_ptr_factory_(this) {}
@@ -323,14 +326,13 @@
 }
 
 void GCMAccountTracker::GetToken(AccountInfos::iterator& account_iter) {
-  DCHECK(GetTokenService());
   DCHECK_EQ(account_iter->second.state, TOKEN_NEEDED);
 
   OAuth2TokenService::ScopeSet scopes;
   scopes.insert(kGCMGroupServerScope);
   scopes.insert(kGCMCheckinServerScope);
   std::unique_ptr<OAuth2TokenService::Request> request =
-      GetTokenService()->StartRequest(account_iter->first, scopes, this);
+      token_service_->StartRequest(account_iter->first, scopes, this);
 
   pending_token_requests_.push_back(std::move(request));
   account_iter->second.state = GETTING_TOKEN;
@@ -361,9 +363,4 @@
   ReportTokens();
 }
 
-OAuth2TokenService* GCMAccountTracker::GetTokenService() {
-  DCHECK(account_tracker_->identity_provider());
-  return account_tracker_->identity_provider()->GetTokenService();
-}
-
 }  // namespace gcm
diff --git a/components/gcm_driver/gcm_account_tracker.h b/components/gcm_driver/gcm_account_tracker.h
index d4ae1f7..1e78da7 100644
--- a/components/gcm_driver/gcm_account_tracker.h
+++ b/components/gcm_driver/gcm_account_tracker.h
@@ -18,6 +18,8 @@
 #include "components/gcm_driver/gcm_connection_observer.h"
 #include "google_apis/gaia/oauth2_token_service.h"
 
+class ProfileOAuth2TokenService;
+
 namespace base {
 class Time;
 }
@@ -72,6 +74,7 @@
   // |account_tracker| is used to deliver information about the accounts present
   // in the browser context to |driver|.
   GCMAccountTracker(std::unique_ptr<AccountTracker> account_tracker,
+                    ProfileOAuth2TokenService* token_service,
                     GCMDriver* driver);
   ~GCMAccountTracker() override;
 
@@ -144,7 +147,8 @@
   // Account tracker.
   std::unique_ptr<AccountTracker> account_tracker_;
 
-  // GCM Driver. Not owned.
+  ProfileOAuth2TokenService* token_service_;
+
   GCMDriver* driver_;
 
   // State of the account.
diff --git a/components/gcm_driver/gcm_account_tracker_unittest.cc b/components/gcm_driver/gcm_account_tracker_unittest.cc
index a544eb3b..ba35363 100644
--- a/components/gcm_driver/gcm_account_tracker_unittest.cc
+++ b/components/gcm_driver/gcm_account_tracker_unittest.cc
@@ -17,7 +17,6 @@
 #include "components/signin/core/browser/fake_signin_manager.h"
 #include "components/signin/core/browser/test_signin_client.h"
 #include "components/sync_preferences/testing_pref_service_syncable.h"
-#include "google_apis/gaia/fake_identity_provider.h"
 #include "google_apis/gaia/fake_oauth2_token_service.h"
 #include "google_apis/gaia/google_service_auth_error.h"
 #include "net/http/http_status_code.h"
@@ -206,16 +205,12 @@
   std::unique_ptr<TestSigninClient> test_signin_client_;
   std::unique_ptr<SigninManagerForTest> fake_signin_manager_;
   std::unique_ptr<FakeProfileOAuth2TokenService> fake_token_service_;
-  std::unique_ptr<FakeIdentityProvider> fake_identity_provider_;
   std::unique_ptr<GCMAccountTracker> tracker_;
 };
 
 GCMAccountTrackerTest::GCMAccountTrackerTest() {
   fake_token_service_.reset(new FakeProfileOAuth2TokenService());
 
-  fake_identity_provider_.reset(
-      new FakeIdentityProvider(fake_token_service_.get()));
-
   test_signin_client_.reset(new TestSigninClient(&pref_service_));
 #if defined(OS_CHROMEOS)
   fake_signin_manager_.reset(new SigninManagerForTest(
@@ -232,11 +227,11 @@
   account_tracker_service_.Initialize(test_signin_client_.get());
 
   std::unique_ptr<AccountTracker> gaia_account_tracker(new AccountTracker(
-      fake_signin_manager_.get(), fake_identity_provider_.get(),
+      fake_signin_manager_.get(), fake_token_service_.get(),
       new net::TestURLRequestContextGetter(message_loop_.task_runner())));
 
-  tracker_.reset(
-      new GCMAccountTracker(std::move(gaia_account_tracker), &driver_));
+  tracker_.reset(new GCMAccountTracker(std::move(gaia_account_tracker),
+                                       fake_token_service_.get(), &driver_));
 }
 
 GCMAccountTrackerTest::~GCMAccountTrackerTest() {
diff --git a/components/gcm_driver/gcm_profile_service.cc b/components/gcm_driver/gcm_profile_service.cc
index 1b65c51..b4503bb 100644
--- a/components/gcm_driver/gcm_profile_service.cc
+++ b/components/gcm_driver/gcm_profile_service.cc
@@ -28,7 +28,6 @@
 #include "components/gcm_driver/gcm_client_factory.h"
 #include "components/gcm_driver/gcm_desktop_utils.h"
 #include "components/gcm_driver/gcm_driver_desktop.h"
-#include "google_apis/gaia/identity_provider.h"
 #include "net/url_request/url_request_context_getter.h"
 #endif
 
@@ -40,7 +39,7 @@
 class GCMProfileService::IdentityObserver : public SigninManagerBase::Observer {
  public:
   IdentityObserver(SigninManagerBase* signin_manager,
-                   ProfileIdentityProvider* identity_provider,
+                   ProfileOAuth2TokenService* token_service,
                    net::URLRequestContextGetter* request_context,
                    GCMDriver* driver);
   ~IdentityObserver() override;
@@ -56,7 +55,7 @@
 
   GCMDriver* driver_;
   SigninManagerBase* signin_manager_;
-  IdentityProvider* identity_provider_;
+  ProfileOAuth2TokenService* token_service_;
   std::unique_ptr<GCMAccountTracker> gcm_account_tracker_;
 
   // The account ID that this service is responsible for. Empty when the service
@@ -70,12 +69,12 @@
 
 GCMProfileService::IdentityObserver::IdentityObserver(
     SigninManagerBase* signin_manager,
-    ProfileIdentityProvider* identity_provider,
+    ProfileOAuth2TokenService* token_service,
     net::URLRequestContextGetter* request_context,
     GCMDriver* driver)
     : driver_(driver),
       signin_manager_(signin_manager),
-      identity_provider_(identity_provider),
+      token_service_(token_service),
       weak_ptr_factory_(this) {
   signin_manager_->AddObserver(this);
 
@@ -117,10 +116,10 @@
     return;
 
   std::unique_ptr<AccountTracker> gaia_account_tracker(
-      new AccountTracker(signin_manager_, identity_provider_, request_context));
+      new AccountTracker(signin_manager_, token_service_, request_context));
 
-  gcm_account_tracker_.reset(
-      new GCMAccountTracker(std::move(gaia_account_tracker), driver_));
+  gcm_account_tracker_.reset(new GCMAccountTracker(
+      std::move(gaia_account_tracker), token_service_, driver_));
 
   gcm_account_tracker_->Start();
 }
@@ -151,13 +150,13 @@
     version_info::Channel channel,
     const std::string& product_category_for_subtypes,
     SigninManagerBase* signin_manager,
-    std::unique_ptr<ProfileIdentityProvider> identity_provider,
+    ProfileOAuth2TokenService* token_service,
     std::unique_ptr<GCMClientFactory> gcm_client_factory,
     const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner,
     const scoped_refptr<base::SequencedTaskRunner>& io_task_runner,
     scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner)
-    : profile_identity_provider_(std::move(identity_provider)),
-      signin_manager_(signin_manager),
+    : signin_manager_(signin_manager),
+      token_service_(token_service),
       request_context_(request_context) {
   driver_ = CreateGCMDriverDesktop(
       std::move(gcm_client_factory), prefs,
@@ -165,9 +164,8 @@
       product_category_for_subtypes, ui_task_runner, io_task_runner,
       blocking_task_runner);
 
-  identity_observer_.reset(
-      new IdentityObserver(signin_manager_, profile_identity_provider_.get(),
-                           request_context_, driver_.get()));
+  identity_observer_.reset(new IdentityObserver(
+      signin_manager_, token_service_, request_context_, driver_.get()));
 }
 #endif  // BUILDFLAG(USE_GCM_FROM_PLATFORM)
 
@@ -191,8 +189,7 @@
 #if !BUILDFLAG(USE_GCM_FROM_PLATFORM)
   if (identity_observer_) {
     identity_observer_ = std::make_unique<IdentityObserver>(
-        signin_manager_, profile_identity_provider_.get(), request_context_,
-        driver.get());
+        signin_manager_, token_service_, request_context_, driver.get());
   }
 #endif  // !BUILDFLAG(USE_GCM_FROM_PLATFORM)
 }
diff --git a/components/gcm_driver/gcm_profile_service.h b/components/gcm_driver/gcm_profile_service.h
index 13275d6..8913f671 100644
--- a/components/gcm_driver/gcm_profile_service.h
+++ b/components/gcm_driver/gcm_profile_service.h
@@ -16,7 +16,7 @@
 #include "build/build_config.h"
 #include "components/gcm_driver/gcm_buildflags.h"
 #include "components/keyed_service/core/keyed_service.h"
-#include "components/signin/core/browser/profile_identity_provider.h"
+#include "components/signin/core/browser/profile_oauth2_token_service.h"
 #include "components/signin/core/browser/signin_manager.h"
 #include "components/version_info/version_info.h"
 
@@ -50,7 +50,7 @@
       version_info::Channel channel,
       const std::string& product_category_for_subtypes,
       SigninManagerBase* signin_manager,
-      std::unique_ptr<ProfileIdentityProvider> identity_provider,
+      ProfileOAuth2TokenService* token_service,
       std::unique_ptr<GCMClientFactory> gcm_client_factory,
       const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner,
       const scoped_refptr<base::SequencedTaskRunner>& io_task_runner,
@@ -74,11 +74,12 @@
   GCMProfileService();
 
  private:
-  std::unique_ptr<ProfileIdentityProvider> profile_identity_provider_;
   std::unique_ptr<GCMDriver> driver_;
 
 #if !BUILDFLAG(USE_GCM_FROM_PLATFORM)
   SigninManagerBase* signin_manager_;
+  ProfileOAuth2TokenService* token_service_;
+
   net::URLRequestContextGetter* request_context_ = nullptr;
 
   // Used for both account tracker and GCM.UserSignedIn UMA.
diff --git a/ios/chrome/browser/services/gcm/ios_chrome_gcm_profile_service_factory.cc b/ios/chrome/browser/services/gcm/ios_chrome_gcm_profile_service_factory.cc
index 6a9939f..13f3a24 100644
--- a/ios/chrome/browser/services/gcm/ios_chrome_gcm_profile_service_factory.cc
+++ b/ios/chrome/browser/services/gcm/ios_chrome_gcm_profile_service_factory.cc
@@ -12,7 +12,6 @@
 #include "components/gcm_driver/gcm_client_factory.h"
 #include "components/gcm_driver/gcm_profile_service.h"
 #include "components/keyed_service/ios/browser_state_dependency_manager.h"
-#include "components/signin/core/browser/profile_identity_provider.h"
 #include "components/signin/core/browser/signin_manager.h"
 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
 #include "ios/chrome/browser/signin/oauth2_token_service_factory.h"
@@ -68,10 +67,7 @@
       browser_state->GetRequestContext(), ::GetChannel(),
       GetProductCategoryForSubtypes(),
       ios::SigninManagerFactory::GetForBrowserState(browser_state),
-      base::WrapUnique(new ProfileIdentityProvider(
-          ios::SigninManagerFactory::GetForBrowserState(browser_state),
-          OAuth2TokenServiceFactory::GetForBrowserState(browser_state),
-          base::Closure())),
+      OAuth2TokenServiceFactory::GetForBrowserState(browser_state),
       base::WrapUnique(new gcm::GCMClientFactory),
       web::WebThread::GetTaskRunnerForThread(web::WebThread::UI),
       web::WebThread::GetTaskRunnerForThread(web::WebThread::IO),