< Summary

Information
Class: /home/runner/work/TauriQt/TauriQt/tauri-runtime-qt/src/bridge/cookies.rs
Assembly: Default
File(s): /home/runner/work/TauriQt/TauriQt/tauri-runtime-qt/src/bridge/cookies.rs
Line coverage
100%
Covered lines: 39
Uncovered lines: 0
Coverable lines: 39
Total lines: 93
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

File(s)

/home/runner/work/TauriQt/TauriQt/tauri-runtime-qt/src/bridge/cookies.rs

#LineLine coverage
 1// SPDX-FileCopyrightText: 2026 Alper Çelik
 2// SPDX-License-Identifier: MIT OR Apache-2.0
 3
 4//! Cookie declarations (owned by the cookies worker).
 5//!
 6//! The runtime keeps its own copy of the profile's cookies: Qt's
 7//! `QWebEngineCookieStore` can only enumerate asynchronously and never signals
 8//! completion, so instead of blocking we mirror the store from its
 9//! `cookieAdded` / `cookieRemoved` signals and answer reads from that copy.
 10//!
 11//! C++ translation units include the cxx-generated header for this bridge:
 12//! `#include "tauri-runtime-qt/src/bridge/cookies.rs.h"`.
 13
 14#[cxx::bridge]
 15pub mod ffi {
 16    unsafe extern "C++" {
 17        include!("qt_cookies.hpp");
 18
 19        /// Starts mirroring the cookie store of the webview behind this handle
 20        /// (the `QWebEngineView*` value returned by `qt_webview_native_handle`).
 2021        fn qt_cookies_watch(webview_ptr: u64);
 22
 23        /// Adds a cookie to the store (`QWebEngineCookieStore::setCookie`).
 24        /// `expires_ms` is Unix epoch milliseconds, or -1 for a session cookie.
 25        /// `same_site`: 0 = default/unset, 1 = none, 2 = lax, 3 = strict.
 4026        fn qt_cookies_set(
 4027            webview_ptr: u64,
 4028            name: &str,
 4029            value: &str,
 4030            domain: &str,
 4031            path: &str,
 4032            secure: bool,
 4033            http_only: bool,
 4034            same_site: i32,
 4035            expires_ms: i64,
 4036        );
 37
 38        /// Deletes a cookie from the store.
 2039        fn qt_cookies_delete(webview_ptr: u64, name: &str, domain: &str, path: &str);
 40
 41        /// Deletes every cookie of the profile.
 2042        fn qt_cookies_clear_all(webview_ptr: u64);
 43    }
 44
 45    extern "Rust" {
 46        /// A cookie entered the store (including the initial load).
 47        #[allow(clippy::too_many_arguments)]
 48        fn qt_on_cookie_added(
 49            webview_ptr: u64,
 50            name: &str,
 51            value: &str,
 52            domain: &str,
 53            path: &str,
 54            secure: bool,
 55            http_only: bool,
 56            same_site: i32,
 57            expires_ms: i64,
 58        );
 59
 60        /// A cookie left the store.
 61        fn qt_on_cookie_removed(webview_ptr: u64, name: &str, domain: &str, path: &str);
 62    }
 63}
 64
 65/// Defined in the same module as the bridge, as cxx requires.
 8066pub fn qt_on_cookie_added(
 8067    webview_ptr: u64,
 8068    name: &str,
 8069    value: &str,
 8070    domain: &str,
 8071    path: &str,
 8072    secure: bool,
 8073    http_only: bool,
 8074    same_site: i32,
 8075    expires_ms: i64,
 8076) {
 8077    crate::ops::cookies::on_cookie_added(
 8078        webview_ptr,
 8079        name,
 8080        value,
 8081        domain,
 8082        path,
 8083        secure,
 8084        http_only,
 8085        same_site,
 8086        expires_ms,
 87    );
 8088}
 89
 90/// Defined in the same module as the bridge, as cxx requires.
 8091pub fn qt_on_cookie_removed(webview_ptr: u64, name: &str, domain: &str, path: &str) {
 8092    crate::ops::cookies::on_cookie_removed(webview_ptr, name, domain, path);
 8093}