1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ASH_POLICY_CORE_DEVICE_LOCAL_ACCOUNT_H_
#define CHROME_BROWSER_ASH_POLICY_CORE_DEVICE_LOCAL_ACCOUNT_H_
#include <string>
#include <vector>
#include "chromeos/ash/components/policy/device_local_account/device_local_account_type.h"
namespace ash {
class CrosSettings;
class OwnerSettingsServiceAsh;
} // namespace ash
namespace policy {
struct WebKioskAppBasicInfo {
WebKioskAppBasicInfo(const std::string& url,
const std::string& title,
const std::string& icon_url);
WebKioskAppBasicInfo();
~WebKioskAppBasicInfo();
const std::string& url() const { return url_; }
const std::string& title() const { return title_; }
const std::string& icon_url() const { return icon_url_; }
private:
std::string url_;
std::string title_;
std::string icon_url_;
};
struct IsolatedWebAppKioskBasicInfo {
public:
IsolatedWebAppKioskBasicInfo(std::string web_bundle_id,
std::string update_manifest_url,
std::string update_channel,
std::string pinned_version,
bool allow_downgrades);
IsolatedWebAppKioskBasicInfo();
~IsolatedWebAppKioskBasicInfo();
IsolatedWebAppKioskBasicInfo(const IsolatedWebAppKioskBasicInfo& other);
IsolatedWebAppKioskBasicInfo& operator=(const IsolatedWebAppKioskBasicInfo&);
[[nodiscard]] const std::string& web_bundle_id() const {
return web_bundle_id_;
}
[[nodiscard]] const std::string& update_manifest_url() const {
return update_manifest_url_;
}
[[nodiscard]] const std::string& update_channel() const {
return update_channel_;
}
[[nodiscard]] const std::string& pinned_version() const {
return pinned_version_;
}
[[nodiscard]] bool allow_downgrades() const { return allow_downgrades_; }
private:
std::string web_bundle_id_;
std::string update_manifest_url_;
std::string update_channel_;
std::string pinned_version_;
bool allow_downgrades_ = false;
};
struct ArcvmKioskAppBasicInfo {
ArcvmKioskAppBasicInfo(const std::string& package_name,
const std::string& class_name,
const std::string& action,
const std::string& display_name);
ArcvmKioskAppBasicInfo();
~ArcvmKioskAppBasicInfo();
ArcvmKioskAppBasicInfo(const ArcvmKioskAppBasicInfo& other);
ArcvmKioskAppBasicInfo& operator=(const ArcvmKioskAppBasicInfo&);
[[nodiscard]] const std::string& package_name() const {
return package_name_;
}
[[nodiscard]] const std::string& class_name() const { return class_name_; }
[[nodiscard]] const std::string& action() const { return action_; }
[[nodiscard]] const std::string& display_name() const {
return display_name_;
}
private:
std::string package_name_;
std::string class_name_;
std::string action_;
std::string display_name_;
};
// This must match DeviceLocalAccountInfoProto.AccountType in
// chrome_device_policy.proto.
struct DeviceLocalAccount {
enum class EphemeralMode {
// Default value. Same behaviour as `kFollowDeviceWidePolicy` value.
kUnset = 0,
// Device-local account ephemeral mode controlled by
// `DeviceEphemeralUsersEnabled` policy.
kFollowDeviceWidePolicy = 1,
// Device-local account must be non-ephemeral.
kDisable = 2,
// Device-local account must be ephemeral.
kEnable = 3,
// Max value, must be last.
kMaxValue = kEnable,
};
DeviceLocalAccount(DeviceLocalAccountType type,
EphemeralMode ephemeral_mode,
const std::string& account_id,
const std::string& kiosk_app_id,
const std::string& kiosk_app_update_url);
DeviceLocalAccount(EphemeralMode ephemeral_mode,
const WebKioskAppBasicInfo& app_info,
const std::string& account_id);
DeviceLocalAccount(EphemeralMode ephemeral_mode,
const IsolatedWebAppKioskBasicInfo& kiosk_iwa_info,
const std::string& account_id);
DeviceLocalAccount(EphemeralMode ephemeral_mode,
const ArcvmKioskAppBasicInfo& arcvm_kiosk_app_info,
const std::string& account_id);
DeviceLocalAccount(const DeviceLocalAccount& other);
~DeviceLocalAccount();
DeviceLocalAccountType type;
EphemeralMode ephemeral_mode;
// A device-local account has two identifiers:
// * The `account_id` is chosen by the entity that defines the device-local
// account. The only constraints are that the `account_id` be unique and,
// for legacy reasons, it contain an @ symbol.
// * The `user_id` is a synthesized identifier that is guaranteed to be
// unique, contain an @ symbol, not collide with the `user_id` of any other
// user on the device (such as regular users or supervised users) and be
// identifiable as belonging to a device-local account by.
// The `account_id` is primarily used by policy code: If device policy defines
// a device-local account with a certain `account_id`, the user policy for
// that account has to be fetched by referencing the same `account_id`.
// The `user_id` is passed to the user_manager::UserManager where it becomes
// part
// of the global user list on the device. The `account_id` would not be safe
// to use here as it is a free-form identifier that could conflict with
// another `user_id` on the device and cannot be easily identified as
// belonging to a device-local account.
std::string account_id;
std::string user_id;
std::string kiosk_app_id;
std::string kiosk_app_update_url;
WebKioskAppBasicInfo web_kiosk_app_info;
IsolatedWebAppKioskBasicInfo kiosk_iwa_info;
ArcvmKioskAppBasicInfo arcvm_kiosk_app_info;
};
// Retrieves a list of device-local accounts from `cros_settings`.
std::vector<DeviceLocalAccount> GetDeviceLocalAccounts(
ash::CrosSettings* cros_settings);
// Stores a list of device-local accounts in `service`. The accounts are stored
// as a list of dictionaries with each dictionary containing the information
// about one `DeviceLocalAccount`.
void SetDeviceLocalAccountsForTesting(
ash::OwnerSettingsServiceAsh* service,
const std::vector<DeviceLocalAccount>& accounts);
} // namespace policy
#endif // CHROME_BROWSER_ASH_POLICY_CORE_DEVICE_LOCAL_ACCOUNT_H_
|