class WebEngineContext;
class WebEngineCookieManager;
class WebEngineFormRepostDecision;
+class WebEngineRequestInterceptor;
class WebEngineSettings;
class HoverEvent;
class WheelEvent;
using VideoPlayingCallback = std::function<void(bool)>;
/**
+ * @brief WebView signal type related with http request interceptor.
+ */
+ using WebEngineRequestInterceptorSignalType = Signal<void(std::shared_ptr<Dali::WebEngineRequestInterceptor>)>;
+
+ /**
* @brief Alert callback when JavaScript alert is called with a message.
* It returns true if a pop-up is created successfully, false otherwise.
*/
* @brief Support mouse events or not.
* @param[in] enabled True if enabled, false othewise.
*/
- virtual void EnableMouseEvents( bool enabled ) = 0;
+ virtual void EnableMouseEvents(bool enabled) = 0;
/**
* @brief Support key events or not.
* @param[in] enabled True if enabled, false othewise.
*/
- virtual void EnableKeyEvents( bool enabled ) = 0;
+ virtual void EnableKeyEvents(bool enabled) = 0;
/**
* @brief Sets focus.
* @brief Sends Hover Events.
* @param[in] event The hover event would be sent.
*/
- virtual bool SendHoverEvent( const HoverEvent& event ) = 0;
+ virtual bool SendHoverEvent(const HoverEvent& event) = 0;
/**
* @brief Sends Wheel Events.
* @param[in] event The wheel event would be sent.
*/
- virtual bool SendWheelEvent( const WheelEvent& event ) = 0;
+ virtual bool SendWheelEvent(const WheelEvent& event) = 0;
/**
* @brief Connects to this signal to be notified when page loading is started.
* @return A signal object to connect with.
*/
virtual WebEngineFrameRenderedSignalType& FrameRenderedSignal() = 0;
+
+ /**
+ * @brief Connects to this signal to be notified when http request need be intercepted.
+ *
+ * @return A signal object to connect with.
+ */
+ virtual WebEngineRequestInterceptorSignalType& RequestInterceptorSignal() = 0;
};
// specialization has to be done in the same namespace
--- /dev/null
+#ifndef DALI_WEB_ENGINE_REQUEST_INTERCEPTOR_H
+#define DALI_WEB_ENGINE_REQUEST_INTERCEPTOR_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 WebEngineRequestInterceptor for intercepting http request.
+ */
+class WebEngineRequestInterceptor
+{
+public:
+ /**
+ * @brief Constructor.
+ */
+ WebEngineRequestInterceptor() = default;
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~WebEngineRequestInterceptor() = default;
+
+ /**
+ * @brief Returns request url.
+ *
+ * @return url on success or empty on failure
+ */
+ virtual std::string GetUrl() const = 0;
+
+ /**
+ * @brief Ignores request.
+ *
+ * @return true on success or false on failure
+ */
+ virtual bool Ignore() = 0;
+
+ /**
+ * @brief Sets status code and status text of response for intercepted request.
+ *
+ * @param[in] statusCode Status code of response
+ * @param[in] customStatusText Status code of response
+ *
+ * @return true if succeeded or false if failed
+ */
+ virtual bool SetResponseStatus(int statusCode, const std::string& customStatusText) = 0;
+
+ /**
+ * @brief Adds HTTP header to response for intercepted request.
+ *
+ * @param[in] fieldName Key of response header
+ * @param[in] fieldValue Value of response header
+ *
+ * @return true if succeeded or false if failed
+ */
+ virtual bool AddResponseHeader(const std::string& fieldName, const std::string& fieldValue) = 0;
+
+ /**
+ * @brief Writes whole response body at once.
+ *
+ * @param[in] body Contents of response
+ * @param[in] length Length of Contents of response
+ *
+ * @return true if succeeded or false if failed
+ */
+ virtual bool AddResponseBody(const std::string& body, uint32_t length) = 0;
+};
+
+} // namespace Dali
+
+#endif // DALI_WEB_ENGINE_REQUEST_INTERCEPTOR_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-request-interceptor.h>
#include <dali/devel-api/adaptor-framework/web-engine-settings.h>
#include <dali/internal/web-engine/common/web-engine-impl.h>
return GetImplementation(*this).FrameRenderedSignal();
}
+Dali::WebEnginePlugin::WebEngineRequestInterceptorSignalType& WebEngine::RequestInterceptorSignal()
+{
+ return GetImplementation(*this).RequestInterceptorSignal();
+}
+
} // namespace Dali
*/
Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& FrameRenderedSignal();
+ /**
+ * @brief Connects to this signal to be notified when http request need be intercepted.
+ *
+ * @return A signal object to connect with.
+ */
+ Dali::WebEnginePlugin::WebEngineRequestInterceptorSignalType& RequestInterceptorSignal();
+
private: // Not intended for application developers
/**
* @brief Internal constructor
${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-plugin.h
+ ${adaptor_devel_api_dir}/adaptor-framework/web-engine-request-interceptor.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
#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-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>
return mPlugin->FrameRenderedSignal();
}
+Dali::WebEnginePlugin::WebEngineRequestInterceptorSignalType& WebEngine::RequestInterceptorSignal()
+{
+ return mPlugin->RequestInterceptorSignal();
+}
+
} // namespace Adaptor
} // namespace Internal
} // namespace Dali
*/
Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& FrameRenderedSignal();
+ /**
+ * @copydoc Dali::WebEngine::RequestInterceptorSignal()
+ */
+ Dali::WebEnginePlugin::WebEngineRequestInterceptorSignalType& RequestInterceptorSignal();
+
private:
/**
* @brief Constructor.