[s13n] Add LegacySeedAccountInfo to IdentityManager

This CL adds LegacySeedAccountInfo to IdentityManager to replace
AccountTrackerService::SeedAccountInfo in production code.

Test: IdentityManagerTest.LegacySeedAccountInfo
Bug: 922473
Change-Id: Ie0107dd36db6e53da851d8b1f19606f2e712f704
Reviewed-on: https://chromium-review.googlesource.com/c/1416792
Commit-Queue: Julie Jeongeun Kim <jkim@igalia.com>
Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#624711}
diff --git a/services/identity/public/cpp/identity_manager.cc b/services/identity/public/cpp/identity_manager.cc
index 775e50e1..af6ed5c 100644
--- a/services/identity/public/cpp/identity_manager.cc
+++ b/services/identity/public/cpp/identity_manager.cc
@@ -263,6 +263,10 @@
   token_service_->LoadCredentials(primary_account_id);
 }
 
+std::string IdentityManager::LegacySeedAccountInfo(const AccountInfo& info) {
+  return account_tracker_service_->SeedAccountInfo(info);
+}
+
 void IdentityManager::AddObserver(Observer* observer) {
   observer_list_.AddObserver(observer);
 }
diff --git a/services/identity/public/cpp/identity_manager.h b/services/identity/public/cpp/identity_manager.h
index 1994f53..e6a06e6 100644
--- a/services/identity/public/cpp/identity_manager.h
+++ b/services/identity/public/cpp/identity_manager.h
@@ -356,6 +356,14 @@
   std::string LegacyPickAccountIdForAccount(const std::string& gaia,
                                             const std::string& email) const;
 
+  // Seeds the account whose account_id is given by
+  // AccountTrackerService::PickAccountIdForAccount() with its corresponding
+  // account information. Returns the same value PickAccountIdForAccount()
+  // when given the same arguments.
+  // NOTE: In normal usage, this method SHOULD NOT be called for getting the
+  // account id. It's only for replacement of production code.
+  std::string LegacySeedAccountInfo(const AccountInfo& info);
+
   // Methods to register or remove observers.
   void AddObserver(Observer* observer);
   void RemoveObserver(Observer* observer);
diff --git a/services/identity/public/cpp/identity_manager_unittest.cc b/services/identity/public/cpp/identity_manager_unittest.cc
index 9702adc..885d763 100644
--- a/services/identity/public/cpp/identity_manager_unittest.cc
+++ b/services/identity/public/cpp/identity_manager_unittest.cc
@@ -1413,6 +1413,29 @@
   run_loop.Run();
 }
 
+TEST_F(IdentityManagerTest, LegacySeedAccountInfo) {
+  ASSERT_FALSE(
+      identity_manager()
+          ->FindAccountInfoForAccountWithRefreshTokenByEmailAddress(kTestEmail2)
+          .has_value());
+  ASSERT_FALSE(
+      identity_manager()
+          ->FindAccountInfoForAccountWithRefreshTokenByGaiaId(kTestGaiaId2)
+          .has_value());
+
+  AccountInfo input_info;
+  input_info.email = kTestEmail2;
+  input_info.gaia = kTestGaiaId2;
+  const std::string account_id =
+      identity_manager()->LegacySeedAccountInfo(input_info);
+
+  AccountInfo account_info = account_tracker()->GetAccountInfo(account_id);
+
+  EXPECT_EQ(account_info.account_id, account_id);
+  EXPECT_EQ(account_info.email, kTestEmail2);
+  EXPECT_EQ(account_info.gaia, kTestGaiaId2);
+}
+
 #if !defined(OS_CHROMEOS)
 TEST_F(
     IdentityManagerTest,