device_local_account.h revision 4e180b6a0b4720a9b8e9e959a882386f690f08ff
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.
4
5#ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_H_
6#define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_H_
7
8#include <string>
9#include <vector>
10
11namespace chromeos {
12class CrosSettings;
13}
14
15namespace policy {
16
17// This must match DeviceLocalAccountInfoProto.AccountType in
18// chrome_device_policy.proto.
19struct DeviceLocalAccount {
20  enum Type {
21    // A login-less, policy-configured browsing session.
22    TYPE_PUBLIC_SESSION,
23    // An account that serves as a container for a single full-screen app.
24    TYPE_KIOSK_APP,
25    // Sentinel, must be last.
26    TYPE_COUNT
27  };
28
29  DeviceLocalAccount(Type type,
30                     const std::string& account_id,
31                     const std::string& kiosk_app_id);
32  ~DeviceLocalAccount();
33
34  Type type;
35  std::string account_id;
36  std::string user_id;
37  std::string kiosk_app_id;
38};
39
40std::string GenerateDeviceLocalAccountUserId(const std::string& account_id,
41                                             DeviceLocalAccount::Type type);
42
43// Determines whether |user_id| belongs to a device-local account and if so,
44// returns the type of device-local account in |type| unless |type| is NULL.
45bool IsDeviceLocalAccountUser(const std::string& user_id,
46                              DeviceLocalAccount::Type* type);
47
48// Stores a list of device-local accounts in |cros_settings|. The accounts are
49// stored as a list of dictionaries with each dictionary containing the
50// information about one |DeviceLocalAccount|.
51void SetDeviceLocalAccounts(
52    chromeos::CrosSettings* cros_settings,
53    const std::vector<DeviceLocalAccount>& accounts);
54
55// Retrieves a list of device-local accounts from |cros_settings|.
56std::vector<DeviceLocalAccount> GetDeviceLocalAccounts(
57    chromeos::CrosSettings* cros_settings);
58
59}  // namespace policy
60
61#endif  // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_H_
62