AbstractBrowsingContext.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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/TokenizedFeatures.h>
  12. #include <LibWeb/HTML/WindowProxy.h>
  13. namespace Web::HTML {
  14. class AbstractBrowsingContext : public JS::Cell {
  15. JS_CELL(AbstractBrowsingContext, Cell);
  16. public:
  17. virtual HTML::WindowProxy* window_proxy() = 0;
  18. virtual HTML::WindowProxy const* window_proxy() const = 0;
  19. String const& name() const { return m_name; }
  20. void set_name(String const& name) { m_name = name; }
  21. JS::GCPtr<BrowsingContext> opener_browsing_context() const { return m_opener_browsing_context; }
  22. void set_opener_browsing_context(JS::GCPtr<BrowsingContext> browsing_context) { m_opener_browsing_context = browsing_context; }
  23. virtual WebIDL::ExceptionOr<void> navigate(
  24. JS::NonnullGCPtr<Fetch::Infrastructure::Request> resource,
  25. BrowsingContext& source_browsing_context,
  26. bool exceptions_enabled = false,
  27. HistoryHandlingBehavior history_handling = HistoryHandlingBehavior::Default,
  28. Optional<PolicyContainer> history_policy_container = {},
  29. DeprecatedString navigation_type = "other",
  30. Optional<String> navigation_id = {},
  31. Function<void(JS::NonnullGCPtr<Fetch::Infrastructure::Response>)> process_response_end_of_body = {})
  32. = 0;
  33. void set_is_popup(TokenizedFeature::Popup is_popup) { m_is_popup = is_popup; }
  34. virtual String const& window_handle() const = 0;
  35. virtual void set_window_handle(String handle) = 0;
  36. protected:
  37. String m_name;
  38. // https://html.spec.whatwg.org/multipage/browsers.html#is-popup
  39. TokenizedFeature::Popup m_is_popup { TokenizedFeature::Popup::No };
  40. // https://html.spec.whatwg.org/multipage/browsers.html#opener-browsing-context
  41. JS::GCPtr<BrowsingContext> m_opener_browsing_context;
  42. };
  43. }