fix nullable member access code to prevent future crash.
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / WebView / WebPolicyDecisionMaker.cs
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 using System;
19 using System.ComponentModel;
20
21 namespace Tizen.NUI
22 {
23     /// <summary>
24     /// It is a class for policy decision maker of web view.
25     /// </summary>
26     [EditorBrowsable(EditorBrowsableState.Never)]
27     public class WebPolicyDecisionMaker : Disposable
28     {
29         internal WebPolicyDecisionMaker(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
30         {
31         }
32
33         /// <summary>
34         /// Decision type
35         /// </summary>
36         [EditorBrowsable(EditorBrowsableState.Never)]
37         public enum DecisionType
38         {
39             /// <summary>
40             /// Accepts the decision.
41             /// </summary>
42             [EditorBrowsable(EditorBrowsableState.Never)]
43             Use,
44
45             /// <summary>
46             /// Decides to download something.
47             /// </summary>
48             [EditorBrowsable(EditorBrowsableState.Never)]
49             Download,
50
51             /// <summary>
52             /// Ignores the decision.
53             /// </summary>
54             [EditorBrowsable(EditorBrowsableState.Never)]
55             Ignore,
56         }
57
58         /// <summary>
59         /// Policy navigation type
60         /// </summary>
61         [EditorBrowsable(EditorBrowsableState.Never)]
62         public enum NavigationType
63         {
64             /// <summary>
65             /// Link clicked
66             /// </summary>
67             [EditorBrowsable(EditorBrowsableState.Never)]
68             LinkClicked,
69
70             /// <summary>
71             /// Form submitted
72             /// </summary>
73             [EditorBrowsable(EditorBrowsableState.Never)]
74             FormSubmitted,
75
76             /// <summary>
77             /// Back forward
78             /// </summary>
79             [EditorBrowsable(EditorBrowsableState.Never)]
80             BackForward,
81
82             /// <summary>
83             /// Reload
84             /// </summary>
85             [EditorBrowsable(EditorBrowsableState.Never)]
86             Reload,
87
88             /// <summary>
89             /// Form resubmitted
90             /// </summary>
91             [EditorBrowsable(EditorBrowsableState.Never)]
92             FormResubmitted,
93
94             /// <summary>
95             /// Other
96             /// </summary>
97             [EditorBrowsable(EditorBrowsableState.Never)]
98             Other,
99         }
100
101         /// <summary>
102         /// Gets the url that request policy decision.
103         /// </summary>
104         [EditorBrowsable(EditorBrowsableState.Never)]
105         public string Url
106         {
107             get
108             {
109                 return Interop.WebPolicyDecisionMaker.GetUrl(SwigCPtr);
110             }
111         }
112
113         /// <summary>
114         /// Gets a cookie that web page has.
115         /// </summary>
116         [EditorBrowsable(EditorBrowsableState.Never)]
117         public string Cookie
118         {
119             get
120             {
121                 return Interop.WebPolicyDecisionMaker.GetCookie(SwigCPtr);
122             }
123         }
124
125         /// <summary>
126         /// Gets a decision type.
127         /// </summary>
128         [EditorBrowsable(EditorBrowsableState.Never)]
129         public DecisionType PolicyDecisionType
130         {
131             get
132             {
133                 return (DecisionType)Interop.WebPolicyDecisionMaker.GetDecisionType(SwigCPtr);
134             }
135         }
136
137         /// <summary>
138         /// Gets a MIME type for response data.
139         /// </summary>
140         [EditorBrowsable(EditorBrowsableState.Never)]
141         public string ResponseMime
142         {
143             get
144             {
145                 return Interop.WebPolicyDecisionMaker.GetResponseMime(SwigCPtr);
146             }
147         }
148
149         /// <summary>
150         /// Gets a HTTP status code.
151         /// </summary>
152         [EditorBrowsable(EditorBrowsableState.Never)]
153         public int ResponseStatusCode
154         {
155             get
156             {
157                 return Interop.WebPolicyDecisionMaker.GetResponseStatusCode(SwigCPtr);
158             }
159         }
160
161         /// <summary>
162         /// Gets a navigation type.
163         /// </summary>
164         [EditorBrowsable(EditorBrowsableState.Never)]
165         public NavigationType DecisionNavigationType
166         {
167             get
168             {
169                 return (NavigationType)Interop.WebPolicyDecisionMaker.GetNavigationType(SwigCPtr);
170             }
171         }
172
173         /// <summary>
174         /// Gets frame of web view.
175         /// </summary>
176         [EditorBrowsable(EditorBrowsableState.Never)]
177         public WebFrame Frame
178         {
179             get
180             {
181                 IntPtr result = Interop.WebPolicyDecisionMaker.GetFrame(SwigCPtr);
182                 return new WebFrame(result, false);
183             }
184         }
185
186         /// <summary>
187         /// Gets a scheme.
188         /// </summary>
189         [EditorBrowsable(EditorBrowsableState.Never)]
190         public string Scheme
191         {
192             get
193             {
194                 return Interop.WebPolicyDecisionMaker.GetScheme(SwigCPtr);
195             }
196         }
197
198         /// <summary>
199         /// Accepts the action which triggers this decision.
200         /// </summary>
201         [EditorBrowsable(EditorBrowsableState.Never)]
202         public bool Use()
203         {
204             bool result = Interop.WebPolicyDecisionMaker.Use(SwigCPtr);
205             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
206             return result;
207         }
208
209         /// <summary>
210         /// Ignores the action which triggers this decision.
211         /// </summary>
212         [EditorBrowsable(EditorBrowsableState.Never)]
213         public bool Ignore()
214         {
215             bool result = Interop.WebPolicyDecisionMaker.Ignore(SwigCPtr);
216             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
217             return result;
218         }
219
220         /// <summary>
221         /// Suspends the operation for policy decision.
222         /// </summary>
223         [EditorBrowsable(EditorBrowsableState.Never)]
224         public bool Suspend()
225         {
226             bool result = Interop.WebPolicyDecisionMaker.Suspend(SwigCPtr);
227             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
228             return result;
229         }
230     }
231 }