Menu

Struct

NewWindowRequest

kurogane::NewWindowRequestSource
pub struct NewWindowRequest { /* private fields */ }

A page’s request for a new window, passed to App::on_new_window.

An application can make one to test its own hook:

use kurogane::{NewWindowKind, NewWindowRequest};

let request = NewWindowRequest::new("https://docs.rs/", "app://app/index.html")
    .with_user_gesture(true)
    .with_kind(NewWindowKind::Popup);
assert_eq!(request.origin().to_string(), "https://docs.rs");
assert_eq!(request.opener_origin().to_string(), "app://app");

Methods

#pub fn new(url: impl Into<String>, opener_url: &str) -> Self

Creates the request of a page at opener_url for a window showing url. It is a tab a script asked for until with_kind and with_user_gesture say otherwise. The origins are worked out as Kurogane works them out for a page’s request.

#pub fn with_user_gesture(self, user_gesture: bool) -> Self

This request, asked for by the user (true) or by a script.

#pub fn with_kind(self, kind: NewWindowKind) -> Self

This request, for a window of kind.

#pub fn url(&self) -> &str

The URL the window would load, as Chromium resolved it. Empty or about:blank when the page fills the window in itself.

#pub fn origin(&self) -> &Origin

The origin of the document the window would show. A window the page fills in itself has the page’s origin. A blob: URL has the origin of the page that made it.

#pub fn opener_origin(&self) -> &Origin

The origin of the page that asked.

#pub fn user_gesture(&self) -> bool

Whether the user asked, by clicking a link or a button, rather than a script on its own.

#pub fn kind(&self) -> NewWindowKind

What the page asked for (a tab, a popup or a window). Kurogane opens each as an application window alike; the kind says how the page asked.

Trait implementations