[Tizen] Implement WebEngine Interface 04/189704/3 accepted/tizen/unified/20180928.080654 submit/tizen/20180928.004536
authorYoungsoo Son <ysoo.son@samsung.com>
Wed, 4 Jul 2018 11:29:57 +0000 (20:29 +0900)
committerJiyun Yang <ji.yang@samsung.com>
Thu, 20 Sep 2018 05:28:15 +0000 (14:28 +0900)
Implement WebEngine which is a proxy class to dynamically load, use and unload web engine plugin

Change-Id: I110cfb82514b5906f974107157b72a72cf930e42
Signed-off-by: Youngsoo Son <ysoo.son@samsung.com>
build/tizen/adaptor/Makefile.am
build/tizen/adaptor/module.list
dali/devel-api/adaptor-framework/web-engine-plugin.h [new file with mode: 0644]
dali/devel-api/adaptor-framework/web-engine.cpp [new file with mode: 0644]
dali/devel-api/adaptor-framework/web-engine.h [new file with mode: 0644]
dali/devel-api/file.list
dali/internal/web-engine/common/web-engine-impl.cpp [new file with mode: 0644]
dali/internal/web-engine/common/web-engine-impl.h [new file with mode: 0644]
dali/internal/web-engine/file.list [new file with mode: 0644]

index 2fad247..caa27d9 100644 (file)
@@ -64,6 +64,7 @@ LIBDALI_ADAPTOR_LA_SOURCES = \
                   $(adaptor_text_ubuntu_src_files) \
                   $(adaptor_resampler_src_files) \
                   $(adaptor_video_common_src_files) \
+                  $(adaptor_web_engine_common_src_files) \
                   $(adaptor_window_system_common_src_files) \
                   $(adaptor_trace_common_src_files) \
                   $(adaptor_thread_common_src_files) \
@@ -116,6 +117,7 @@ LIBDALI_ADAPTOR_LA_SOURCES = \
                   $(adaptor_text_common_src_files) \
                   $(adaptor_resampler_src_files) \
                   $(adaptor_video_common_src_files) \
+                  $(adaptor_web_engine_common_src_files) \
                   $(adaptor_window_system_common_src_files) \
                   $(adaptor_window_system_tizen_src_files) \
                   $(adaptor_window_system_tizen_wayland_src_files) \
@@ -178,6 +180,7 @@ LIBDALI_ADAPTOR_LA_SOURCES = \
                   $(adaptor_text_common_src_files) \
                   $(adaptor_resampler_src_files) \
                   $(adaptor_video_common_src_files) \
+                  $(adaptor_web_engine_common_src_files) \
                   $(adaptor_window_system_common_src_files) \
                   $(adaptor_window_system_tizen_src_files) \
                   $(adaptor_window_system_tizen_wayland_src_files) \
@@ -239,6 +242,7 @@ LIBDALI_ADAPTOR_LA_SOURCES = \
                   $(adaptor_text_common_src_files) \
                   $(adaptor_resampler_src_files) \
                   $(adaptor_video_common_src_files) \
+                  $(adaptor_web_engine_common_src_files) \
                   $(adaptor_window_system_common_src_files) \
                   $(adaptor_window_system_tizen_src_files) \
                   $(adaptor_window_system_tizen_wayland_src_files) \
@@ -299,6 +303,7 @@ LIBDALI_ADAPTOR_LA_SOURCES = \
                   $(adaptor_text_common_src_files) \
                   $(adaptor_resampler_src_files) \
                   $(adaptor_video_common_src_files) \
+                  $(adaptor_web_engine_common_src_files) \
                   $(adaptor_window_system_common_src_files) \
                   $(adaptor_window_system_tizen_src_files) \
                   $(adaptor_window_system_tizen_wayland_src_files) \
@@ -362,6 +367,7 @@ LIBDALI_ADAPTOR_LA_SOURCES = \
                   $(adaptor_text_common_src_files) \
                   $(adaptor_resampler_src_files) \
                   $(adaptor_video_common_src_files) \
+                  $(adaptor_web_engine_common_src_files) \
                   $(adaptor_window_system_common_src_files) \
                   $(adaptor_window_system_tizen_src_files) \
                   $(adaptor_window_system_tizen_wayland_src_files) \
index f174bc1..30e4128 100644 (file)
@@ -55,6 +55,10 @@ include ../../../dali/internal/text/file.list
 adaptor_video_dir = ../../../dali/internal/video
 include ../../../dali/internal/video/file.list
 
+# Module: web
+adaptor_web_engine_dir = ../../../dali/internal/web-engine
+include ../../../dali/internal/web-engine/file.list
+
 # Module: window-system
 adaptor_window_system_dir = ../../../dali/internal/window-system
 include ../../../dali/internal/window-system/file.list
diff --git a/dali/devel-api/adaptor-framework/web-engine-plugin.h b/dali/devel-api/adaptor-framework/web-engine-plugin.h
new file mode 100644 (file)
index 0000000..215ea0d
--- /dev/null
@@ -0,0 +1,198 @@
+#ifndef DALI_WEB_ENGINE_PLUGIN_H
+#define DALI_WEB_ENGINE_PLUGIN_H
+
+/*
+ * Copyright (c) 2018 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 <dali/public-api/images/native-image-interface.h>
+#include <dali/public-api/signals/dali-signal.h>
+#include <functional>
+
+namespace Dali
+{
+
+class KeyEvent;
+class TouchData;
+
+/**
+ * @brief WebEnginePlugin is an abstract interface, used by dali-adaptor to access WebEngine plugin.
+ * A concrete implementation must be created for each platform and provided as dynamic library.
+ */
+class WebEnginePlugin
+{
+public:
+
+  typedef Signal< void( const std::string& ) > WebEngineSignalType;
+
+  /**
+   * @brief Constructor.
+   */
+  WebEnginePlugin()
+  {
+  }
+
+  /**
+   * @brief Destructor.
+   */
+  virtual ~WebEnginePlugin()
+  {
+  }
+
+  /**
+   * @brief Creates WebEngine instance.
+   *
+   * @param [in] width The width of Web
+   * @param [in] height The height of Web
+   * @param [in] locale The locale of Web
+   * @param [in] timezoneId The timezoneID of Web
+   */
+  virtual void Create( int width, int height, const std::string& locale, const std::string& timezoneId ) = 0;
+
+  /**
+   * @brief Destroys WebEngine instance.
+   */
+  virtual void Destroy() = 0;
+
+  /**
+   * @brief Loads a web page based on a given URL.
+   *
+   * @param [in] url The URL of the resource to load
+   */
+  virtual void LoadUrl( const std::string& url ) = 0;
+
+  /**
+   * @brief Gets image to render.
+   */
+  virtual NativeImageInterfacePtr GetNativeImageSource() = 0;
+
+  /**
+   * @brief Returns the URL of the Web.
+   *
+   * @return Url of string type
+   */
+  virtual const std::string& GetUrl() = 0;
+
+  /**
+   * @brief Loads a given string as web contents.
+   *
+   * @param [in] htmlString The string to use as the contents of the web page
+   */
+  virtual void LoadHTMLString( const std::string& htmlString ) = 0;
+
+  /**
+   * @brief Reloads the Web.
+   */
+  virtual void Reload() = 0;
+
+  /**
+   * @brief Stops loading web contents on the current page.
+   */
+  virtual void StopLoading() = 0;
+
+  /**
+   * @brief Returns whether forward is possible.
+   *
+   * @return True if forward is possible, false otherwise
+   */
+  virtual bool CanGoForward() = 0;
+
+  /**
+   * @brief Goes to forward.
+   */
+  virtual void GoForward() = 0;
+
+  /**
+   * @brief Returns whether backward is possible.
+   *
+   * @return True if backward is possible, false otherwise
+   */
+  virtual bool CanGoBack() = 0;
+
+  /**
+   * @brief Goes to back.
+   */
+  virtual void GoBack() = 0;
+
+  /**
+    * @brief Evaluates JavaScript code represented as a string.
+    *
+    * @param[in] script The JavaScript code
+    */
+  virtual void EvaluateJavaScript( const std::string& script ) = 0;
+
+  /**
+    * @brief Adds a JavaScript interface.
+    *
+    * @param[in] exposedObjectName The name of exposed object
+    * @param[in] jsFunctionName The name of JavaScript function
+    * @param[in] cb The callback function
+    */
+  virtual void AddJavaScriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName, std::function< std::string(const std::string&) > cb ) = 0;
+
+  /**
+    * @brief Removes a JavaScript interface.
+    *
+    * @param[in] exposedObjectName The name of exposed object
+    * @param[in] jsFunctionName The name of JavaScript function
+    */
+  virtual void RemoveJavascriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName ) = 0;
+
+  /**
+   * @brief Clears the history of Web.
+   */
+  virtual void ClearHistory() = 0;
+
+  /**
+   * @brief Clears the cache of Web.
+   */
+  virtual void ClearCache() = 0;
+
+  /**
+   * @brief Sets size of Web Page.
+   */
+  virtual void SetSize( int width, int height ) = 0;
+
+  /**
+   * @brief Sends Touch Events.
+   */
+  virtual bool SendTouchEvent( const TouchData& touch ) = 0;
+
+  /**
+   * @brief Sends Key Events.
+   */
+  virtual bool SendKeyEvent( const KeyEvent& event ) = 0;
+
+  /**
+   * @brief Connects to this signal to be notified when page loading is started.
+   *
+   * @return A signal object to connect with.
+   */
+  virtual WebEngineSignalType& PageLoadStartedSignal() = 0;
+
+  /**
+   * @brief Connects to this signal to be notified when page loading is finished.
+   *
+   * @return A signal object to connect with.
+   */
+  virtual WebEngineSignalType& PageLoadFinishedSignal() = 0;
+
+};
+
+} // namespace Dali;
+
+#endif
diff --git a/dali/devel-api/adaptor-framework/web-engine.cpp b/dali/devel-api/adaptor-framework/web-engine.cpp
new file mode 100644 (file)
index 0000000..b8921c0
--- /dev/null
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2018 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/devel-api/adaptor-framework/web-engine.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/web-engine/common/web-engine-impl.h>
+
+namespace Dali
+{
+
+WebEngine::WebEngine()
+{
+}
+
+WebEngine::WebEngine( Internal::Adaptor::WebEngine* internal )
+: BaseHandle( internal )
+{
+}
+
+WebEngine::~WebEngine()
+{
+}
+
+WebEngine WebEngine::New()
+{
+  Internal::Adaptor::WebEnginePtr engine = Internal::Adaptor::WebEngine::New();
+
+  return WebEngine( engine.Get() );
+}
+
+WebEngine::WebEngine( const WebEngine& webEngine )
+: BaseHandle( webEngine )
+{
+}
+
+WebEngine& WebEngine::operator=( const WebEngine& webEngine )
+{
+  if( *this != webEngine )
+  {
+    BaseHandle::operator=( webEngine );
+  }
+  return *this;
+}
+
+WebEngine WebEngine::DownCast( BaseHandle handle )
+{
+  return WebEngine( dynamic_cast< Internal::Adaptor::WebEngine* >( handle.GetObjectPtr() ) );
+}
+
+void WebEngine::Create( int width, int height, const std::string& locale, const std::string& timezoneId )
+{
+  GetImplementation( *this ).Create( width, height, locale, timezoneId );
+}
+
+void WebEngine::Destroy()
+{
+  GetImplementation( *this ).Destroy();
+}
+
+NativeImageInterfacePtr WebEngine::GetNativeImageSource()
+{
+  return GetImplementation( *this ).GetNativeImageSource();
+}
+
+void WebEngine::LoadUrl( const std::string& url )
+{
+  return GetImplementation( *this ).LoadUrl( url );
+}
+
+const std::string& WebEngine::GetUrl()
+{
+  return GetImplementation( *this ).GetUrl();
+}
+
+void WebEngine::LoadHTMLString( const std::string& htmlString )
+{
+  GetImplementation( *this ).LoadHTMLString( htmlString );
+}
+
+void WebEngine::Reload()
+{
+  GetImplementation( *this ).Reload();
+}
+
+void WebEngine::StopLoading()
+{
+  GetImplementation( *this ).StopLoading();
+}
+
+bool WebEngine::CanGoForward()
+{
+  return GetImplementation( *this ).CanGoForward();
+}
+
+void WebEngine::GoForward()
+{
+  GetImplementation( *this ).GoForward();
+}
+
+bool WebEngine::CanGoBack()
+{
+  return GetImplementation( *this ).CanGoBack();
+}
+
+void WebEngine::GoBack()
+{
+  GetImplementation( *this ).GoBack();
+}
+
+void WebEngine::EvaluateJavaScript( const std::string& script )
+{
+  GetImplementation( *this ).EvaluateJavaScript( script );
+}
+
+void WebEngine::AddJavaScriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName, std::function< std::string(const std::string&) > cb )
+{
+  GetImplementation( *this ).AddJavaScriptInterface( exposedObjectName, jsFunctionName, cb );
+}
+
+void WebEngine::RemoveJavascriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName )
+{
+  GetImplementation( *this ).RemoveJavascriptInterface( exposedObjectName, jsFunctionName );
+}
+
+void WebEngine::ClearHistory()
+{
+  return GetImplementation( *this ).ClearHistory();
+}
+
+void WebEngine::ClearCache()
+{
+  return GetImplementation( *this ).ClearCache();
+}
+
+void WebEngine::SetSize( int width, int height )
+{
+  return GetImplementation( *this ).SetSize( width, height );
+}
+
+bool WebEngine::SendTouchEvent( const TouchData& touch )
+{
+  return GetImplementation( *this ).SendTouchEvent( touch );
+}
+
+bool WebEngine::SendKeyEvent( const KeyEvent& event )
+{
+  return GetImplementation( *this ).SendKeyEvent( event );
+}
+
+Dali::WebEnginePlugin::WebEngineSignalType& WebEngine::PageLoadStartedSignal()
+{
+  return GetImplementation( *this ).PageLoadStartedSignal();
+}
+
+Dali::WebEnginePlugin::WebEngineSignalType& WebEngine::PageLoadFinishedSignal()
+{
+  return GetImplementation( *this ).PageLoadFinishedSignal();
+}
+
+} // namespace Dali;
+
diff --git a/dali/devel-api/adaptor-framework/web-engine.h b/dali/devel-api/adaptor-framework/web-engine.h
new file mode 100644 (file)
index 0000000..12fdf73
--- /dev/null
@@ -0,0 +1,238 @@
+#ifndef DALI_WEB_ENGINE_H
+#define DALI_WEB_ENGINE_H
+
+/*
+ * Copyright (c) 2018 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 <dali/public-api/object/base-handle.h>
+
+//INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/web-engine-plugin.h>
+#include <dali/public-api/dali-adaptor-common.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+  class WebEngine;
+} // namespace Adaptor
+
+} // namespace Internal
+
+/**
+ * @brief Proxy class to dynamically load, use and unload web engine plugin.
+ *
+ * The purpose of this class is to dynamically load the web engine plugin if and when its needed.
+ * So we don't slow down every application startup if they never need web engine.
+ */
+class DALI_ADAPTOR_API WebEngine : public BaseHandle
+{
+public:
+
+  /**
+   * @brief Constructor.
+   */
+  WebEngine();
+
+  /**
+   * @brief Destructor.
+   */
+  ~WebEngine();
+
+  /**
+   * @brief Creates a new instance of a WebEngine.
+   */
+  static WebEngine New();
+
+  /**
+   * @brief Copy constructor.
+   *
+   * @param[in] WebEngine WebEngine to copy. The copied WebEngine will point at the same implementation
+   */
+  WebEngine( const WebEngine& WebEngine );
+
+  /**
+   * @brief Assignment operator.
+   *
+   * @param[in] WebEngine The WebEngine to assign from.
+   * @return The updated WebEngine.
+   */
+  WebEngine& operator=( const WebEngine& WebEngine );
+
+  /**
+   * @brief Downcast a handle to WebEngine handle.
+   *
+   * If handle points to a WebEngine the downcast produces valid
+   * handle. If not the returned handle is left uninitialized.
+   *
+   * @param[in] handle Handle to an object
+   * @return Handle to a WebEngine or an uninitialized handle
+   */
+  static WebEngine DownCast( BaseHandle handle );
+
+  /**
+   * @brief Creates WebEngine instance.
+   *
+   * @param [in] width The width of Web
+   * @param [in] height The height of Web
+   * @param [in] locale The locale of Web
+   * @param [in] timezoneId The timezoneID of Web
+   */
+  void Create( int width, int height, const std::string& locale, const std::string& timezoneId );
+
+  /**
+   * @brief Destroys WebEngine instance.
+   */
+  void Destroy();
+
+  /**
+   * @brief Gets native image source to render.
+   */
+  NativeImageInterfacePtr GetNativeImageSource();
+
+  /**
+   * @brief Loads a web page based on a given URL.
+   *
+   * @param [in] url The URL of the resource to load
+   */
+  void LoadUrl( const std::string& url );
+
+  /**
+   * @brief Gets the url.
+   */
+  const std::string& GetUrl();
+
+  /**
+   * @brief Loads a given string as web contents.
+   *
+   * @param [in] htmlString The string to use as the contents of the web page
+   */
+  void LoadHTMLString( const std::string& htmlString );
+
+  /**
+   * @brief Reloads the Web.
+   */
+  void Reload();
+
+  /**
+   * @brief Stops loading web contents on the current page.
+   */
+  void StopLoading();
+
+  /**
+   * @brief Returns whether forward is possible.
+   *
+   * @return True if forward is possible, false otherwise
+   */
+  bool CanGoForward();
+
+  /**
+   * @brief Goes to forward.
+   */
+  void GoForward();
+
+  /**
+   * @brief Returns whether backward is possible.
+   *
+   * @return True if backward is possible, false otherwise
+   */
+  bool CanGoBack();
+
+  /**
+   * @brief Goes to back.
+   */
+  void GoBack();
+
+  /**
+    * @brief Evaluates JavaScript code represented as a string.
+    *
+    * @param[in] script The JavaScript code
+    */
+  void EvaluateJavaScript( const std::string& script );
+
+  /**
+    * @brief Adds a JavaScript interface.
+    *
+    * @param[in] exposedObjectName The name of exposed object
+    * @param[in] jsFunctionName The name of JavaScript function
+    * @param[in] cb The callback function
+    */
+  void AddJavaScriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName, std::function< std::string(const std::string&) > cb );
+
+  /**
+    * @brief Removes a JavaScript interface.
+    *
+    * @param[in] exposedObjectName The name of exposed object
+    * @param[in] jsFunctionName The name of JavaScript function
+    */
+  void RemoveJavascriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName );
+
+  /**
+   * @brief Clears the history of Web.
+   */
+  void ClearHistory();
+
+  /**
+   * @brief Clears the cache of Web.
+   */
+  void ClearCache();
+
+  /**
+   * @brief Sets the size of Web Pages.
+   */
+  void SetSize( int width, int height );
+
+  /**
+   * @brief Sends Touch Events.
+   */
+  bool SendTouchEvent( const TouchData& touch );
+
+  /**
+   * @brief Sends key Events.
+   */
+  bool SendKeyEvent( const KeyEvent& event );
+
+  /**
+   * @brief Connects to this signal to be notified when page loading is started.
+   *
+   * @return A signal object to connect with.
+   */
+  Dali::WebEnginePlugin::WebEngineSignalType& PageLoadStartedSignal();
+
+  /**
+   * @brief Connects to this signal to be notified when page loading is finished.
+   *
+   * @return A signal object to connect with.
+   */
+  Dali::WebEnginePlugin::WebEngineSignalType& PageLoadFinishedSignal();
+
+private: // Not intended for application developers
+
+  /**
+   * @brief Internal constructor
+   */
+  explicit DALI_INTERNAL WebEngine( Internal::Adaptor::WebEngine* internal );
+};
+
+} // namespace Dali;
+
+#endif // DALI_WEB_ENGINE_H
index a98a7be..0785a88 100755 (executable)
@@ -27,7 +27,8 @@ devel_api_src_files = \
   $(adaptor_devel_api_dir)/adaptor-framework/lifecycle-controller.cpp \
   $(adaptor_devel_api_dir)/adaptor-framework/video-player.cpp \
   $(adaptor_devel_api_dir)/adaptor-framework/virtual-keyboard.cpp \
-  $(adaptor_devel_api_dir)/adaptor-framework/thread-settings.cpp
+  $(adaptor_devel_api_dir)/adaptor-framework/thread-settings.cpp \
+  $(adaptor_devel_api_dir)/adaptor-framework/web-engine.cpp
 
 
 
@@ -63,6 +64,8 @@ devel_api_adaptor_framework_header_files = \
   $(adaptor_devel_api_dir)/adaptor-framework/tilt-sensor.h \
   $(adaptor_devel_api_dir)/adaptor-framework/video-player.h \
   $(adaptor_devel_api_dir)/adaptor-framework/video-player-plugin.h \
+  $(adaptor_devel_api_dir)/adaptor-framework/web-engine.h \
+  $(adaptor_devel_api_dir)/adaptor-framework/web-engine-plugin.h \
   $(adaptor_devel_api_dir)/adaptor-framework/key-extension-plugin.h \
   $(adaptor_devel_api_dir)/adaptor-framework/virtual-keyboard.h \
   $(adaptor_devel_api_dir)/adaptor-framework/physical-keyboard.h \
diff --git a/dali/internal/web-engine/common/web-engine-impl.cpp b/dali/internal/web-engine/common/web-engine-impl.cpp
new file mode 100644 (file)
index 0000000..2e87c5e
--- /dev/null
@@ -0,0 +1,292 @@
+/*
+ * Copyright (c) 2018 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/internal/web-engine/common/web-engine-impl.h>
+
+// EXTERNAL INCLUDES
+#include <dlfcn.h>
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/adaptor-framework/native-image-source.h>
+#include <dali/public-api/object/type-registry.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace // unnamed namespace
+{
+
+const char* WEB_ENGINE_LITE_PLUGIN_SO( "libdali-web-engine-lite-plugin.so" );
+
+Dali::BaseHandle Create()
+{
+  return Dali::WebEngine::New();
+}
+
+Dali::TypeRegistration type( typeid( Dali::WebEngine ), typeid( Dali::BaseHandle ), Create );
+
+} // unnamed namespace
+
+WebEnginePtr WebEngine::New()
+{
+  WebEngine* engine = new WebEngine();
+
+  if ( engine->Initialize() )
+  {
+    return WebEnginePtr( engine );
+  }
+
+  delete engine;
+
+  return WebEnginePtr();
+}
+
+WebEngine::WebEngine()
+: mPlugin( NULL ),
+  mHandle( NULL ),
+  mCreateWebEnginePtr( NULL ),
+  mDestroyWebEnginePtr( NULL )
+{
+}
+
+WebEngine::~WebEngine()
+{
+  if( mHandle != NULL )
+  {
+    if( mDestroyWebEnginePtr != NULL )
+    {
+      mPlugin->Destroy();
+      mDestroyWebEnginePtr( mPlugin );
+    }
+
+    dlclose( mHandle );
+  }
+}
+
+bool WebEngine::Initialize()
+{
+  char* error = NULL;
+
+  mHandle = dlopen( WEB_ENGINE_LITE_PLUGIN_SO, RTLD_LAZY );
+
+  error = dlerror();
+  if( mHandle == NULL || error != NULL )
+  {
+    DALI_LOG_ERROR( "WebEngine::Initialize(), dlopen error: %s\n", error );
+    return false;
+  }
+
+  mCreateWebEnginePtr = reinterpret_cast< CreateWebEngineFunction >( dlsym( mHandle, "CreateWebEnginePlugin" ) );
+  if( mCreateWebEnginePtr == NULL )
+  {
+    DALI_LOG_ERROR( "Can't load symbol CreateWebEnginePlugin(), error: %s\n", error );
+    return false;
+  }
+
+  mPlugin = mCreateWebEnginePtr();
+
+  if( mPlugin == NULL )
+  {
+    DALI_LOG_ERROR( "Can't create the WebEnginePlugin object\n" );
+    return false;
+  }
+
+  mDestroyWebEnginePtr = reinterpret_cast< DestroyWebEngineFunction >( dlsym( mHandle, "DestroyWebEnginePlugin" ) );
+
+  if( mDestroyWebEnginePtr == NULL )
+  {
+
+    DALI_LOG_ERROR( "Can't load symbol DestroyWebEnginePlugin(), error: %s\n", error );
+    return false;
+  }
+
+  return true;
+}
+
+void WebEngine::Create( int width, int height, const std::string& locale, const std::string& timezoneId )
+{
+  if( mPlugin != NULL )
+  {
+    mPlugin->Create( width, height, locale, timezoneId );
+  }
+}
+
+void WebEngine::Destroy()
+{
+  if( mPlugin != NULL )
+  {
+    mPlugin->Destroy();
+  }
+}
+
+Dali::NativeImageInterfacePtr WebEngine::GetNativeImageSource()
+{
+  return mPlugin->GetNativeImageSource();
+}
+
+void WebEngine::LoadUrl( const std::string& url )
+{
+  if( mPlugin != NULL )
+  {
+    mPlugin->LoadUrl( url );
+  }
+}
+
+const std::string& WebEngine::GetUrl()
+{
+  static std::string emptyUrl;
+  return mPlugin ? mPlugin->GetUrl() : emptyUrl;
+}
+
+void WebEngine::LoadHTMLString( const std::string& htmlString )
+{
+  if( mPlugin != NULL )
+  {
+    mPlugin->LoadHTMLString( htmlString );
+  }
+}
+
+void WebEngine::Reload()
+{
+  if( mPlugin != NULL )
+  {
+    mPlugin->Reload();
+  }
+}
+
+void WebEngine::StopLoading()
+{
+  if( mPlugin != NULL )
+  {
+    mPlugin->StopLoading();
+  }
+}
+
+bool WebEngine::CanGoForward()
+{
+  return mPlugin ? mPlugin->CanGoForward() : false;
+}
+
+void WebEngine::GoForward()
+{
+  if( mPlugin != NULL )
+  {
+    mPlugin->GoForward();
+  }
+}
+
+bool WebEngine::CanGoBack()
+{
+  return mPlugin ? mPlugin->CanGoBack() : false;
+}
+
+void WebEngine::GoBack()
+{
+  if( mPlugin != NULL )
+  {
+    mPlugin->GoBack();
+  }
+}
+
+void WebEngine::EvaluateJavaScript( const std::string& script )
+{
+  if( mPlugin != NULL )
+  {
+    mPlugin->EvaluateJavaScript( script );
+  }
+}
+
+void WebEngine::AddJavaScriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName, std::function< std::string(const std::string&) > cb )
+{
+  if( mPlugin != NULL )
+  {
+    mPlugin->AddJavaScriptInterface( exposedObjectName, jsFunctionName, cb );
+  }
+}
+
+void WebEngine::RemoveJavascriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName )
+{
+  if( mPlugin != NULL )
+  {
+    mPlugin->RemoveJavascriptInterface( exposedObjectName, jsFunctionName );
+  }
+}
+
+void WebEngine::ClearHistory()
+{
+  if( mPlugin != NULL )
+  {
+    mPlugin->ClearHistory();
+  }
+}
+
+void WebEngine::ClearCache()
+{
+  if( mPlugin != NULL )
+  {
+    mPlugin->ClearCache();
+  }
+}
+
+void WebEngine::SetSize( int width, int height )
+{
+  if( mPlugin != NULL )
+  {
+    mPlugin->SetSize( width, height );
+  }
+}
+
+bool WebEngine::SendTouchEvent( const Dali::TouchData& touch )
+{
+  if( mPlugin != NULL )
+  {
+    return mPlugin->SendTouchEvent( touch );
+  }
+
+  return false;
+}
+
+bool WebEngine::SendKeyEvent( const Dali::KeyEvent& event )
+{
+  if( mPlugin != NULL )
+  {
+    return mPlugin->SendKeyEvent( event );
+  }
+
+  return false;
+}
+
+Dali::WebEnginePlugin::WebEngineSignalType& WebEngine::PageLoadStartedSignal()
+{
+  return mPlugin->PageLoadStartedSignal();
+}
+
+Dali::WebEnginePlugin::WebEngineSignalType& WebEngine::PageLoadFinishedSignal()
+{
+  return mPlugin->PageLoadFinishedSignal();
+}
+
+} // namespace Adaptor;
+} // namespace Internal;
+} // namespace Dali;
+
diff --git a/dali/internal/web-engine/common/web-engine-impl.h b/dali/internal/web-engine/common/web-engine-impl.h
new file mode 100644 (file)
index 0000000..3cb1eb6
--- /dev/null
@@ -0,0 +1,226 @@
+#ifndef DALI_WEB_ENGINE_IMPL_H
+#define DALI_WEB_ENGINE_IMPL_H
+
+/*
+ * Copyright (c) 2018 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 <dali/public-api/object/base-object.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/web-engine.h>
+#include <dali/devel-api/adaptor-framework/web-engine-plugin.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class WebEngine;
+
+typedef IntrusivePtr< WebEngine > WebEnginePtr;
+
+/**
+ * @brief WebEngine class is used for Web.
+ */
+class WebEngine : public Dali::BaseObject
+{
+public:
+
+  /**
+   * @brief Creates a new WebEngine handle
+   *
+   * @return WebEngine pointer
+   */
+  static WebEnginePtr New();
+
+  /**
+   * @copydoc Dali::WebEngine::Create()
+   */
+  void Create( int width, int height, const std::string& locale, const std::string& timezoneId );
+
+  /**
+   * @copydoc Dali::WebEngine::Destroy()
+   */
+  void Destroy();
+
+  /**
+   * @copydoc Dali::WebEngine::GetNativeImageSource()
+   */
+  Dali::NativeImageInterfacePtr GetNativeImageSource();
+
+  /**
+   * @copydoc Dali::WebEngine::LoadUrl()
+   */
+  void LoadUrl( const std::string& url );
+
+  /**
+   * @copydoc Dali::WebEngine::GetUrl()
+   */
+  const std::string& GetUrl();
+
+  /**
+   * @copydoc Dali::WebEngine::LoadHTMLString()
+   */
+  void LoadHTMLString( const std::string& htmlString );
+
+  /**
+   * @copydoc Dali::WebEngine::Reload()
+   */
+  void Reload();
+
+  /**
+   * @copydoc Dali::WebEngine::StopLoading()
+   */
+  void StopLoading();
+
+  /**
+   * @copydoc Dali::WebEngine::CanGoForward()
+   */
+  bool CanGoForward();
+
+  /**
+   * @copydoc Dali::WebEngine::GoForward()
+   */
+  void GoForward();
+
+  /**
+   * @copydoc Dali::WebEngine::CanGoBack()
+   */
+  bool CanGoBack();
+
+  /**
+   * @copydoc Dali::WebEngine::GoBack()
+   */
+  void GoBack();
+
+  /**
+   * @copydoc Dali::WebEngine::EvaluateJavaScript()
+   */
+  void EvaluateJavaScript( const std::string& script );
+
+  /**
+   * @copydoc Dali::WebEngine::AddJavaScriptInterface()
+   */
+  void AddJavaScriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName, std::function< std::string(const std::string&) > cb );
+
+  /**
+   * @copydoc Dali::WebEngine::RemoveJavascriptInterface()
+   */
+  void RemoveJavascriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName );
+
+  /**
+   * @copydoc Dali::WebEngine::ClearHistory()
+   */
+  void ClearHistory();
+
+  /**
+   * @copydoc Dali::WebEngine::ClearCache()
+   */
+  void ClearCache();
+
+  /**
+   * @copydoc Dali::WebEngine::SetSize()
+   */
+  void SetSize( int width, int height );
+
+  /**
+   * @copydoc Dali::WebEngine::SendTouchEvent()
+   */
+  bool SendTouchEvent( const Dali::TouchData& touch );
+
+  /**
+   * @copydoc Dali::WebEngine::SendKeyEvent()
+   */
+  bool SendKeyEvent( const Dali::KeyEvent& event );
+
+  /**
+   * @copydoc Dali::WebEngine::PageLoadStartedSignal()
+   */
+  Dali::WebEnginePlugin::WebEngineSignalType& PageLoadStartedSignal();
+
+  /**
+   * @copydoc Dali::WebEngine::PageLoadFinishedSignal()
+   */
+  Dali::WebEnginePlugin::WebEngineSignalType& PageLoadFinishedSignal();
+
+private:
+
+  /**
+   * @brief Constructor.
+   */
+  WebEngine();
+
+  /**
+   * @brief Destructor.
+   */
+  virtual ~WebEngine();
+
+  // Undefined copy constructor
+  WebEngine( const WebEngine& WebEngine );
+
+  // Undefined assignment operator
+  WebEngine& operator=( const WebEngine& WebEngine );
+
+  /**
+   * @brief Initializes member data.
+   *
+   * @return Whether the initialization succeed or not.
+   */
+  bool Initialize();
+
+private:
+
+  Dali::WebEnginePlugin* mPlugin; ///< WebEngine plugin handle
+  void* mHandle; ///< Handle for the loaded library
+
+  typedef Dali::WebEnginePlugin* (*CreateWebEngineFunction)();
+  typedef void (*DestroyWebEngineFunction)( Dali::WebEnginePlugin* plugin );
+
+  CreateWebEngineFunction mCreateWebEnginePtr;
+  DestroyWebEngineFunction mDestroyWebEnginePtr;
+};
+
+} // namespace Adaptor
+} // namespace Internal
+
+inline static Internal::Adaptor::WebEngine& GetImplementation( Dali::WebEngine& webEngine )
+{
+  DALI_ASSERT_ALWAYS( webEngine && "WebEngine handle is empty." );
+
+  BaseObject& handle = webEngine.GetBaseObject();
+
+  return static_cast< Internal::Adaptor::WebEngine& >( handle );
+}
+
+inline static const Internal::Adaptor::WebEngine& GetImplementation( const Dali::WebEngine& webEngine )
+{
+  DALI_ASSERT_ALWAYS( webEngine && "WebEngine handle is empty." );
+
+  const BaseObject& handle = webEngine.GetBaseObject();
+
+  return static_cast< const Internal::Adaptor::WebEngine& >( handle );
+}
+
+} // namespace Dali;
+
+#endif
+
diff --git a/dali/internal/web-engine/file.list b/dali/internal/web-engine/file.list
new file mode 100644 (file)
index 0000000..0c4109d
--- /dev/null
@@ -0,0 +1,5 @@
+
+
+# module: web, backend: common
+adaptor_web_engine_common_src_files=\
+    ${adaptor_web_engine_dir}/common/web-engine-impl.cpp