ltk_webkit/wpe/
privacy.rsuse std::ffi::{ c_char, CString };
use std::ptr;
use wpe_webkit_sys::*;
pub fn set_tracking_prevention( enabled: bool )
{
unsafe
{
let session = super::session::network_session();
if !session.is_null() { webkit_network_session_set_itp_enabled( session, enabled as glib_sys::gboolean ); }
}
}
pub fn set_third_party_cookies( allowed: bool )
{
let policy = if allowed { WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS } else { WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY };
unsafe
{
let session = super::session::network_session();
if session.is_null() { return; }
let cookies = webkit_network_session_get_cookie_manager( session );
if !cookies.is_null() { webkit_cookie_manager_set_accept_policy( cookies, policy ); }
}
}
pub fn set_preferred_languages( languages: &[ &str ] )
{
let owned: Vec<CString> = languages.iter().filter_map( |l| CString::new( *l ).ok() ).collect();
if owned.is_empty() { return; }
let mut list: Vec<*const c_char> = owned.iter().map( |l| l.as_ptr() ).collect();
list.push( ptr::null() );
unsafe
{
let context = super::context::web_context();
if !context.is_null() { webkit_web_context_set_preferred_languages( context, list.as_ptr() ); }
}
}