Add WebAuthDisplayQR, Response and MediaPermission 92/318392/4
authordongsug.song <dongsug.song@samsung.com>
Thu, 5 Sep 2024 12:34:42 +0000 (21:34 +0900)
committerdongsug.song <dongsug.song@samsung.com>
Mon, 30 Sep 2024 04:24:09 +0000 (13:24 +0900)
Change-Id: Iaf8239be32e894bf34f4a987fa99cf5b4a06b41f

automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp
automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp
dali-toolkit/devel-api/controls/web-view/web-view.cpp
dali-toolkit/devel-api/controls/web-view/web-view.h
dali-toolkit/internal/controls/web-view/web-view-impl.cpp
dali-toolkit/internal/controls/web-view/web-view-impl.h

index 71436e8a05a8c5b4083e29a873dda668be3d6bc9..6071a0088c047ccde9bd14cb28a775ec5864f7d1 100644 (file)
@@ -43,6 +43,7 @@
 #include <string.h>
 #include <toolkit-application.h>
 #include <memory>
+#include <dali/devel-api/adaptor-framework/web-engine/web-engine-user-media-permission-request.h>
 
 namespace Dali
 {
@@ -1508,6 +1509,18 @@ public:
   void GetPlainTextAsynchronously(PlainTextReceivedCallback callback) override
   {
   }
+  void WebAuthenticationCancel() override
+  {
+  }
+  void RegisterWebAuthDisplayQRCallback(WebEngineWebAuthDisplayQRCallback callback) override
+  {
+  }
+  void RegisterWebAuthResponseCallback(WebEngineWebAuthResponseCallback callback) override
+  {
+  }
+  void RegisterUserMediaPermissionRequestCallback(WebEngineUserMediaPermissionRequestCallback callback) override
+  {
+  }
 
 private:
   MockWebEngineSettings        settings;
@@ -1997,6 +2010,26 @@ public:
     mTextFoundCallback = callback;
   }
 
+  void WebAuthenticationCancel()
+  {
+    mWebAuthenticationCancel = true;
+  }
+
+  void RegisterWebAuthDisplayQRCallback(Dali::WebEnginePlugin::WebEngineWebAuthDisplayQRCallback callback)
+  {
+    mWebAuthDisplayQRCallback = callback;
+  }
+
+  void RegisterWebAuthResponseCallback(Dali::WebEnginePlugin::WebEngineWebAuthResponseCallback callback)
+  {
+    mWebAuthResponseCallback = callback;
+  }
+
+  void RegisterUserMediaPermissionRequestCallback(Dali::WebEnginePlugin::WebEngineUserMediaPermissionRequestCallback callback)
+  {
+    mUserMediaPermissionRequestCallback = callback;
+  }
+
   std::string              mUrl;
   std::vector<std::string> mHistory;
   size_t                   mCurrentPlusOnePos;
@@ -2046,6 +2079,25 @@ public:
   Dali::WebEnginePlugin::WebEngineFullscreenEnteredCallback       mFullscreenEnteredCallback;
   Dali::WebEnginePlugin::WebEngineFullscreenExitedCallback        mFullscreenExitedCallback;
   Dali::WebEnginePlugin::WebEngineTextFoundCallback               mTextFoundCallback;
+  bool                                                            mWebAuthenticationCancel;
+  Dali::WebEnginePlugin::WebEngineWebAuthDisplayQRCallback        mWebAuthDisplayQRCallback;
+  Dali::WebEnginePlugin::WebEngineWebAuthResponseCallback         mWebAuthResponseCallback;
+  Dali::WebEnginePlugin::WebEngineUserMediaPermissionRequestCallback mUserMediaPermissionRequestCallback;
+};
+
+class MockUserMediaPermissionRequest : public Dali::WebEngineUserMediaPermissionRequest
+{
+public:
+  MockUserMediaPermissionRequest()
+  {
+  }
+  void Set(bool allowed) const override
+  {
+  }
+  bool Suspend() const override
+  {
+    return true;
+  }
 };
 
 namespace
@@ -2176,6 +2228,19 @@ bool OnLoadUrl()
     {
       gInstance->mTextFoundCallback(1);
     }
+    if(gInstance->mWebAuthDisplayQRCallback)
+    {
+      gInstance->mWebAuthDisplayQRCallback("test-string");
+    }
+    if(gInstance->mWebAuthResponseCallback)
+    {
+      gInstance->mWebAuthResponseCallback();
+    }
+    if(gInstance->mUserMediaPermissionRequestCallback)
+    {
+      std::unique_ptr<Dali::WebEngineUserMediaPermissionRequest> request(new MockUserMediaPermissionRequest());
+      gInstance->mUserMediaPermissionRequestCallback(std::move(request), "message");
+    }
   }
   return false;
 }
@@ -2950,5 +3015,25 @@ void WebEngine::RegisterTextFoundCallback(Dali::WebEnginePlugin::WebEngineTextFo
   Internal::Adaptor::GetImplementation(*this).RegisterTextFoundCallback(callback);
 }
 
+void WebEngine::WebAuthenticationCancel()
+{
+  Internal::Adaptor::GetImplementation(*this).WebAuthenticationCancel();
+}
+
+void WebEngine::RegisterWebAuthDisplayQRCallback(Dali::WebEnginePlugin::WebEngineWebAuthDisplayQRCallback callback)
+{
+  Internal::Adaptor::GetImplementation(*this).RegisterWebAuthDisplayQRCallback(callback);
+}
+
+void WebEngine::RegisterWebAuthResponseCallback(Dali::WebEnginePlugin::WebEngineWebAuthResponseCallback callback)
+{
+  Internal::Adaptor::GetImplementation(*this).RegisterWebAuthResponseCallback(callback);
+}
+
+void WebEngine::RegisterUserMediaPermissionRequestCallback(Dali::WebEnginePlugin::WebEngineUserMediaPermissionRequestCallback callback)
+{
+  Internal::Adaptor::GetImplementation(*this).RegisterUserMediaPermissionRequestCallback(callback);
+}
+
 
 } // namespace Dali
index 6946a930098ecc6e91f5444ffcf083935c5c7d10..696b5b7933a74ba243e249f584e3c47d28d0ab81 100644 (file)
@@ -46,6 +46,7 @@
 #include <dali/integration-api/events/touch-event-integ.h>
 #include <dali/integration-api/events/wheel-event-integ.h>
 #include <dali/public-api/images/pixel-data.h>
+#include <dali/devel-api/adaptor-framework/web-engine/web-engine-user-media-permission-request.h>
 
 using namespace Dali;
 using namespace Toolkit;
@@ -107,6 +108,9 @@ static int                                                                gNewWi
 static int                                                                gFullscreenEnteredCallbackCalled        = 0;
 static int                                                                gFullscreenExitedCallbackCalled         = 0;
 static int                                                                gTextFoundCallbackCalled                = 0;
+static int                                                                gWebAuthDisplayQRCalled                 = 0;
+static int                                                                gWebAuthDisplayResponseCalled           = 0;
+static int                                                                gUserMediaPermissionRequestCalled       = 0;
 
 struct CallbackFunctor
 {
@@ -349,6 +353,21 @@ static void OnTextFound(uint32_t arg)
   gTextFoundCallbackCalled++;
 }
 
+static void OnWebAuthDisplayQR(const std::string&)
+{
+  gWebAuthDisplayQRCalled++;
+}
+
+static void OnWebAuthResponse()
+{
+  gWebAuthDisplayResponseCalled++;
+}
+
+static void OnUserMediaPermissionRequest(std::unique_ptr<Dali::WebEngineUserMediaPermissionRequest> request, const std::string& msg)
+{
+  gUserMediaPermissionRequestCalled++;
+}
+
 } // namespace
 
 void web_view_startup(void)
@@ -2544,3 +2563,73 @@ int UtcDaliWebViewRegisterTextFoundCallback(void)
   DALI_TEST_EQUALS(gTextFoundCallbackCalled, 1, TEST_LOCATION);
   END_TEST;
 }
+
+int UtcDaliWebViewRegisterWebAuthDisplayQRCallback(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK(view);
+
+  view.RegisterWebAuthDisplayQRCallback(&OnWebAuthDisplayQR);
+  DALI_TEST_EQUALS(gWebAuthDisplayQRCalled, 0, TEST_LOCATION);
+
+  view.LoadUrl(TEST_URL1);
+  Test::EmitGlobalTimerSignal();
+  DALI_TEST_EQUALS(gWebAuthDisplayQRCalled, 1, TEST_LOCATION);
+  END_TEST;
+}
+
+int UtcDaliWebViewRegisterWebAuthResponseCallback(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK(view);
+
+  view.RegisterWebAuthResponseCallback(&OnWebAuthResponse);
+  DALI_TEST_EQUALS(gWebAuthDisplayResponseCalled, 0, TEST_LOCATION);
+
+  view.LoadUrl(TEST_URL1);
+  Test::EmitGlobalTimerSignal();
+  DALI_TEST_EQUALS(gWebAuthDisplayResponseCalled, 1, TEST_LOCATION);
+  END_TEST;
+}
+
+int UtcDaliWebViewRegisterUserMediaPermissionRequestCallback(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK(view);
+
+  view.RegisterUserMediaPermissionRequestCallback(&OnUserMediaPermissionRequest);
+  DALI_TEST_EQUALS(gUserMediaPermissionRequestCalled, 0, TEST_LOCATION);
+
+  view.LoadUrl(TEST_URL1);
+  Test::EmitGlobalTimerSignal();
+  DALI_TEST_EQUALS(gUserMediaPermissionRequestCalled, 1, TEST_LOCATION);
+  END_TEST;
+}
+
+int UtcDaliWebViewWebAuthenticationCancel(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK(view);
+
+  try
+  {
+    // Just call API and exception check.
+    view.WebAuthenticationCancel();
+    tet_result(TET_PASS);
+  }
+  catch(...)
+  {
+    // Should not throw exception
+    tet_result(TET_FAIL);
+  }
+
+  END_TEST;
+}
index 7900fc1d535dd3470de146099264d37258854729..c04dc07b76c593265a821d9ab2623809519dc8c9 100755 (executable)
@@ -449,6 +449,27 @@ void WebView::GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceive
   Dali::Toolkit::GetImpl(*this).GetPlainTextAsynchronously(callback);
 }
 
+void WebView::WebAuthenticationCancel()
+{
+  Dali::Toolkit::GetImpl(*this).WebAuthenticationCancel();
+}
+
+void WebView::RegisterWebAuthDisplayQRCallback(Dali::WebEnginePlugin::WebEngineWebAuthDisplayQRCallback callback)
+{
+  Dali::Toolkit::GetImpl(*this).RegisterWebAuthDisplayQRCallback(callback);
+}
+
+void WebView::RegisterWebAuthResponseCallback(Dali::WebEnginePlugin::WebEngineWebAuthResponseCallback callback)
+{
+  Dali::Toolkit::GetImpl(*this).RegisterWebAuthResponseCallback(callback);
+}
+
+void WebView::RegisterUserMediaPermissionRequestCallback(Dali::WebEnginePlugin::WebEngineUserMediaPermissionRequestCallback callback)
+{
+  Dali::Toolkit::GetImpl(*this).RegisterUserMediaPermissionRequestCallback(callback);
+}
+
+
 WebView::WebView(Internal::WebView& implementation)
 : Control(implementation)
 {
index 6b5c5dd545c73da859cbb6d2d585463a11a564b4..da29099e5ad2266666851d4c15c620926f42af90 100755 (executable)
@@ -804,6 +804,32 @@ public:
    */
   void GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceivedCallback callback);
 
+  /**
+   * @brief Cancel WebAuthentication(cancel in progress passkey operation).
+   */
+  void WebAuthenticationCancel();
+
+  /**
+   * @brief Register WebAuthDisplayQR callback.
+   *
+   * @param[in] callback The callback informs browser app to display QR code popup for passkey scenario.
+   */
+  void RegisterWebAuthDisplayQRCallback(Dali::WebEnginePlugin::WebEngineWebAuthDisplayQRCallback callback);
+
+  /**
+   * @brief Register WebAuthResponse callback.
+   *
+   * @param[in] callback The callback informs browser app that the passkey registration and authentication has been successful and app can close QR popup.
+   */
+  void RegisterWebAuthResponseCallback(Dali::WebEnginePlugin::WebEngineWebAuthResponseCallback callback);
+
+  /**
+   * @brief Register UserMediaPermissionRequest callback.
+   *
+   * @param[in] callback The callback to be called for handling user media permission.
+   */
+  void RegisterUserMediaPermissionRequestCallback(Dali::WebEnginePlugin::WebEngineUserMediaPermissionRequestCallback callback);
+
 public: // Not intended for application developers
   /// @cond internal
   /**
index ff4665e71ce22e1c7b5a94bd4be398b58f69f8c2..ef9c838f21f711569178c1ec34634da90baebb93 100644 (file)
@@ -913,6 +913,38 @@ void WebView::GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceive
   }
 }
 
+void WebView::WebAuthenticationCancel()
+{
+  if(mWebEngine)
+  {
+    mWebEngine.WebAuthenticationCancel();
+  }
+}
+
+void WebView::RegisterWebAuthDisplayQRCallback(Dali::WebEnginePlugin::WebEngineWebAuthDisplayQRCallback callback)
+{
+  if(mWebEngine)
+  {
+    mWebEngine.RegisterWebAuthDisplayQRCallback(std::move(callback));
+  }
+}
+
+void WebView::RegisterWebAuthResponseCallback(Dali::WebEnginePlugin::WebEngineWebAuthResponseCallback callback)
+{
+  if(mWebEngine)
+  {
+    mWebEngine.RegisterWebAuthResponseCallback(std::move(callback));
+  }
+}
+
+void WebView::RegisterUserMediaPermissionRequestCallback(Dali::WebEnginePlugin::WebEngineUserMediaPermissionRequestCallback callback)
+{
+  if(mWebEngine)
+  {
+    mWebEngine.RegisterUserMediaPermissionRequestCallback(std::move(callback));
+  }
+}
+
 void WebView::OnFrameRendered()
 {
   if(mFrameRenderedCallback)
index 3a7ee8820643ce0ecbec422338a15e33b55b268c..359490145faebc0d723d017030c9e712d9e5c4ab 100644 (file)
@@ -447,6 +447,26 @@ public:
    */
   void GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceivedCallback callback);
 
+  /**
+   * @copydoc Dali::Toolkit::WebView::WebAuthenticationCancel()
+   */
+  void WebAuthenticationCancel();
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::RegisterWebAuthDisplayQRCallback()
+   */
+  void RegisterWebAuthDisplayQRCallback(Dali::WebEnginePlugin::WebEngineWebAuthDisplayQRCallback callback);
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::RegisterWebAuthResponseCallback()
+   */
+  void RegisterWebAuthResponseCallback(Dali::WebEnginePlugin::WebEngineWebAuthResponseCallback callback);
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::RegisterUserMediaPermissionRequestCallback()
+   */
+  void RegisterUserMediaPermissionRequestCallback(Dali::WebEnginePlugin::WebEngineUserMediaPermissionRequestCallback callback);
+
 public: // Properties
   /**
    * @brief Called when a property of an object of this type is set.