summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Loader/FrameLoader.h
blob: ff6d23a7549a05103eddd65a656692da9d2fec84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/Forward.h>
#include <LibWeb/Forward.h>
#include <LibWeb/Loader/Resource.h>

namespace Web {

class FrameLoader final
    : public ResourceClient {
public:
    enum class Type {
        Navigation,
        Reload,
        IFrame,
    };

    explicit FrameLoader(Frame&);
    ~FrameLoader();

    bool load(const URL&, Type);
    bool load(const LoadRequest&, Type);

    void load_html(const StringView&, const URL&);

    Frame& frame() { return m_frame; }
    const Frame& frame() const { return m_frame; }

private:
    // ^ResourceClient
    virtual void resource_did_load() override;
    virtual void resource_did_fail() override;

    void load_error_page(const URL& failed_url, const String& error_message);
    bool parse_document(DOM::Document&, const ByteBuffer& data);

    Frame& m_frame;
};

}