Serenity Operating System
1/*
2 * Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
3 * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
4 *
5 * SPDX-License-Identifier: BSD-2-Clause
6 */
7
8#pragma once
9
10#include <LibWeb/Bindings/PlatformObject.h>
11#include <LibWeb/WebIDL/ExceptionOr.h>
12
13namespace Web::HTML {
14
15class History final : public Bindings::PlatformObject {
16 WEB_PLATFORM_OBJECT(History, Bindings::PlatformObject);
17
18public:
19 static WebIDL::ExceptionOr<JS::NonnullGCPtr<History>> create(JS::Realm&, DOM::Document&);
20
21 virtual ~History() override;
22
23 WebIDL::ExceptionOr<void> push_state(JS::Value data, DeprecatedString const& unused, DeprecatedString const& url);
24 WebIDL::ExceptionOr<void> replace_state(JS::Value data, DeprecatedString const& unused, DeprecatedString const& url);
25 WebIDL::ExceptionOr<void> go(long delta);
26 WebIDL::ExceptionOr<void> back();
27 WebIDL::ExceptionOr<void> forward();
28 WebIDL::ExceptionOr<u64> length() const;
29
30private:
31 History(JS::Realm&, DOM::Document&);
32
33 virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
34 virtual void visit_edges(Cell::Visitor&) override;
35
36 enum class IsPush {
37 No,
38 Yes,
39 };
40 WebIDL::ExceptionOr<void> shared_history_push_replace_state(JS::Value data, DeprecatedString const& url, IsPush is_push);
41
42 JS::NonnullGCPtr<DOM::Document> m_associated_document;
43};
44
45}