fix nullable member access code to prevent future crash.
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / WebView / WebSettings.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.ComponentModel;
19
20 namespace Tizen.NUI
21 {
22     /// <summary>
23     /// WebSettings is a class for settings of web view.
24     /// </summary>
25     [EditorBrowsable(EditorBrowsableState.Never)]
26     public class WebSettings : Disposable
27     {
28         private bool mixedContentsAllowed;
29         private bool spatialNavigationEnabled;
30         private bool webSecurityEnabled;
31         private bool cacheBuilderEnabled;
32         private bool doNotTrackEnabled;
33         private bool fileAccessFromExternalUrlAllowed;
34         private bool scriptsOpenWindowsAllowed;
35         private bool scrollbarThumbFocusNotificationsUsed;
36         private bool viewportMetaTag;
37
38         internal WebSettings(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
39         {
40         }
41
42         /// <summary>
43         /// Allows mixed contents or not.
44         /// </summary>
45         [EditorBrowsable(EditorBrowsableState.Never)]
46         public bool MixedContentsAllowed
47         {
48             get
49             {
50                 return mixedContentsAllowed;
51             }
52             set
53             {
54                 Interop.WebSettings.AllowMixedContents(SwigCPtr, value);
55                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
56                 mixedContentsAllowed = value;
57             }
58         }
59
60         /// <summary>
61         /// Enables spatial navigation or not.
62         /// </summary>
63         [EditorBrowsable(EditorBrowsableState.Never)]
64         public bool SpatialNavigationEnabled
65         {
66             get
67             {
68                 return spatialNavigationEnabled;
69             }
70             set
71             {
72                 Interop.WebSettings.EnableSpatialNavigation(SwigCPtr, value);
73                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
74                 spatialNavigationEnabled = value;
75             }
76         }
77
78         /// <summary>
79         /// Default Font Size.
80         /// </summary>
81         [EditorBrowsable(EditorBrowsableState.Never)]
82         public int DefaultFontSize
83         {
84             get
85             {
86                 return Interop.WebSettings.GetDefaultFontSize(SwigCPtr);
87             }
88             set
89             {
90                 Interop.WebSettings.SetDefaultFontSize(SwigCPtr, value);
91                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
92             }
93         }
94
95         /// <summary>
96         /// Enables web security or not.
97         /// </summary>
98         [EditorBrowsable(EditorBrowsableState.Never)]
99         public bool WebSecurityEnabled
100         {
101             get
102             {
103                 return webSecurityEnabled;
104             }
105             set
106             {
107                 Interop.WebSettings.EnableWebSecurity(SwigCPtr, value);
108                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
109                 webSecurityEnabled = value;
110             }
111         }
112
113         /// <summary>
114         /// Enable cache builer
115         /// </summary>
116         [EditorBrowsable(EditorBrowsableState.Never)]
117         public bool CacheBuilderEnabled
118         {
119             get 
120             {
121                 return cacheBuilderEnabled;
122             }
123             set 
124             {
125                 Interop.WebSettings.EnableCacheBuilder(SwigCPtr, value);
126                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
127                 cacheBuilderEnabled = value;
128             }
129         }
130
131         /// <summary>
132         /// Enable do not track, to protect user privacy security.
133         /// </summary>
134         public bool DoNotTrackEnabled
135         {
136             get
137             {
138                 return doNotTrackEnabled;
139             }
140             set
141             {
142                 Interop.WebSettings.EnableDoNotTrack(SwigCPtr, value);
143                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
144                 doNotTrackEnabled = value;
145             }
146         }
147
148         /// <summary>
149         /// Use scrollbar thumb focus notifications
150         /// </summary>
151         [EditorBrowsable(EditorBrowsableState.Never)]
152         public bool ScrollbarThumbFocusNotificationsUsed
153         {
154             get
155             {
156                 return scrollbarThumbFocusNotificationsUsed;
157             }
158             set
159             {
160                 Interop.WebSettings.UseScrollbarThumbFocusNotifications(SwigCPtr, value);
161                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
162                 scrollbarThumbFocusNotificationsUsed = value;
163             }
164         }
165
166         /// <summary>
167         /// Allows file access from external url or not.
168         /// </summary>
169         [EditorBrowsable(EditorBrowsableState.Never)]
170         public bool FileAccessFromExternalUrlAllowed
171         {
172             get
173             {
174                 return fileAccessFromExternalUrlAllowed;
175             }
176             set
177             {
178                 Interop.WebSettings.AllowFileAccessFromExternalUrl(SwigCPtr, value);
179                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
180                 fileAccessFromExternalUrlAllowed = value;
181             }
182         }
183
184         /// <summary>
185         /// Enables JavaScript or not.
186         /// </summary>
187         [EditorBrowsable(EditorBrowsableState.Never)]
188         public bool JavaScriptEnabled
189         {
190             get
191             {
192                 return Interop.WebSettings.IsJavaScriptEnabled(SwigCPtr);
193             }
194             set
195             {
196                 Interop.WebSettings.EnableJavaScript(SwigCPtr, value);
197                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
198             }
199         }
200
201         /// <summary>
202         /// Enable auto fitting
203         /// </summary>
204         [EditorBrowsable(EditorBrowsableState.Never)]
205         public bool AutoFittingEnabled
206         {
207             get
208             {
209                 return Interop.WebSettings.IsAutoFittingEnabled(SwigCPtr);
210             }
211             set
212             {
213                 Interop.WebSettings.EnableAutoFitting(SwigCPtr, value);
214                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215             }
216         }
217
218         /// <summary>
219         /// Enable plugins
220         /// </summary>
221         [EditorBrowsable(EditorBrowsableState.Never)]
222         public bool PluginsEnabled
223         {
224             get
225             {
226                 return Interop.WebSettings.ArePluginsEnabled(SwigCPtr);
227             }
228             set 
229             {
230                 Interop.WebSettings.EnablePlugins(SwigCPtr, value);
231                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
232             }
233         }
234
235         /// <summary>
236         /// Enable private browsing
237         /// </summary>
238         [EditorBrowsable(EditorBrowsableState.Never)]
239         public bool PrivateBrowsingEnabled
240         {
241             get
242             {
243                 return Interop.WebSettings.IsPrivateBrowsingEnabled(SwigCPtr);
244             }
245             set
246             {
247                 Interop.WebSettings.EnablePrivateBrowsing(SwigCPtr, value);
248                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
249             }
250         }
251
252         /// <summary>
253         /// Enable link magnifier
254         /// </summary>
255         [EditorBrowsable(EditorBrowsableState.Never)]
256         public bool LinkMagnifierEnabled
257         {
258             get
259             {
260                 return Interop.WebSettings.IsLinkMagnifierEnabled(SwigCPtr);
261             }
262             set
263             {
264                 Interop.WebSettings.EnableLinkMagnifier(SwigCPtr, value);
265                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
266             }
267         }
268
269         /// <summary>
270         /// Use keypad without user action
271         /// </summary>
272         [EditorBrowsable(EditorBrowsableState.Never)]
273         public bool KeypadWithoutUserActionUsed
274         {
275             get
276             {
277                 return Interop.WebSettings.IsKeypadWithoutUserActionUsed(SwigCPtr);
278             }
279             set
280             {
281                 Interop.WebSettings.UseKeypadWithoutUserAction(SwigCPtr, value);
282                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
283             }
284         }
285
286         /// <summary>
287         /// Enable autofill password form
288         /// </summary>
289         [EditorBrowsable(EditorBrowsableState.Never)]
290         public bool AutofillPasswordFormEnabled
291         {
292             get
293             {
294                 return Interop.WebSettings.IsAutofillPasswordFormEnabled(SwigCPtr);
295             }
296             set
297             {
298                 Interop.WebSettings.EnableAutofillPasswordForm(SwigCPtr, value);
299                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
300             }
301         }
302
303         /// <summary>
304         /// Enable form candidate data
305         /// </summary>
306         [EditorBrowsable(EditorBrowsableState.Never)]
307         public bool FormCandidateDataEnabled
308         {
309             get
310             {
311                 return Interop.WebSettings.IsFormCandidateDataEnabled(SwigCPtr);
312             }
313             set
314             {
315                 Interop.WebSettings.EnableFormCandidateData(SwigCPtr, value);
316                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
317             }
318         }
319
320         /// <summary>
321         /// Enable text selection
322         /// </summary>
323         [EditorBrowsable(EditorBrowsableState.Never)]
324         public bool TextSelectionEnabled
325         {
326             get
327             {
328                 return Interop.WebSettings.IsTextSelectionEnabled(SwigCPtr);
329             }
330             set
331             {
332                 Interop.WebSettings.EnableTextSelection(SwigCPtr, value);
333                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
334             }
335         }
336
337         /// <summary>
338         /// Enable text autosizing
339         /// </summary>
340         [EditorBrowsable(EditorBrowsableState.Never)]
341         public bool TextAutosizingEnabled
342         {
343             get
344             {
345                 return Interop.WebSettings.IsTextAutosizingEnabled(SwigCPtr);
346             }
347             set
348             {
349                 Interop.WebSettings.EnableTextAutosizing(SwigCPtr, value);
350                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
351             }
352         }
353
354         /// <summary>
355         /// Enable arrow scroll
356         /// </summary>
357         [EditorBrowsable(EditorBrowsableState.Never)]
358         public bool ArrowScrollEnabled
359         {
360             get
361             {
362                 return Interop.WebSettings.IsArrowScrollEnabled(SwigCPtr);
363             }
364             set
365             {
366                 Interop.WebSettings.EnableArrowScroll(SwigCPtr, value);
367                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
368             }
369         }
370
371         /// <summary>
372         /// Enable clipboard
373         /// </summary>
374         [EditorBrowsable(EditorBrowsableState.Never)]
375         public bool ClipboardEnabled
376         {
377             get
378             {
379                 return Interop.WebSettings.IsClipboardEnabled(SwigCPtr);
380             }
381             set
382             {
383                 Interop.WebSettings.EnableClipboard(SwigCPtr, value);
384                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
385             }
386         }
387
388         /// <summary>
389         /// Enable ime panel
390         /// </summary>
391         [EditorBrowsable(EditorBrowsableState.Never)]
392         public bool ImePanelEnabled
393         {
394             get
395             {
396                 return Interop.WebSettings.IsImePanelEnabled(SwigCPtr);
397             }
398             set
399             {
400                 Interop.WebSettings.EnableImePanel(SwigCPtr, value);
401                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
402             }
403         }
404
405         /// <summary>
406         /// Allows scripts open windows or not.
407         /// </summary>
408         [EditorBrowsable(EditorBrowsableState.Never)]
409         public bool ScriptsOpenWindowsAllowed
410         {
411             get
412             {
413                 return scriptsOpenWindowsAllowed;
414             }
415             set
416             {
417                 Interop.WebSettings.AllowScriptsOpenWindows(SwigCPtr, value);
418                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
419                 scriptsOpenWindowsAllowed = value;
420             }
421         }
422
423         /// <summary>
424         /// Allow images load automatically or not.
425         /// </summary>
426         [EditorBrowsable(EditorBrowsableState.Never)]
427         public bool AutomaticImageLoadingAllowed
428         {
429             get
430             {
431                 return Interop.WebSettings.AreImagesLoadedAutomatically(SwigCPtr);
432             }
433             set
434             {
435                 Interop.WebSettings.AllowImagesLoadAutomatically(SwigCPtr, value);
436                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
437             }
438         }
439
440         /// <summary>
441         /// Default text encoding name.
442         /// </summary>
443         [EditorBrowsable(EditorBrowsableState.Never)]
444         public string DefaultTextEncodingName
445         {
446             get
447             {
448                 return Interop.WebSettings.GetDefaultTextEncodingName(SwigCPtr);
449             }
450             set
451             {
452                 Interop.WebSettings.SetDefaultTextEncodingName(SwigCPtr, value);
453                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
454             }
455         }
456
457         /// <summary>
458         ///  Viewport meta tag.
459         /// </summary>
460         [EditorBrowsable(EditorBrowsableState.Never)]
461         public bool ViewportMetaTag
462         {
463             get
464             {
465                 return viewportMetaTag;
466             }
467             set
468             {
469                 Interop.WebSettings.SetViewportMetaTag(SwigCPtr, value);
470                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
471                 viewportMetaTag = value;
472             }
473         }
474
475         /// <summary>
476         ///  Force zoom
477         /// </summary>
478         [EditorBrowsable(EditorBrowsableState.Never)]
479         public bool ZoomForced
480         {
481             get
482             {
483                 return Interop.WebSettings.IsZoomForced(SwigCPtr);
484             }
485             set
486             {
487                 Interop.WebSettings.SetForceZoom(SwigCPtr, value);
488                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
489             }
490         }
491
492         /// <summary>
493         ///  Enable text zoom
494         /// </summary>
495         [EditorBrowsable(EditorBrowsableState.Never)]
496         public bool TextZoomEnabled
497         {
498             get
499             {
500                 return Interop.WebSettings.IsTextZoomEnabled(SwigCPtr);
501             }
502             set
503             {
504                 Interop.WebSettings.SetTextZoomEnabled(SwigCPtr, value);
505                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
506             }
507         }
508
509         /// <summary>
510         ///  Enable extra feature
511         /// </summary>
512         /// <param name="str">The string of extra feature.</param>
513         /// <param name="tag">Enable or disable.</param>
514         [EditorBrowsable(EditorBrowsableState.Never)]
515         public void EnableExtraFeature(string str, bool tag)
516         {
517             Interop.WebSettings.SetExtraFeature(SwigCPtr, str, tag);
518             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
519         }
520
521         /// <summary>
522         ///  Enable extra feature
523         /// </summary>
524         /// <param name="str">The string of extra feature.</param>
525         [EditorBrowsable(EditorBrowsableState.Never)]
526         public bool IsExtraFeatureEnabled(string str)
527         {
528             bool ret = Interop.WebSettings.IsExtraFeatureEnabled(SwigCPtr, str);
529             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
530             return ret;
531         }
532     }
533 }