[dali_2.1.30] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / controls / web-view / web-context.h
1 #ifndef DALI_TOOLKIT_WEB_CONTEXT_H
2 #define DALI_TOOLKIT_WEB_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 <dali/devel-api/adaptor-framework/web-engine-context.h>
23 #include <string>
24
25 // INTERNAL INCLUDES
26 #include <dali-toolkit/public-api/dali-toolkit-common.h>
27
28 namespace Dali
29 {
30 class WebEngineSecurityOrigin;
31
32 namespace Toolkit
33 {
34 /**
35  * @addtogroup dali_toolkit_controls_web_view
36  * @{
37  */
38
39 /**
40  * @brief WebContext is a control for context of WebView.
41  *
42  * For working WebContext, a WebEngineContext should be provided.
43  *
44  */
45 class DALI_TOOLKIT_API WebContext
46 {
47 public:
48   /**
49    * @brief Create a WebContext.
50    *
51    * @param[in] context The context of web engine.
52    */
53   WebContext(Dali::WebEngineContext& context);
54
55   /**
56    * @brief Destructor.
57    */
58   virtual ~WebContext() final;
59
60   /**
61    * @brief Return the cache model type.
62    *
63    * @return #Dali::WebEngineContext::CacheModel
64    */
65   Dali::WebEngineContext::CacheModel GetCacheModel() const;
66
67   /**
68    * @brief Request to set the cache model.
69    *
70    * @param[in] cacheModel The cache model
71    */
72   void SetCacheModel(Dali::WebEngineContext::CacheModel cacheModel);
73
74   /**
75    * @brief Set the given proxy URI to network backend of specific context.
76    *
77    * @param[in] uri The proxy URI to set
78    */
79   void SetProxyUri(const std::string& uri);
80
81   /**
82    * @brief Get the proxy URI from the network backend of specific context.
83    *
84    * @return current proxy URI or null string if it's not set
85    */
86   std::string GetProxyUri() const;
87
88   /**
89    * @brief Set the given proxy to network backend of specific context.
90    *
91    * @param[in] proxy URI to set
92    * @param[in] bypass rule to set
93    */
94   void SetProxyBypassRule(const std::string& proxy, const std::string& bypass);
95
96   /**
97    * @brief Get the proxy bypass rule from the network backend of specific context.
98    *
99    * @return current proxy bypass rule or null string if it's not set
100    */
101   std::string GetProxyBypassRule() const;
102
103   /**
104    * @brief Add CA certificates to persistent NSS certificate database
105    *
106    * Function accepts a path to a CA certificate file, a path to a directory
107    * containing CA certificate files, or a colon-seprarated list of those.
108    * Certificate files should have *.crt extension.
109    * Directories are traversed recursively.
110    *
111    * @param[in] certificatePath path to a CA certificate file(s), see above for details
112    */
113   void SetCertificateFilePath(const std::string& certificatePath);
114
115   /**
116    * @brief Get CA certifcate file path
117    *
118    * It returns an internal string and should not be modified.
119    *
120    * @return certificate_file path which is set during ewk_context_certificate_file_set or null string otherwise
121    */
122   std::string GetCertificateFilePath() const;
123
124   /**
125    * @brief Set a proxy auth credential to network backend of specific context.
126    *
127    * @param[in] username username to set
128    * @param[in] password password to set
129    */
130   void SetDefaultProxyAuth(const std::string& username, const std::string& password);
131
132   /**
133    * @brief Requests for deleting all web databases.
134    */
135   void DeleteAllWebDatabase();
136
137   /**
138    * @brief Request for getting web database origins.
139    *
140    * @param[in] callback callback called after getting web database origins
141    *
142    * @return true if succeeded, false otherwise
143    */
144   bool GetWebDatabaseOrigins(Dali::WebEngineContext::WebEngineSecurityOriginAcquiredCallback callback);
145
146   /**
147    * @brief Request for deleting web databases for origin.
148    *
149    * @param[in] origin database origin
150    *
151    * @return true if succeeded, false otherwise
152    */
153   bool DeleteWebDatabase(Dali::WebEngineSecurityOrigin& origin);
154
155   /**
156    * @brief Gets list of origins that is stored in web storage db.
157    *
158    * @param[in] callback callback called after getting web storage origins
159    *
160    * @return true if succeeded, false otherwise
161    */
162   bool GetWebStorageOrigins(Dali::WebEngineContext::WebEngineSecurityOriginAcquiredCallback callback);
163
164   /**
165    * @brief Get list of origins that is stored in web storage db.
166    *
167    * @param[in] origin storage origin
168    * @param[in] callback callback called after getting web storage origins
169    *
170    * @return true if succeeded, false otherwise
171    */
172   bool GetWebStorageUsageForOrigin(Dali::WebEngineSecurityOrigin& origin, Dali::WebEngineContext::WebEngineStorageUsageAcquiredCallback callback);
173
174   /**
175    * @brief Delete all web storage.
176    *
177    * @details This function does not ensure that all data will be removed.
178    *          Should be used to extend free physical memory.
179    */
180   void DeleteAllWebStorage();
181
182   /**
183    * @brief Delete web storage db.
184    *
185    * @param[in] origin origin of db
186    *
187    * @return true if succeeded, false otherwise
188    */
189   bool DeleteWebStorage(Dali::WebEngineSecurityOrigin& origin);
190
191   /**
192    * @brief Request for deleting all local file systems.
193    */
194   void DeleteLocalFileSystem();
195
196   /**
197    * @brief Requests to clear cache
198    */
199   void ClearCache();
200
201   /**
202    * @brief Request for deleting web application cache for origin.
203    *
204    * @param[in] origin application cache origin
205    *
206    * @return true if succeeded, false otherwise
207    */
208   bool DeleteApplicationCache(Dali::WebEngineSecurityOrigin& origin);
209
210   /**
211    * @brief Asynchronous request to get list of all password data.
212    *
213    * @param[in] callback callback called after getting form password
214    */
215   void GetFormPasswordList(Dali::WebEngineContext::WebEngineFormPasswordAcquiredCallback callback);
216
217   /**
218    * @brief Register callback for download started.
219    *
220    * @param[in] callback callback for download started
221    */
222   void RegisterDownloadStartedCallback(Dali::WebEngineContext::WebEngineDownloadStartedCallback callback);
223
224   /**
225    * @brief Register callback for mime overridden.
226    *
227    * @param[in] callback callback for mime overridden
228    */
229   void RegisterMimeOverriddenCallback(Dali::WebEngineContext::WebEngineMimeOverriddenCallback callback);
230
231   /**
232    * @brief Callback to be called when http request need be intercepted.
233    *
234    * @param[in] callback
235    */
236   void RegisterRequestInterceptedCallback(Dali::WebEngineContext::WebEngineRequestInterceptedCallback callback);
237
238   /**
239    * @brief Toggle the cache to be enabled or disabled
240    *
241    * @param[in] cacheEnabled enable or disable cache
242    */
243   void EnableCache(bool cacheEnabled);
244
245   /**
246    * @brief Query if the cache is enabled
247    *
248    * @return true is cache is enabled or false otherwise
249    */
250   bool IsCacheEnabled() const;
251
252   /**
253    * @brief Set application id for context.
254    *
255    * @param[in] appId application id
256    */
257   void SetAppId(const std::string& appId);
258
259   /**
260    * @brief Set application version for context.
261    *
262    * @param[in] appVersion application version
263    *
264    * @return true if successful, false otherwise
265    */
266   bool SetAppVersion(const std::string& appVersion);
267
268   /**
269    * @brief To declare application type
270    *
271    * @param[in] applicationType The Application_Type enum
272    *
273    */
274   void SetApplicationType(const Dali::WebEngineContext::ApplicationType applicationType);
275
276   /**
277    * @brief Set time offset
278    *
279    * @param[in] timeOffset The value will be added to system time as offset
280    */
281   void SetTimeOffset(float timeOffset);
282
283   /**
284    * @brief Set timezone offset
285    *
286    * @param[in] timeZoneOffset offset for time zone.
287    * @param[in] daylightSavingTime The value is for daylight saving time use.
288    */
289   void SetTimeZoneOffset(float timeZoneOffset, float daylightSavingTime);
290
291   /**
292    * @brief Set default zoom factor
293    *
294    * @param[in] zoomFactor default zoom factor
295    */
296   void SetDefaultZoomFactor(float zoomFactor);
297
298   /**
299    * @brief Get default zoom factor
300    *
301    * Gets default zoom factor for all pages opened with this context.
302    *
303    * @return default zoom factor or negative value on error
304    */
305   float GetDefaultZoomFactor() const;
306
307   /**
308    * @brief Register url schemes as CORS enabled
309    *
310    * @param[in] schemes The URL schemes list which will be added to web security policy
311    *
312    */
313   void RegisterUrlSchemesAsCorsEnabled(const std::vector<std::string>& schemes);
314
315   /**
316    * @brief Register JS plugin mime types.
317    *
318    * @param[in] mimeTypes The MIME types will be checked by the renderer frame loader
319    * to skip creating default frame for the object tags with the registered MIME type.
320    */
321   void RegisterJsPluginMimeTypes(const std::vector<std::string>& mimeTypes);
322
323   /**
324    * @brief Request for deleting all web application caches.
325    *
326    * @return @c true on success, otherwise @c false
327    */
328   bool DeleteAllApplicationCache();
329
330   /**
331    * @brief Request for deleting all web indexed databases.
332    *
333    * @return @c true on success, otherwise @c false
334    */
335   bool DeleteAllWebIndexedDatabase();
336
337   /**
338    * @brief Delete a given password data list
339    *
340    * @param[in] list List with Ewk_Password_Data
341    */
342   void DeleteFormPasswordDataList(const std::vector<std::string>& list);
343
344   /**
345    * @brief Delete whole password data from DB
346    */
347   void DeleteAllFormPasswordData();
348
349   /**
350    * @brief Delete all candidate form data from DB
351    */
352   void DeleteAllFormCandidateData();
353
354   /**
355    * @brief Notify low memory to free unused memory.
356    *
357    * @return @c true on success or @c false otherwise.
358    */
359   bool FreeUnusedMemory();
360
361 private:
362   Dali::WebEngineContext& mWebEngineContext;
363 };
364
365 /**
366  * @}
367  */
368
369 } // namespace Toolkit
370
371 } // namespace Dali
372
373 #endif // DALI_TOOLKIT_WEB_CONTEXT_H