| 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> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "chromeos/settings/cros_settings_names.h" | 21 #include "chromeos/settings/cros_settings_names.h" |
| 22 #include "components/signin/core/account_id/account_id.h" | 22 #include "components/signin/core/account_id/account_id.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 kDeviceLocalAccountDomainSuffix[] = ".device-local.localhost"; | 32 const char kDeviceLocalAccountDomainSuffix[] = ".device-local.localhost"; |
| 32 | 33 |
| 33 } // namespace | 34 } // namespace |
| 34 | 35 |
| 35 DeviceLocalAccount::DeviceLocalAccount(Type type, | 36 DeviceLocalAccount::DeviceLocalAccount(Type type, |
| 36 const std::string& account_id, | 37 const std::string& account_id, |
| 37 const std::string& kiosk_app_id, | 38 const std::string& kiosk_app_id, |
| 38 const std::string& kiosk_app_update_url) | 39 const std::string& kiosk_app_update_url) |
| 39 : type(type), | 40 : type(type), |
| 40 account_id(account_id), | 41 account_id(account_id), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 52 std::string GenerateDeviceLocalAccountUserId(const std::string& account_id, | 53 std::string GenerateDeviceLocalAccountUserId(const std::string& account_id, |
| 53 DeviceLocalAccount::Type type) { | 54 DeviceLocalAccount::Type type) { |
| 54 std::string domain_prefix; | 55 std::string domain_prefix; |
| 55 switch (type) { | 56 switch (type) { |
| 56 case DeviceLocalAccount::TYPE_PUBLIC_SESSION: | 57 case DeviceLocalAccount::TYPE_PUBLIC_SESSION: |
| 57 domain_prefix = kPublicAccountDomainPrefix; | 58 domain_prefix = kPublicAccountDomainPrefix; |
| 58 break; | 59 break; |
| 59 case DeviceLocalAccount::TYPE_KIOSK_APP: | 60 case DeviceLocalAccount::TYPE_KIOSK_APP: |
| 60 domain_prefix = kKioskAppAccountDomainPrefix; | 61 domain_prefix = kKioskAppAccountDomainPrefix; |
| 61 break; | 62 break; |
| 63 case DeviceLocalAccount::TYPE_ARC_KIOSK_APP: |
| 64 domain_prefix = kArcKioskAppAccountDomainPrefix; |
| 65 break; |
| 62 case DeviceLocalAccount::TYPE_COUNT: | 66 case DeviceLocalAccount::TYPE_COUNT: |
| 63 NOTREACHED(); | 67 NOTREACHED(); |
| 64 break; | 68 break; |
| 65 } | 69 } |
| 66 return gaia::CanonicalizeEmail( | 70 return gaia::CanonicalizeEmail( |
| 67 base::HexEncode(account_id.c_str(), account_id.size()) + "@" + | 71 base::HexEncode(account_id.c_str(), account_id.size()) + "@" + |
| 68 domain_prefix + kDeviceLocalAccountDomainSuffix); | 72 domain_prefix + kDeviceLocalAccountDomainSuffix); |
| 69 } | 73 } |
| 70 | 74 |
| 71 bool IsDeviceLocalAccountUser(const std::string& user_id, | 75 bool IsDeviceLocalAccountUser(const std::string& user_id, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 85 if (domain_prefix == kPublicAccountDomainPrefix) { | 89 if (domain_prefix == kPublicAccountDomainPrefix) { |
| 86 if (type) | 90 if (type) |
| 87 *type = DeviceLocalAccount::TYPE_PUBLIC_SESSION; | 91 *type = DeviceLocalAccount::TYPE_PUBLIC_SESSION; |
| 88 return true; | 92 return true; |
| 89 } | 93 } |
| 90 if (domain_prefix == kKioskAppAccountDomainPrefix) { | 94 if (domain_prefix == kKioskAppAccountDomainPrefix) { |
| 91 if (type) | 95 if (type) |
| 92 *type = DeviceLocalAccount::TYPE_KIOSK_APP; | 96 *type = DeviceLocalAccount::TYPE_KIOSK_APP; |
| 93 return true; | 97 return true; |
| 94 } | 98 } |
| 99 if (domain_prefix == kArcKioskAppAccountDomainPrefix) { |
| 100 if (type) |
| 101 *type = DeviceLocalAccount::TYPE_ARC_KIOSK_APP; |
| 102 return true; |
| 103 } |
| 95 | 104 |
| 96 // |user_id| is a device-local account but its type is not recognized. | 105 // |user_id| is a device-local account but its type is not recognized. |
| 97 NOTREACHED(); | 106 NOTREACHED(); |
| 98 if (type) | 107 if (type) |
| 99 *type = DeviceLocalAccount::TYPE_COUNT; | 108 *type = DeviceLocalAccount::TYPE_COUNT; |
| 100 return true; | 109 return true; |
| 101 } | 110 } |
| 102 | 111 |
| 103 void SetDeviceLocalAccounts(chromeos::OwnerSettingsServiceChromeOS* service, | 112 void SetDeviceLocalAccounts(chromeos::OwnerSettingsServiceChromeOS* service, |
| 104 const std::vector<DeviceLocalAccount>& accounts) { | 113 const std::vector<DeviceLocalAccount>& accounts) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 accounts.push_back( | 197 accounts.push_back( |
| 189 DeviceLocalAccount(static_cast<DeviceLocalAccount::Type>(type), | 198 DeviceLocalAccount(static_cast<DeviceLocalAccount::Type>(type), |
| 190 account_id, | 199 account_id, |
| 191 kiosk_app_id, | 200 kiosk_app_id, |
| 192 kiosk_app_update_url)); | 201 kiosk_app_update_url)); |
| 193 } | 202 } |
| 194 return accounts; | 203 return accounts; |
| 195 } | 204 } |
| 196 | 205 |
| 197 } // namespace policy | 206 } // namespace policy |
| OLD | NEW |