ladybird/Services/WebContent/WebContentServer.ipc
Luke Wilde 8dc8835b64 LibWeb+LibWebView+WebContent: Allow muted media to autoplay by default
The autoplay setting was binary and its default blocked all media,
including muted video, leaving sites that rely on muted autoplay
visibly broken. Replace it with a tri-state user-agent autoplay
policy (allow audio and video, block audio, or block audio and video)
defaulting to allowing only inaudible media to autoplay.

This is enforced through the media element's "allowed to play" check,
so unmuting a muted autoplay or calling `play()` cannot slip audio
past the policy; audible playback is permitted once the document has
been activated by the user. The policy lives in a dedicated
AutoplaySettings consulted from HTMLMediaElement instead of the
Permissions Policy "allowed to use feature" check it was previously
conflated with.
2026-06-19 09:41:32 +02:00

192 lines
10 KiB
Text

#include <LibCore/SharedVersion.h>
#include <LibGfx/Rect.h>
#include <LibHTTP/Cookie/Cookie.h>
#include <LibIPC/File.h>
#include <LibIPC/TransportHandle.h>
#include <LibURL/URL.h>
#include <LibWeb/Bindings/Navigation.h>
#include <LibWeb/Clipboard/SystemClipboard.h>
#include <LibWeb/CSS/PreferredColorScheme.h>
#include <LibWeb/CSS/PreferredContrast.h>
#include <LibWeb/CSS/PreferredMotion.h>
#include <LibWeb/CSS/Selector.h>
#include <LibWeb/CSS/StyleSheetIdentifier.h>
#include <LibWeb/HTML/AutoplayPolicy.h>
#include <LibWeb/HTML/ColorPickerUpdateState.h>
#include <LibWeb/HTML/BroadcastChannelMessage.h>
#include <LibWeb/HTML/SelectedFile.h>
#include <LibWeb/HTML/SessionHistoryEntry.h>
#include <LibWeb/HTML/VisibilityState.h>
#include <LibWeb/HTML/WorkerAgentTypes.h>
#include <LibWeb/Page/InputEvent.h>
#include <LibWeb/StorageAPI/StorageEndpoint.h>
#include <LibWeb/Page/ViewportIsFullscreen.h>
#include <LibWeb/WebDriver/ExecuteScript.h>
#include <LibWeb/WebDriver/Response.h>
#include <LibWebView/Attribute.h>
#include <LibWebView/DOMNodeProperties.h>
#include <LibWebView/PageInfo.h>
#include <LibWebView/Settings.h>
#include <LibWebView/StorageSetResult.h>
endpoint WebContentServer
{
init_transport(int peer_pid) => (int peer_pid)
initialize(u64 initial_page_id) =|
close_server() =|
get_window_handle(u64 page_id) => (String handle)
set_window_handle(u64 page_id, String handle) =|
connect_to_webdriver(u64 page_id, ByteString webdriver_endpoint) =|
complete_webdriver_history_traversal(u64 page_id, u64 request_id, bool accepted, bool will_replace_web_content_process, bool will_change_top_level_entry) =|
complete_webdriver_navigation_completion(u64 page_id, u64 request_id, Web::WebDriver::Response response) =|
connect_to_web_ui(u64 page_id, IPC::TransportHandle handle) =|
connect_to_request_server(IPC::TransportHandle handle) =|
connect_to_image_decoder(IPC::TransportHandle handle) =|
connect_to_compositor_process(IPC::TransportHandle handle) =|
compositor_process_reconnected() =|
update_system_theme(u64 page_id, Core::AnonymousBuffer theme_buffer) =|
update_screen_rects(u64 page_id, Vector<Web::DevicePixelRect> rects, u32 main_screen_index) =|
load_url(u64 page_id, URL::URL url, Web::Bindings::NavigationHistoryBehavior history_handling) =|
load_url_with_document_resource(u64 page_id, URL::URL url,
Variant<Empty, String, Web::HTML::POSTResource> document_resource,
Web::Bindings::NavigationHistoryBehavior history_handling) =|
load_html(u64 page_id, ByteString html) =|
load_html_with_url(u64 page_id, ByteString html, URL::URL url) =|
reload(u64 page_id) =|
traverse_the_history_by_delta(u64 page_id, i32 delta) =|
traverse_the_history_to_step(u64 page_id, i32 step) =|
check_if_traverse_history_step_is_canceled(u64 page_id, u64 request_id, i32 step) =|
set_top_level_session_history(u64 page_id, Vector<Web::HTML::SessionHistoryEntryDescriptor> entries,
size_t current_top_level_entry_index, bool allow_reconstructing_current_entry) =|
reset_session_history_for_testing(u64 page_id) =|
set_viewport(u64 page_id, Web::DevicePixelSize size, double device_pixel_ratio, Web::ViewportIsFullscreen is_fullscreen) =|
key_event(u64 page_id, Web::KeyEvent event) =|
mouse_event(u64 page_id, Web::MouseEvent event) =|
drag_event(u64 page_id, Web::DragEvent event) =|
pinch_event(u64 page_id, Web::PinchEvent event) =|
debug_request(u64 page_id, ByteString request, ByteString argument) =|
get_source(u64 page_id) =|
inspect_dom_tree(u64 page_id) =|
inspect_storage(u64 page_id, Web::StorageAPI::StorageEndpointType storage_endpoint, u64 request_id) =|
set_session_storage_item(u64 page_id, String key, String value) => (Optional<WebView::StorageSetResult> result)
remove_session_storage_item(u64 page_id, String key) => (Optional<String> old_value)
clear_session_storage(u64 page_id) => (bool did_clear)
inspect_dom_node(u64 page_id, WebView::DOMNodeProperties::Type property_type, Web::UniqueNodeID node_id, Optional<Web::CSS::PseudoElement> pseudo_element, JsonValue options) =|
inspect_grid_layouts(u64 page_id, Web::UniqueNodeID root_node_id) =|
inspect_current_grid(u64 page_id, Web::UniqueNodeID node_id) =|
inspect_current_flexbox(u64 page_id, Web::UniqueNodeID node_id, bool only_look_at_parents) =|
clear_inspected_dom_node(u64 page_id) =|
highlight_dom_node(u64 page_id, Web::UniqueNodeID node_id, Optional<Web::CSS::PseudoElement> pseudo_element) =|
highlight_flexbox(u64 page_id, Web::UniqueNodeID node_id, JsonValue options) =|
clear_flexbox_highlight(u64 page_id, Web::UniqueNodeID node_id) =|
highlight_grid(u64 page_id, Web::UniqueNodeID node_id, JsonValue options) =|
clear_grid_highlight(u64 page_id, Web::UniqueNodeID node_id) =|
inspect_accessibility_tree(u64 page_id) =|
get_hovered_node_id(u64 page_id) =|
get_node_id_at_position(u64 page_id, u64 request_id, Web::DevicePixelPoint position) =|
js_console_input(u64 page_id, String js_source) =|
run_javascript(u64 page_id, String js_source) =|
list_style_sheets(u64 page_id) =|
request_style_sheet_source(u64 page_id, Web::CSS::StyleSheetIdentifier identifier) =|
set_listen_for_dom_mutations(u64 page_id, bool listen_for_dom_mutations) =|
did_connect_devtools_client(u64 page_id) =|
did_disconnect_devtools_client(u64 page_id) =|
get_dom_node_inner_html(u64 page_id, Web::UniqueNodeID node_id) =|
get_dom_node_outer_html(u64 page_id, Web::UniqueNodeID node_id) =|
set_dom_node_outer_html(u64 page_id, Web::UniqueNodeID node_id, String html) =|
set_dom_node_text(u64 page_id, Web::UniqueNodeID node_id, String text) =|
set_dom_node_tag(u64 page_id, Web::UniqueNodeID node_id, String name) =|
add_dom_node_attributes(u64 page_id, Web::UniqueNodeID node_id, Vector<WebView::Attribute> attributes) =|
replace_dom_node_attribute(u64 page_id, Web::UniqueNodeID node_id, String name, Vector<WebView::Attribute> replacement_attributes) =|
create_child_element(u64 page_id, Web::UniqueNodeID node_id) =|
create_child_text_node(u64 page_id, Web::UniqueNodeID node_id) =|
insert_dom_node_before(u64 page_id, Web::UniqueNodeID node_id, Web::UniqueNodeID parent_node_id, Optional<Web::UniqueNodeID> sibling_node_id) =|
clone_dom_node(u64 page_id, Web::UniqueNodeID node_id) =|
remove_dom_node(u64 page_id, Web::UniqueNodeID node_id) =|
take_document_screenshot(u64 page_id) =|
take_dom_node_screenshot(u64 page_id, Web::UniqueNodeID node_id) =|
request_internal_page_info(u64 page_id, WebView::PageInfoType type) =|
get_selected_text(u64 page_id) => (ByteString selection)
cut_selected_text(u64 page_id) => (ByteString selection)
select_all(u64 page_id) =|
paste(u64 page_id, Utf16String text) =|
set_marked_text_from_input_method(u64 page_id, Utf16String text) =|
commit_text_from_input_method(u64 page_id, Utf16String text) =|
unmark_text_from_input_method(u64 page_id) =|
find_in_page(u64 page_id, String query, AK::CaseSensitivity case_sensitivity) =|
find_in_page_next_match(u64 page_id) =|
find_in_page_previous_match(u64 page_id) =|
set_content_blockers(u64 page_id, Core::AnonymousBuffer patterns) =|
set_autoplay_settings(u64 page_id, Web::HTML::AutoplayPolicy policy, Vector<String> allowlist) =|
set_proxy_mappings(u64 page_id, Vector<ByteString> proxies, HashMap<ByteString, size_t> mappings) =|
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_preferred_languages(u64 page_id, Vector<String> preferred_languages) =|
set_browsing_behavior(u64 page_id, WebView::BrowsingBehavior browsing_behavior) =|
set_enable_global_privacy_control(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_zoom_level(u64 page_id, double zoom_level) =|
set_maximum_frames_per_second(u64 page_id, double maximum_frames_per_second) =|
set_window_position(u64 page_id, Web::DevicePixelPoint position) =|
set_window_size(u64 page_id, Web::DevicePixelSize size) =|
did_update_window_rect(u64 page_id) =|
reset_zoom(u64 page_id) =|
handle_file_return(u64 page_id, i32 error, Optional<IPC::File> file, i32 request_id) =|
did_delete_all_cookies(u64 page_id, u64 request_id) =|
set_system_visibility_state(u64 page_id, Web::HTML::VisibilityState visibility_state) =|
alert_closed(u64 page_id) =|
confirm_closed(u64 page_id, bool accepted) =|
prompt_closed(u64 page_id, Optional<String> response) =|
color_picker_update(u64 page_id, Optional<Color> picked_color, Web::HTML::ColorPickerUpdateState state) =|
file_picker_closed(u64 page_id, Vector<Web::HTML::SelectedFile> selected_files) =|
select_dropdown_closed(u64 page_id, Optional<u32> selected_item_id) =|
retrieved_clipboard_entries(u64 page_id, u64 request_id, Vector<Web::Clipboard::SystemClipboardItem> items) =|
toggle_media_play_state(u64 page_id) =|
toggle_media_mute_state(u64 page_id) =|
toggle_media_loop_state(u64 page_id) =|
toggle_media_fullscreen_state(u64 page_id) =|
toggle_media_controls_state(u64 page_id) =|
toggle_page_mute_state(u64 page_id) =|
set_user_style(u64 page_id, String source) =|
system_time_zone_changed() =|
set_document_cookie_version_buffer(u64 page_id, Core::AnonymousBuffer document_cookie_version_buffer) =|
set_document_cookie_version_index(u64 page_id, i64 document_id, Core::SharedVersionIndex document_index) =|
cookies_changed(u64 page_id, Vector<HTTP::Cookie::Cookie> cookies) =|
broadcast_channel_message(Web::HTML::BroadcastChannelMessage message) =|
did_worker_agent_finish_loading_script(Web::HTML::WorkerAgentOwnerToken owner_token) =|
did_worker_agent_fail_loading_script(Web::HTML::WorkerAgentOwnerToken owner_token) =|
did_worker_agent_report_exception(Web::HTML::WorkerAgentOwnerToken owner_token, String message, String filename, u32 lineno, u32 colno) =|
did_worker_agent_close(Web::HTML::WorkerAgentOwnerToken owner_token) =|
request_close(u64 page_id) =|
exit_fullscreen(u64 page_id) =|
}