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 Toggle the cache to be enabled or disabled
96 * Function works asynchronously.
97 * By default the cache is disabled resulting in not storing network data on disk.
99 * @param[in] cacheDisabled enable or disable cache
101 void DisableCache(bool cacheDisabled);
104 * @brief Set a proxy auth credential to network backend of specific context.
106 * @param[in] username username to set
107 * @param[in] password password to set
109 void SetDefaultProxyAuth(const std::string& username, const std::string& password);
112 * @brief Requests for deleting all web databases.
114 void DeleteAllWebDatabase();
117 * @brief Request for getting web database origins.
119 * @param[in] callback callback called after getting web database origins
121 * @return true if succeeded, false otherwise
123 bool GetWebDatabaseOrigins(Dali::WebEngineContext::WebEngineSecurityOriginAcquiredCallback callback);
126 * @brief Request for deleting web databases for origin.
128 * @param[in] origin database origin
130 * @return true if succeeded, false otherwise
132 bool DeleteWebDatabase(Dali::WebEngineSecurityOrigin& origin);
135 * @brief Gets list of origins that is stored in web storage db.
137 * @param[in] callback callback called after getting web storage origins
139 * @return true if succeeded, false otherwise
141 bool GetWebStorageOrigins(Dali::WebEngineContext::WebEngineSecurityOriginAcquiredCallback callback);
144 * @brief Get list of origins that is stored in web storage db.
146 * @param[in] origin storage origin
147 * @param[in] callback callback called after getting web storage origins
149 * @return true if succeeded, false otherwise
151 bool GetWebStorageUsageForOrigin(Dali::WebEngineSecurityOrigin& origin, Dali::WebEngineContext::WebEngineStorageUsageAcquiredCallback callback);
154 * @brief Delete all web storage.
156 * @details This function does not ensure that all data will be removed.
157 * Should be used to extend free physical memory.
159 void DeleteAllWebStorage();
162 * @brief Delete origin that is stored in web storage db.
164 * @param[in] origin origin of db
166 * @return true if succeeded, false otherwise
168 bool DeleteWebStorageOrigin(Dali::WebEngineSecurityOrigin& origin);
171 * @brief Request for deleting all local file systems.
173 void DeleteLocalFileSystem();
176 * @brief Requests to clear cache
181 * @brief Request for deleting web application cache for origin.
183 * @param[in] origin application cache origin
185 * @return true if succeeded, false otherwise
187 bool DeleteApplicationCache(Dali::WebEngineSecurityOrigin& origin);
190 * @brief Asynchronous request to get list of all password data.
192 * @param[in] callback callback called after getting form password
194 void GetFormPasswordList(Dali::WebEngineContext::WebEngineFormPasswordAcquiredCallback callback);
197 * @brief Register callback for download started.
199 * @param[in] callback callback for download started
201 void RegisterDownloadStartedCallback(Dali::WebEngineContext::WebEngineDownloadStartedCallback callback);
204 * @brief Register callback for mime overridden.
206 * @param[in] callback callback for mime overridden
208 void RegisterMimeOverriddenCallback(Dali::WebEngineContext::WebEngineMimeOverriddenCallback callback);
211 Dali::WebEngineContext& mWebEngineContext;
218 } // namespace Toolkit
222 #endif // DALI_TOOLKIT_WEB_CONTEXT_H