Skip to content

Truly independent web browser

1.2 KB
Raw Blame
/*
 * Copyright (c) 2021, Brandon Scott <[email protected]>
 * Copyright (c) 2020, Hunter Salyer <[email protected]>
 * Copyright (c) 2021-2022, Sam Atkins <[email protected]>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <LibJS/Console.h>
#include <LibJS/Forward.h>
#include <LibJS/Runtime/Value.h>
#include <LibWeb/Forward.h>
#include <LibWeb/HTML/Scripting/ConsoleInputCompletion.h>
#include <WebContent/Forward.h>

namespace WebContent {

class WebContentConsoleClient : public JS::ConsoleClient {
    GC_CELL(WebContentConsoleClient, JS::ConsoleClient);
    GC_DECLARE_ALLOCATOR(WebContentConsoleClient);

public:
    virtual ~WebContentConsoleClient() override;

    void handle_input(StringView js_source);
    Optional<Web::HTML::ConsoleInputCompletion> complete_input(StringView input);

    virtual void handle_result(JS::Value) = 0;

protected:
    WebContentConsoleClient(JS::Console&, PageClient&, ConsoleGlobalEnvironmentExtensions&);

    virtual void visit_edges(JS::Cell::Visitor&) override;

    GC::Ref<PageClient> m_client;
    GC::Ref<ConsoleGlobalEnvironmentExtensions> m_console_global_environment_extensions;
};

}