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 <set> | 7 #include <set> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/chromeos/login/users/user_manager.h" | |
16 #include "chrome/browser/chromeos/settings/cros_settings.h" | 15 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 16 #include "chromeos/login/user_names.h" |
17 #include "chromeos/settings/cros_settings_names.h" | 17 #include "chromeos/settings/cros_settings_names.h" |
18 #include "google_apis/gaia/gaia_auth_util.h" | 18 #include "google_apis/gaia/gaia_auth_util.h" |
19 | 19 |
20 namespace policy { | 20 namespace policy { |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 const char kPublicAccountDomainPrefix[] = "public-accounts"; | 24 const char kPublicAccountDomainPrefix[] = "public-accounts"; |
25 const char kKioskAppAccountDomainPrefix[] = "kiosk-apps"; | 25 const char kKioskAppAccountDomainPrefix[] = "kiosk-apps"; |
26 const char kDeviceLocalAccountDomainSuffix[] = ".device-local.localhost"; | 26 const char kDeviceLocalAccountDomainSuffix[] = ".device-local.localhost"; |
(...skipping 28 matching lines...) Expand all Loading... |
55 } | 55 } |
56 return gaia::CanonicalizeEmail( | 56 return gaia::CanonicalizeEmail( |
57 base::HexEncode(account_id.c_str(), account_id.size()) + "@" + | 57 base::HexEncode(account_id.c_str(), account_id.size()) + "@" + |
58 domain_prefix + kDeviceLocalAccountDomainSuffix); | 58 domain_prefix + kDeviceLocalAccountDomainSuffix); |
59 } | 59 } |
60 | 60 |
61 bool IsDeviceLocalAccountUser(const std::string& user_id, | 61 bool IsDeviceLocalAccountUser(const std::string& user_id, |
62 DeviceLocalAccount::Type* type) { | 62 DeviceLocalAccount::Type* type) { |
63 // For historical reasons, the guest user ID does not contain an @ symbol and | 63 // For historical reasons, the guest user ID does not contain an @ symbol and |
64 // therefore, cannot be parsed by gaia::ExtractDomainName(). | 64 // therefore, cannot be parsed by gaia::ExtractDomainName(). |
65 if (user_id == chromeos::UserManager::kGuestUserName) | 65 if (user_id == chromeos::login::kGuestUserName) |
66 return false; | 66 return false; |
67 const std::string domain = gaia::ExtractDomainName(user_id); | 67 const std::string domain = gaia::ExtractDomainName(user_id); |
68 if (!EndsWith(domain, kDeviceLocalAccountDomainSuffix, true)) | 68 if (!EndsWith(domain, kDeviceLocalAccountDomainSuffix, true)) |
69 return false; | 69 return false; |
70 | 70 |
71 const std::string domain_prefix = domain.substr( | 71 const std::string domain_prefix = domain.substr( |
72 0, domain.size() - arraysize(kDeviceLocalAccountDomainSuffix) + 1); | 72 0, domain.size() - arraysize(kDeviceLocalAccountDomainSuffix) + 1); |
73 | 73 |
74 if (domain_prefix == kPublicAccountDomainPrefix) { | 74 if (domain_prefix == kPublicAccountDomainPrefix) { |
75 if (type) | 75 if (type) |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 continue; | 166 continue; |
167 } | 167 } |
168 | 168 |
169 accounts.push_back(DeviceLocalAccount( | 169 accounts.push_back(DeviceLocalAccount( |
170 static_cast<DeviceLocalAccount::Type>(type), account_id, kiosk_app_id)); | 170 static_cast<DeviceLocalAccount::Type>(type), account_id, kiosk_app_id)); |
171 } | 171 } |
172 return accounts; | 172 return accounts; |
173 } | 173 } |
174 | 174 |
175 } // namespace policy | 175 } // namespace policy |
OLD | NEW |