#ifndef CHROME_BROWSER_ASH_CROSTINI_CROSTINI_SHARED_DEVICES_H_
#define CHROME_BROWSER_ASH_CROSTINI_CROSTINI_SHARED_DEVICES_H_
#include "base/memory/raw_ptr.h"
#include "components/keyed_service/core/keyed_service.h"
#include <string>
#include "base/memory/weak_ptr.h"
#include "base/values.h"
#include "chrome/browser/ash/guest_os/guest_id.h"
#include "chrome/browser/ash/guest_os/guest_os_session_tracker.h"
#include "chromeos/ash/components/dbus/cicerone/cicerone_client.h"
class Profile;
namespace crostini {
class CrostiniSharedDevices : public KeyedService,
public guest_os::ContainerStartedObserver {
public:
explicit CrostiniSharedDevices(Profile* profile);
CrostiniSharedDevices(const CrostiniSharedDevices&) = delete;
CrostiniSharedDevices& operator=(const CrostiniSharedDevices&) = delete;
~CrostiniSharedDevices() override;
using ResultCallback = base::OnceCallback<void(bool)>;
bool IsVmDeviceShared(guest_os::GuestId container_id,
const std::string& vm_device);
void SetVmDeviceShared(guest_os::GuestId container_id,
const std::string& vm_device,
bool shared,
ResultCallback callback);
private:
void ApplySharingState(guest_os::GuestId container_id,
base::Value::Dict next_shared_devices,
ResultCallback callback);
void OnContainerStarted(const guest_os::GuestId& container_id) override;
void OnUpdateContainerDevices(
const guest_os::GuestId container_id,
base::Value::Dict next_shared_devices,
ResultCallback callback,
std::optional<vm_tools::cicerone::UpdateContainerDevicesResponse>
response);
raw_ptr<Profile> profile_;
base::WeakPtrFactory<CrostiniSharedDevices> weak_ptr_factory_{this};
};
}
#endif