1 #ifndef DALI_WEB_ENGINE_CONTEXT_H
2 #define DALI_WEB_ENGINE_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.
28 #include <dali/devel-api/adaptor-framework/web-engine-security-origin.h>
33 * @brief A class WebEngineContext for context of web engine.
35 class WebEngineContext
39 * @brief Callback for getting web database origins.
41 using WebEngineSecurityOriginAcquiredCallback = std::function<void(std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>>&)>;
44 * @brief Callback for getting web storage usage.
46 using WebEngineStorageUsageAcquiredCallback = std::function<void(uint64_t)>;
48 // forward declaration.
52 * @brief Callback for getting form password.
54 using WebEngineFormPasswordAcquiredCallback = std::function<void(std::vector<std::unique_ptr<PasswordData>>&)>;
57 * @brief Callback for download started with url.
59 using WebEngineDownloadStartedCallback = std::function<void(const std::string&)>;
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.
68 using WebEngineMimeOverriddenCallback = std::function<bool(const std::string&, const std::string&, std::string&)>;
71 * @brief Enumeration for cache model options.
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.
81 * @brief Struct for password data
92 WebEngineContext() = default;
97 virtual ~WebEngineContext() = default;
100 * @brief Return the cache model type.
101 * @return #CacheModel
103 virtual CacheModel GetCacheModel() const = 0;
106 * @brief Request to set the cache model.
107 * @param[in] cacheModel The cache model
109 virtual void SetCacheModel(CacheModel cacheModel) = 0;
112 * @brief Set the given proxy URI to network backend of specific context.
113 * @param[in] uri The proxy URI to set
115 virtual void SetProxyUri(const std::string& uri) = 0;
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
126 virtual void SetDefaultProxyAuth(const std::string& username, const std::string& password) = 0;
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
136 virtual void SetCertificateFilePath(const std::string& certificatePath) = 0;
139 * @brief Request for deleting all web databases.
141 virtual void DeleteAllWebDatabase() = 0;
144 * @brief Request for getting web database origins.
146 * @param[in] callback callback called after getting web database origins
148 * @return true if succeeded, false otherwise
150 virtual bool GetWebDatabaseOrigins(WebEngineSecurityOriginAcquiredCallback callback) = 0;
153 * @brief Request for deleting web databases for origin.
155 * @param[in] origin application cache origin
157 * @return true if succeeded, false otherwise
159 virtual bool DeleteWebDatabase(WebEngineSecurityOrigin& origin) = 0;
162 * @brief Get list of origins that is stored in web storage db.
164 * @param[in] callback callback called after getting web storage origins
166 * @return true if succeeded, false otherwise
168 virtual bool GetWebStorageOrigins(WebEngineSecurityOriginAcquiredCallback callback) = 0;
171 * @brief Get list of origins that is stored in web storage db.
173 * @param[in] origin storage origin
174 * @param[in] callback callback called after getting web storage origins
176 * @return true if succeeded, false otherwise
178 virtual bool GetWebStorageUsageForOrigin(WebEngineSecurityOrigin& origin, WebEngineStorageUsageAcquiredCallback callback) = 0;
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.
185 virtual void DeleteAllWebStorage() = 0;
188 * @brief Delete origin that is stored in web storage database.
190 * @param[in] origin origin of database
192 * @return true if succeeded, false otherwise
194 virtual bool DeleteWebStorageOrigin(WebEngineSecurityOrigin& origin) = 0;
197 * @brief Request for deleting all local file systems.
199 virtual void DeleteLocalFileSystem() = 0;
202 * @brief Toggle the cache to be enabled or disabled
203 * Function works asynchronously.
205 * @param[in] cacheDisabled enable or disable cache
207 virtual void DisableCache(bool cacheDisabled) = 0;
210 * @brief Request to clear cache
212 virtual void ClearCache() = 0;
215 * @brief Request for deleting web application cache for origin.
217 * @param[in] origin application cache origin
219 * @return true if succeeded, false otherwise
221 virtual bool DeleteApplicationCache(WebEngineSecurityOrigin& origin) = 0;
224 * @brief Asynchronous request to get list of all password data.
226 * @param[in] callback callback called after getting form password
228 virtual void GetFormPasswordList(WebEngineFormPasswordAcquiredCallback callback) = 0;
231 * @brief Register callback for download started.
233 * @param[in] callback callback for download started
235 virtual void RegisterDownloadStartedCallback(WebEngineDownloadStartedCallback callback) = 0;
238 * @brief Register callback for mime overridden.
240 * @param[in] callback callback for mime overridden
242 virtual void RegisterMimeOverriddenCallback(WebEngineMimeOverriddenCallback callback) = 0;
247 #endif // DALI_WEB_ENGINE_CONTEXT_H