1 #ifndef DALI_TOOLKIT_WEB_CONTEXT_H
2 #define DALI_TOOLKIT_WEB_CONTEXT_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/devel-api/adaptor-framework/web-engine-context.h>
26 #include <dali-toolkit/public-api/dali-toolkit-common.h>
30 class WebEngineSecurityOrigin;
35 * @addtogroup dali_toolkit_controls_web_view
40 * @brief WebContext is a control for context of WebView.
42 * For working WebContext, a WebEngineContext should be provided.
45 class DALI_TOOLKIT_API WebContext
49 * @brief Create a WebContext.
51 * @param[in] context The context of web engine.
53 WebContext(Dali::WebEngineContext& context);
58 virtual ~WebContext() final;
61 * @brief Return the cache model type.
63 * @return #Dali::WebEngineContext::CacheModel
65 Dali::WebEngineContext::CacheModel GetCacheModel() const;
68 * @brief Request to set the cache model.
70 * @param[in] cacheModel The cache model
72 void SetCacheModel(Dali::WebEngineContext::CacheModel cacheModel);
75 * @brief Set the given proxy URI to network backend of specific context.
77 * @param[in] uri The proxy URI to set
79 void SetProxyUri(const std::string& uri);
82 * @brief Add CA certificates to persistent NSS certificate database
84 * Function accepts a path to a CA certificate file, a path to a directory
85 * containing CA certificate files, or a colon-seprarated list of those.
86 * Certificate files should have *.crt extension.
87 * Directories are traversed recursively.
89 * @param[in] certificatePath path to a CA certificate file(s), see above for details
91 void SetCertificateFilePath(const std::string& certificatePath);
94 * @brief Set a proxy auth credential to network backend of specific context.
96 * @param[in] username username to set
97 * @param[in] password password to set
99 void SetDefaultProxyAuth(const std::string& username, const std::string& password);
102 * @brief Requests for deleting all web databases.
104 void DeleteAllWebDatabase();
107 * @brief Request for getting web database origins.
109 * @param[in] callback callback called after getting web database origins
111 * @return true if succeeded, false otherwise
113 bool GetWebDatabaseOrigins(Dali::WebEngineContext::WebEngineSecurityOriginAcquiredCallback callback);
116 * @brief Request for deleting web databases for origin.
118 * @param[in] origin database origin
120 * @return true if succeeded, false otherwise
122 bool DeleteWebDatabase(Dali::WebEngineSecurityOrigin& origin);
125 * @brief Gets list of origins that is stored in web storage db.
127 * @param[in] callback callback called after getting web storage origins
129 * @return true if succeeded, false otherwise
131 bool GetWebStorageOrigins(Dali::WebEngineContext::WebEngineSecurityOriginAcquiredCallback callback);
134 * @brief Get list of origins that is stored in web storage db.
136 * @param[in] origin storage origin
137 * @param[in] callback callback called after getting web storage origins
139 * @return true if succeeded, false otherwise
141 bool GetWebStorageUsageForOrigin(Dali::WebEngineSecurityOrigin& origin, Dali::WebEngineContext::WebEngineStorageUsageAcquiredCallback callback);
144 * @brief Delete all web storage.
146 * @details This function does not ensure that all data will be removed.
147 * Should be used to extend free physical memory.
149 void DeleteAllWebStorage();
152 * @brief Delete web storage db.
154 * @param[in] origin origin of db
156 * @return true if succeeded, false otherwise
158 bool DeleteWebStorage(Dali::WebEngineSecurityOrigin& origin);
161 * @brief Request for deleting all local file systems.
163 void DeleteLocalFileSystem();
166 * @brief Requests to clear cache
171 * @brief Request for deleting web application cache for origin.
173 * @param[in] origin application cache origin
175 * @return true if succeeded, false otherwise
177 bool DeleteApplicationCache(Dali::WebEngineSecurityOrigin& origin);
180 * @brief Asynchronous request to get list of all password data.
182 * @param[in] callback callback called after getting form password
184 void GetFormPasswordList(Dali::WebEngineContext::WebEngineFormPasswordAcquiredCallback callback);
187 * @brief Register callback for download started.
189 * @param[in] callback callback for download started
191 void RegisterDownloadStartedCallback(Dali::WebEngineContext::WebEngineDownloadStartedCallback callback);
194 * @brief Register callback for mime overridden.
196 * @param[in] callback callback for mime overridden
198 void RegisterMimeOverriddenCallback(Dali::WebEngineContext::WebEngineMimeOverriddenCallback callback);
201 * @brief Toggle the cache to be enabled or disabled
203 * @param[in] cacheEnabled enable or disable cache
205 void EnableCache(bool cacheEnabled);
208 * @brief Query if the cache is enabled
210 * @return @c true is cache is enabled or @c false otherwise
212 bool IsCacheEnabled() const;
215 * @brief Get CA certifcate file path
217 * It returns an internal string and should not be modified.
219 * @return @c certificate_file is path which is set during ewk_context_certificate_file_set or @c null string otherwise
221 std::string GetContextCertificateFile() const;
224 * @brief Set application id for @a context.
226 * @param[in] appID application id
228 void SetContextAppId(const std::string& appID);
231 * @brief Set application version for @a context.
233 * @param[in] appVersion application version
235 * @return @c true if successful, @c false otherwise
237 bool SetContextAppVersion(const std::string& appVersion);
240 * @brief To declare application type
242 * @param[in] applicationType The Application_Type enum
245 void SetContextApplicationType(const Dali::WebEngineContext::ApplicationType applicationType);
248 * @brief Set time offset
250 * @param[in] timeOffset The value will be added to system time as offset
252 void SetContextTimeOffset(float timeOffset);
255 * @brief Set timezone offset
257 * @param[in] timeZoneOffset offset for time zone.
258 * @param[in] daylightSavingTime The value is for daylight saving time use.
260 void SetContextTimeZoneOffset(float timeZoneOffset, float daylightSavingTime);
263 * @brief Register url schemes as CORS enabled
265 * @param[in] schemes The URL schemes list which will be added to web security policy
268 void RegisterUrlSchemesAsCorsEnabled(const std::vector<std::string>& schemes);
271 * @brief Register JS plugin mime types.
273 * @param[in] mimeTypes The MIME types will be checked by the renderer frame loader
274 * to skip creating default frame for the object tags with the registered MIME type.
276 void RegisterJsPluginMimeTypes(const std::vector<std::string>& mimeTypes);
279 * @brief Set default zoom factor
281 * @param[in] zoomFactor default zoom factor
283 void SetDefaultZoomFactor(float zoomFactor);
286 * @brief Get default zoom factor
288 * Gets default zoom factor for all pages opened with this context.
290 * @return @c default zoom factor or negative value on error
292 float GetContextDefaultZoomFactor() const;
295 * @brief Request for deleting all web application caches.
297 * @return @c true on success, otherwise @c false
299 bool DeleteAllApplicationCache();
302 * @brief Request for deleting all web indexed databases.
304 * @return @c true on success, otherwise @c false
306 bool DeleteAllWebIndexedDatabase();
309 * @brief Delete a given password data list
311 * @param[in] list List with Ewk_Password_Data
313 void DeleteFormPasswordDataList(const std::vector<std::string>& list);
316 * @brief Delete whole password data from DB
318 void DeleteAllFormPasswordData();
321 * @brief Delete all candidate form data from DB
323 void DeleteAllFormCandidateData();
326 * @brief Get the proxy URI from the network backend of specific context.
328 * @return current proxy URI or @c null string if it's not set
330 std::string GetContextProxy() const;
333 * @brief Set the given proxy to network backend of specific context.
335 * @param[in] proxy URI to set
336 * @param[in] bypass rule to set
338 void SetContextProxy(const std::string& proxy, const std::string& bypass);
341 * @brief Get the proxy bypass rule from the network backend of specific context.
343 * @return current proxy bypass rule or @c null string if it's not set
345 std::string GetProxyBypassRule() const;
348 * @brief Notify low memory to free unused memory.
350 * @return @c true on success or @c false otherwise.
352 bool FreeUnusedMemory();
355 Dali::WebEngineContext& mWebEngineContext;
362 } // namespace Toolkit
366 #endif // DALI_TOOLKIT_WEB_CONTEXT_H