FrameLoader.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Forward.h>
  8. #include <LibWeb/Forward.h>
  9. #include <LibWeb/Loader/Resource.h>
  10. namespace Web {
  11. constexpr size_t maximum_redirects_allowed = 20;
  12. class FrameLoader final
  13. : public ResourceClient {
  14. public:
  15. enum class Type {
  16. Navigation,
  17. Reload,
  18. IFrame,
  19. };
  20. explicit FrameLoader(HTML::BrowsingContext&);
  21. ~FrameLoader();
  22. bool load(const AK::URL&, Type);
  23. bool load(LoadRequest&, Type);
  24. void load_html(StringView, const AK::URL&);
  25. HTML::BrowsingContext& browsing_context() { return m_browsing_context; }
  26. HTML::BrowsingContext const& browsing_context() const { return m_browsing_context; }
  27. private:
  28. // ^ResourceClient
  29. virtual void resource_did_load() override;
  30. virtual void resource_did_fail() override;
  31. void load_error_page(const AK::URL& failed_url, const String& error_message);
  32. void load_favicon(RefPtr<Gfx::Bitmap> bitmap = nullptr);
  33. bool parse_document(DOM::Document&, const ByteBuffer& data);
  34. void store_response_cookies(AK::URL const& url, String const& cookies);
  35. HTML::BrowsingContext& m_browsing_context;
  36. size_t m_redirects_count { 0 };
  37. };
  38. }