#pragma once
#include "APIObject.h"
#include "Connection.h"
#include "MessageReceiver.h"
#include <WebCore/FrameIdentifier.h>
#include <WebCore/InspectorClient.h>
#include <wtf/Noncopyable.h>
#include <wtf/text/WTFString.h>
namespace WebKit {
class WebPage;
class WebInspector : public API::ObjectImpl<API::Object::Type::BundleInspector>, private IPC::Connection::Client {
public:
static Ref<WebInspector> create(WebPage*);
WebPage* page() const { return m_page; }
void updateDockingAvailability();
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
void didClose(IPC::Connection&) override { close(); }
void didReceiveInvalidMessage(IPC::Connection&, IPC::MessageName) override { close(); }
void show();
void close();
void openInNewTab(const String& urlString);
void canAttachWindow(bool& result);
void showConsole();
void showResources();
void showMainResourceForFrame(WebCore::FrameIdentifier);
void setAttached(bool attached) { m_attached = attached; }
void evaluateScriptForTest(const String& script);
void startPageProfiling();
void stopPageProfiling();
void startElementSelection();
void stopElementSelection();
void elementSelectionChanged(bool);
void timelineRecordingChanged(bool);
void setDeveloperPreferenceOverride(WebCore::InspectorClient::DeveloperPreference, Optional<bool>);
void setFrontendConnection(IPC::Attachment);
void disconnectFromPage() { close(); }
private:
friend class WebInspectorClient;
explicit WebInspector(WebPage*);
virtual ~WebInspector();
bool canAttachWindow();
void openLocalInspectorFrontend(bool underTest);
void closeFrontendConnection();
void bringToFront();
void whenFrontendConnectionEstablished(Function<void()>&&);
WebPage* m_page;
RefPtr<IPC::Connection> m_frontendConnection;
Vector<Function<void()>> m_frontendConnectionActions;
bool m_attached { false };
bool m_previousCanAttach { false };
};
}