// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_ASH_COMPONENTS_DBUS_ARC_ARC_KEYMASTER_CLIENT_H_
#define CHROMEOS_ASH_COMPONENTS_DBUS_ARC_ARC_KEYMASTER_CLIENT_H_
#include "base/files/scoped_file.h"
#include "chromeos/dbus/common/dbus_callback.h"
#include "chromeos/dbus/common/dbus_client.h"
namespace ash {
// ArcKeymasterClient is used to bootstrap a Mojo connection with the
// arc-keymasterd daemon in Chrome OS.
class COMPONENT_EXPORT(ASH_DBUS_ARC) ArcKeymasterClient
: public chromeos::DBusClient {
public:
// Returns the global instance if initialized. May return null.
static ArcKeymasterClient* Get();
// Creates and initializes the global instance. |bus| must not be null.
static void Initialize(dbus::Bus* bus);
// Creates and initializes a fake global instance.
static void InitializeFake();
// Destroys the global instance if it has been initialized.
static void Shutdown();
ArcKeymasterClient(const ArcKeymasterClient&) = delete;
ArcKeymasterClient& operator=(const ArcKeymasterClient&) = delete;
// Bootstrap the Mojo connection between Chrome and the keymaster service.
// Should pass in the child end of the Mojo pipe.
virtual void BootstrapMojoConnection(
base::ScopedFD fd,
chromeos::VoidDBusMethodCallback callback) = 0;
protected:
// Initialize() should be used instead.
ArcKeymasterClient();
~ArcKeymasterClient() override;
};
} // namespace ash
#endif // CHROMEOS_ASH_COMPONENTS_DBUS_ARC_ARC_KEYMASTER_CLIENT_H_