Add some new APIs like Context, Settings, etc. (#2419)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / WebCookieManager.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     /// WebCookieManager is a class for cookie manager of web view.
24     /// </summary>
25     [EditorBrowsable(EditorBrowsableState.Never)]
26     public class WebCookieManager : Disposable
27     {
28         /// <summary>
29         /// Cookie Accept Policy
30         /// </summary>
31         [EditorBrowsable(EditorBrowsableState.Never)]
32         public enum CookieAcceptPolicyType
33         {
34             /// <summary>
35             /// Always
36             /// </summary>
37             [EditorBrowsable(EditorBrowsableState.Never)]
38             Always,
39
40             /// <summary>
41             /// Never
42             /// </summary>
43             [EditorBrowsable(EditorBrowsableState.Never)]
44             Never,
45
46             /// <summary>
47             /// No third party.
48             /// </summary>
49             [EditorBrowsable(EditorBrowsableState.Never)]
50             NoThirdParty,
51         }
52
53         /// <summary>
54         /// Cookie accept policy
55         /// </summary>
56         [EditorBrowsable(EditorBrowsableState.Never)]
57         public CookieAcceptPolicyType CookieAcceptPolicy
58         {
59             get
60             {
61                 return (CookieAcceptPolicyType)Interop.WebCookieManager.GetCookieAcceptPolicy(SwigCPtr);
62             }
63             set
64             {
65                 Interop.WebCookieManager.SetCookieAcceptPolicy(SwigCPtr, (int)value);
66             }
67         }
68
69         /// <summary>
70         /// Cookie persistent storage type.
71         /// </summary>
72         [EditorBrowsable(EditorBrowsableState.Never)]
73         public enum CookiePersistentStorageType
74         {
75             /// <summary>
76             /// @deprecated Cookies are stored in a text file.
77             /// </summary>
78             [EditorBrowsable(EditorBrowsableState.Never)]
79             Text,
80
81             /// <summary>
82             /// stored in a SQLite file
83             /// </summary>
84             [EditorBrowsable(EditorBrowsableState.Never)]
85             SqlLite,
86         }
87
88         /// <summary>
89         /// Set the proxy uri.
90         /// </summary>
91         [EditorBrowsable(EditorBrowsableState.Never)]
92         public void SetPersistentStorage(string path, CookiePersistentStorageType storageType)
93         {
94             Interop.WebCookieManager.SetPersistentStorage(SwigCPtr, path, (int)storageType);
95             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
96         }
97
98         /// <summary>
99         /// Set Default Proxy Auth.
100         /// </summary>
101         [EditorBrowsable(EditorBrowsableState.Never)]
102         public void ClearCookies()
103         {
104             Interop.WebCookieManager.ClearCookies(SwigCPtr);
105             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
106         }
107
108         internal WebCookieManager(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
109         {
110         }
111
112         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WebCookieManager obj)
113         {
114             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
115         }
116
117         /// <summary>
118         /// Dispose for IDisposable pattern
119         /// </summary>
120         [EditorBrowsable(EditorBrowsableState.Never)]
121         protected override void Dispose(DisposeTypes type)
122         {
123             if (disposed)
124             {
125                 return;
126             }
127
128             if (type == DisposeTypes.Explicit)
129             {
130                 //Called by User
131                 //Release your own managed resources here.
132                 //You should release all of your own disposable objects here.
133             }
134
135             base.Dispose(type);
136         }
137     }
138 }