summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML/History.h
blob: 5e78cc6bd99fd33eb2e747af756d12b3c31b3a42 (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
47
/*
 * Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/RefCounted.h>
#include <AK/Weakable.h>
#include <LibJS/Heap/Handle.h>
#include <LibWeb/Bindings/Wrappable.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/Forward.h>

namespace Web::HTML {

class History final
    : public RefCounted<History>
    , public Weakable<History>
    , public Bindings::Wrappable {
public:
    using WrapperType = Bindings::HistoryWrapper;

    static NonnullRefPtr<History> create(DOM::Document& document)
    {
        return adopt_ref(*new History(document));
    }

    virtual ~History() override;

    DOM::ExceptionOr<void> push_state(JS::Value data, String const& unused, String const& url);
    DOM::ExceptionOr<void> replace_state(JS::Value data, String const& unused, String const& url);

private:
    explicit History(DOM::Document&);

    enum class IsPush {
        No,
        Yes,
    };
    DOM::ExceptionOr<void> shared_history_push_replace_state(JS::Value data, String const& url, IsPush is_push);

    DOM::Document& m_associated_document;
};

}