Add some new APIs like Context, Settings, etc. (#2419)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / WebContext.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     /// WebContext is a class for context of web view.
25     /// </summary>
26     [EditorBrowsable(EditorBrowsableState.Never)]
27     public class WebContext : Disposable
28     {
29         /// <summary>
30         /// Cache model
31         /// </summary>
32         [EditorBrowsable(EditorBrowsableState.Never)]
33         public enum CacheModelType
34         {
35             /// <summary>
36             /// The smallest cache capacity
37             /// </summary>
38             [EditorBrowsable(EditorBrowsableState.Never)]
39             DocumentViewer,
40
41             /// <summary>
42             /// The bigger cache capacity than DocumentBrowser
43             /// </summary>
44             [EditorBrowsable(EditorBrowsableState.Never)]
45             DocumentBrowser,
46
47             /// <summary>
48             /// The biggest cache capacity.
49             /// </summary>
50             [EditorBrowsable(EditorBrowsableState.Never)]
51             PrimaryWebBrowser,
52         }
53
54         /// <summary>
55         /// Cache model
56         /// </summary>
57         [EditorBrowsable(EditorBrowsableState.Never)]
58         public CacheModelType CacheModel
59         {
60             get
61             {
62                 return (CacheModelType)Interop.WebContext.GetCacheModel(SwigCPtr);
63             }
64             set
65             {
66                 Interop.WebContext.SetCacheModel(SwigCPtr, (int)value);
67             }
68         }
69
70         /// <summary>
71         /// Set the proxy uri.
72         /// </summary>
73         [EditorBrowsable(EditorBrowsableState.Never)]
74         public Uri ProxyUri
75         {
76             get
77             {
78                 return new Uri(proxyUri);
79             }
80             set
81             {
82                 if (value != null)
83                 {
84                     proxyUri = value.AbsoluteUri;
85                     Interop.WebContext.SetProxyUri(SwigCPtr, proxyUri);
86                 }
87             }
88         }
89
90         /// <summary>
91         /// Set the Certificate File Path.
92         /// </summary>
93         [EditorBrowsable(EditorBrowsableState.Never)]
94         public string CertificateFilePath
95         {
96             get
97             {
98                 return certificateFilePath;
99             }
100             set
101             {
102                 certificateFilePath = value;
103                 Interop.WebContext.SetCertificateFilePath(SwigCPtr, value);
104             }
105         }
106
107         /// <summary>
108         /// Disable cache or not.
109         /// </summary>
110         [EditorBrowsable(EditorBrowsableState.Never)]
111         public bool DisableCache
112         {
113             get
114             {
115                 return disableCache;
116             }
117             set
118             {
119                 disableCache = value;
120                 Interop.WebContext.DisableCache(SwigCPtr, value);
121             }
122         }
123
124         /// <summary>
125         /// Set Default Proxy Auth.
126         /// </summary>
127         [EditorBrowsable(EditorBrowsableState.Never)]
128         public void SetDefaultProxyAuth(string username, string password)
129         {
130             Interop.WebContext.SetDefaultProxyAuth(SwigCPtr, username, password);
131             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
132         }
133
134         /// <summary>
135         /// Delete Web Database.
136         /// </summary>
137         [EditorBrowsable(EditorBrowsableState.Never)]
138         public void DeleteWebDatabase()
139         {
140             Interop.WebContext.DeleteWebDatabase(SwigCPtr);
141             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
142         }
143
144         /// <summary>
145         /// Delete Web Storage.
146         /// </summary>
147         [EditorBrowsable(EditorBrowsableState.Never)]
148         public void DeleteWebStorage()
149         {
150             Interop.WebContext.DeleteWebStorage(SwigCPtr);
151             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
152         }
153
154         /// <summary>
155         /// Delete Local FileSystem.
156         /// </summary>
157         [EditorBrowsable(EditorBrowsableState.Never)]
158         public void DeleteLocalFileSystem()
159         {
160             Interop.WebContext.DeleteLocalFileSystem(SwigCPtr);
161             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
162         }
163
164         /// <summary>
165         /// Clear cache.
166         /// </summary>
167         [EditorBrowsable(EditorBrowsableState.Never)]
168         public void ClearCache()
169         {
170             Interop.WebContext.ClearCache(SwigCPtr);
171             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
172         }
173
174         internal WebContext(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
175         {
176         }
177
178         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WebContext obj)
179         {
180             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
181         }
182
183         /// <summary>
184         /// Dispose for IDisposable pattern
185         /// </summary>
186         [EditorBrowsable(EditorBrowsableState.Never)]
187         protected override void Dispose(DisposeTypes type)
188         {
189             if (disposed)
190             {
191                 return;
192             }
193
194             if (type == DisposeTypes.Explicit)
195             {
196                 //Called by User
197                 //Release your own managed resources here.
198                 //You should release all of your own disposable objects here.
199             }
200
201             base.Dispose(type);
202         }
203
204         // private
205         private string proxyUri;
206         private string certificateFilePath;
207         private bool disableCache;
208     }
209 }