blob: f62f9f8704b44260de574376b1f680e14eadd859 [file] [log] [blame]
// 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_shell_protocol_Browser_h
#define content_shell_protocol_Browser_h
#include "content/shell/browser/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 shell {
namespace protocol {
namespace Browser {
using WindowID = int;
using WindowState = String;
class Bounds;
// ------------- Forward and enum declarations.
namespace WindowStateEnum {
extern const char Normal[];
extern const char Minimized[];
extern const char Maximized[];
extern const char Fullscreen[];
} // namespace WindowStateEnum
namespace SetDownloadBehavior {
namespace BehaviorEnum {
extern const char* Deny;
extern const char* Allow;
extern const char* AllowAndName;
extern const char* Default;
} // BehaviorEnum
} // SetDownloadBehavior
namespace DownloadProgress {
namespace StateEnum {
extern const char* InProgress;
extern const char* Completed;
extern const char* Canceled;
} // StateEnum
} // DownloadProgress
// ------------- Type and builder declarations.
class Bounds : public ::crdtp::ProtocolObject<Bounds> {
public:
~Bounds() override; // Defined below
bool HasLeft() { return !!m_left; }
int GetLeft(int defaultValue) const {
return m_left.value_or(defaultValue);
}
const std::optional<int>& GetLeft() const {
return m_left;
}
void SetLeft(int value); // Defined below
bool HasTop() { return !!m_top; }
int GetTop(int defaultValue) const {
return m_top.value_or(defaultValue);
}
const std::optional<int>& GetTop() const {
return m_top;
}
void SetTop(int value); // Defined below
bool HasWidth() { return !!m_width; }
int GetWidth(int defaultValue) const {
return m_width.value_or(defaultValue);
}
const std::optional<int>& GetWidth() const {
return m_width;
}
void SetWidth(int value); // Defined below
bool HasHeight() { return !!m_height; }
int GetHeight(int defaultValue) const {
return m_height.value_or(defaultValue);
}
const std::optional<int>& GetHeight() const {
return m_height;
}
void SetHeight(int value); // Defined below
bool HasWindowState() { return !!m_windowState; }
String GetWindowState(const String& defaultValue) const {
return m_windowState.value_or(defaultValue);
}
const std::optional<String>& GetWindowState() const {
return m_windowState;
}
void SetWindowState(const String& value); // Defined below
template<int STATE>
class BoundsBuilder {
public:
enum {
NoFieldsSet = 0,
AllFieldsSet = (0)};
BoundsBuilder<STATE>& SetLeft(int value); // Defined below
BoundsBuilder<STATE>& SetTop(int value); // Defined below
BoundsBuilder<STATE>& SetWidth(int value); // Defined below
BoundsBuilder<STATE>& SetHeight(int value); // Defined below
BoundsBuilder<STATE>& SetWindowState(const String& value); // Defined below
std::unique_ptr<Bounds> Build()
{
static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
return std::move(m_result);
}
private:
friend class Bounds;
BoundsBuilder() : m_result(new Bounds()) { }
template<int STEP> BoundsBuilder<STATE | STEP>& castState()
{
return *reinterpret_cast<BoundsBuilder<STATE | STEP>*>(this);
}
std::unique_ptr<protocol::Browser::Bounds> m_result;
};
static BoundsBuilder<0> Create()
{
return BoundsBuilder<0>();
}
private:
DECLARE_SERIALIZATION_SUPPORT();
Bounds(); // Defined below
std::optional<int> m_left;
std::optional<int> m_top;
std::optional<int> m_width;
std::optional<int> m_height;
std::optional<String> m_windowState;
};
// ------------- 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 Bounds::~Bounds() = default;
inline void Bounds::SetLeft(int value) { m_left = value; }
inline void Bounds::SetTop(int value) { m_top = value; }
inline void Bounds::SetWidth(int value) { m_width = value; }
inline void Bounds::SetHeight(int value) { m_height = value; }
inline void Bounds::SetWindowState(const String& value) { m_windowState = value; }
template<int STATE>
inline Bounds::BoundsBuilder<STATE>& Bounds::BoundsBuilder<STATE>::SetLeft(int value) {
m_result->SetLeft(value);
return *this;
}
template<int STATE>
inline Bounds::BoundsBuilder<STATE>& Bounds::BoundsBuilder<STATE>::SetTop(int value) {
m_result->SetTop(value);
return *this;
}
template<int STATE>
inline Bounds::BoundsBuilder<STATE>& Bounds::BoundsBuilder<STATE>::SetWidth(int value) {
m_result->SetWidth(value);
return *this;
}
template<int STATE>
inline Bounds::BoundsBuilder<STATE>& Bounds::BoundsBuilder<STATE>::SetHeight(int value) {
m_result->SetHeight(value);
return *this;
}
template<int STATE>
inline Bounds::BoundsBuilder<STATE>& Bounds::BoundsBuilder<STATE>::SetWindowState(const String& value) {
m_result->SetWindowState(value);
return *this;
}
inline Bounds::Bounds() {
}
// ------------- Backend interface.
class Backend {
public:
virtual ~Backend() { }
virtual DispatchResponse GetWindowForTarget(std::optional<String> in_targetId, int* out_windowId, std::unique_ptr<protocol::Browser::Bounds>* out_bounds) = 0;
virtual DispatchResponse Disable()
{
return DispatchResponse::Success();
}
};
// ------------- Frontend interface.
class Frontend {
public:
explicit Frontend(FrontendChannel* frontend_channel) : frontend_channel_(frontend_channel) {}
void flush();
void sendRawNotification(std::unique_ptr<Serializable>);
private:
FrontendChannel* frontend_channel_;
};
// ------------- Dispatcher.
class Dispatcher {
public:
static void wire(UberDispatcher*, Backend*);
private:
Dispatcher() { }
};
// ------------- Metainfo.
class Metainfo {
public:
using BackendClass = Backend;
using FrontendClass = Frontend;
using DispatcherClass = Dispatcher;
static const char domainName[];
static const char commandPrefix[];
static const char version[];
};
} // namespace Browser
} // namespace content
} // namespace shell
} // namespace protocol
#endif // !defined(content_shell_protocol_Browser_h)