1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// from webkit2gtk-gir-files
// DO NOT EDIT

use glib::object::IsA;
use glib::translate::*;
use std::fmt;

glib::wrapper! {
    /// A permission request.
    ///
    /// There are situations where an embedder would need to ask the user
    /// for permission to do certain types of operations, such as switching
    /// to fullscreen mode or reporting the user's location through the
    /// standard Geolocation API. In those cases, WebKit will emit a
    /// `signal::WebView::permission-request` signal with a
    /// [`PermissionRequest`][crate::PermissionRequest] object attached to it.
    ///
    /// # Implements
    ///
    /// [`PermissionRequestExt`][trait@crate::prelude::PermissionRequestExt]
    #[doc(alias = "WebKitPermissionRequest")]
    pub struct PermissionRequest(Interface<ffi::WebKitPermissionRequest, ffi::WebKitPermissionRequestIface>);

    match fn {
        type_ => || ffi::webkit_permission_request_get_type(),
    }
}

impl PermissionRequest {
    pub const NONE: Option<&'static PermissionRequest> = None;
}

/// Trait containing all [`struct@PermissionRequest`] methods.
///
/// # Implementors
///
/// [`DeviceInfoPermissionRequest`][struct@crate::DeviceInfoPermissionRequest], [`GeolocationPermissionRequest`][struct@crate::GeolocationPermissionRequest], [`InstallMissingMediaPluginsPermissionRequest`][struct@crate::InstallMissingMediaPluginsPermissionRequest], [`MediaKeySystemPermissionRequest`][struct@crate::MediaKeySystemPermissionRequest], [`NotificationPermissionRequest`][struct@crate::NotificationPermissionRequest], [`PermissionRequest`][struct@crate::PermissionRequest], [`PointerLockPermissionRequest`][struct@crate::PointerLockPermissionRequest], [`UserMediaPermissionRequest`][struct@crate::UserMediaPermissionRequest], [`WebsiteDataAccessPermissionRequest`][struct@crate::WebsiteDataAccessPermissionRequest]
pub trait PermissionRequestExt: 'static {
    /// Allow the action which triggered this request.
    #[doc(alias = "webkit_permission_request_allow")]
    fn allow(&self);

    /// Deny the action which triggered this request.
    #[doc(alias = "webkit_permission_request_deny")]
    fn deny(&self);
}

impl<O: IsA<PermissionRequest>> PermissionRequestExt for O {
    fn allow(&self) {
        unsafe {
            ffi::webkit_permission_request_allow(self.as_ref().to_glib_none().0);
        }
    }

    fn deny(&self) {
        unsafe {
            ffi::webkit_permission_request_deny(self.as_ref().to_glib_none().0);
        }
    }
}

impl fmt::Display for PermissionRequest {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("PermissionRequest")
    }
}