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

Side by Side Diff: chrome/browser/extensions/api/identity/identity_get_profile_user_info_function.cc

Issue 2663883003: Move impl of identity.GetProfileUserInfo() extension API to its own file (Closed)
Patch Set: nit Created 3 years, 10 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
« no previous file with comments | « chrome/browser/extensions/api/identity/identity_get_profile_user_info_function.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/extensions/api/identity/identity_get_profile_user_info_ function.h"
6
7 #include "chrome/browser/extensions/api/identity/identity_constants.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/signin/signin_manager_factory.h"
10 #include "chrome/common/extensions/api/identity.h"
11 #include "components/signin/core/browser/signin_manager.h"
12 #include "extensions/common/extension.h"
13 #include "extensions/common/permissions/permissions_data.h"
14
15 namespace extensions {
16
17 IdentityGetProfileUserInfoFunction::IdentityGetProfileUserInfoFunction() {
18 }
19
20 IdentityGetProfileUserInfoFunction::~IdentityGetProfileUserInfoFunction() {
21 }
22
23 ExtensionFunction::ResponseAction IdentityGetProfileUserInfoFunction::Run() {
24 if (GetProfile()->IsOffTheRecord()) {
25 return RespondNow(Error(identity_constants::kOffTheRecord));
26 }
27
28 AccountInfo account = SigninManagerFactory::GetForProfile(
29 GetProfile())->GetAuthenticatedAccountInfo();
30 api::identity::ProfileUserInfo profile_user_info;
31 if (extension()->permissions_data()->HasAPIPermission(
32 APIPermission::kIdentityEmail)) {
33 profile_user_info.email = account.email;
34 profile_user_info.id = account.gaia;
35 }
36
37 return RespondNow(OneArgument(profile_user_info.ToValue()));
38 }
39
40 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/identity/identity_get_profile_user_info_function.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698