Index: services/identity/identity_manager.cc |
diff --git a/services/identity/identity_manager.cc b/services/identity/identity_manager.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8ea9d7250cfebd9e4b73f159a15f07bff6f70bc9 |
--- /dev/null |
+++ b/services/identity/identity_manager.cc |
@@ -0,0 +1,39 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "services/identity/identity_manager.h" |
+ |
+#include "components/signin/core/account_id/account_id.h" |
+#include "components/signin/core/browser/account_info.h" |
+#include "components/signin/core/browser/signin_manager_base.h" |
+#include "mojo/public/cpp/bindings/strong_binding.h" |
+ |
+namespace identity { |
+ |
+// static |
+void IdentityManager::Create(mojom::IdentityManagerRequest request, |
+ SigninManagerBase* signin_manager) { |
+ mojo::MakeStrongBinding(base::MakeUnique<IdentityManager>(signin_manager), |
+ std::move(request)); |
+} |
+ |
+IdentityManager::IdentityManager(SigninManagerBase* signin_manager) |
+ : signin_manager_(signin_manager) {} |
+ |
+IdentityManager::~IdentityManager() {} |
+ |
+void IdentityManager::GetPrimaryAccountId( |
+ const GetPrimaryAccountIdCallback& callback) { |
+ AccountId account_id = EmptyAccountId(); |
+ |
+ if (signin_manager_->IsAuthenticated()) { |
+ AccountInfo account_info = signin_manager_->GetAuthenticatedAccountInfo(); |
+ account_id = |
+ AccountId::FromUserEmailGaiaId(account_info.email, account_info.gaia); |
+ } |
+ |
+ callback.Run(account_id); |
+} |
+ |
+} // namespace identity |