OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "services/identity/identity_manager.h" |
| 6 |
| 7 #include "components/signin/core/account_id/account_id.h" |
| 8 #include "components/signin/core/browser/account_info.h" |
| 9 #include "components/signin/core/browser/signin_manager_base.h" |
| 10 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 11 |
| 12 namespace identity { |
| 13 |
| 14 // static |
| 15 void IdentityManager::Create(mojom::IdentityManagerRequest request, |
| 16 SigninManagerBase* signin_manager) { |
| 17 mojo::MakeStrongBinding(base::MakeUnique<IdentityManager>(signin_manager), |
| 18 std::move(request)); |
| 19 } |
| 20 |
| 21 IdentityManager::IdentityManager(SigninManagerBase* signin_manager) |
| 22 : signin_manager_(signin_manager) {} |
| 23 |
| 24 IdentityManager::~IdentityManager() {} |
| 25 |
| 26 void IdentityManager::GetPrimaryAccountId( |
| 27 const GetPrimaryAccountIdCallback& callback) { |
| 28 AccountId account_id = EmptyAccountId(); |
| 29 |
| 30 if (signin_manager_->IsAuthenticated()) { |
| 31 AccountInfo account_info = signin_manager_->GetAuthenticatedAccountInfo(); |
| 32 account_id = |
| 33 AccountId::FromUserEmailGaiaId(account_info.email, account_info.gaia); |
| 34 } |
| 35 |
| 36 callback.Run(account_id); |
| 37 } |
| 38 |
| 39 } // namespace identity |
OLD | NEW |