mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
LibWeb: Support sending DNT header with requests
This commit is contained in:
parent
830b287c46
commit
fb20326979
Notes:
sideshowbarker
2024-07-17 07:14:09 +09:00
Author: https://github.com/jamierocks Commit: https://github.com/LadybirdBrowser/ladybird/commit/fb20326979 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/373 Reviewed-by: https://github.com/trflynn89
7 changed files with 22 additions and 0 deletions
|
@ -1689,6 +1689,10 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_network_or_cache_fet
|
|||
// NOTE: `Accept` and `Accept-Language` are already included (unless fetch() is used, which does not include
|
||||
// the latter by default), and `Accept-Charset` is a waste of bytes. See HTTP header layer division for
|
||||
// more details.
|
||||
if (ResourceLoader::the().enable_do_not_track() && !http_request->header_list()->contains("DNT"sv.bytes())) {
|
||||
auto header = Infrastructure::Header::from_string_pair("DNT"sv, "1"sv);
|
||||
http_request->header_list()->append(move(header));
|
||||
}
|
||||
|
||||
// 21. If includeCredentials is true, then:
|
||||
if (include_credentials == IncludeCredentials::Yes) {
|
||||
|
|
|
@ -99,6 +99,9 @@ public:
|
|||
String const& platform() const { return m_platform; }
|
||||
void set_platform(String platform) { m_platform = move(platform); }
|
||||
|
||||
bool enable_do_not_track() const { return m_enable_do_not_track; }
|
||||
void set_enable_do_not_track(bool enable) { m_enable_do_not_track = enable; }
|
||||
|
||||
void clear_cache();
|
||||
void evict_from_cache(LoadRequest const&);
|
||||
|
||||
|
@ -116,6 +119,7 @@ private:
|
|||
NonnullRefPtr<ResourceLoaderConnector> m_connector;
|
||||
String m_user_agent;
|
||||
String m_platform;
|
||||
bool m_enable_do_not_track { false };
|
||||
Optional<JS::GCPtr<Page>> m_page {};
|
||||
};
|
||||
|
||||
|
|
|
@ -169,6 +169,11 @@ void ViewImplementation::set_preferred_motion(Web::CSS::PreferredMotion motion)
|
|||
client().async_set_preferred_motion(page_id(), motion);
|
||||
}
|
||||
|
||||
void ViewImplementation::set_enable_do_not_track(bool enable)
|
||||
{
|
||||
client().async_set_enable_do_not_track(page_id(), enable);
|
||||
}
|
||||
|
||||
ByteString ViewImplementation::selected_text()
|
||||
{
|
||||
return client().get_selected_text(page_id());
|
||||
|
|
|
@ -66,6 +66,8 @@ public:
|
|||
void set_preferred_contrast(Web::CSS::PreferredContrast);
|
||||
void set_preferred_motion(Web::CSS::PreferredMotion);
|
||||
|
||||
void set_enable_do_not_track(bool);
|
||||
|
||||
ByteString selected_text();
|
||||
Optional<String> selected_text_with_whitespace_collapsed();
|
||||
void select_all();
|
||||
|
|
|
@ -928,6 +928,11 @@ void ConnectionFromClient::set_preferred_motion(u64 page_id, Web::CSS::Preferred
|
|||
page->set_preferred_motion(motion);
|
||||
}
|
||||
|
||||
void ConnectionFromClient::set_enable_do_not_track(u64, bool enable)
|
||||
{
|
||||
Web::ResourceLoader::the().set_enable_do_not_track(enable);
|
||||
}
|
||||
|
||||
void ConnectionFromClient::set_has_focus(u64 page_id, bool has_focus)
|
||||
{
|
||||
if (auto page = this->page(page_id); page.has_value())
|
||||
|
|
|
@ -95,6 +95,7 @@ private:
|
|||
virtual void set_preferred_color_scheme(u64 page_id, Web::CSS::PreferredColorScheme const&) override;
|
||||
virtual void set_preferred_contrast(u64 page_id, Web::CSS::PreferredContrast const&) override;
|
||||
virtual void set_preferred_motion(u64 page_id, Web::CSS::PreferredMotion const&) override;
|
||||
virtual void set_enable_do_not_track(u64 page_id, bool) override;
|
||||
virtual void set_has_focus(u64 page_id, bool) override;
|
||||
virtual void set_is_scripting_enabled(u64 page_id, bool) override;
|
||||
virtual void set_device_pixels_per_css_pixel(u64 page_id, float) override;
|
||||
|
|
|
@ -81,6 +81,7 @@ endpoint WebContentServer
|
|||
set_preferred_color_scheme(u64 page_id, Web::CSS::PreferredColorScheme color_scheme) =|
|
||||
set_preferred_contrast(u64 page_id, Web::CSS::PreferredContrast contrast) =|
|
||||
set_preferred_motion(u64 page_id, Web::CSS::PreferredMotion motion) =|
|
||||
set_enable_do_not_track(u64 page_id, bool enable) =|
|
||||
set_has_focus(u64 page_id, bool has_focus) =|
|
||||
set_is_scripting_enabled(u64 page_id, bool is_scripting_enabled) =|
|
||||
set_device_pixels_per_css_pixel(u64 page_id, float device_pixels_per_css_pixel) =|
|
||||
|
|
Loading…
Reference in a new issue