| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/extensions/users_private/users_private_api.h" | 5 #include "chrome/browser/chromeos/extensions/users_private/users_private_api.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 } | 91 } |
| 92 | 92 |
| 93 if (chromeos::OwnerSettingsServiceChromeOS* service = | 93 if (chromeos::OwnerSettingsServiceChromeOS* service = |
| 94 chromeos::OwnerSettingsServiceChromeOSFactory::GetForBrowserContext( | 94 chromeos::OwnerSettingsServiceChromeOSFactory::GetForBrowserContext( |
| 95 profile)) { | 95 profile)) { |
| 96 service->Set(chromeos::kAccountsPrefUsers, *email_list.get()); | 96 service->Set(chromeos::kAccountsPrefUsers, *email_list.get()); |
| 97 } | 97 } |
| 98 | 98 |
| 99 // Now populate the list of User objects for returning to the JS. | 99 // Now populate the list of User objects for returning to the JS. |
| 100 for (size_t i = 0; i < email_list->GetSize(); ++i) { | 100 for (size_t i = 0; i < email_list->GetSize(); ++i) { |
| 101 api::users_private::User user; | 101 std::string email; |
| 102 email_list->GetString(i, &user.email); | 102 email_list->GetString(i, &email); |
| 103 AccountId account_id = AccountId::FromUserEmail(user.email); | 103 AccountId account_id = AccountId::FromUserEmail(email); |
| 104 user.name = base::UTF16ToUTF8(user_manager->GetUserDisplayName(account_id)); | 104 const user_manager::User* user = user_manager->FindUser(account_id); |
| 105 if (user.name.empty()) { | 105 api::users_private::User api_user; |
| 106 // User is not associated with a gaia account. | 106 if (user) { |
| 107 user.name = user_manager->GetUserDisplayEmail(account_id); | 107 api_user.email = user->GetDisplayEmail(); |
| 108 api_user.name = base::UTF16ToUTF8(user->GetDisplayName()); |
| 109 api_user.is_owner = |
| 110 user->GetAccountId() == user_manager->GetOwnerAccountId(); |
| 111 api_user.is_supervised = user->IsSupervised(); |
| 112 } else { |
| 113 // User is unknown (i.e. not on device). |
| 114 api_user.email = email; |
| 115 api_user.name = email; |
| 116 api_user.is_owner = false; |
| 117 api_user.is_supervised = false; |
| 108 } | 118 } |
| 109 user.is_owner = chromeos::ProfileHelper::IsOwnerProfile(profile) && | 119 user_list->Append(api_user.ToValue()); |
| 110 user.email == profile->GetProfileUserName(); | |
| 111 user_list->Append(user.ToValue()); | |
| 112 } | 120 } |
| 113 | 121 |
| 114 return RespondNow(OneArgument(std::move(user_list))); | 122 return RespondNow(OneArgument(std::move(user_list))); |
| 115 } | 123 } |
| 116 | 124 |
| 117 //////////////////////////////////////////////////////////////////////////////// | 125 //////////////////////////////////////////////////////////////////////////////// |
| 118 // UsersPrivateAddWhitelistedUserFunction | 126 // UsersPrivateAddWhitelistedUserFunction |
| 119 | 127 |
| 120 UsersPrivateAddWhitelistedUserFunction::UsersPrivateAddWhitelistedUserFunction() | 128 UsersPrivateAddWhitelistedUserFunction::UsersPrivateAddWhitelistedUserFunction() |
| 121 : chrome_details_(this) { | 129 : chrome_details_(this) { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 | 227 |
| 220 ExtensionFunction::ResponseAction | 228 ExtensionFunction::ResponseAction |
| 221 UsersPrivateIsWhitelistManagedFunction::Run() { | 229 UsersPrivateIsWhitelistManagedFunction::Run() { |
| 222 bool is_managed = g_browser_process->platform_part() | 230 bool is_managed = g_browser_process->platform_part() |
| 223 ->browser_policy_connector_chromeos() | 231 ->browser_policy_connector_chromeos() |
| 224 ->IsEnterpriseManaged(); | 232 ->IsEnterpriseManaged(); |
| 225 return RespondNow(OneArgument(base::MakeUnique<base::Value>(is_managed))); | 233 return RespondNow(OneArgument(base::MakeUnique<base::Value>(is_managed))); |
| 226 } | 234 } |
| 227 | 235 |
| 228 } // namespace extensions | 236 } // namespace extensions |
| OLD | NEW |