// This file is generated by TypeBuilder_h.template.

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef content_protocol_Target_h
#define content_protocol_Target_h

#include "content/common/content_export.h"
#include "content/browser/devtools/protocol/protocol.h"
// For each imported domain we generate a ValueConversions struct instead of a full domain definition
// and include Domain::API version from there.

namespace content {
namespace protocol {
namespace Target {
using TargetID = String;
using SessionID = String;
class TargetInfo;
class FilterEntry;
class RemoteLocation;
using WindowState = String;

// ------------- Forward and enum declarations.

namespace WindowStateEnum {
inline constexpr char Normal[] = "normal";
inline constexpr char Minimized[] = "minimized";
inline constexpr char Maximized[] = "maximized";
inline constexpr char Fullscreen[] = "fullscreen";
} // namespace WindowStateEnum

// ------------- Type and builder declarations.

class CONTENT_EXPORT TargetInfo : public ::crdtp::ProtocolObject<TargetInfo> {
public:
    ~TargetInfo() override;  // Defined below

    String GetTargetId() { return m_targetId; }
    void SetTargetId(const String& value);  // Defined below

    String GetType() { return m_type; }
    void SetType(const String& value);  // Defined below

    String GetTitle() { return m_title; }
    void SetTitle(const String& value);  // Defined below

    String GetUrl() { return m_url; }
    void SetUrl(const String& value);  // Defined below

    bool GetAttached() { return m_attached; }
    void SetAttached(bool value);  // Defined below

    bool HasParentId() { return !!m_parentId; }
    String GetParentId(const String& defaultValue) const {
       return m_parentId.value_or(defaultValue);
    }
    const std::optional<String>& GetParentId() const {
       return m_parentId;
    }
    void SetParentId(const String& value);  // Defined below

    bool HasOpenerId() { return !!m_openerId; }
    String GetOpenerId(const String& defaultValue) const {
       return m_openerId.value_or(defaultValue);
    }
    const std::optional<String>& GetOpenerId() const {
       return m_openerId;
    }
    void SetOpenerId(const String& value);  // Defined below

    bool GetCanAccessOpener() { return m_canAccessOpener; }
    void SetCanAccessOpener(bool value);  // Defined below

    bool HasOpenerFrameId() { return !!m_openerFrameId; }
    String GetOpenerFrameId(const String& defaultValue) const {
       return m_openerFrameId.value_or(defaultValue);
    }
    const std::optional<String>& GetOpenerFrameId() const {
       return m_openerFrameId;
    }
    void SetOpenerFrameId(const String& value);  // Defined below

    bool HasParentFrameId() { return !!m_parentFrameId; }
    String GetParentFrameId(const String& defaultValue) const {
       return m_parentFrameId.value_or(defaultValue);
    }
    const std::optional<String>& GetParentFrameId() const {
       return m_parentFrameId;
    }
    void SetParentFrameId(const String& value);  // Defined below

    bool HasBrowserContextId() { return !!m_browserContextId; }
    String GetBrowserContextId(const String& defaultValue) const {
       return m_browserContextId.value_or(defaultValue);
    }
    const std::optional<String>& GetBrowserContextId() const {
       return m_browserContextId;
    }
    void SetBrowserContextId(const String& value);  // Defined below

    bool HasSubtype() { return !!m_subtype; }
    String GetSubtype(const String& defaultValue) const {
       return m_subtype.value_or(defaultValue);
    }
    const std::optional<String>& GetSubtype() const {
       return m_subtype;
    }
    void SetSubtype(const String& value);  // Defined below

    bool HasEmbedderData() { return !!m_embedderData; }
    protocol::DictionaryValue* GetEmbedderData(protocol::DictionaryValue* defaultValue) {
       return m_embedderData ? m_embedderData.get() : defaultValue;
    }
    const std::unique_ptr<protocol::DictionaryValue>& GetEmbedderData() const {
       return m_embedderData;
    }
    void SetEmbedderData(std::unique_ptr<protocol::DictionaryValue> value);  // Defined below

    template<int STATE>
    class TargetInfoBuilder {
    public:
        enum {
            NoFieldsSet = 0,
            TargetIdSet = 1 << 1,
            TypeSet = 1 << 2,
            TitleSet = 1 << 3,
            UrlSet = 1 << 4,
            AttachedSet = 1 << 5,
            CanAccessOpenerSet = 1 << 6,
            AllFieldsSet = (TargetIdSet | TypeSet | TitleSet | UrlSet | AttachedSet | CanAccessOpenerSet | 0)};


        TargetInfoBuilder<STATE | TargetIdSet>& SetTargetId(const String& value);  // Defined below

        TargetInfoBuilder<STATE | TypeSet>& SetType(const String& value);  // Defined below

        TargetInfoBuilder<STATE | TitleSet>& SetTitle(const String& value);  // Defined below

        TargetInfoBuilder<STATE | UrlSet>& SetUrl(const String& value);  // Defined below

        TargetInfoBuilder<STATE | AttachedSet>& SetAttached(bool value);  // Defined below

        TargetInfoBuilder<STATE>& SetParentId(const String& value);  // Defined below

        TargetInfoBuilder<STATE>& SetOpenerId(const String& value);  // Defined below

        TargetInfoBuilder<STATE | CanAccessOpenerSet>& SetCanAccessOpener(bool value);  // Defined below

        TargetInfoBuilder<STATE>& SetOpenerFrameId(const String& value);  // Defined below

        TargetInfoBuilder<STATE>& SetParentFrameId(const String& value);  // Defined below

        TargetInfoBuilder<STATE>& SetBrowserContextId(const String& value);  // Defined below

        TargetInfoBuilder<STATE>& SetSubtype(const String& value);  // Defined below

        TargetInfoBuilder<STATE>& SetEmbedderData(std::unique_ptr<protocol::DictionaryValue> value);  // Defined below

        std::unique_ptr<TargetInfo> Build()
        {
            static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
            return std::move(m_result);
        }

    private:
        friend class TargetInfo;
        TargetInfoBuilder() : m_result(new TargetInfo()) { }

        template<int STEP> TargetInfoBuilder<STATE | STEP>& castState()
        {
            return *reinterpret_cast<TargetInfoBuilder<STATE | STEP>*>(this);
        }

        std::unique_ptr<protocol::Target::TargetInfo> m_result;
    };

    static TargetInfoBuilder<0> Create()
    {
        return TargetInfoBuilder<0>();
    }

private:
    DECLARE_SERIALIZATION_SUPPORT();

    TargetInfo();  // Defined below

    String m_targetId;
    String m_type;
    String m_title;
    String m_url;
    bool m_attached;
    std::optional<String> m_parentId;
    std::optional<String> m_openerId;
    bool m_canAccessOpener;
    std::optional<String> m_openerFrameId;
    std::optional<String> m_parentFrameId;
    std::optional<String> m_browserContextId;
    std::optional<String> m_subtype;
    std::unique_ptr<protocol::DictionaryValue> m_embedderData;
};


class CONTENT_EXPORT FilterEntry : public ::crdtp::ProtocolObject<FilterEntry> {
public:
    ~FilterEntry() override;  // Defined below

    bool HasExclude() { return !!m_exclude; }
    bool GetExclude(bool defaultValue) const {
       return m_exclude.value_or(defaultValue);
    }
    const std::optional<bool>& GetExclude() const {
       return m_exclude;
    }
    void SetExclude(bool value);  // Defined below

    bool HasType() { return !!m_type; }
    String GetType(const String& defaultValue) const {
       return m_type.value_or(defaultValue);
    }
    const std::optional<String>& GetType() const {
       return m_type;
    }
    void SetType(const String& value);  // Defined below

    template<int STATE>
    class FilterEntryBuilder {
    public:
        enum {
            NoFieldsSet = 0,
            AllFieldsSet = (0)};


        FilterEntryBuilder<STATE>& SetExclude(bool value);  // Defined below

        FilterEntryBuilder<STATE>& SetType(const String& value);  // Defined below

        std::unique_ptr<FilterEntry> Build()
        {
            static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
            return std::move(m_result);
        }

    private:
        friend class FilterEntry;
        FilterEntryBuilder() : m_result(new FilterEntry()) { }

        template<int STEP> FilterEntryBuilder<STATE | STEP>& castState()
        {
            return *reinterpret_cast<FilterEntryBuilder<STATE | STEP>*>(this);
        }

        std::unique_ptr<protocol::Target::FilterEntry> m_result;
    };

    static FilterEntryBuilder<0> Create()
    {
        return FilterEntryBuilder<0>();
    }

private:
    DECLARE_SERIALIZATION_SUPPORT();

    FilterEntry();  // Defined below

    std::optional<bool> m_exclude;
    std::optional<String> m_type;
};


class CONTENT_EXPORT RemoteLocation : public ::crdtp::ProtocolObject<RemoteLocation> {
public:
    ~RemoteLocation() override;  // Defined below

    String GetHost() { return m_host; }
    void SetHost(const String& value);  // Defined below

    int GetPort() { return m_port; }
    void SetPort(int value);  // Defined below

    template<int STATE>
    class RemoteLocationBuilder {
    public:
        enum {
            NoFieldsSet = 0,
            HostSet = 1 << 1,
            PortSet = 1 << 2,
            AllFieldsSet = (HostSet | PortSet | 0)};


        RemoteLocationBuilder<STATE | HostSet>& SetHost(const String& value);  // Defined below

        RemoteLocationBuilder<STATE | PortSet>& SetPort(int value);  // Defined below

        std::unique_ptr<RemoteLocation> Build()
        {
            static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
            return std::move(m_result);
        }

    private:
        friend class RemoteLocation;
        RemoteLocationBuilder() : m_result(new RemoteLocation()) { }

        template<int STEP> RemoteLocationBuilder<STATE | STEP>& castState()
        {
            return *reinterpret_cast<RemoteLocationBuilder<STATE | STEP>*>(this);
        }

        std::unique_ptr<protocol::Target::RemoteLocation> m_result;
    };

    static RemoteLocationBuilder<0> Create()
    {
        return RemoteLocationBuilder<0>();
    }

private:
    DECLARE_SERIALIZATION_SUPPORT();

    RemoteLocation();  // Defined below

    String m_host;
    int m_port;
};


// ------------- Type and builder method definitions.
//
// These methods separate from the type declaration because of
// https://github.com/llvm/llvm-project/issues/59966. The DevTools protocol has
// mutually recursive types, so we cannot simply reorder the types.
inline TargetInfo::~TargetInfo() = default;
inline void TargetInfo::SetTargetId(const String& value) { m_targetId = value; }
inline void TargetInfo::SetType(const String& value) { m_type = value; }
inline void TargetInfo::SetTitle(const String& value) { m_title = value; }
inline void TargetInfo::SetUrl(const String& value) { m_url = value; }
inline void TargetInfo::SetAttached(bool value) { m_attached = value; }
inline void TargetInfo::SetParentId(const String& value) { m_parentId = value; }
inline void TargetInfo::SetOpenerId(const String& value) { m_openerId = value; }
inline void TargetInfo::SetCanAccessOpener(bool value) { m_canAccessOpener = value; }
inline void TargetInfo::SetOpenerFrameId(const String& value) { m_openerFrameId = value; }
inline void TargetInfo::SetParentFrameId(const String& value) { m_parentFrameId = value; }
inline void TargetInfo::SetBrowserContextId(const String& value) { m_browserContextId = value; }
inline void TargetInfo::SetSubtype(const String& value) { m_subtype = value; }
inline void TargetInfo::SetEmbedderData(std::unique_ptr<protocol::DictionaryValue> value) { m_embedderData = std::move(value); }

template<int STATE>
inline TargetInfo::TargetInfoBuilder<STATE | TargetInfo::TargetInfoBuilder<STATE>::TargetIdSet>&
TargetInfo::TargetInfoBuilder<STATE>::SetTargetId(const String& value) {
  static_assert(!(STATE & TargetIdSet), "property targetId should not be set yet");
  m_result->SetTargetId(value);
  return castState<TargetIdSet>();
}
template<int STATE>
inline TargetInfo::TargetInfoBuilder<STATE | TargetInfo::TargetInfoBuilder<STATE>::TypeSet>&
TargetInfo::TargetInfoBuilder<STATE>::SetType(const String& value) {
  static_assert(!(STATE & TypeSet), "property type should not be set yet");
  m_result->SetType(value);
  return castState<TypeSet>();
}
template<int STATE>
inline TargetInfo::TargetInfoBuilder<STATE | TargetInfo::TargetInfoBuilder<STATE>::TitleSet>&
TargetInfo::TargetInfoBuilder<STATE>::SetTitle(const String& value) {
  static_assert(!(STATE & TitleSet), "property title should not be set yet");
  m_result->SetTitle(value);
  return castState<TitleSet>();
}
template<int STATE>
inline TargetInfo::TargetInfoBuilder<STATE | TargetInfo::TargetInfoBuilder<STATE>::UrlSet>&
TargetInfo::TargetInfoBuilder<STATE>::SetUrl(const String& value) {
  static_assert(!(STATE & UrlSet), "property url should not be set yet");
  m_result->SetUrl(value);
  return castState<UrlSet>();
}
template<int STATE>
inline TargetInfo::TargetInfoBuilder<STATE | TargetInfo::TargetInfoBuilder<STATE>::AttachedSet>&
TargetInfo::TargetInfoBuilder<STATE>::SetAttached(bool value) {
  static_assert(!(STATE & AttachedSet), "property attached should not be set yet");
  m_result->SetAttached(value);
  return castState<AttachedSet>();
}
template<int STATE>
inline TargetInfo::TargetInfoBuilder<STATE>& TargetInfo::TargetInfoBuilder<STATE>::SetParentId(const String& value) {
  m_result->SetParentId(value);
  return *this;
}
template<int STATE>
inline TargetInfo::TargetInfoBuilder<STATE>& TargetInfo::TargetInfoBuilder<STATE>::SetOpenerId(const String& value) {
  m_result->SetOpenerId(value);
  return *this;
}
template<int STATE>
inline TargetInfo::TargetInfoBuilder<STATE | TargetInfo::TargetInfoBuilder<STATE>::CanAccessOpenerSet>&
TargetInfo::TargetInfoBuilder<STATE>::SetCanAccessOpener(bool value) {
  static_assert(!(STATE & CanAccessOpenerSet), "property canAccessOpener should not be set yet");
  m_result->SetCanAccessOpener(value);
  return castState<CanAccessOpenerSet>();
}
template<int STATE>
inline TargetInfo::TargetInfoBuilder<STATE>& TargetInfo::TargetInfoBuilder<STATE>::SetOpenerFrameId(const String& value) {
  m_result->SetOpenerFrameId(value);
  return *this;
}
template<int STATE>
inline TargetInfo::TargetInfoBuilder<STATE>& TargetInfo::TargetInfoBuilder<STATE>::SetParentFrameId(const String& value) {
  m_result->SetParentFrameId(value);
  return *this;
}
template<int STATE>
inline TargetInfo::TargetInfoBuilder<STATE>& TargetInfo::TargetInfoBuilder<STATE>::SetBrowserContextId(const String& value) {
  m_result->SetBrowserContextId(value);
  return *this;
}
template<int STATE>
inline TargetInfo::TargetInfoBuilder<STATE>& TargetInfo::TargetInfoBuilder<STATE>::SetSubtype(const String& value) {
  m_result->SetSubtype(value);
  return *this;
}
template<int STATE>
inline TargetInfo::TargetInfoBuilder<STATE>& TargetInfo::TargetInfoBuilder<STATE>::SetEmbedderData(std::unique_ptr<protocol::DictionaryValue> value) {
  m_result->SetEmbedderData(std::move(value));
  return *this;
}

inline TargetInfo::TargetInfo() {
  m_attached = false;
  m_canAccessOpener = false;
}
inline FilterEntry::~FilterEntry() = default;
inline void FilterEntry::SetExclude(bool value) { m_exclude = value; }
inline void FilterEntry::SetType(const String& value) { m_type = value; }

template<int STATE>
inline FilterEntry::FilterEntryBuilder<STATE>& FilterEntry::FilterEntryBuilder<STATE>::SetExclude(bool value) {
  m_result->SetExclude(value);
  return *this;
}
template<int STATE>
inline FilterEntry::FilterEntryBuilder<STATE>& FilterEntry::FilterEntryBuilder<STATE>::SetType(const String& value) {
  m_result->SetType(value);
  return *this;
}

inline FilterEntry::FilterEntry() {
}
inline RemoteLocation::~RemoteLocation() = default;
inline void RemoteLocation::SetHost(const String& value) { m_host = value; }
inline void RemoteLocation::SetPort(int value) { m_port = value; }

template<int STATE>
inline RemoteLocation::RemoteLocationBuilder<STATE | RemoteLocation::RemoteLocationBuilder<STATE>::HostSet>&
RemoteLocation::RemoteLocationBuilder<STATE>::SetHost(const String& value) {
  static_assert(!(STATE & HostSet), "property host should not be set yet");
  m_result->SetHost(value);
  return castState<HostSet>();
}
template<int STATE>
inline RemoteLocation::RemoteLocationBuilder<STATE | RemoteLocation::RemoteLocationBuilder<STATE>::PortSet>&
RemoteLocation::RemoteLocationBuilder<STATE>::SetPort(int value) {
  static_assert(!(STATE & PortSet), "property port should not be set yet");
  m_result->SetPort(value);
  return castState<PortSet>();
}

inline RemoteLocation::RemoteLocation() {
  m_port = 0;
}

// ------------- Backend interface.

class CONTENT_EXPORT Backend {
public:
    virtual ~Backend() { }

    virtual DispatchResponse ActivateTarget(const String& in_targetId) = 0;
    virtual DispatchResponse AttachToTarget(const String& in_targetId, std::optional<bool> in_flatten, String* out_sessionId) = 0;
    virtual DispatchResponse AttachToBrowserTarget(String* out_sessionId) = 0;
    virtual DispatchResponse CloseTarget(const String& in_targetId, bool* out_success) = 0;
    class CONTENT_EXPORT ExposeDevToolsProtocolCallback {
    public:
        virtual void sendSuccess() = 0;
        virtual void sendFailure(const DispatchResponse&) = 0;
        virtual void fallThrough() = 0;
        virtual ~ExposeDevToolsProtocolCallback() { }
    };
    virtual void ExposeDevToolsProtocol(const String& in_targetId, std::optional<String> in_bindingName, std::optional<bool> in_inheritPermissions, std::unique_ptr<ExposeDevToolsProtocolCallback> callback) = 0;
    class CONTENT_EXPORT CreateBrowserContextCallback {
    public:
        virtual void sendSuccess(const String& browserContextId) = 0;
        virtual void sendFailure(const DispatchResponse&) = 0;
        virtual void fallThrough() = 0;
        virtual ~CreateBrowserContextCallback() { }
    };
    virtual void CreateBrowserContext(std::optional<bool> in_disposeOnDetach, std::optional<String> in_proxyServer, std::optional<String> in_proxyBypassList, std::unique_ptr<protocol::Array<String>> in_originsWithUniversalNetworkAccess, std::unique_ptr<CreateBrowserContextCallback> callback) = 0;
    virtual DispatchResponse GetBrowserContexts(std::unique_ptr<protocol::Array<String>>* out_browserContextIds, std::optional<String>* out_defaultBrowserContextId) = 0;
    virtual DispatchResponse CreateTarget(const String& in_url, std::optional<int> in_left, std::optional<int> in_top, std::optional<int> in_width, std::optional<int> in_height, std::optional<String> in_windowState, std::optional<String> in_browserContextId, std::optional<bool> in_enableBeginFrameControl, std::optional<bool> in_newWindow, std::optional<bool> in_background, std::optional<bool> in_forTab, std::optional<bool> in_hidden, std::optional<bool> in_focus, String* out_targetId) = 0;
    virtual DispatchResponse DetachFromTarget(std::optional<String> in_sessionId, std::optional<String> in_targetId) = 0;
    class CONTENT_EXPORT DisposeBrowserContextCallback {
    public:
        virtual void sendSuccess() = 0;
        virtual void sendFailure(const DispatchResponse&) = 0;
        virtual void fallThrough() = 0;
        virtual ~DisposeBrowserContextCallback() { }
    };
    virtual void DisposeBrowserContext(const String& in_browserContextId, std::unique_ptr<DisposeBrowserContextCallback> callback) = 0;
    virtual DispatchResponse GetTargetInfo(std::optional<String> in_targetId, std::unique_ptr<protocol::Target::TargetInfo>* out_targetInfo) = 0;
    virtual DispatchResponse GetTargets(std::unique_ptr<protocol::Array<protocol::Target::FilterEntry>> in_filter, std::unique_ptr<protocol::Array<protocol::Target::TargetInfo>>* out_targetInfos) = 0;
    virtual DispatchResponse SendMessageToTarget(const String& in_message, std::optional<String> in_sessionId, std::optional<String> in_targetId) = 0;
    class CONTENT_EXPORT SetAutoAttachCallback {
    public:
        virtual void sendSuccess() = 0;
        virtual void sendFailure(const DispatchResponse&) = 0;
        virtual void fallThrough() = 0;
        virtual ~SetAutoAttachCallback() { }
    };
    virtual void SetAutoAttach(bool in_autoAttach, bool in_waitForDebuggerOnStart, std::optional<bool> in_flatten, std::unique_ptr<protocol::Array<protocol::Target::FilterEntry>> in_filter, std::unique_ptr<SetAutoAttachCallback> callback) = 0;
    class CONTENT_EXPORT AutoAttachRelatedCallback {
    public:
        virtual void sendSuccess() = 0;
        virtual void sendFailure(const DispatchResponse&) = 0;
        virtual void fallThrough() = 0;
        virtual ~AutoAttachRelatedCallback() { }
    };
    virtual void AutoAttachRelated(const String& in_targetId, bool in_waitForDebuggerOnStart, std::unique_ptr<protocol::Array<protocol::Target::FilterEntry>> in_filter, std::unique_ptr<AutoAttachRelatedCallback> callback) = 0;
    virtual DispatchResponse SetDiscoverTargets(bool in_discover, std::unique_ptr<protocol::Array<protocol::Target::FilterEntry>> in_filter) = 0;
    virtual DispatchResponse SetRemoteLocations(std::unique_ptr<protocol::Array<protocol::Target::RemoteLocation>> in_locations) = 0;
    virtual DispatchResponse GetDevToolsTarget(const String& in_targetId, std::optional<String>* out_targetId) = 0;
    virtual DispatchResponse OpenDevTools(const String& in_targetId, std::optional<String> in_panelId, String* out_targetId) = 0;

    virtual DispatchResponse Disable()
    {
        return DispatchResponse::Success();
    }
};

// ------------- Frontend interface.

class CONTENT_EXPORT Frontend {
public:
  explicit Frontend(FrontendChannel* frontend_channel) : frontend_channel_(frontend_channel) {}
    void AttachedToTarget(const String& sessionId, std::unique_ptr<protocol::Target::TargetInfo> targetInfo, bool waitingForDebugger);
    void DetachedFromTarget(const String& sessionId, std::optional<String> targetId = {});
    void ReceivedMessageFromTarget(const String& sessionId, const String& message, std::optional<String> targetId = {});
    void TargetCreated(std::unique_ptr<protocol::Target::TargetInfo> targetInfo);
    void TargetDestroyed(const String& targetId);
    void TargetCrashed(const String& targetId, const String& status, int errorCode);
    void TargetInfoChanged(std::unique_ptr<protocol::Target::TargetInfo> targetInfo);

  void flush();
  void sendRawNotification(std::unique_ptr<Serializable>);
 private:
  FrontendChannel* frontend_channel_;
};

// ------------- Dispatcher.

class CONTENT_EXPORT Dispatcher {
public:
    static void wire(UberDispatcher*, Backend*);

private:
    Dispatcher() { }
};

// ------------- Metainfo.

class CONTENT_EXPORT Metainfo {
public:
    using BackendClass = Backend;
    using FrontendClass = Frontend;
    using DispatcherClass = Dispatcher;
    static const char domainName[];
    static const char commandPrefix[];
    static const char version[];
};

} // namespace Target
} // namespace content
} // namespace protocol

#endif // !defined(content_protocol_Target_h)
