Add APIs for ssl certificate and http authentication. 80/254280/4
authorhuayong.xu <huayong.xu@samsung.com>
Thu, 25 Feb 2021 11:57:59 +0000 (19:57 +0800)
committerhuayong.xu <huayong.xu@samsung.com>
Tue, 6 Apr 2021 08:45:23 +0000 (16:45 +0800)
This patch is to add some APIs for ssl certificate and http
authentication in web engine.

Change-Id: I1f72530682234fede563f593654d7908396cc8f5

dali/devel-api/adaptor-framework/web-engine-certificate.h [new file with mode: 0755]
dali/devel-api/adaptor-framework/web-engine-http-auth-handler.h [new file with mode: 0755]
dali/devel-api/adaptor-framework/web-engine-plugin.h
dali/devel-api/adaptor-framework/web-engine.cpp
dali/devel-api/adaptor-framework/web-engine.h
dali/devel-api/file.list
dali/internal/web-engine/common/web-engine-impl.cpp
dali/internal/web-engine/common/web-engine-impl.h

diff --git a/dali/devel-api/adaptor-framework/web-engine-certificate.h b/dali/devel-api/adaptor-framework/web-engine-certificate.h
new file mode 100755 (executable)
index 0000000..cd0b055
--- /dev/null
@@ -0,0 +1,73 @@
+#ifndef DALI_WEB_ENGINE_CERTIFICATE_H
+#define DALI_WEB_ENGINE_CERTIFICATE_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 WebEngineCertificate for certificate of web engine.
+ */
+class WebEngineCertificate
+{
+public:
+  /**
+   * @brief Constructor.
+   */
+  WebEngineCertificate() = default;
+
+  /**
+   * @brief Destructor.
+   */
+  virtual ~WebEngineCertificate() = default;
+
+  /**
+   * @brief Allow the site access about certificate error.
+   *
+   * @param[in] allowed A value to decide policy
+   */
+  virtual void Allow(bool allowed) = 0;
+
+  /**
+   * @brief Returns information whether the certificate comes from main frame.
+   *
+   * @return true if the certificate comes from main frame, false otherwise
+   */
+  virtual bool IsFromMainFrame() const = 0;
+
+  /**
+   * @brief Query certificate's PEM data.
+   *
+   * @return A certificate itself in the PEM format.
+   */
+  virtual std::string GetPem() const = 0;
+
+  /**
+   * @brief Query if the context loaded with a given certificate is secure.
+   *
+   * @return true if the context is secure, false otherwise
+   */
+  virtual bool IsContextSecure() const = 0;
+};
+
+} // namespace Dali
+
+#endif // DALI_WEB_ENGINE_CERTIFICATE_H
diff --git a/dali/devel-api/adaptor-framework/web-engine-http-auth-handler.h b/dali/devel-api/adaptor-framework/web-engine-http-auth-handler.h
new file mode 100755 (executable)
index 0000000..6fcc132
--- /dev/null
@@ -0,0 +1,70 @@
+#ifndef DALI_WEB_ENGINE_HTTP_AUTH_HANDLER_H
+#define DALI_WEB_ENGINE_HTTP_AUTH_HANDLER_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 WebEngineHttpAuthHandler for HTTP authentication handler of web engine.
+ */
+class WebEngineHttpAuthHandler
+{
+public:
+  /**
+   * @brief Constructor.
+   */
+  WebEngineHttpAuthHandler() = default;
+
+  /**
+   * @brief Destructor.
+   */
+  virtual ~WebEngineHttpAuthHandler() = default;
+
+  /**
+   * @brief Gets the realm string of authentication challenge received.
+   *
+   * @return the realm of authentication challenge
+   */
+  virtual std::string GetRealm() const = 0;
+
+  /**
+   * @brief Suspend the operation for authentication challenge.
+   */
+  virtual void Suspend() = 0;
+
+  /**
+   * @brief Send credential for authentication challenge.
+   *
+   * @param[in] user user id from user input.
+   * @param[in] password user password from user input.
+   */
+  virtual void UseCredential(const std::string& user, const std::string& password) = 0;
+
+  /**
+   * @brief Send cancellation notification for authentication challenge.
+   */
+  virtual void CancelCredential() = 0;
+};
+
+} // namespace Dali
+
+#endif // DALI_WEB_ENGINE_HTTP_AUTH_HANDLER_H
index bbfa6f6..c87fbe4 100644 (file)
@@ -32,10 +32,12 @@ class KeyEvent;
 class PixelData;
 class TouchEvent;
 class WebEngineBackForwardList;
+class WebEngineCertificate;
 class WebEngineConsoleMessage;
 class WebEngineContext;
 class WebEngineCookieManager;
 class WebEngineFormRepostDecision;
+class WebEngineHttpAuthHandler;
 class WebEngineLoadError;
 class WebEnginePolicyDecision;
 class WebEngineRequestInterceptor;
@@ -102,6 +104,16 @@ public:
   using WebEngineConsoleMessageSignalType = Signal<void(std::shared_ptr<Dali::WebEngineConsoleMessage>)>;
 
   /**
+   * @brief WebView signal type related with certificate changed.
+   */
+  using WebEngineCertificateSignalType = Signal<void(std::shared_ptr<Dali::WebEngineCertificate>)>;
+
+  /**
+   * @brief WebView signal type related with http authentication.
+   */
+  using WebEngineHttpAuthHandlerSignalType = Signal<void(std::shared_ptr<Dali::WebEngineHttpAuthHandler>)>;
+
+  /**
    * @brief Alert callback when JavaScript alert is called with a message.
    *  It returns true if a pop-up is created successfully, false otherwise.
    */
@@ -768,6 +780,27 @@ public:
    * @return A signal object to connect with.
    */
   virtual WebEnginePolicyDecisionSignalType& PolicyDecisionSignal() = 0;
+
+  /**
+   * @brief Connects to this signal to be notified when certificate need be confirmed.
+   *
+   * @return A signal object to connect with.
+   */
+  virtual WebEngineCertificateSignalType& CertificateConfirmSignal() = 0;
+
+  /**
+   * @brief Connects to this signal to be notified when ssl certificate is changed.
+   *
+   * @return A signal object to connect with.
+   */
+  virtual WebEngineCertificateSignalType& SslCertificateChangedSignal() = 0;
+
+  /**
+   * @brief Connects to this signal to be notified when http authentication need be confirmed.
+   *
+   * @return A signal object to connect with.
+   */
+  virtual WebEngineHttpAuthHandlerSignalType& HttpAuthHandlerSignal() = 0;
 };
 
 // specialization has to be done in the same namespace
index b1d9fa0..c7edd4c 100755 (executable)
 
 // INTERNAL INCLUDES
 #include <dali/devel-api/adaptor-framework/web-engine-back-forward-list.h>
+#include <dali/devel-api/adaptor-framework/web-engine-certificate.h>
 #include <dali/devel-api/adaptor-framework/web-engine-console-message.h>
 #include <dali/devel-api/adaptor-framework/web-engine-context.h>
 #include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
+#include <dali/devel-api/adaptor-framework/web-engine-http-auth-handler.h>
 #include <dali/devel-api/adaptor-framework/web-engine-load-error.h>
 #include <dali/devel-api/adaptor-framework/web-engine-policy-decision.h>
 #include <dali/devel-api/adaptor-framework/web-engine-request-interceptor.h>
@@ -518,4 +520,19 @@ Dali::WebEnginePlugin::WebEnginePolicyDecisionSignalType& WebEngine::PolicyDecis
   return GetImplementation(*this).PolicyDecisionSignal();
 }
 
+Dali::WebEnginePlugin::WebEngineCertificateSignalType& WebEngine::CertificateConfirmSignal()
+{
+  return GetImplementation(*this).CertificateConfirmSignal();
+}
+
+Dali::WebEnginePlugin::WebEngineCertificateSignalType& WebEngine::SslCertificateChangedSignal()
+{
+  return GetImplementation(*this).SslCertificateChangedSignal();
+}
+
+Dali::WebEnginePlugin::WebEngineHttpAuthHandlerSignalType& WebEngine::HttpAuthHandlerSignal()
+{
+  return GetImplementation(*this).HttpAuthHandlerSignal();
+}
+
 } // namespace Dali
index 9b479e4..ca3ea6f 100755 (executable)
@@ -685,6 +685,27 @@ public:
    */
   Dali::WebEnginePlugin::WebEnginePolicyDecisionSignalType& PolicyDecisionSignal();
 
+  /**
+   * @brief Connects to this signal to be notified when certificate need be confirmed.
+   *
+   * @return A signal object to connect with.
+   */
+  Dali::WebEnginePlugin::WebEngineCertificateSignalType& CertificateConfirmSignal();
+
+  /**
+   * @brief Connects to this signal to be notified when ssl certificate is changed.
+   *
+   * @return A signal object to connect with.
+   */
+  Dali::WebEnginePlugin::WebEngineCertificateSignalType& SslCertificateChangedSignal();
+
+  /**
+   * @brief Connects to this signal to be notified when http authentication need be confirmed.
+   *
+   * @return A signal object to connect with.
+   */
+  Dali::WebEnginePlugin::WebEngineHttpAuthHandlerSignalType& HttpAuthHandlerSignal();
+
 private: // Not intended for application developers
   /**
    * @brief Internal constructor
index b5664dc..8e3ed5f 100755 (executable)
@@ -91,11 +91,13 @@ SET( devel_api_adaptor_framework_header_files
   ${adaptor_devel_api_dir}/adaptor-framework/web-engine.h
   ${adaptor_devel_api_dir}/adaptor-framework/web-engine-back-forward-list-item.h
   ${adaptor_devel_api_dir}/adaptor-framework/web-engine-back-forward-list.h
+  ${adaptor_devel_api_dir}/adaptor-framework/web-engine-certificate.h
   ${adaptor_devel_api_dir}/adaptor-framework/web-engine-console-message.h
   ${adaptor_devel_api_dir}/adaptor-framework/web-engine-context.h
   ${adaptor_devel_api_dir}/adaptor-framework/web-engine-cookie-manager.h
   ${adaptor_devel_api_dir}/adaptor-framework/web-engine-form-repost-decision.h
   ${adaptor_devel_api_dir}/adaptor-framework/web-engine-frame.h
+  ${adaptor_devel_api_dir}/adaptor-framework/web-engine-http-auth-handler.h
   ${adaptor_devel_api_dir}/adaptor-framework/web-engine-load-error.h
   ${adaptor_devel_api_dir}/adaptor-framework/web-engine-plugin.h
   ${adaptor_devel_api_dir}/adaptor-framework/web-engine-policy-decision.h
index 4c3b7d8..be477de 100755 (executable)
 // INTERNAL INCLUDES
 #include <dali/devel-api/adaptor-framework/environment-variable.h>
 #include <dali/devel-api/adaptor-framework/web-engine-back-forward-list.h>
+#include <dali/devel-api/adaptor-framework/web-engine-certificate.h>
 #include <dali/devel-api/adaptor-framework/web-engine-console-message.h>
 #include <dali/devel-api/adaptor-framework/web-engine-context.h>
 #include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
-#include <dali/devel-api/adaptor-framework/web-engine-request-interceptor.h>
+#include <dali/devel-api/adaptor-framework/web-engine-http-auth-handler.h>
 #include <dali/devel-api/adaptor-framework/web-engine-load-error.h>
 #include <dali/devel-api/adaptor-framework/web-engine-policy-decision.h>
+#include <dali/devel-api/adaptor-framework/web-engine-request-interceptor.h>
 #include <dali/devel-api/adaptor-framework/web-engine-settings.h>
 #include <dali/internal/system/common/environment-variables.h>
 #include <dali/public-api/adaptor-framework/native-image-source.h>
@@ -350,7 +352,7 @@ void WebEngine::JavaScriptAlertReply()
 
 void WebEngine::RegisterJavaScriptConfirmCallback(Dali::WebEnginePlugin::JavaScriptConfirmCallback callback)
 {
-  mPlugin->RegisterJavaScriptAlertCallback(callback);
+  mPlugin->RegisterJavaScriptConfirmCallback(callback);
 }
 
 void WebEngine::JavaScriptConfirmReply(bool confirmed)
@@ -613,6 +615,21 @@ Dali::WebEnginePlugin::WebEnginePolicyDecisionSignalType& WebEngine::PolicyDecis
   return mPlugin->PolicyDecisionSignal();
 }
 
+Dali::WebEnginePlugin::WebEngineCertificateSignalType& WebEngine::CertificateConfirmSignal()
+{
+  return mPlugin->CertificateConfirmSignal();
+}
+
+Dali::WebEnginePlugin::WebEngineCertificateSignalType& WebEngine::SslCertificateChangedSignal()
+{
+  return mPlugin->SslCertificateChangedSignal();
+}
+
+Dali::WebEnginePlugin::WebEngineHttpAuthHandlerSignalType& WebEngine::HttpAuthHandlerSignal()
+{
+  return mPlugin->HttpAuthHandlerSignal();
+}
+
 } // namespace Adaptor
 } // namespace Internal
 } // namespace Dali
index 0500628..b572c76 100755 (executable)
@@ -499,6 +499,21 @@ public:
    */
   Dali::WebEnginePlugin::WebEnginePolicyDecisionSignalType& PolicyDecisionSignal();
 
+  /**
+   * @copydoc Dali::WebEngine::CertificateConfirmSignal()
+   */
+  Dali::WebEnginePlugin::WebEngineCertificateSignalType& CertificateConfirmSignal();
+
+  /**
+   * @copydoc Dali::WebEngine::SslCertificateChangedSignal()
+   */
+  Dali::WebEnginePlugin::WebEngineCertificateSignalType& SslCertificateChangedSignal();
+
+  /**
+   * @copydoc Dali::WebEngine::HttpAuthHandlerSignal()
+   */
+  Dali::WebEnginePlugin::WebEngineHttpAuthHandlerSignalType& HttpAuthHandlerSignal();
+
 private:
   /**
    * @brief Constructor.