ac3367ff9ea23e13a87de5756b38339cd5db4468
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / web-engine-cookie-manager.h
1 #ifndef DALI_WEB_ENGINE_COOKIE_MANAGER_H
2 #define DALI_WEB_ENGINE_COOKIE_MANAGER_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <string>
23
24 namespace Dali
25 {
26 /**
27  * @brief A class WebEngineCookieManager for cookie manager of web engine.
28  */
29 class WebEngineCookieManager
30 {
31 public:
32   /**
33    * @brief Enumeration for the cookies accept policies.
34    */
35   enum class CookieAcceptPolicy
36   {
37     ALWAYS,         ///< Accepts every cookie sent from any page.
38     NEVER,          ///< Rejects all the cookies.
39     NO_THIRD_PARTY, ///< Accepts only cookies set by the main document that is loaded.
40   };
41
42   /**
43    * @brief Enumeration for the cookie persistent storage type.
44    */
45   enum class CookiePersistentStorage
46   {
47     TEXT,   ///< Cookies are stored in a text file in the Mozilla "cookies.txt" format.
48     SQLITE, ///< Cookies are stored in a SQLite file in the current Mozilla format.
49   };
50
51   /**
52    * @brief Constructor.
53    */
54   WebEngineCookieManager() = default;
55
56   /**
57    * @brief Destructor.
58    */
59   virtual ~WebEngineCookieManager() = default;
60
61   /**
62    * @brief Sets @a policy as the cookie acceptance policy for @a manager.
63    * @details By default, only cookies set by the main document loaded are
64    *          accepted.
65    *
66    * @param[in] policy A #Dali::WebEngineCookieManager::CookieAcceptPolicy
67    */
68   virtual void SetCookieAcceptPolicy(CookieAcceptPolicy policy) = 0;
69
70   /**
71    * @brief Gets the cookie acceptance policy.
72    * The default is Toolkit::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY.
73    * @see Toolkit::WebEngineCookieManager::CookieAcceptPolicy::Type
74    */
75   virtual CookieAcceptPolicy GetCookieAcceptPolicy() const = 0;
76
77   /**
78    * @brief Deletes all the cookies of @a manager.
79    */
80   virtual void ClearCookies() = 0;
81
82   /**
83    * @brief Sets the @a path where non-session cookies are stored persistently using
84    *        @a storage as the format to read/write the cookies.
85    * @details Cookies are initially read from @a path/Cookies to create an initial
86    *          set of cookies. Then, non-session cookies will be written to @a path/Cookies.
87    *          By default, @a manager doesn't store the cookies persistently, so you need to
88    *          call this method to keep cookies saved across sessions.
89    *          If @a path does not exist it will be created.
90    * @param[in] path The path where to read/write Cookies
91    * @param[in] storage The type of storage
92    */
93   virtual void SetPersistentStorage(const std::string& path, CookiePersistentStorage storage) = 0;
94 };
95
96 } // namespace Dali
97
98 #endif // DALI_WEB_ENGINE_COOKIE_MANAGER_H