OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/policy/device_local_account.h" | 5 #include "chrome/browser/chromeos/policy/device_local_account.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" | 18 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" |
19 #include "chrome/browser/chromeos/settings/cros_settings.h" | 19 #include "chrome/browser/chromeos/settings/cros_settings.h" |
20 #include "chromeos/login/user_names.h" | |
21 #include "chromeos/settings/cros_settings_names.h" | 20 #include "chromeos/settings/cros_settings_names.h" |
22 #include "components/signin/core/account_id/account_id.h" | 21 #include "components/signin/core/account_id/account_id.h" |
| 22 #include "components/user_manager/user_names.h" |
23 #include "google_apis/gaia/gaia_auth_util.h" | 23 #include "google_apis/gaia/gaia_auth_util.h" |
24 | 24 |
25 namespace policy { | 25 namespace policy { |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 const char kPublicAccountDomainPrefix[] = "public-accounts"; | 29 const char kPublicAccountDomainPrefix[] = "public-accounts"; |
30 const char kKioskAppAccountDomainPrefix[] = "kiosk-apps"; | 30 const char kKioskAppAccountDomainPrefix[] = "kiosk-apps"; |
31 const char kArcKioskAppAccountDomainPrefix[] = "arc-kiosk-apps"; | 31 const char kArcKioskAppAccountDomainPrefix[] = "arc-kiosk-apps"; |
32 const char kDeviceLocalAccountDomainSuffix[] = ".device-local.localhost"; | 32 const char kDeviceLocalAccountDomainSuffix[] = ".device-local.localhost"; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 } | 69 } |
70 return gaia::CanonicalizeEmail( | 70 return gaia::CanonicalizeEmail( |
71 base::HexEncode(account_id.c_str(), account_id.size()) + "@" + | 71 base::HexEncode(account_id.c_str(), account_id.size()) + "@" + |
72 domain_prefix + kDeviceLocalAccountDomainSuffix); | 72 domain_prefix + kDeviceLocalAccountDomainSuffix); |
73 } | 73 } |
74 | 74 |
75 bool IsDeviceLocalAccountUser(const std::string& user_id, | 75 bool IsDeviceLocalAccountUser(const std::string& user_id, |
76 DeviceLocalAccount::Type* type) { | 76 DeviceLocalAccount::Type* type) { |
77 // For historical reasons, the guest user ID does not contain an @ symbol and | 77 // For historical reasons, the guest user ID does not contain an @ symbol and |
78 // therefore, cannot be parsed by gaia::ExtractDomainName(). | 78 // therefore, cannot be parsed by gaia::ExtractDomainName(). |
79 if (user_id == chromeos::login::GuestAccountId().GetUserEmail()) | 79 if (user_id == user_manager::GuestAccountId().GetUserEmail()) |
80 return false; | 80 return false; |
81 const std::string domain = gaia::ExtractDomainName(user_id); | 81 const std::string domain = gaia::ExtractDomainName(user_id); |
82 if (!base::EndsWith(domain, kDeviceLocalAccountDomainSuffix, | 82 if (!base::EndsWith(domain, kDeviceLocalAccountDomainSuffix, |
83 base::CompareCase::SENSITIVE)) | 83 base::CompareCase::SENSITIVE)) |
84 return false; | 84 return false; |
85 | 85 |
86 const std::string domain_prefix = domain.substr( | 86 const std::string domain_prefix = domain.substr( |
87 0, domain.size() - arraysize(kDeviceLocalAccountDomainSuffix) + 1); | 87 0, domain.size() - arraysize(kDeviceLocalAccountDomainSuffix) + 1); |
88 | 88 |
89 if (domain_prefix == kPublicAccountDomainPrefix) { | 89 if (domain_prefix == kPublicAccountDomainPrefix) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 accounts.push_back( | 197 accounts.push_back( |
198 DeviceLocalAccount(static_cast<DeviceLocalAccount::Type>(type), | 198 DeviceLocalAccount(static_cast<DeviceLocalAccount::Type>(type), |
199 account_id, | 199 account_id, |
200 kiosk_app_id, | 200 kiosk_app_id, |
201 kiosk_app_update_url)); | 201 kiosk_app_update_url)); |
202 } | 202 } |
203 return accounts; | 203 return accounts; |
204 } | 204 } |
205 | 205 |
206 } // namespace policy | 206 } // namespace policy |
OLD | NEW |