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 Get the proxy URI from the network backend of specific context.
84 * @return current proxy URI or null string if it's not set
86 std::string GetProxyUri() const;
89 * @brief Set the given proxy to network backend of specific context.
91 * @param[in] proxy URI to set
92 * @param[in] bypass rule to set
94 void SetProxyBypassRule(const std::string& proxy, const std::string& bypass);
97 * @brief Get the proxy bypass rule from the network backend of specific context.
99 * @return current proxy bypass rule or null string if it's not set
101 std::string GetProxyBypassRule() const;
104 * @brief Add CA certificates to persistent NSS certificate database
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.
111 * @param[in] certificatePath path to a CA certificate file(s), see above for details
113 void SetCertificateFilePath(const std::string& certificatePath);
116 * @brief Get CA certifcate file path
118 * It returns an internal string and should not be modified.
120 * @return certificate_file path which is set during ewk_context_certificate_file_set or null string otherwise
122 std::string GetCertificateFilePath() const;
125 * @brief Set a proxy auth credential to network backend of specific context.
127 * @param[in] username username to set
128 * @param[in] password password to set
130 void SetDefaultProxyAuth(const std::string& username, const std::string& password);
133 * @brief Requests for deleting all web databases.
135 void DeleteAllWebDatabase();
138 * @brief Request for getting web database origins.
140 * @param[in] callback callback called after getting web database origins
142 * @return true if succeeded, false otherwise
144 bool GetWebDatabaseOrigins(Dali::WebEngineContext::WebEngineSecurityOriginAcquiredCallback callback);
147 * @brief Request for deleting web databases for origin.
149 * @param[in] origin database origin
151 * @return true if succeeded, false otherwise
153 bool DeleteWebDatabase(Dali::WebEngineSecurityOrigin& origin);
156 * @brief Gets list of origins that is stored in web storage db.
158 * @param[in] callback callback called after getting web storage origins
160 * @return true if succeeded, false otherwise
162 bool GetWebStorageOrigins(Dali::WebEngineContext::WebEngineSecurityOriginAcquiredCallback callback);
165 * @brief Get list of origins that is stored in web storage db.
167 * @param[in] origin storage origin
168 * @param[in] callback callback called after getting web storage origins
170 * @return true if succeeded, false otherwise
172 bool GetWebStorageUsageForOrigin(Dali::WebEngineSecurityOrigin& origin, Dali::WebEngineContext::WebEngineStorageUsageAcquiredCallback callback);
175 * @brief Delete all web storage.
177 * @details This function does not ensure that all data will be removed.
178 * Should be used to extend free physical memory.
180 void DeleteAllWebStorage();
183 * @brief Delete web storage db.
185 * @param[in] origin origin of db
187 * @return true if succeeded, false otherwise
189 bool DeleteWebStorage(Dali::WebEngineSecurityOrigin& origin);
192 * @brief Request for deleting all local file systems.
194 void DeleteLocalFileSystem();
197 * @brief Requests to clear cache
202 * @brief Request for deleting web application cache for origin.
204 * @param[in] origin application cache origin
206 * @return true if succeeded, false otherwise
208 bool DeleteApplicationCache(Dali::WebEngineSecurityOrigin& origin);
211 * @brief Asynchronous request to get list of all password data.
213 * @param[in] callback callback called after getting form password
215 void GetFormPasswordList(Dali::WebEngineContext::WebEngineFormPasswordAcquiredCallback callback);
218 * @brief Register callback for download started.
220 * @param[in] callback callback for download started
222 void RegisterDownloadStartedCallback(Dali::WebEngineContext::WebEngineDownloadStartedCallback callback);
225 * @brief Register callback for mime overridden.
227 * @param[in] callback callback for mime overridden
229 void RegisterMimeOverriddenCallback(Dali::WebEngineContext::WebEngineMimeOverriddenCallback callback);
232 * @brief Callback to be called when http request need be intercepted.
234 * @param[in] callback
236 void RegisterRequestInterceptedCallback(Dali::WebEngineContext::WebEngineRequestInterceptedCallback callback);
239 * @brief Toggle the cache to be enabled or disabled
241 * @param[in] cacheEnabled enable or disable cache
243 void EnableCache(bool cacheEnabled);
246 * @brief Query if the cache is enabled
248 * @return true is cache is enabled or false otherwise
250 bool IsCacheEnabled() const;
253 * @brief Set application id for context.
255 * @param[in] appId application id
257 void SetAppId(const std::string& appId);
260 * @brief Set application version for context.
262 * @param[in] appVersion application version
264 * @return true if successful, false otherwise
266 bool SetAppVersion(const std::string& appVersion);
269 * @brief To declare application type
271 * @param[in] applicationType The Application_Type enum
274 void SetApplicationType(const Dali::WebEngineContext::ApplicationType applicationType);
277 * @brief Set time offset
279 * @param[in] timeOffset The value will be added to system time as offset
281 void SetTimeOffset(float timeOffset);
284 * @brief Set timezone offset
286 * @param[in] timeZoneOffset offset for time zone.
287 * @param[in] daylightSavingTime The value is for daylight saving time use.
289 void SetTimeZoneOffset(float timeZoneOffset, float daylightSavingTime);
292 * @brief Set default zoom factor
294 * @param[in] zoomFactor default zoom factor
296 void SetDefaultZoomFactor(float zoomFactor);
299 * @brief Get default zoom factor
301 * Gets default zoom factor for all pages opened with this context.
303 * @return default zoom factor or negative value on error
305 float GetDefaultZoomFactor() const;
308 * @brief Register url schemes as CORS enabled
310 * @param[in] schemes The URL schemes list which will be added to web security policy
313 void RegisterUrlSchemesAsCorsEnabled(const std::vector<std::string>& schemes);
316 * @brief Register JS plugin mime types.
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.
321 void RegisterJsPluginMimeTypes(const std::vector<std::string>& mimeTypes);
324 * @brief Request for deleting all web application caches.
326 * @return @c true on success, otherwise @c false
328 bool DeleteAllApplicationCache();
331 * @brief Request for deleting all web indexed databases.
333 * @return @c true on success, otherwise @c false
335 bool DeleteAllWebIndexedDatabase();
338 * @brief Delete a given password data list
340 * @param[in] list List with Ewk_Password_Data
342 void DeleteFormPasswordDataList(const std::vector<std::string>& list);
345 * @brief Delete whole password data from DB
347 void DeleteAllFormPasswordData();
350 * @brief Delete all candidate form data from DB
352 void DeleteAllFormCandidateData();
355 * @brief Notify low memory to free unused memory.
357 * @return @c true on success or @c false otherwise.
359 bool FreeUnusedMemory();
362 Dali::WebEngineContext& mWebEngineContext;
369 } // namespace Toolkit
373 #endif // DALI_TOOLKIT_WEB_CONTEXT_H