# Struct `kurogane::NewWindowRequest`

```rust
pub struct NewWindowRequest { /* private fields */ }
```

A page's request for a new window, passed to
[`App::on_new_window`](https://kurogane-rs.org/docs/api/app/app.md#method.on_new_window).

An application can make one to test its own hook:

```rust
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");
```

[crate::App::on_new_window]: https://kurogane-rs.org/docs/api/app/app.md#method.on_new_window

## Methods

### `new`

```rust
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`](https://kurogane-rs.org/docs/api/requests/newwindowrequest.md#method.with_kind) and
[`with_user_gesture`](https://kurogane-rs.org/docs/api/requests/newwindowrequest.md#method.with_user_gesture) say otherwise. The
origins are worked out as Kurogane works them out for a page's
request.

[Self::with_kind]: https://kurogane-rs.org/docs/api/requests/newwindowrequest.md#method.with_kind
[Self::with_user_gesture]: https://kurogane-rs.org/docs/api/requests/newwindowrequest.md#method.with_user_gesture

### `with_user_gesture`

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

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

### `with_kind`

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

This request, for a window of `kind`.

### `url`

```rust
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.

### `origin`

```rust
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.

### `opener_origin`

```rust
pub fn opener_origin(&self) -> &Origin
```

The origin of the page that asked.

### `user_gesture`

```rust
pub fn user_gesture(&self) -> bool
```

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

### `kind`

```rust
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

- `impl Clone for NewWindowRequest`
- `impl Debug for NewWindowRequest`

Source: https://github.com/0x48piraj/kurogane/blob/584c586118ee53cc04604007ee038557bd859092/kurogane/src/new_window.rs#L37
