2020-06-06 08:02:44 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-06-06 08:02:44 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <AK/Forward.h>
|
|
|
|
|
#include <LibWeb/Forward.h>
|
2020-06-06 08:38:08 -03:00
|
|
|
#include <LibWeb/Loader/Resource.h>
|
2020-06-06 08:02:44 -03:00
|
|
|
|
|
|
|
|
namespace Web {
|
|
|
|
|
|
2021-05-11 16:22:56 -03:00
|
|
|
constexpr size_t maximum_redirects_allowed = 20;
|
|
|
|
|
|
2020-06-06 08:38:08 -03:00
|
|
|
class FrameLoader final
|
|
|
|
|
: public ResourceClient {
|
2020-06-06 08:02:44 -03:00
|
|
|
public:
|
2020-07-07 12:25:33 -03:00
|
|
|
enum class Type {
|
|
|
|
|
Navigation,
|
|
|
|
|
Reload,
|
|
|
|
|
IFrame,
|
|
|
|
|
};
|
|
|
|
|
|
2022-04-03 11:36:28 -03:00
|
|
|
static void set_default_favicon_path(String);
|
2022-04-03 13:01:10 -03:00
|
|
|
static void set_error_page_url(String);
|
2022-04-03 11:36:28 -03:00
|
|
|
|
2021-11-18 11:01:28 -03:00
|
|
|
explicit FrameLoader(HTML::BrowsingContext&);
|
2020-06-06 08:02:44 -03:00
|
|
|
~FrameLoader();
|
|
|
|
|
|
2021-09-12 18:33:23 -03:00
|
|
|
bool load(const AK::URL&, Type);
|
2021-09-12 01:15:15 -03:00
|
|
|
bool load(LoadRequest&, Type);
|
2020-06-06 08:02:44 -03:00
|
|
|
|
2021-11-10 20:55:02 -03:00
|
|
|
void load_html(StringView, const AK::URL&);
|
2020-10-08 17:03:16 -03:00
|
|
|
|
2021-11-18 11:01:28 -03:00
|
|
|
HTML::BrowsingContext& browsing_context() { return m_browsing_context; }
|
|
|
|
|
HTML::BrowsingContext const& browsing_context() const { return m_browsing_context; }
|
2020-06-06 08:02:44 -03:00
|
|
|
|
|
|
|
|
private:
|
2020-06-06 08:38:08 -03:00
|
|
|
// ^ResourceClient
|
|
|
|
|
virtual void resource_did_load() override;
|
|
|
|
|
virtual void resource_did_fail() override;
|
|
|
|
|
|
2022-04-01 14:58:27 -03:00
|
|
|
void load_error_page(const AK::URL& failed_url, String const& error_message);
|
2021-08-06 17:28:22 -03:00
|
|
|
void load_favicon(RefPtr<Gfx::Bitmap> bitmap = nullptr);
|
2022-04-01 14:58:27 -03:00
|
|
|
bool parse_document(DOM::Document&, ByteBuffer const& data);
|
2020-06-06 08:02:44 -03:00
|
|
|
|
2022-02-12 11:02:56 -03:00
|
|
|
void store_response_cookies(AK::URL const& url, String const& cookies);
|
|
|
|
|
|
2021-11-18 11:01:28 -03:00
|
|
|
HTML::BrowsingContext& m_browsing_context;
|
2021-05-11 16:22:56 -03:00
|
|
|
size_t m_redirects_count { 0 };
|
2020-06-06 08:02:44 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|