25360f3d17f563c28041f9d135fad846cefdb6af
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / 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         /// <summary>
29         /// Allow Mixed Contents
30         /// </summary>
31         [EditorBrowsable(EditorBrowsableState.Never)]
32         public bool AllowMixedContents
33         {
34             get
35             {
36                 return allowMixedContents;
37             }
38             set
39             {
40                 allowMixedContents = value;
41                 Interop.WebSettings.AllowMixedContents(SwigCPtr, value);
42             }
43         }
44
45         /// <summary>
46         /// Enable Spatial Navigation.
47         /// </summary>
48         [EditorBrowsable(EditorBrowsableState.Never)]
49         public bool EnableSpatialNavigation
50         {
51             get
52             {
53                 return enableSpatialNavigation;
54             }
55             set
56             {
57                 enableSpatialNavigation = value;
58                 Interop.WebSettings.EnableSpatialNavigation(SwigCPtr, value);
59             }
60         }
61
62         /// <summary>
63         /// Default Font Size.
64         /// </summary>
65         [EditorBrowsable(EditorBrowsableState.Never)]
66         public int DefaultFontSize
67         {
68             get
69             {
70                 return Interop.WebSettings.GetDefaultFontSize(SwigCPtr);
71             }
72             set
73             {
74                 Interop.WebSettings.SetDefaultFontSize(SwigCPtr, value);
75             }
76         }
77
78         /// <summary>
79         /// Enable web security.
80         /// </summary>
81         [EditorBrowsable(EditorBrowsableState.Never)]
82         public bool EnableWebSecurity
83         {
84             get
85             {
86                 return enableWebSecurity;
87             }
88             set
89             {
90                 enableWebSecurity = value;
91                 Interop.WebSettings.EnableWebSecurity(SwigCPtr, value);
92             }
93         }
94
95         /// <summary>
96         /// Allow File Access From External Url.
97         /// </summary>
98         [EditorBrowsable(EditorBrowsableState.Never)]
99         public bool AllowFileAccessFromExternalUrl
100         {
101             get
102             {
103                 return allowFileAccessFromExternalUrl;
104             }
105             set
106             {
107                 allowFileAccessFromExternalUrl = value;
108                 Interop.WebSettings.AllowFileAccessFromExternalUrl(SwigCPtr, value);
109             }
110         }
111
112         /// <summary>
113         /// Enable JavaScript.
114         /// </summary>
115         [EditorBrowsable(EditorBrowsableState.Never)]
116         public bool EnableJavaScript
117         {
118             get
119             {
120                 return Interop.WebSettings.IsJavaScriptEnabled(SwigCPtr);
121             }
122             set
123             {
124                 Interop.WebSettings.EnableJavaScript(SwigCPtr, value);
125             }
126         }
127
128         /// <summary>
129         /// Allow Scripts Open Windows.
130         /// </summary>
131         [EditorBrowsable(EditorBrowsableState.Never)]
132         public bool AllowScriptsOpenWindows
133         {
134             get
135             {
136                 return allowScriptsOpenWindows;
137             }
138             set
139             {
140                 allowScriptsOpenWindows = value;
141                 Interop.WebSettings.AllowScriptsOpenWindows(SwigCPtr, value);
142             }
143         }
144
145         /// <summary>
146         /// Allow Images Load Automatically.
147         /// </summary>
148         [EditorBrowsable(EditorBrowsableState.Never)]
149         public bool AllowImagesLoadAutomatically
150         {
151             get
152             {
153                 return Interop.WebSettings.AreImagesAutomaticallyLoaded(SwigCPtr);
154             }
155             set
156             {
157                 Interop.WebSettings.AllowImagesLoadAutomatically(SwigCPtr, value);
158             }
159         }
160
161         /// <summary>
162         /// Default Text Encoding Name.
163         /// </summary>
164         [EditorBrowsable(EditorBrowsableState.Never)]
165         public string DefaultTextEncodingName
166         {
167             get
168             {
169                 return Interop.WebSettings.GetDefaultTextEncodingName(SwigCPtr);
170             }
171             set
172             {
173                 Interop.WebSettings.SetDefaultTextEncodingName(SwigCPtr, value);
174             }
175         }
176
177         internal WebSettings(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
178         {
179         }
180
181         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WebSettings obj)
182         {
183             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
184         }
185
186         /// <summary>
187         /// Dispose for IDisposable pattern
188         /// </summary>
189         [EditorBrowsable(EditorBrowsableState.Never)]
190         protected override void Dispose(DisposeTypes type)
191         {
192             if (disposed)
193             {
194                 return;
195             }
196
197             if (type == DisposeTypes.Explicit)
198             {
199                 //Called by User
200                 //Release your own managed resources here.
201                 //You should release all of your own disposable objects here.
202             }
203
204             base.Dispose(type);
205         }
206
207         // private.
208         private bool allowMixedContents;
209         private bool enableSpatialNavigation;
210         private bool enableWebSecurity;
211         private bool allowFileAccessFromExternalUrl;
212         private bool allowScriptsOpenWindows;
213     }
214 }