7fa398b6fd02be3cf9cb4736b98cdd52bc720780
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / WebView / 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         private string proxyUri;
30         private string certificateFilePath;
31         private bool disableCache;
32
33         internal WebContext(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
34         {
35         }
36
37         /// <summary>
38         /// Cache model
39         /// </summary>
40         [EditorBrowsable(EditorBrowsableState.Never)]
41         public enum CacheModelType
42         {
43             /// <summary>
44             /// The smallest cache capacity
45             /// </summary>
46             [EditorBrowsable(EditorBrowsableState.Never)]
47             DocumentViewer,
48
49             /// <summary>
50             /// The bigger cache capacity than DocumentBrowser
51             /// </summary>
52             [EditorBrowsable(EditorBrowsableState.Never)]
53             DocumentBrowser,
54
55             /// <summary>
56             /// The biggest cache capacity.
57             /// </summary>
58             [EditorBrowsable(EditorBrowsableState.Never)]
59             PrimaryWebBrowser,
60         }
61
62         /// <summary>
63         /// Cache model
64         /// </summary>
65         [EditorBrowsable(EditorBrowsableState.Never)]
66         public CacheModelType CacheModel
67         {
68             get
69             {
70                 return (CacheModelType)Interop.WebContext.GetCacheModel(SwigCPtr);
71             }
72             set
73             {
74                 Interop.WebContext.SetCacheModel(SwigCPtr, (int)value);
75             }
76         }
77
78         /// <summary>
79         /// Set the proxy uri.
80         /// </summary>
81         [EditorBrowsable(EditorBrowsableState.Never)]
82         public Uri ProxyUri
83         {
84             get
85             {
86                 return new Uri(proxyUri);
87             }
88             set
89             {
90                 if (value != null)
91                 {
92                     proxyUri = value.AbsoluteUri;
93                     Interop.WebContext.SetProxyUri(SwigCPtr, proxyUri);
94                 }
95             }
96         }
97
98         /// <summary>
99         /// Set the Certificate File Path.
100         /// </summary>
101         [EditorBrowsable(EditorBrowsableState.Never)]
102         public string CertificateFilePath
103         {
104             get
105             {
106                 return certificateFilePath;
107             }
108             set
109             {
110                 certificateFilePath = value;
111                 Interop.WebContext.SetCertificateFilePath(SwigCPtr, value);
112             }
113         }
114
115         /// <summary>
116         /// Disable cache or not.
117         /// </summary>
118         [EditorBrowsable(EditorBrowsableState.Never)]
119         public bool DisableCache
120         {
121             get
122             {
123                 return disableCache;
124             }
125             set
126             {
127                 disableCache = value;
128                 Interop.WebContext.DisableCache(SwigCPtr, value);
129             }
130         }
131
132         /// <summary>
133         /// Set Default Proxy Auth.
134         /// </summary>
135         [EditorBrowsable(EditorBrowsableState.Never)]
136         public void SetDefaultProxyAuth(string username, string password)
137         {
138             Interop.WebContext.SetDefaultProxyAuth(SwigCPtr, username, password);
139             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
140         }
141
142         /// <summary>
143         /// Delete Web Database.
144         /// </summary>
145         [EditorBrowsable(EditorBrowsableState.Never)]
146         public void DeleteWebDatabase()
147         {
148             Interop.WebContext.DeleteWebDatabase(SwigCPtr);
149             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
150         }
151
152         /// <summary>
153         /// Delete Web Storage.
154         /// </summary>
155         [EditorBrowsable(EditorBrowsableState.Never)]
156         public void DeleteWebStorage()
157         {
158             Interop.WebContext.DeleteWebStorage(SwigCPtr);
159             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
160         }
161
162         /// <summary>
163         /// Delete Local FileSystem.
164         /// </summary>
165         [EditorBrowsable(EditorBrowsableState.Never)]
166         public void DeleteLocalFileSystem()
167         {
168             Interop.WebContext.DeleteLocalFileSystem(SwigCPtr);
169             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
170         }
171
172         /// <summary>
173         /// Clear cache.
174         /// </summary>
175         [EditorBrowsable(EditorBrowsableState.Never)]
176         public void ClearCache()
177         {
178             Interop.WebContext.ClearCache(SwigCPtr);
179             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
180         }
181     }
182 }