| 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 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "components/user_manager/user_id.h" |
| 12 |
| 11 namespace chromeos { | 13 namespace chromeos { |
| 12 class CrosSettings; | 14 class CrosSettings; |
| 13 class OwnerSettingsServiceChromeOS; | 15 class OwnerSettingsServiceChromeOS; |
| 14 } | 16 } |
| 15 | 17 |
| 16 namespace policy { | 18 namespace policy { |
| 17 | 19 |
| 18 // This must match DeviceLocalAccountInfoProto.AccountType in | 20 // This must match DeviceLocalAccountInfoProto.AccountType in |
| 19 // chrome_device_policy.proto. | 21 // chrome_device_policy.proto. |
| 20 struct DeviceLocalAccount { | 22 struct DeviceLocalAccount { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 32 const std::string& kiosk_app_id, | 34 const std::string& kiosk_app_id, |
| 33 const std::string& kiosk_app_update_url); | 35 const std::string& kiosk_app_update_url); |
| 34 ~DeviceLocalAccount(); | 36 ~DeviceLocalAccount(); |
| 35 | 37 |
| 36 Type type; | 38 Type type; |
| 37 // A device-local account has two identifiers: | 39 // A device-local account has two identifiers: |
| 38 // * The |account_id| is chosen by the entity that defines the device-local | 40 // * The |account_id| is chosen by the entity that defines the device-local |
| 39 // account. The only constraints are that the |account_id| be unique and, | 41 // account. The only constraints are that the |account_id| be unique and, |
| 40 // for legacy reasons, it contain an @ symbol. | 42 // for legacy reasons, it contain an @ symbol. |
| 41 // * The |user_id| is a synthesized identifier that is guaranteed to be | 43 // * The |user_id| is a synthesized identifier that is guaranteed to be |
| 42 // unique, contain an @ symbol, not collide with the |user_id| of any other | 44 // unique, which email contains an @ symbol, doesn not collide with the |
| 43 // user on the device (such as regular users or supervised users) and be | 45 // |user_id| of any other user on the device (such as regular users or |
| 44 // identifiable as belonging to a device-local account by. | 46 // supervised users) and be identifiable as belonging to a device-local |
| 47 // account by. |
| 45 // The |account_id| is primarily used by policy code: If device policy defines | 48 // The |account_id| is primarily used by policy code: If device policy defines |
| 46 // a device-local account with a certain |account_id|, the user policy for | 49 // a device-local account with a certain |account_id|, the user policy for |
| 47 // that account has to be fetched by referencing the same |account_id|. | 50 // that account has to be fetched by referencing the same |account_id|. |
| 48 // The |user_id| is passed to the user_manager::UserManager where it becomes | 51 // The |user_id| is passed to the user_manager::UserManager where it becomes |
| 49 // part | 52 // part |
| 50 // of the global user list on the device. The |account_id| would not be safe | 53 // of the global user list on the device. The |account_id| would not be safe |
| 51 // to use here as it is a free-form identifier that could conflict with | 54 // to use here as it is a free-form identifier that could conflict with |
| 52 // another |user_id| on the device and cannot be easily identified as | 55 // another |user_id| on the device and cannot be easily identified as |
| 53 // belonging to a device-local account. | 56 // belonging to a device-local account. |
| 54 std::string account_id; | 57 std::string account_id; |
| 55 std::string user_id; | 58 user_manager::UserID user_id; |
| 56 std::string kiosk_app_id; | 59 std::string kiosk_app_id; |
| 57 std::string kiosk_app_update_url; | 60 std::string kiosk_app_update_url; |
| 58 }; | 61 }; |
| 59 | 62 |
| 60 std::string GenerateDeviceLocalAccountUserId(const std::string& account_id, | 63 user_manager::UserID GenerateDeviceLocalAccountUserId(const std::string& account
_id, |
| 61 DeviceLocalAccount::Type type); | 64 DeviceLocalAccount::Type type); |
| 62 | 65 |
| 63 // Determines whether |user_id| belongs to a device-local account and if so, | 66 // Determines whether |user_id| belongs to a device-local account and if so, |
| 64 // returns the type of device-local account in |type| unless |type| is NULL. | 67 // returns the type of device-local account in |type| unless |type| is NULL. |
| 65 bool IsDeviceLocalAccountUser(const std::string& user_id, | 68 bool IsDeviceLocalAccountUser(const user_manager::UserID& user_id, |
| 66 DeviceLocalAccount::Type* type); | 69 DeviceLocalAccount::Type* type); |
| 67 | 70 |
| 68 // Stores a list of device-local accounts in |service|. The accounts are stored | 71 // Stores a list of device-local accounts in |service|. The accounts are stored |
| 69 // as a list of dictionaries with each dictionary containing the information | 72 // as a list of dictionaries with each dictionary containing the information |
| 70 // about one |DeviceLocalAccount|. | 73 // about one |DeviceLocalAccount|. |
| 71 void SetDeviceLocalAccounts(chromeos::OwnerSettingsServiceChromeOS* service, | 74 void SetDeviceLocalAccounts(chromeos::OwnerSettingsServiceChromeOS* service, |
| 72 const std::vector<DeviceLocalAccount>& accounts); | 75 const std::vector<DeviceLocalAccount>& accounts); |
| 73 | 76 |
| 74 // Retrieves a list of device-local accounts from |cros_settings|. | 77 // Retrieves a list of device-local accounts from |cros_settings|. |
| 75 std::vector<DeviceLocalAccount> GetDeviceLocalAccounts( | 78 std::vector<DeviceLocalAccount> GetDeviceLocalAccounts( |
| 76 chromeos::CrosSettings* cros_settings); | 79 chromeos::CrosSettings* cros_settings); |
| 77 | 80 |
| 78 } // namespace policy | 81 } // namespace policy |
| 79 | 82 |
| 80 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_H_ | 83 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_H_ |
| OLD | NEW |