summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML/AbstractBrowsingContext.h
blob: cf284234d91a3199c98c5e2ba3a2e1cee5172984 (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
48
49
50
51
52
53
54
55
56
57
/*
 * Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <LibJS/Forward.h>
#include <LibJS/Heap/Cell.h>
#include <LibWeb/HTML/HistoryHandlingBehavior.h>
#include <LibWeb/HTML/PolicyContainers.h>
#include <LibWeb/HTML/TokenizedFeatures.h>
#include <LibWeb/HTML/WindowProxy.h>

namespace Web::HTML {

class AbstractBrowsingContext : public JS::Cell {
    JS_CELL(AbstractBrowsingContext, Cell);

public:
    virtual HTML::WindowProxy* window_proxy() = 0;
    virtual HTML::WindowProxy const* window_proxy() const = 0;

    String const& name() const { return m_name; }
    void set_name(String const& name) { m_name = name; }

    JS::GCPtr<BrowsingContext> opener_browsing_context() const { return m_opener_browsing_context; }
    void set_opener_browsing_context(JS::GCPtr<BrowsingContext> browsing_context) { m_opener_browsing_context = browsing_context; }

    virtual WebIDL::ExceptionOr<void> navigate(
        JS::NonnullGCPtr<Fetch::Infrastructure::Request> resource,
        BrowsingContext& source_browsing_context,
        bool exceptions_enabled = false,
        HistoryHandlingBehavior history_handling = HistoryHandlingBehavior::Default,
        Optional<PolicyContainer> history_policy_container = {},
        DeprecatedString navigation_type = "other",
        Optional<String> navigation_id = {},
        Function<void(JS::NonnullGCPtr<Fetch::Infrastructure::Response>)> process_response_end_of_body = {})
        = 0;

    void set_is_popup(TokenizedFeature::Popup is_popup) { m_is_popup = is_popup; }

    virtual String const& window_handle() const = 0;
    virtual void set_window_handle(String handle) = 0;

protected:
    String m_name;

    // https://html.spec.whatwg.org/multipage/browsers.html#is-popup
    TokenizedFeature::Popup m_is_popup { TokenizedFeature::Popup::No };

    // https://html.spec.whatwg.org/multipage/browsers.html#opener-browsing-context
    JS::GCPtr<BrowsingContext> m_opener_browsing_context;
};

}