[NUI] Add Apis of Webview Settings.
[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 allowMixedContents;
29         private bool enableSpatialNavigation;
30         private bool enableWebSecurity;
31         private bool enableCacheBuilder;
32         private bool enableDoNotTrack;
33         private bool allowFileAccessFromExternalUrl;
34         private bool allowScriptsOpenWindows;
35         private bool useScrollbarThumbFocusNotifications;
36
37         internal WebSettings(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
38         {
39         }
40
41         /// <summary>
42         /// Allow Mixed Contents
43         /// </summary>
44         [EditorBrowsable(EditorBrowsableState.Never)]
45         public bool AllowMixedContents
46         {
47             get
48             {
49                 return allowMixedContents;
50             }
51             set
52             {
53                 allowMixedContents = value;
54                 Interop.WebSettings.AllowMixedContents(SwigCPtr, value);
55             }
56         }
57
58         /// <summary>
59         /// Enable Spatial Navigation.
60         /// </summary>
61         [EditorBrowsable(EditorBrowsableState.Never)]
62         public bool EnableSpatialNavigation
63         {
64             get
65             {
66                 return enableSpatialNavigation;
67             }
68             set
69             {
70                 enableSpatialNavigation = value;
71                 Interop.WebSettings.EnableSpatialNavigation(SwigCPtr, value);
72             }
73         }
74
75         /// <summary>
76         /// Default Font Size.
77         /// </summary>
78         [EditorBrowsable(EditorBrowsableState.Never)]
79         public int DefaultFontSize
80         {
81             get
82             {
83                 return Interop.WebSettings.GetDefaultFontSize(SwigCPtr);
84             }
85             set
86             {
87                 Interop.WebSettings.SetDefaultFontSize(SwigCPtr, value);
88             }
89         }
90
91         /// <summary>
92         /// Enable web security.
93         /// </summary>
94         [EditorBrowsable(EditorBrowsableState.Never)]
95         public bool EnableWebSecurity
96         {
97             get
98             {
99                 return enableWebSecurity;
100             }
101             set
102             {
103                 enableWebSecurity = value;
104                 Interop.WebSettings.EnableWebSecurity(SwigCPtr, value);
105             }
106         }
107
108         /// <summary>
109         /// Enable cache builer
110         /// </summary>
111         [EditorBrowsable(EditorBrowsableState.Never)]
112         public bool CacheBuilderEnabled
113         {
114             get 
115             {
116                 return enableCacheBuilder;
117             }
118             set 
119             {
120                 enableCacheBuilder = value;
121                 Interop.WebSettings.EnableCacheBuilder(SwigCPtr, value);
122             }
123         }
124
125         /// <summary>
126         /// Enable do not track, to protect user privacy security.
127         /// </summary>
128         public bool DoNotTrackEnabled
129         {
130             get
131             {
132                 return enableDoNotTrack;
133             }
134             set
135             {
136                 enableDoNotTrack = value;
137                 Interop.WebSettings.EnableDoNotTrack(SwigCPtr, value);
138             }
139         }
140
141         /// <summary>
142         /// Use scrollbar thumb focus notifications
143         /// </summary>
144         [EditorBrowsable(EditorBrowsableState.Never)]
145         public bool ScrollbarThumbFocusNotificationsUsed
146         {
147             get
148             {
149                 return useScrollbarThumbFocusNotifications;
150             }
151             set
152             {
153                 useScrollbarThumbFocusNotifications = value;
154                 Interop.WebSettings.UseScrollbarThumbFocusNotifications(SwigCPtr, value);
155             }
156         }
157
158         /// <summary>
159         /// Allow File Access From External Url.
160         /// </summary>
161         [EditorBrowsable(EditorBrowsableState.Never)]
162         public bool AllowFileAccessFromExternalUrl
163         {
164             get
165             {
166                 return allowFileAccessFromExternalUrl;
167             }
168             set
169             {
170                 allowFileAccessFromExternalUrl = value;
171                 Interop.WebSettings.AllowFileAccessFromExternalUrl(SwigCPtr, value);
172             }
173         }
174
175         /// <summary>
176         /// Enable JavaScript.
177         /// </summary>
178         [EditorBrowsable(EditorBrowsableState.Never)]
179         public bool EnableJavaScript
180         {
181             get
182             {
183                 return Interop.WebSettings.IsJavaScriptEnabled(SwigCPtr);
184             }
185             set
186             {
187                 Interop.WebSettings.EnableJavaScript(SwigCPtr, value);
188             }
189         }
190
191         /// <summary>
192         /// Enable auto fitting
193         /// </summary>
194         [EditorBrowsable(EditorBrowsableState.Never)]
195         public bool AutoFittingEnabled
196         {
197             get
198             {
199                 return Interop.WebSettings.IsAutoFittingEnabled(SwigCPtr);
200             }
201             set
202             {
203                 Interop.WebSettings.EnableAutoFitting(SwigCPtr, value);
204             }
205         }
206
207         /// <summary>
208         /// Enable plugins
209         /// </summary>
210         [EditorBrowsable(EditorBrowsableState.Never)]
211         public bool PluginsEnabled
212         {
213             get
214             {
215                 return Interop.WebSettings.ArePluginsEnabled(SwigCPtr);
216             }
217             set 
218             {
219                 Interop.WebSettings.EnablePlugins(SwigCPtr, value);
220             }
221         }
222
223         /// <summary>
224         /// Enable private browsing
225         /// </summary>
226         [EditorBrowsable(EditorBrowsableState.Never)]
227         public bool PrivateBrowsingEnabled
228         {
229             get
230             {
231                 return Interop.WebSettings.IsPrivateBrowsingEnabled(SwigCPtr);
232             }
233             set
234             {
235                 Interop.WebSettings.EnablePrivateBrowsing(SwigCPtr, value);
236             }
237         }
238
239         /// <summary>
240         /// Enable link magnifier
241         /// </summary>
242         [EditorBrowsable(EditorBrowsableState.Never)]
243         public bool LinkMagnifierEnabled
244         {
245             get
246             {
247                 return Interop.WebSettings.IsLinkMagnifierEnabled(SwigCPtr);
248             }
249             set
250             {
251                 Interop.WebSettings.EnableLinkMagnifier(SwigCPtr, value);
252             }
253         }
254
255         /// <summary>
256         /// Use keypad without user action
257         /// </summary>
258         [EditorBrowsable(EditorBrowsableState.Never)]
259         public bool KeypadWithoutUserActionUsed
260         {
261             get
262             {
263                 return Interop.WebSettings.IsKeypadWithoutUserActionUsed(SwigCPtr);
264             }
265             set
266             {
267                 Interop.WebSettings.UseKeypadWithoutUserAction(SwigCPtr, value);
268             }
269         }
270
271         /// <summary>
272         /// Enable autofill password form
273         /// </summary>
274         [EditorBrowsable(EditorBrowsableState.Never)]
275         public bool AutofillPasswordFormEnabled
276         {
277             get
278             {
279                 return Interop.WebSettings.IsAutofillPasswordFormEnabled(SwigCPtr);
280             }
281             set
282             {
283                 Interop.WebSettings.EnableAutofillPasswordForm(SwigCPtr, value);
284             }
285         }
286
287         /// <summary>
288         /// Enable form candidate data
289         /// </summary>
290         [EditorBrowsable(EditorBrowsableState.Never)]
291         public bool FormCandidateDataEnabled
292         {
293             get
294             {
295                 return Interop.WebSettings.IsFormCandidateDataEnabled(SwigCPtr);
296             }
297             set
298             {
299                 Interop.WebSettings.EnableFormCandidateData(SwigCPtr, value);
300             }
301         }
302
303         /// <summary>
304         /// Enable text selection
305         /// </summary>
306         [EditorBrowsable(EditorBrowsableState.Never)]
307         public bool TextSelectionEnabled
308         {
309             get
310             {
311                 return Interop.WebSettings.IsTextSelectionEnabled(SwigCPtr);
312             }
313             set
314             {
315                 Interop.WebSettings.EnableTextSelection(SwigCPtr, value);
316             }
317         }
318
319         /// <summary>
320         /// Enable text autosizing
321         /// </summary>
322         [EditorBrowsable(EditorBrowsableState.Never)]
323         public bool TextAutosizingEnabled
324         {
325             get
326             {
327                 return Interop.WebSettings.IsTextAutosizingEnabled(SwigCPtr);
328             }
329             set
330             {
331                 Interop.WebSettings.EnableTextAutosizing(SwigCPtr, value);
332             }
333         }
334
335         /// <summary>
336         /// Enable arrow scroll
337         /// </summary>
338         [EditorBrowsable(EditorBrowsableState.Never)]
339         public bool ArrowScrollEnabled
340         {
341             get
342             {
343                 return Interop.WebSettings.IsArrowScrollEnabled(SwigCPtr);
344             }
345             set
346             {
347                 Interop.WebSettings.EnableArrowScroll(SwigCPtr, value);
348             }
349         }
350
351         /// <summary>
352         /// Enable clipboard
353         /// </summary>
354         [EditorBrowsable(EditorBrowsableState.Never)]
355         public bool ClipboardEnabled
356         {
357             get
358             {
359                 return Interop.WebSettings.IsClipboardEnabled(SwigCPtr);
360             }
361             set
362             {
363                 Interop.WebSettings.EnableClipboard(SwigCPtr, value);
364             }
365         }
366
367         /// <summary>
368         /// Enable ime panel
369         /// </summary>
370         [EditorBrowsable(EditorBrowsableState.Never)]
371         public bool ImePanelEnabled
372         {
373             get
374             {
375                 return Interop.WebSettings.IsImePanelEnabled(SwigCPtr);
376             }
377             set
378             {
379                 Interop.WebSettings.EnableImePanel(SwigCPtr, value);
380             }
381         }
382
383         /// <summary>
384         /// Allow Scripts Open Windows.
385         /// </summary>
386         [EditorBrowsable(EditorBrowsableState.Never)]
387         public bool AllowScriptsOpenWindows
388         {
389             get
390             {
391                 return allowScriptsOpenWindows;
392             }
393             set
394             {
395                 allowScriptsOpenWindows = value;
396                 Interop.WebSettings.AllowScriptsOpenWindows(SwigCPtr, value);
397             }
398         }
399
400         /// <summary>
401         /// Allow Images Load Automatically.
402         /// </summary>
403         [EditorBrowsable(EditorBrowsableState.Never)]
404         public bool AllowImagesLoadAutomatically
405         {
406             get
407             {
408                 return Interop.WebSettings.AreImagesAutomaticallyLoaded(SwigCPtr);
409             }
410             set
411             {
412                 Interop.WebSettings.AllowImagesLoadAutomatically(SwigCPtr, value);
413             }
414         }
415
416         /// <summary>
417         /// Default Text Encoding Name.
418         /// </summary>
419         [EditorBrowsable(EditorBrowsableState.Never)]
420         public string DefaultTextEncodingName
421         {
422             get
423             {
424                 return Interop.WebSettings.GetDefaultTextEncodingName(SwigCPtr);
425             }
426             set
427             {
428                 Interop.WebSettings.SetDefaultTextEncodingName(SwigCPtr, value);
429             }
430         }
431
432         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WebSettings obj)
433         {
434             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
435         }
436     }
437 }