#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list-item.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-form-repost-decision.h>
#include <dali/devel-api/adaptor-framework/web-engine-settings.h>
#include <dali/public-api/adaptor-framework/native-image-source.h>
#include <dali/public-api/images/pixel-data.h>
#include <dali/public-api/object/any.h>
#include <dali/public-api/object/base-object.h>
+#include <memory>
#include <toolkit-application.h>
namespace Dali
WebEngineBackForwardListItem* pMockItem;
};
+class MockWebEngineFormRepostDecision : public WebEngineFormRepostDecision
+{
+public:
+ MockWebEngineFormRepostDecision()
+ {
+ }
+
+ void Reply(bool allowed) override {}
+};
+
class MockWebEngineSettings : public WebEngineSettings
{
public:
return mUrlChangedSignal;
}
+ Dali::WebEnginePlugin::WebEngineFormRepostDecisionSignalType& FormRepostDecisionSignal()
+ {
+ return mFormRepostDecisionSignal;
+ }
+
+ Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& FrameRenderedSignal()
+ {
+ return mFrameRenderedSignal;
+ }
+
std::string mUrl;
std::vector< std::string > mHistory;
size_t mCurrentPlusOnePos;
std::vector<JavaScriptEvaluatedResultCallback> mResultCallbacks;
bool mEvaluating;
- Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType mScrollEdgeReachedSignal;
- Dali::Vector2 mScrollPosition;
- Dali::Vector2 mScrollSize;
- Dali::Vector2 mContentSize;
- WebEngineBackForwardList* mockWebEngineBackForwardList;
- WebEngineContext* mockWebEngineContext;
- WebEngineCookieManager* mockWebEngineCookieManager;
- WebEngineSettings* mockWebEngineSettings;
- Dali::WebEnginePlugin::WebEngineUrlChangedSignalType mUrlChangedSignal;
+ Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType mScrollEdgeReachedSignal;
+ Dali::Vector2 mScrollPosition;
+ Dali::Vector2 mScrollSize;
+ Dali::Vector2 mContentSize;
+ WebEngineBackForwardList* mockWebEngineBackForwardList;
+ WebEngineContext* mockWebEngineContext;
+ WebEngineCookieManager* mockWebEngineCookieManager;
+ WebEngineSettings* mockWebEngineSettings;
+ Dali::WebEnginePlugin::WebEngineUrlChangedSignalType mUrlChangedSignal;
+ Dali::WebEnginePlugin::WebEngineFormRepostDecisionSignalType mFormRepostDecisionSignal;
+ Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType mFrameRenderedSignal;
JavaScriptAlertCallback mJavaScriptAlertCallback;
JavaScriptConfirmCallback mJavaScriptConfirmCallback;
gInstance->mPageLoadInProgressSignal.Emit( gInstance->mUrl );
gInstance->mPageLoadFinishedSignal.Emit( gInstance->mUrl );
gInstance->mUrlChangedSignal.Emit( "http://new-test" );
+
+ std::shared_ptr<Dali::WebEngineFormRepostDecision> decision(new MockWebEngineFormRepostDecision());
+ gInstance->mFormRepostDecisionSignal.Emit(decision);
+ gInstance->mFrameRenderedSignal.Emit();
}
return false;
}
return Internal::Adaptor::GetImplementation( *this ).UrlChangedSignal();
}
+Dali::WebEnginePlugin::WebEngineFormRepostDecisionSignalType& WebEngine::FormRepostDecisionSignal()
+{
+ return Internal::Adaptor::GetImplementation( *this ).FormRepostDecisionSignal();
+}
+
+Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& WebEngine::FrameRenderedSignal()
+{
+ return Internal::Adaptor::GetImplementation( *this ).FrameRenderedSignal();
+}
+
} // namespace Dali;
#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h>
#include <dali-toolkit/devel-api/controls/web-view/web-context.h>
#include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-form-repost-decision.h>
#include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
#include <dali-toolkit/devel-api/controls/web-view/web-view.h>
static bool gTouched = false;
static bool gHovered = false;
static bool gWheelEventHandled = false;
+static int gFormRepostDecisionCallbackCalled = 0;
+static std::shared_ptr<Dali::Toolkit::WebFormRepostDecision> gFormRepostDecisionInstance;
+static int gFrameRenderedCallbackCalled = 0;
struct CallbackFunctor
{
return true;
}
+static void OnFormRepostDecision(WebView, std::shared_ptr<Dali::Toolkit::WebFormRepostDecision> decision)
+{
+ gFormRepostDecisionCallbackCalled++;
+ gFormRepostDecisionInstance = decision;
+}
+
+static void OnFrameRendered(WebView)
+{
+ gFrameRenderedCallbackCalled++;
+}
+
} // namespace
void web_view_startup(void)
END_TEST;
}
+int UtcDaliWebViewFormRepostDecisionFrameRendering(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+ view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+ view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
+ view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
+ application.GetScene().Add( view );
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_CHECK( view );
+
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ view.FormRepostDecisionSignal().Connect(&OnFormRepostDecision);
+ view.FrameRenderedSignal().Connect(&OnFrameRendered);
+ bool signal1 = false;
+ bool signal2 = false;
+ view.ConnectSignal( testTracker, "formRepostDecision", CallbackFunctor(&signal1) );
+ view.ConnectSignal( testTracker, "frameRendered", CallbackFunctor(&signal2) );
+ DALI_TEST_EQUALS( gFormRepostDecisionCallbackCalled, 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( gFrameRenderedCallbackCalled, 0, TEST_LOCATION );
+
+ view.LoadUrl( TEST_URL1 );
+ Test::EmitGlobalTimerSignal();
+ DALI_TEST_EQUALS( gFormRepostDecisionCallbackCalled, 1, TEST_LOCATION );
+ DALI_TEST_EQUALS( gFrameRenderedCallbackCalled, 1, TEST_LOCATION );
+ DALI_TEST_CHECK( signal1 & signal2);
+
+ // form repost decision.
+ DALI_TEST_CHECK(gFormRepostDecisionInstance);
+ gFormRepostDecisionInstance->Reply(true);
+
+ // reset
+ gFormRepostDecisionInstance = nullptr;
+
+ END_TEST;
+}
+
int UtcDaliWebViewGetWebBackForwardList(void)
{
ToolkitTestApplication application;
*/
/**
- * @brief WebCookieManager is a control for settings of WebView.
+ * @brief WebCookieManager is a control for cookie manager of WebView.
*
*
* For working WebCookieManager, a WebView should be provided.
--- /dev/null
+/*
+ * 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/controls/web-view/web-form-repost-decision.h>
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/web-engine-form-repost-decision.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+WebFormRepostDecision::WebFormRepostDecision(std::shared_ptr<Dali::WebEngineFormRepostDecision> decision)
+: mFormRepostDecision(std::move(decision))
+{
+}
+
+WebFormRepostDecision::~WebFormRepostDecision()
+{
+}
+
+void WebFormRepostDecision::Reply(bool allowed)
+{
+ if(mFormRepostDecision)
+ {
+ mFormRepostDecision->Reply(allowed);
+ }
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_WEB_FORM_REPOST_DECISION_H
+#define DALI_TOOLKIT_WEB_FORM_REPOST_DECISION_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 <memory>
+#include <string>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
+
+namespace Dali
+{
+class WebEngineFormRepostDecision;
+
+namespace Toolkit
+{
+/**
+ * @addtogroup dali_toolkit_controls_web_view
+ * @{
+ */
+
+/**
+ * @brief WebFormRepostDecision is a class for form repost decision of WebView.
+ *
+ *
+ * For working WebFormRepostDecision, a Dali::WebEngineFormRepostDecision should be provided.
+ *
+ */
+class DALI_TOOLKIT_API WebFormRepostDecision
+{
+public:
+ /**
+ * @brief Creates a WebFormRepostDecision.
+ */
+ WebFormRepostDecision(std::shared_ptr<Dali::WebEngineFormRepostDecision> decision);
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~WebFormRepostDecision() final;
+
+ /**
+ * @brief Reply the result about form repost decision.
+ *
+ * @param[in] allowed Whether allow form repost decision request or not
+ */
+ void Reply(bool allowed);
+
+private:
+ std::shared_ptr<Dali::WebEngineFormRepostDecision> mFormRepostDecision;
+};
+
+/**
+ * @}
+ */
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_WEB_FORM_REPOST_DECISION_H
Dali::Toolkit::GetImpl(*this).AddJavaScriptMessageHandler(exposedObjectName, handler);
}
-void WebView::RegisterJavaScriptAlertCallback( Dali::WebEnginePlugin::JavaScriptAlertCallback callback )
+void WebView::RegisterJavaScriptAlertCallback(Dali::WebEnginePlugin::JavaScriptAlertCallback callback)
{
- Dali::Toolkit::GetImpl( *this ).RegisterJavaScriptAlertCallback( callback );
+ Dali::Toolkit::GetImpl(*this).RegisterJavaScriptAlertCallback(callback);
}
void WebView::JavaScriptAlertReply()
{
- Dali::Toolkit::GetImpl( *this ).JavaScriptAlertReply();
+ Dali::Toolkit::GetImpl(*this).JavaScriptAlertReply();
}
-void WebView::RegisterJavaScriptConfirmCallback( Dali::WebEnginePlugin::JavaScriptConfirmCallback callback )
+void WebView::RegisterJavaScriptConfirmCallback(Dali::WebEnginePlugin::JavaScriptConfirmCallback callback)
{
- Dali::Toolkit::GetImpl( *this ).RegisterJavaScriptConfirmCallback( callback );
+ Dali::Toolkit::GetImpl(*this).RegisterJavaScriptConfirmCallback(callback);
}
-void WebView::JavaScriptConfirmReply( bool confirmed )
+void WebView::JavaScriptConfirmReply(bool confirmed)
{
- Dali::Toolkit::GetImpl( *this ).JavaScriptConfirmReply( confirmed );
+ Dali::Toolkit::GetImpl(*this).JavaScriptConfirmReply(confirmed);
}
-void WebView::RegisterJavaScriptPromptCallback( Dali::WebEnginePlugin::JavaScriptPromptCallback callback )
+void WebView::RegisterJavaScriptPromptCallback(Dali::WebEnginePlugin::JavaScriptPromptCallback callback)
{
- Dali::Toolkit::GetImpl( *this ).RegisterJavaScriptPromptCallback( callback );
+ Dali::Toolkit::GetImpl(*this).RegisterJavaScriptPromptCallback(callback);
}
-void WebView::JavaScriptPromptReply( const std::string& result )
+void WebView::JavaScriptPromptReply(const std::string& result)
{
- Dali::Toolkit::GetImpl( *this ).JavaScriptPromptReply( result );
+ Dali::Toolkit::GetImpl(*this).JavaScriptPromptReply(result);
}
void WebView::ClearHistory()
void WebView::ClearAllTilesResources()
{
- Dali::Toolkit::GetImpl( *this ).ClearAllTilesResources();
+ Dali::Toolkit::GetImpl(*this).ClearAllTilesResources();
}
WebView::WebViewPageLoadSignalType& WebView::PageLoadStartedSignal()
WebView::WebViewPageLoadSignalType& WebView::PageLoadInProgressSignal()
{
- return Dali::Toolkit::GetImpl( *this ).PageLoadInProgressSignal();
+ return Dali::Toolkit::GetImpl(*this).PageLoadInProgressSignal();
}
WebView::WebViewPageLoadSignalType& WebView::PageLoadFinishedSignal()
WebView::WebViewUrlChangedSignalType& WebView::UrlChangedSignal()
{
- return Dali::Toolkit::GetImpl( *this ).UrlChangedSignal();
+ return Dali::Toolkit::GetImpl(*this).UrlChangedSignal();
+}
+
+WebView::WebViewFormRepostDecisionSignalType& WebView::FormRepostDecisionSignal()
+{
+ return Dali::Toolkit::GetImpl(*this).FormRepostDecisionSignal();
+}
+
+WebView::WebViewFrameRenderedSignalType& WebView::FrameRenderedSignal()
+{
+ return Dali::Toolkit::GetImpl(*this).FrameRenderedSignal();
}
WebView::WebView(Internal::WebView& implementation)
// EXTERNAL INCLUDES
#include <functional>
+#include <memory>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/control.h>
class WebBackForwardList;
class WebContext;
class WebCookieManager;
+class WebFormRepostDecision;
class WebSettings;
namespace Internal DALI_INTERNAL
*/
using WebViewUrlChangedSignalType = Signal<void(WebView, const std::string&)>;
+ /**
+ * @brief WebView signal type related with form repost decision.
+ */
+ using WebViewFormRepostDecisionSignalType = Signal<void(WebView, std::shared_ptr<Dali::Toolkit::WebFormRepostDecision>)>;
+
+ /**
+ * @brief WebView signal type related with frame rendered.
+ */
+ using WebViewFrameRenderedSignalType = Signal<void(WebView)>;
+
public:
/**
* @brief Creates an initialized WebView.
*/
WebViewUrlChangedSignalType& UrlChangedSignal();
+ /**
+ * @brief Connects to this signal to be notified when form repost decision is requested.
+ *
+ * @return A signal object to connect with.
+ */
+ WebViewFormRepostDecisionSignalType& FormRepostDecisionSignal();
+
+ /**
+ * @brief Connects to this signal to be notified when frame is rendered.
+ *
+ * @return A signal object to connect with.
+ */
+ WebViewFrameRenderedSignalType& FrameRenderedSignal();
+
public: // Not intended for application developers
/// @cond internal
/**
${devel_api_src_dir}/controls/web-view/web-back-forward-list-item.cpp
${devel_api_src_dir}/controls/web-view/web-context.cpp
${devel_api_src_dir}/controls/web-view/web-cookie-manager.cpp
+ ${devel_api_src_dir}/controls/web-view/web-form-repost-decision.cpp
${devel_api_src_dir}/controls/web-view/web-settings.cpp
${devel_api_src_dir}/controls/web-view/web-view.cpp
${devel_api_src_dir}/focus-manager/keyinput-focus-manager.cpp
${devel_api_src_dir}/controls/web-view/web-back-forward-list-item.h
${devel_api_src_dir}/controls/web-view/web-context.h
${devel_api_src_dir}/controls/web-view/web-cookie-manager.h
+ ${devel_api_src_dir}/controls/web-view/web-form-repost-decision.h
${devel_api_src_dir}/controls/web-view/web-settings.h
${devel_api_src_dir}/controls/web-view/web-view.h
)
#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list.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-form-repost-decision.h>
#include <dali/devel-api/adaptor-framework/web-engine-settings.h>
#include <dali/devel-api/common/stage.h>
#include <dali/devel-api/scripting/enum-helper.h>
#include <dali/public-api/object/type-registry-helper.h>
#include <dali/public-api/object/type-registry.h>
#include <cstring>
+#include <memory>
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
#include <dali-toolkit/devel-api/controls/web-view/web-context.h>
#include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-form-repost-decision.h>
#include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
#include <dali-toolkit/devel-api/image-loader/texture-manager.h>
#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "pageLoadError", PAGE_LOAD_ERROR_SIGNAL )
DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "scrollEdgeReached", SCROLL_EDGE_REACHED_SIGNAL )
DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "urlChanged", URL_CHANGED_SIGNAL )
+DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "formRepostDecision", FORM_REPOST_DECISION_SIGNAL )
+DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "frameRendered", FRAME_RENDERED_SIGNAL )
DALI_TYPE_REGISTRATION_END()
// clang-format on
mWebEngine.PageLoadErrorSignal().Connect(this, &WebView::OnPageLoadError);
mWebEngine.ScrollEdgeReachedSignal().Connect(this, &WebView::OnScrollEdgeReached);
mWebEngine.UrlChangedSignal().Connect(this, &WebView::OnUrlChanged);
+ mWebEngine.FormRepostDecisionSignal().Connect(this, &WebView::OnFormRepostDecision);
+ mWebEngine.FrameRenderedSignal().Connect(this, &WebView::OnFrameRendered);
mWebContext = std::unique_ptr<Dali::Toolkit::WebContext>(new WebContext(mWebEngine.GetContext()));
mWebCookieManager = std::unique_ptr<Dali::Toolkit::WebCookieManager>(new WebCookieManager(mWebEngine.GetCookieManager()));
return mUrlChangedSignal;
}
+Dali::Toolkit::WebView::WebViewFormRepostDecisionSignalType& WebView::FormRepostDecisionSignal()
+{
+ return mFormRepostDecisionSignal;
+}
+
+Dali::Toolkit::WebView::WebViewFrameRenderedSignalType& WebView::FrameRenderedSignal()
+{
+ return mFrameRenderedSignal;
+}
+
void WebView::OnPageLoadStarted(const std::string& url)
{
if(!mPageLoadStartedSignal.Empty())
}
}
+void WebView::OnFormRepostDecision(std::shared_ptr<Dali::WebEngineFormRepostDecision> decision)
+{
+ if(!mFormRepostDecisionSignal.Empty())
+ {
+ Dali::Toolkit::WebView handle(GetOwner());
+ std::shared_ptr<Dali::Toolkit::WebFormRepostDecision> repostDecision(new Dali::Toolkit::WebFormRepostDecision(decision));
+ mFormRepostDecisionSignal.Emit(handle, std::move(repostDecision));
+ }
+}
+
+void WebView::OnFrameRendered()
+{
+ if(!mFrameRenderedSignal.Empty())
+ {
+ Dali::Toolkit::WebView handle(GetOwner());
+ mFrameRenderedSignal.Emit(handle);
+ }
+}
+
bool WebView::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
{
Dali::BaseHandle handle(object);
webView.UrlChangedSignal().Connect(tracker, functor);
connected = true;
}
+ else if(0 == strcmp(signalName.c_str(), FORM_REPOST_DECISION_SIGNAL))
+ {
+ webView.FormRepostDecisionSignal().Connect(tracker, functor);
+ connected = true;
+ }
+ else if(0 == strcmp(signalName.c_str(), FRAME_RENDERED_SIGNAL))
+ {
+ webView.FrameRenderedSignal().Connect(tracker, functor);
+ connected = true;
+ }
return connected;
}
void ClearHistory();
/**
- * @brief Clears all tiles resources of Web.
+ * @copydoc Dali::Toolkit::WebView::ClearAllTilesResources()
*/
void ClearAllTilesResources();
*/
Dali::Toolkit::WebView::WebViewUrlChangedSignalType& UrlChangedSignal();
+ /**
+ * @copydoc Dali::Toolkit::WebView::FormRepostDecisionSignal()
+ */
+ Dali::Toolkit::WebView::WebViewFormRepostDecisionSignalType& FormRepostDecisionSignal();
+
+ /**
+ * @copydoc Dali::Toolkit::WebView::FrameRenderedSignal()
+ */
+ Dali::Toolkit::WebView::WebViewFrameRenderedSignalType& FrameRenderedSignal();
+
public: // Properties
/**
* @brief Called when a property of an object of this type is set.
*/
bool OnWheelEvent(Actor actor, const Dali::WheelEvent& wheel);
+ /**
+ * @brief Callback function to be called when form repost decision need be checked.
+ * @param[in] decision The new decision for form repost
+ */
+ void OnFormRepostDecision(std::shared_ptr<Dali::WebEngineFormRepostDecision> decision);
+
+ /**
+ * @brief Callback function to be called when frame is rendered.
+ */
+ void OnFrameRendered();
+
private:
std::string mUrl;
Dali::Toolkit::Visual::Base mVisual;
Dali::Rect<int> mWebViewArea;
bool mMouseEventsEnabled;
bool mKeyEventsEnabled;
+
+ Dali::Toolkit::WebView::WebViewFormRepostDecisionSignalType mFormRepostDecisionSignal;
+ Dali::Toolkit::WebView::WebViewFrameRenderedSignalType mFrameRenderedSignal;
};
} // namespace Internal