< 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`).
 2121        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.
 4226        fn qt_cookies_set(
 4227            webview_ptr: u64,
 4228            name: &str,
 4229            value: &str,
 4230            domain: &str,
 4231            path: &str,
 4232            secure: bool,
 4233            http_only: bool,
 4234            same_site: i32,
 4235            expires_ms: i64,
 4236        );
 37
 38        /// Deletes a cookie from the store.
 2139        fn qt_cookies_delete(webview_ptr: u64, name: &str, domain: &str, path: &str);
 40
 41        /// Deletes every cookie of the profile.
 2142        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.
 8466pub fn qt_on_cookie_added(
 8467    webview_ptr: u64,
 8468    name: &str,
 8469    value: &str,
 8470    domain: &str,
 8471    path: &str,
 8472    secure: bool,
 8473    http_only: bool,
 8474    same_site: i32,
 8475    expires_ms: i64,
 8476) {
 8477    crate::ops::cookies::on_cookie_added(
 8478        webview_ptr,
 8479        name,
 8480        value,
 8481        domain,
 8482        path,
 8483        secure,
 8484        http_only,
 8485        same_site,
 8486        expires_ms,
 87    );
 8488}
 89
 90/// Defined in the same module as the bridge, as cxx requires.
 8491pub fn qt_on_cookie_removed(webview_ptr: u64, name: &str, domain: &str, path: &str) {
 8492    crate::ops::cookies::on_cookie_removed(webview_ptr, name, domain, path);
 8493}