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

Unified Diff: services/identity/identity_manager.cc

Issue 2753753007: Introduce Identity Service and its initial usage (Closed)
Patch Set: Response to reviews 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
« no previous file with comments | « services/identity/identity_manager.h ('k') | services/identity/identity_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « services/identity/identity_manager.h ('k') | services/identity/identity_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698