Chromium Code Reviews| 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 |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | |
| 12 #include "base/values.h" | 13 #include "base/values.h" |
| 13 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/chromeos/extensions/users_private/users_private_delegat e.h" | 15 #include "chrome/browser/chromeos/extensions/users_private/users_private_delegat e.h" |
| 15 #include "chrome/browser/chromeos/extensions/users_private/users_private_delegat e_factory.h" | 16 #include "chrome/browser/chromeos/extensions/users_private/users_private_delegat e_factory.h" |
| 16 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" | 17 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" |
| 17 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact ory.h" | 18 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact ory.h" |
| 18 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 19 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 19 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 20 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 20 #include "chrome/browser/chromeos/settings/cros_settings.h" | 21 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 21 #include "chrome/browser/extensions/chrome_extension_function.h" | 22 #include "chrome/browser/extensions/chrome_extension_function.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 if (chromeos::OwnerSettingsServiceChromeOS* service = | 93 if (chromeos::OwnerSettingsServiceChromeOS* service = |
| 93 chromeos::OwnerSettingsServiceChromeOSFactory::GetForBrowserContext( | 94 chromeos::OwnerSettingsServiceChromeOSFactory::GetForBrowserContext( |
| 94 profile)) { | 95 profile)) { |
| 95 service->Set(chromeos::kAccountsPrefUsers, *email_list.get()); | 96 service->Set(chromeos::kAccountsPrefUsers, *email_list.get()); |
| 96 } | 97 } |
| 97 | 98 |
| 98 // 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. |
| 99 for (size_t i = 0; i < email_list->GetSize(); ++i) { | 100 for (size_t i = 0; i < email_list->GetSize(); ++i) { |
| 100 api::users_private::User user; | 101 api::users_private::User user; |
| 101 email_list->GetString(i, &user.email); | 102 email_list->GetString(i, &user.email); |
| 102 user.name = | 103 AccountId account_id = AccountId::FromUserEmail(user.email); |
| 103 user_manager->GetUserDisplayEmail(AccountId::FromUserEmail(user.email)); | 104 user.name = base::UTF16ToUTF8(user_manager->GetUserDisplayName(account_id)); |
| 105 if (user.name.empty()) { | |
| 106 // User is not associated with a gaia account. | |
|
michaelpg
2017/04/06 14:50:29
what cases don't have gaia accounts or display nam
stevenjb
2017/04/06 16:27:58
I'm not really sure, just making sure we are consi
| |
| 107 user.name = user_manager->GetUserDisplayEmail(account_id); | |
| 108 } | |
| 104 user.is_owner = chromeos::ProfileHelper::IsOwnerProfile(profile) && | 109 user.is_owner = chromeos::ProfileHelper::IsOwnerProfile(profile) && |
| 105 user.email == profile->GetProfileUserName(); | 110 user.email == profile->GetProfileUserName(); |
| 106 user_list->Append(user.ToValue()); | 111 user_list->Append(user.ToValue()); |
| 107 } | 112 } |
| 108 | 113 |
| 109 return RespondNow(OneArgument(std::move(user_list))); | 114 return RespondNow(OneArgument(std::move(user_list))); |
| 110 } | 115 } |
| 111 | 116 |
| 112 //////////////////////////////////////////////////////////////////////////////// | 117 //////////////////////////////////////////////////////////////////////////////// |
| 113 // UsersPrivateAddWhitelistedUserFunction | 118 // UsersPrivateAddWhitelistedUserFunction |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 214 | 219 |
| 215 ExtensionFunction::ResponseAction | 220 ExtensionFunction::ResponseAction |
| 216 UsersPrivateIsWhitelistManagedFunction::Run() { | 221 UsersPrivateIsWhitelistManagedFunction::Run() { |
| 217 bool is_managed = g_browser_process->platform_part() | 222 bool is_managed = g_browser_process->platform_part() |
| 218 ->browser_policy_connector_chromeos() | 223 ->browser_policy_connector_chromeos() |
| 219 ->IsEnterpriseManaged(); | 224 ->IsEnterpriseManaged(); |
| 220 return RespondNow(OneArgument(base::MakeUnique<base::Value>(is_managed))); | 225 return RespondNow(OneArgument(base::MakeUnique<base::Value>(is_managed))); |
| 221 } | 226 } |
| 222 | 227 |
| 223 } // namespace extensions | 228 } // namespace extensions |
| OLD | NEW |