Elim cr-checkbox
[chromium-blink-merge.git] / chrome / browser / chromeos / policy / device_local_account.h
blob88271192ab4c6c2393bbc7c51ccaa36ddcae60d3
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_H_
8 #include <string>
9 #include <vector>
11 namespace chromeos {
12 class CrosSettings;
13 class OwnerSettingsServiceChromeOS;
16 namespace policy {
18 // This must match DeviceLocalAccountInfoProto.AccountType in
19 // chrome_device_policy.proto.
20 struct DeviceLocalAccount {
21 enum Type {
22 // A login-less, policy-configured browsing session.
23 TYPE_PUBLIC_SESSION,
24 // An account that serves as a container for a single full-screen app.
25 TYPE_KIOSK_APP,
26 // Sentinel, must be last.
27 TYPE_COUNT
30 DeviceLocalAccount(Type type,
31 const std::string& account_id,
32 const std::string& kiosk_app_id,
33 const std::string& kiosk_app_update_url);
34 ~DeviceLocalAccount();
36 Type type;
37 // A device-local account has two identifiers:
38 // * 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,
40 // for legacy reasons, it contain an @ symbol.
41 // * 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
43 // user on the device (such as regular users or supervised users) and be
44 // identifiable as belonging to a device-local account by.
45 // 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
47 // 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
49 // part
50 // 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
52 // another |user_id| on the device and cannot be easily identified as
53 // belonging to a device-local account.
54 std::string account_id;
55 std::string user_id;
56 std::string kiosk_app_id;
57 std::string kiosk_app_update_url;
60 std::string GenerateDeviceLocalAccountUserId(const std::string& account_id,
61 DeviceLocalAccount::Type type);
63 // 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.
65 bool IsDeviceLocalAccountUser(const std::string& user_id,
66 DeviceLocalAccount::Type* type);
68 // 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
70 // about one |DeviceLocalAccount|.
71 void SetDeviceLocalAccounts(chromeos::OwnerSettingsServiceChromeOS* service,
72 const std::vector<DeviceLocalAccount>& accounts);
74 // Retrieves a list of device-local accounts from |cros_settings|.
75 std::vector<DeviceLocalAccount> GetDeviceLocalAccounts(
76 chromeos::CrosSettings* cros_settings);
78 } // namespace policy
80 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_H_