Add changesWatch for webview cookie
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / web-engine-context.h
1 #ifndef DALI_WEB_ENGINE_CONTEXT_H
2 #define DALI_WEB_ENGINE_CONTEXT_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 <functional>
23 #include <memory>
24 #include <string>
25 #include <vector>
26
27 // INTERNAL INCLUDES
28 #include <dali/devel-api/adaptor-framework/web-engine-security-origin.h>
29
30 namespace Dali
31 {
32 /**
33  * @brief A class WebEngineContext for context of web engine.
34  */
35 class WebEngineContext
36 {
37 public:
38   /**
39    * @brief Callback for getting web database origins.
40    */
41   using WebEngineSecurityOriginAcquiredCallback = std::function<void(std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>>&)>;
42
43   /**
44    * @brief Callback for getting web storage usage.
45    */
46   using WebEngineStorageUsageAcquiredCallback = std::function<void(uint64_t)>;
47
48   // forward declaration.
49   struct PasswordData;
50
51   /**
52    * @brief Callback for getting form password.
53    */
54   using WebEngineFormPasswordAcquiredCallback = std::function<void(std::vector<std::unique_ptr<PasswordData>>&)>;
55
56   /**
57    * @brief Callback for download started with url.
58    */
59   using WebEngineDownloadStartedCallback = std::function<void(const std::string&)>;
60
61   /**
62    * @brief Callback for overriding default mime type.
63    * @param[in] url for which the mime type can be overridden
64    * @param[in] current mime type that will be overridden
65    * @param[out] a new mime type for web engine.
66    * @return true if mime should be overridden by new mime, false otherwise.
67    */
68   using WebEngineMimeOverriddenCallback = std::function<bool(const std::string&, const std::string&, std::string&)>;
69
70   /**
71    * @brief Enumeration for cache model options.
72    */
73   enum class CacheModel
74   {
75     DOCUMENT_VIEWER,     ///< Use the smallest cache capacity.
76     DOCUMENT_BROWSER,    ///< Use the bigger cache capacity than DocumentBrowser.
77     PRIMARY_WEB_BROWSER, ///< Use the biggest cache capacity.
78   };
79
80   /**
81    * @brief Struct for password data
82    */
83   struct PasswordData
84   {
85     std::string url;
86     bool        useFingerprint;
87   };
88
89   /**
90    * @brief Constructor.
91    */
92   WebEngineContext() = default;
93
94   /**
95    * @brief Destructor.
96    */
97   virtual ~WebEngineContext() = default;
98
99   /**
100    * @brief Return the cache model type.
101    * @return #CacheModel
102    */
103   virtual CacheModel GetCacheModel() const = 0;
104
105   /**
106    * @brief Request to set the cache model.
107    * @param[in] cacheModel The cache model
108    */
109   virtual void SetCacheModel(CacheModel cacheModel) = 0;
110
111   /**
112    * @brief Set the given proxy URI to network backend of specific context.
113    * @param[in] uri The proxy URI to set
114    */
115   virtual void SetProxyUri(const std::string& uri) = 0;
116
117   /**
118    * @brief Set a proxy auth credential to network backend of specific context.
119    * @details Normally, proxy auth credential should be got from the callback
120    *          set by ewk_view_authentication_callback_set, once the username in
121    *          this API has been set with a non-null value, the authentication
122    *          callback will never been invoked. Try to avoid using this API.
123    * @param[in] username username to set
124    * @param[in] password password to set
125    */
126   virtual void SetDefaultProxyAuth(const std::string& username, const std::string& password) = 0;
127
128   /**
129    * @brief Add CA certificates to persistent NSS certificate database
130    * Function accepts a path to a CA certificate file, a path to a directory
131    * containing CA certificate files, or a colon-seprarated list of those.
132    * Certificate files should have *.crt extension.
133    * Directories are traversed recursively.
134    * @param[in] certificatePath path to a CA certificate file(s), see above for details
135    */
136   virtual void SetCertificateFilePath(const std::string& certificatePath) = 0;
137
138   /**
139    * @brief Request for deleting all web databases.
140    */
141   virtual void DeleteAllWebDatabase() = 0;
142
143   /**
144    * @brief Request for getting web database origins.
145    *
146    * @param[in] callback callback called after getting web database origins
147    *
148    * @return true if succeeded, false otherwise
149    */
150   virtual bool GetWebDatabaseOrigins(WebEngineSecurityOriginAcquiredCallback callback) = 0;
151
152   /**
153    * @brief Request for deleting web databases for origin.
154    *
155    * @param[in] origin application cache origin
156    *
157    * @return true if succeeded, false otherwise
158    */
159   virtual bool DeleteWebDatabase(WebEngineSecurityOrigin& origin) = 0;
160
161   /**
162    * @brief Get list of origins that is stored in web storage db.
163    *
164    * @param[in] callback callback called after getting web storage origins
165    *
166    * @return true if succeeded, false otherwise
167    */
168   virtual bool GetWebStorageOrigins(WebEngineSecurityOriginAcquiredCallback callback) = 0;
169
170   /**
171    * @brief Get list of origins that is stored in web storage db.
172    *
173    * @param[in] origin storage origin
174    * @param[in] callback callback called after getting web storage origins
175    *
176    * @return true if succeeded, false otherwise
177    */
178   virtual bool GetWebStorageUsageForOrigin(WebEngineSecurityOrigin& origin, WebEngineStorageUsageAcquiredCallback callback) = 0;
179
180   /**
181    * @brief Delete all web storage.
182    * @details This function does not ensure that all data will be removed.
183    *          Should be used to extend free physical memory.
184    */
185   virtual void DeleteAllWebStorage() = 0;
186
187   /**
188    * @brief Delete origin that is stored in web storage database.
189    *
190    * @param[in] origin origin of database
191    *
192    * @return true if succeeded, false otherwise
193    */
194   virtual bool DeleteWebStorageOrigin(WebEngineSecurityOrigin& origin) = 0;
195
196   /**
197    * @brief Request for deleting all local file systems.
198    */
199   virtual void DeleteLocalFileSystem() = 0;
200
201   /**
202    * @brief Toggle the cache to be enabled or disabled
203    * Function works asynchronously.
204    *
205    * @param[in] cacheDisabled enable or disable cache
206    */
207   virtual void DisableCache(bool cacheDisabled) = 0;
208
209   /**
210    * @brief Request to clear cache
211    */
212   virtual void ClearCache() = 0;
213
214   /**
215    * @brief Request for deleting web application cache for origin.
216    *
217    * @param[in] origin application cache origin
218    *
219    * @return true if succeeded, false otherwise
220    */
221   virtual bool DeleteApplicationCache(WebEngineSecurityOrigin& origin) = 0;
222
223   /**
224    * @brief Asynchronous request to get list of all password data.
225    *
226    * @param[in] callback callback called after getting form password
227    */
228   virtual void GetFormPasswordList(WebEngineFormPasswordAcquiredCallback callback) = 0;
229
230   /**
231    * @brief Register callback for download started.
232    *
233    * @param[in] callback callback for download started
234    */
235   virtual void RegisterDownloadStartedCallback(WebEngineDownloadStartedCallback callback) = 0;
236
237   /**
238    * @brief Register callback for mime overridden.
239    *
240    * @param[in] callback callback for mime overridden
241    */
242   virtual void RegisterMimeOverriddenCallback(WebEngineMimeOverriddenCallback callback) = 0;
243 };
244
245 } // namespace Dali
246
247 #endif // DALI_WEB_ENGINE_CONTEXT_H