| 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 "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 |
| OLD | NEW |