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

Side by Side Diff: services/identity/identity_manager.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 unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698