AbstractBrowsingContext.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibJS/Forward.h>
  8. #include <LibJS/Heap/Cell.h>
  9. #include <LibWeb/HTML/HistoryHandlingBehavior.h>
  10. #include <LibWeb/HTML/PolicyContainers.h>
  11. #include <LibWeb/HTML/WindowProxy.h>
  12. namespace Web::HTML {
  13. class AbstractBrowsingContext : public JS::Cell {
  14. JS_CELL(AbstractBrowsingContext, Cell);
  15. public:
  16. virtual HTML::WindowProxy* window_proxy() = 0;
  17. virtual HTML::WindowProxy const* window_proxy() const = 0;
  18. DeprecatedString const& name() const { return m_name; }
  19. void set_name(DeprecatedString const& name) { m_name = name; }
  20. JS::GCPtr<BrowsingContext> opener_browsing_context() const { return m_opener_browsing_context; }
  21. void set_opener_browsing_context(JS::GCPtr<BrowsingContext> browsing_context) { m_opener_browsing_context = browsing_context; }
  22. virtual WebIDL::ExceptionOr<void> navigate(
  23. JS::NonnullGCPtr<Fetch::Infrastructure::Request> resource,
  24. BrowsingContext& source_browsing_context,
  25. bool exceptions_enabled = false,
  26. HistoryHandlingBehavior history_handling = HistoryHandlingBehavior::Default,
  27. Optional<PolicyContainer> history_policy_container = {},
  28. DeprecatedString navigation_type = "other",
  29. Optional<DeprecatedString> navigation_id = {},
  30. Function<void(JS::NonnullGCPtr<Fetch::Infrastructure::Response>)> process_response_end_of_body = {})
  31. = 0;
  32. void set_is_popup(bool is_popup) { m_is_popup = is_popup; }
  33. virtual String const& window_handle() const = 0;
  34. virtual void set_window_handle(String handle) = 0;
  35. protected:
  36. DeprecatedString m_name;
  37. // https://html.spec.whatwg.org/multipage/browsers.html#is-popup
  38. bool m_is_popup { false };
  39. // https://html.spec.whatwg.org/multipage/browsers.html#opener-browsing-context
  40. JS::GCPtr<BrowsingContext> m_opener_browsing_context;
  41. };
  42. }