Add some APIs into web context. 37/254837/5
authorhuayong.xu <huayong.xu@samsung.com>
Mon, 8 Mar 2021 02:05:52 +0000 (10:05 +0800)
committerhuayong.xu <huayong.xu@samsung.com>
Thu, 8 Apr 2021 02:05:38 +0000 (10:05 +0800)
This patch is to add some APIs with callbacks into web context.

Change-Id: I64bd978492b9152767c6a01272cf3f2144d83ae0

dali/devel-api/adaptor-framework/web-engine-context.h [changed mode: 0644->0755]
dali/devel-api/adaptor-framework/web-engine-security-origin.h [new file with mode: 0755]
dali/devel-api/file.list

old mode 100644 (file)
new mode 100755 (executable)
index 22a5b67..b4daccd
  */
 
 // EXTERNAL INCLUDES
+#include <functional>
+#include <memory>
 #include <string>
+#include <vector>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/web-engine-security-origin.h>
 
 namespace Dali
 {
@@ -30,6 +36,38 @@ class WebEngineContext
 {
 public:
   /**
+   * @brief Callback for getting web database origins.
+   */
+  using WebEngineSecurityOriginAcquiredCallback = std::function<void(std::vector<std::unique_ptr<Dali::WebEngineSecurityOrigin>>&)>;
+
+  /**
+   * @brief Callback for getting web storage usage.
+   */
+  using WebEngineStorageUsageAcquiredCallback = std::function<void(uint64_t)>;
+
+  // forward declaration.
+  struct PasswordData;
+
+  /**
+   * @brief Callback for getting form password.
+   */
+  using WebEngineFormPasswordAcquiredCallback = std::function<void(std::vector<std::unique_ptr<PasswordData>>&)>;
+
+  /**
+   * @brief Callback for download started with url.
+   */
+  using WebEngineDownloadStartedCallback = std::function<void(const std::string&)>;
+
+  /**
+   * @brief Callback for overriding default mime type.
+   * @param[in] url for which the mime type can be overridden
+   * @param[in] current mime type that will be overridden
+   * @param[out] a new mime type for web engine.
+   * @return true if mime should be overridden by new mime, false otherwise.
+   */
+  using WebEngineMimeOverriddenCallback = std::function<bool(const std::string&, const std::string&, std::string&)>;
+
+  /**
    * @brief Enumeration for cache model options.
    */
   enum class CacheModel
@@ -40,6 +78,15 @@ public:
   };
 
   /**
+   * @brief Struct for password data
+   */
+  struct PasswordData
+  {
+    std::string url;
+    bool        useFingerprint;
+  };
+
+  /**
    * @brief Constructor.
    */
   WebEngineContext() = default;
@@ -50,25 +97,25 @@ public:
   virtual ~WebEngineContext() = default;
 
   /**
-   * @brief Returns the cache model type.
+   * @brief Return the cache model type.
    * @return #CacheModel
    */
   virtual CacheModel GetCacheModel() const = 0;
 
   /**
-   * @brief Requests to set the cache model.
+   * @brief Request to set the cache model.
    * @param[in] cacheModel The cache model
    */
   virtual void SetCacheModel(CacheModel cacheModel) = 0;
 
   /**
-   * @brief Sets the given proxy URI to network backend of specific context.
+   * @brief Set the given proxy URI to network backend of specific context.
    * @param[in] uri The proxy URI to set
    */
   virtual void SetProxyUri(const std::string& uri) = 0;
 
   /**
-   * @brief Sets a proxy auth credential to network backend of specific context.
+   * @brief Set a proxy auth credential to network backend of specific context.
    * @details Normally, proxy auth credential should be got from the callback
    *          set by ewk_view_authentication_callback_set, once the username in
    *          this API has been set with a non-null value, the authentication
@@ -79,7 +126,7 @@ public:
   virtual void SetDefaultProxyAuth(const std::string& username, const std::string& password) = 0;
 
   /**
-   * Adds CA certificates to persistent NSS certificate database
+   * @brief Add CA certificates to persistent NSS certificate database
    * Function accepts a path to a CA certificate file, a path to a directory
    * containing CA certificate files, or a colon-seprarated list of those.
    * Certificate files should have *.crt extension.
@@ -89,34 +136,110 @@ public:
   virtual void SetCertificateFilePath(const std::string& certificatePath) = 0;
 
   /**
-   * Requests for deleting all web databases.
+   * @brief Request for deleting all web databases.
+   */
+  virtual void DeleteAllWebDatabase() = 0;
+
+  /**
+   * @brief Request for getting web database origins.
+   *
+   * @param[in] callback callback called after getting web database origins
+   *
+   * @return true if succeeded, false otherwise
    */
-  virtual void DeleteWebDatabase() = 0;
+  virtual bool GetWebDatabaseOrigins(WebEngineSecurityOriginAcquiredCallback callback) = 0;
 
   /**
-   * @brief Deletes web storage.
+   * @brief Request for deleting web databases for origin.
+   *
+   * @param[in] origin application cache origin
+   *
+   * @return true if succeeded, false otherwise
+   */
+  virtual bool DeleteWebDatabase(WebEngineSecurityOrigin& origin) = 0;
+
+  /**
+   * @brief Get list of origins that is stored in web storage db.
+   *
+   * @param[in] callback callback called after getting web storage origins
+   *
+   * @return true if succeeded, false otherwise
+   */
+  virtual bool GetWebStorageOrigins(WebEngineSecurityOriginAcquiredCallback callback) = 0;
+
+  /**
+   * @brief Get list of origins that is stored in web storage db.
+   *
+   * @param[in] origin storage origin
+   * @param[in] callback callback called after getting web storage origins
+   *
+   * @return true if succeeded, false otherwise
+   */
+  virtual bool GetWebStorageUsageForOrigin(WebEngineSecurityOrigin& origin, WebEngineStorageUsageAcquiredCallback callback) = 0;
+
+  /**
+   * @brief Delete all web storage.
    * @details This function does not ensure that all data will be removed.
    *          Should be used to extend free physical memory.
    */
-  virtual void DeleteWebStorage() = 0;
+  virtual void DeleteAllWebStorage() = 0;
+
+  /**
+   * @brief Delete origin that is stored in web storage database.
+   *
+   * @param[in] origin origin of database
+   *
+   * @return true if succeeded, false otherwise
+   */
+  virtual bool DeleteWebStorageOrigin(WebEngineSecurityOrigin& origin) = 0;
 
   /**
-   * @brief Requests for deleting all local file systems.
+   * @brief Request for deleting all local file systems.
    */
   virtual void DeleteLocalFileSystem() = 0;
 
   /**
-   * Toggles the cache to be enabled or disabled
+   * @brief Toggle the cache to be enabled or disabled
    * Function works asynchronously.
-   * By default the cache is disabled resulting in not storing network data on disk.
+   *
    * @param[in] cacheDisabled enable or disable cache
    */
   virtual void DisableCache(bool cacheDisabled) = 0;
 
   /**
-   * @brief Requests to clear cache
+   * @brief Request to clear cache
    */
   virtual void ClearCache() = 0;
+
+  /**
+   * @brief Request for deleting web application cache for origin.
+   *
+   * @param[in] origin application cache origin
+   *
+   * @return true if succeeded, false otherwise
+   */
+  virtual bool DeleteApplicationCache(WebEngineSecurityOrigin& origin) = 0;
+
+  /**
+   * @brief Asynchronous request to get list of all password data.
+   *
+   * @param[in] callback callback called after getting form password
+   */
+  virtual void GetFormPasswordList(WebEngineFormPasswordAcquiredCallback callback) = 0;
+
+  /**
+   * @brief Register callback for download started.
+   *
+   * @param[in] callback callback for download started
+   */
+  virtual void RegisterDownloadStartedCallback(WebEngineDownloadStartedCallback callback) = 0;
+
+  /**
+   * @brief Register callback for mime overridden.
+   *
+   * @param[in] callback callback for mime overridden
+   */
+  virtual void RegisterMimeOverriddenCallback(WebEngineMimeOverriddenCallback callback) = 0;
 };
 
 } // namespace Dali
diff --git a/dali/devel-api/adaptor-framework/web-engine-security-origin.h b/dali/devel-api/adaptor-framework/web-engine-security-origin.h
new file mode 100755 (executable)
index 0000000..4161878
--- /dev/null
@@ -0,0 +1,59 @@
+#ifndef DALI_WEB_ENGINE_SECURITY_ORIGIN_H
+#define DALI_WEB_ENGINE_SECURITY_ORIGIN_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+
+namespace Dali
+{
+/**
+ * @brief A class WebEngineSecurityOrigin for security origin of web engine.
+ */
+class WebEngineSecurityOrigin
+{
+public:
+  /**
+   * @brief Constructor.
+   */
+  WebEngineSecurityOrigin() = default;
+
+  /**
+   * @brief Destructor.
+   */
+  virtual ~WebEngineSecurityOrigin() = default;
+
+  /**
+   * @brief Requests for getting host of security origin.
+   *
+   * @return host of security origin
+   */
+  virtual std::string GetHost() const = 0;
+
+  /**
+   * @brief Requests for getting host of security origin.
+   *
+   * @return protocol of security origin
+   */
+  virtual std::string GetProtocol() const = 0;
+};
+
+} // namespace Dali
+
+#endif // DALI_WEB_ENGINE_SECURITY_ORIGIN_H
index 8e3ed5f..847830e 100755 (executable)
@@ -102,6 +102,7 @@ SET( devel_api_adaptor_framework_header_files
   ${adaptor_devel_api_dir}/adaptor-framework/web-engine-plugin.h
   ${adaptor_devel_api_dir}/adaptor-framework/web-engine-policy-decision.h
   ${adaptor_devel_api_dir}/adaptor-framework/web-engine-request-interceptor.h
+  ${adaptor_devel_api_dir}/adaptor-framework/web-engine-security-origin.h
   ${adaptor_devel_api_dir}/adaptor-framework/web-engine-settings.h
   ${adaptor_devel_api_dir}/adaptor-framework/key-extension-plugin.h
   ${adaptor_devel_api_dir}/adaptor-framework/virtual-keyboard.h