webkit6/auto/policy_decision.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from webkit-gir-files
4// DO NOT EDIT
5
6use crate::{WebsitePolicies, ffi};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10 /// A pending policy decision.
11 ///
12 /// Often WebKit allows the client to decide the policy for certain
13 /// operations. For instance, a client may want to open a link in a new
14 /// tab, block a navigation entirely, query the user or trigger a download
15 /// instead of a navigation. In these cases WebKit will fire the
16 /// [`decide-policy`][struct@crate::WebView#decide-policy] signal with a [`PolicyDecision`][crate::PolicyDecision]
17 /// object. If the signal handler does nothing, WebKit will act as if
18 /// [`PolicyDecisionExt::use_()`][crate::prelude::PolicyDecisionExt::use_()] was called as soon as signal handling
19 /// completes. To make a policy decision asynchronously, simply increment
20 /// the reference count of the [`PolicyDecision`][crate::PolicyDecision] object.
21 ///
22 /// This is an Abstract Base Class, you cannot instantiate it.
23 ///
24 /// # Implements
25 ///
26 /// [`PolicyDecisionExt`][trait@crate::prelude::PolicyDecisionExt]
27 #[doc(alias = "WebKitPolicyDecision")]
28 pub struct PolicyDecision(Object<ffi::WebKitPolicyDecision, ffi::WebKitPolicyDecisionClass>);
29
30 match fn {
31 type_ => || ffi::webkit_policy_decision_get_type(),
32 }
33}
34
35impl PolicyDecision {
36 pub const NONE: Option<&'static PolicyDecision> = None;
37}
38
39/// Trait containing all [`struct@PolicyDecision`] methods.
40///
41/// # Implementors
42///
43/// [`NavigationPolicyDecision`][struct@crate::NavigationPolicyDecision], [`PolicyDecision`][struct@crate::PolicyDecision], [`ResponsePolicyDecision`][struct@crate::ResponsePolicyDecision]
44pub trait PolicyDecisionExt: IsA<PolicyDecision> + 'static {
45 /// Spawn a download from this decision.
46 #[doc(alias = "webkit_policy_decision_download")]
47 fn download(&self) {
48 unsafe {
49 ffi::webkit_policy_decision_download(self.as_ref().to_glib_none().0);
50 }
51 }
52
53 /// [`ResponsePolicyDecision`][crate::ResponsePolicyDecision], this would cancel the request.
54 ///
55 /// Ignore the action which triggered this decision. For instance, for a
56 /// [`ResponsePolicyDecision`][crate::ResponsePolicyDecision], this would cancel the request.
57 #[doc(alias = "webkit_policy_decision_ignore")]
58 fn ignore(&self) {
59 unsafe {
60 ffi::webkit_policy_decision_ignore(self.as_ref().to_glib_none().0);
61 }
62 }
63
64 /// Accept the action which triggered this decision.
65 #[doc(alias = "webkit_policy_decision_use")]
66 #[doc(alias = "use")]
67 fn use_(&self) {
68 unsafe {
69 ffi::webkit_policy_decision_use(self.as_ref().to_glib_none().0);
70 }
71 }
72
73 /// Accept the navigation action and continue with provided `policies`.
74 ///
75 /// Accept the navigation action which triggered this decision, and
76 /// continue with `policies` affecting all subsequent loads of resources
77 /// in the origin associated with the accepted navigation action.
78 ///
79 /// For example, a navigation decision to a video sharing website may
80 /// be accepted under the priviso no movies are allowed to autoplay. The
81 /// autoplay policy in this case would be set in the `policies`.
82 /// ## `policies`
83 /// a [`WebsitePolicies`][crate::WebsitePolicies]
84 #[doc(alias = "webkit_policy_decision_use_with_policies")]
85 fn use_with_policies(&self, policies: &WebsitePolicies) {
86 unsafe {
87 ffi::webkit_policy_decision_use_with_policies(
88 self.as_ref().to_glib_none().0,
89 policies.to_glib_none().0,
90 );
91 }
92 }
93}
94
95impl<O: IsA<PolicyDecision>> PolicyDecisionExt for O {}