[WebView] Update API reference
[platform/core/csapi/tizenfx.git] / src / Tizen.WebView / Tizen.WebView / CookieManager.cs
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
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 using System;
17
18 namespace Tizen.WebView
19 {
20     /// <summary>
21     /// Enumeration that contains accept policies for the cookies.
22     /// </summary>
23     public enum CookieAcceptPolicy
24     {
25         /// <summary>
26         /// Accepts every cookie sent from any page.
27         /// </summary>
28         Always,
29         /// <summary>
30         /// Rejects all cookies.
31         /// </summary>
32         Never,
33         /// <summary>
34         /// Accepts only cookies set by the main document loaded.
35         /// </summary>
36         NoThirdParty
37     }
38
39     /// <summary>
40     /// Enumeration that creates a type name for the storage of persistent cookies.
41     /// </summary>
42     public enum CookiePersistentStorage
43     {
44         /// <summary>
45         /// Cookies are stored in a text file in the Mozilla "cookies.txt" format.
46         /// </summary>
47         Text,
48         /// <summary>
49         /// Cookies are stored in a SQLite file in the current Mozilla format.
50         /// </summary>
51         SqlLite
52     }
53
54     /// <summary>
55     /// This class provides methods for the cookie manager.
56     /// </summary>
57     public class CookieManager
58     {
59         private IntPtr _handle;
60
61         internal CookieManager(IntPtr handle)
62         {
63             _handle = handle;
64         }
65
66         /// <summary>
67         /// Sets the cookie acceptance policy.
68         /// </summary>
69         /// <remarks>
70         /// By default, only cookies set by the main document loaded are accepted.
71         /// </remarks>
72         /// <param name="policy">The cookie acceptance policy</param>
73         public void SetCookieAcceptPolicy(CookieAcceptPolicy policy)
74         {
75             Interop.ChromiumEwk.ewk_cookie_manager_accept_policy_set(_handle, (Interop.ChromiumEwk.CookieAcceptPolicy)policy);
76         }
77
78         /// <summary>
79         /// Deletes all the cookies.
80         /// </summary>
81         public void ClearCookies()
82         {
83             Interop.ChromiumEwk.ewk_cookie_manager_cookies_clear(_handle);
84         }
85
86         /// <summary>
87         /// Sets the storage where non-session cookies are stored persistently to read/write the cookies.
88         /// </summary>
89         /// <privilege>http://tizen.org/privilege/mediastorage</privilege>
90         /// <privilege>http://tizen.org/privilege/externalstorage</privilege>
91         /// <param name="path">The path where to read/write Cookies</param>
92         /// <param name="storage">The type of storage</param>
93         public void SetPersistentStorage(string path, CookiePersistentStorage storage)
94         {
95             Interop.ChromiumEwk.ewk_cookie_manager_persistent_storage_set(_handle, path, (Interop.ChromiumEwk.CookiePersistentStorage)storage);
96         }
97     }
98 }