Menu

Struct

PermissionResponder

kurogane::PermissionResponderSource
pub struct PermissionResponder { /* private fields */ }

Answers a PermissionRequest the hook left for later (PermissionDecision::Later), from any thread.

A request is answered once; the first answer counts. Dropping every responder of a request without answering denies it. An answer that comes after the page went away grants nothing.

App::new("./dist")
    .on_permission(|request, _| {
        let question = format!("Allow {:?} for {}?", request.permissions(), request.origin());
        let responder = request.responder();
        std::thread::spawn(move || {
            if ask_the_user(&question) {
                responder.allow();
            } else {
                responder.deny();
            }
        });
        PermissionDecision::Later
    })
    .run_or_exit();

Methods

#pub fn allow(self)

Grants everything the request asks for.

#pub fn deny(self)

Grants nothing.

Trait implementations