1 module webkit2.PolicyDecision;
2 
3 private import gobject.ObjectG;
4 private import webkit2.WebsitePolicies;
5 private import webkit2.c.functions;
6 public  import webkit2.c.types;
7 
8 
9 /**
10  * Often WebKit allows the client to decide the policy for certain
11  * operations. For instance, a client may want to open a link in a new
12  * tab, block a navigation entirely, query the user or trigger a download
13  * instead of a navigation. In these cases WebKit will fire the
14  * #WebKitWebView::decide-policy signal with a #WebKitPolicyDecision
15  * object. If the signal handler does nothing, WebKit will act as if
16  * webkit_policy_decision_use() was called as soon as signal handling
17  * completes. To make a policy decision asynchronously, simply increment
18  * the reference count of the #WebKitPolicyDecision object.
19  */
20 public class PolicyDecision : ObjectG
21 {
22 	/** the main Gtk struct */
23 	protected WebKitPolicyDecision* webKitPolicyDecision;
24 
25 	/** Get the main Gtk struct */
26 	public WebKitPolicyDecision* getPolicyDecisionStruct(bool transferOwnership = false)
27 	{
28 		if (transferOwnership)
29 			ownedRef = false;
30 		return webKitPolicyDecision;
31 	}
32 
33 	/** the main Gtk struct as a void* */
34 	protected override void* getStruct()
35 	{
36 		return cast(void*)webKitPolicyDecision;
37 	}
38 
39 	/**
40 	 * Sets our main struct and passes it to the parent class.
41 	 */
42 	public this (WebKitPolicyDecision* webKitPolicyDecision, bool ownedRef = false)
43 	{
44 		this.webKitPolicyDecision = webKitPolicyDecision;
45 		super(cast(GObject*)webKitPolicyDecision, ownedRef);
46 	}
47 
48 
49 	/** */
50 	public static GType getType()
51 	{
52 		return webkit_policy_decision_get_type();
53 	}
54 
55 	/**
56 	 * Spawn a download from this decision.
57 	 */
58 	public void download()
59 	{
60 		webkit_policy_decision_download(webKitPolicyDecision);
61 	}
62 
63 	/**
64 	 * Ignore the action which triggered this decision. For instance, for a
65 	 * #WebKitResponsePolicyDecision, this would cancel the request.
66 	 */
67 	public void ignore()
68 	{
69 		webkit_policy_decision_ignore(webKitPolicyDecision);
70 	}
71 
72 	/**
73 	 * Accept the action which triggered this decision.
74 	 */
75 	public void use()
76 	{
77 		webkit_policy_decision_use(webKitPolicyDecision);
78 	}
79 
80 	/**
81 	 * Accept the navigation action which triggered this decision, and
82 	 * continue with @policies affecting all subsequent loads of resources
83 	 * in the origin associated with the accepted navigation action.
84 	 *
85 	 * For example, a navigation decision to a video sharing website may
86 	 * be accepted under the priviso no movies are allowed to autoplay. The
87 	 * autoplay policy in this case would be set in the @policies.
88 	 *
89 	 * Params:
90 	 *     policies = a #WebKitWebsitePolicies
91 	 *
92 	 * Since: 2.30
93 	 */
94 	public void useWithPolicies(WebsitePolicies policies)
95 	{
96 		webkit_policy_decision_use_with_policies(webKitPolicyDecision, (policies is null) ? null : policies.getWebsitePoliciesStruct());
97 	}
98 }