Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Unified Diff: chrome/browser/extensions/api/identity/identity_get_profile_user_info_function.cc

Issue 2753753007: Introduce Identity Service and its initial usage (Closed)
Patch Set: Self-review Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/identity/identity_get_profile_user_info_function.cc
diff --git a/chrome/browser/extensions/api/identity/identity_get_profile_user_info_function.cc b/chrome/browser/extensions/api/identity/identity_get_profile_user_info_function.cc
index 0940586623b4d09a5a3d803c6aa7f49d128616ac..2a7c6cd9db0b6b8050a7304df66289a4f72d580d 100644
--- a/chrome/browser/extensions/api/identity/identity_get_profile_user_info_function.cc
+++ b/chrome/browser/extensions/api/identity/identity_get_profile_user_info_function.cc
@@ -6,11 +6,12 @@
#include "chrome/browser/extensions/api/identity/identity_constants.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/common/extensions/api/identity.h"
-#include "components/signin/core/browser/signin_manager.h"
+#include "content/public/common/service_manager_connection.h"
#include "extensions/common/extension.h"
#include "extensions/common/permissions/permissions_data.h"
+#include "services/identity/public/interfaces/constants.mojom.h"
+#include "services/service_manager/public/cpp/connector.h"
namespace extensions {
@@ -25,16 +26,28 @@ ExtensionFunction::ResponseAction IdentityGetProfileUserInfoFunction::Run() {
return RespondNow(Error(identity_constants::kOffTheRecord));
}
- AccountInfo account = SigninManagerFactory::GetForProfile(
- GetProfile())->GetAuthenticatedAccountInfo();
+ if (!identity_manager_.is_bound()) {
Ken Rockot(use gerrit already) 2017/03/21 14:53:09 It's been a while, but IIRC this test is redundant
blundell 2017/03/21 16:08:47 +1000, I'd love to use this effort as a demonstrat
blundell 2017/03/24 09:37:59 Done.
+ content::BrowserContext::GetConnectorFor(GetProfile())
+ ->BindInterface(identity::mojom::kServiceName,
+ mojo::MakeRequest(&identity_manager_));
+ }
+
+ identity_manager_->GetPrimaryAccountId(base::Bind(
+ &IdentityGetProfileUserInfoFunction::OnReceivedPrimaryAccountId, this));
+
+ return RespondLater();
+}
+
+void IdentityGetProfileUserInfoFunction::OnReceivedPrimaryAccountId(
+ const base::Optional<AccountId>& account_id) {
api::identity::ProfileUserInfo profile_user_info;
- if (extension()->permissions_data()->HasAPIPermission(
- APIPermission::kIdentityEmail)) {
- profile_user_info.email = account.email;
- profile_user_info.id = account.gaia;
+ if (account_id && extension()->permissions_data()->HasAPIPermission(
msarda 2017/03/23 10:48:57 I think there is no point in making a call to get
blundell 2017/03/24 09:37:59 Done.
+ APIPermission::kIdentityEmail)) {
+ profile_user_info.email = account_id->GetUserEmail();
+ profile_user_info.id = account_id->GetGaiaId();
}
- return RespondNow(OneArgument(profile_user_info.ToValue()));
+ Respond(OneArgument(profile_user_info.ToValue()));
}
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698