Fix FindExtendedAccountInfoForAccount

The method should return an AccountInfo even if some of the information
is missing (i.e. has not been fetched by AccountFetcherService yet) as
the tests usually do not set extended information on AccountInfo.

Bug: 926204
Change-Id: Iba9fafa25914618eefd09310cf91739159373895
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1503456
Reviewed-by: David Roger <droger@chromium.org>
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Auto-Submit: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638572}
diff --git a/services/identity/public/cpp/identity_manager.cc b/services/identity/public/cpp/identity_manager.cc
index 7403d91..f6a76448c 100644
--- a/services/identity/public/cpp/identity_manager.cc
+++ b/services/identity/public/cpp/identity_manager.cc
@@ -149,11 +149,6 @@
   if (!HasAccountWithRefreshToken(extended_account_info.account_id))
     return base::nullopt;
 
-  // If the extended information is not available, AccountInfo::IsValid() will
-  // return false. If this is the case, return base::nullopt.
-  if (!extended_account_info.IsValid())
-    return base::nullopt;
-
   return GetAccountInfoForAccountWithRefreshToken(account_info.account_id);
 }
 
diff --git a/services/identity/public/cpp/identity_manager_unittest.cc b/services/identity/public/cpp/identity_manager_unittest.cc
index 71616843..c74f6b67 100644
--- a/services/identity/public/cpp/identity_manager_unittest.cc
+++ b/services/identity/public/cpp/identity_manager_unittest.cc
@@ -2473,27 +2473,8 @@
   SetRefreshTokenForAccount(identity_manager(), account_info.account_id,
                             "refresh-token");
 
-  // FindExtendedAccountInfoForAccount() returns empty optional if the account
-  // has not extended information.
-  EXPECT_FALSE(identity_manager()
-                   ->FindExtendedAccountInfoForAccount(account_info)
-                   .has_value());
-
-  // Populate the extended information of the account.
-  base::DictionaryValue user_info;
-  user_info.SetString("id", account_info.gaia);
-  user_info.SetString("email", account_info.email);
-  user_info.SetString("hd", "hosted_domain");
-  user_info.SetString("name", "full_name");
-  user_info.SetString("given_name", "given_name");
-  user_info.SetString("locale", "locale");
-  user_info.SetString("picture", "picture_url");
-  account_tracker()->SetAccountInfoFromUserInfo(account_info.account_id,
-                                                &user_info);
-
   // FindExtendedAccountInfoForAccount() returns extended account information if
-  // the account is know, has valid refresh token and has extended account
-  // information.
+  // the account is known and has valid refresh token.
   const base::Optional<AccountInfo> extended_account_info =
       identity_manager()->FindExtendedAccountInfoForAccount(account_info);