Implements wrt message callback
authorWonYoung Choi <wy80.choi@samsung.com>
Wed, 8 Apr 2015 05:22:19 +0000 (14:22 +0900)
committerWonYoung Choi <wy80.choi@samsung.com>
Wed, 8 Apr 2015 05:22:19 +0000 (14:22 +0900)
Change-Id: I0dc3e16862d0f1c4153ddf3c0f0cd30666ea8a7d

src/runtime/native_app_window.cc
src/runtime/native_app_window.h
src/runtime/native_window.cc
src/runtime/native_window.h
src/runtime/web_application.cc
src/runtime/web_application.h
src/runtime/web_view.cc
src/runtime/web_view.h

index d9f7ac4..04aab7f 100755 (executable)
@@ -14,7 +14,7 @@ NativeAppWindow::NativeAppWindow() {
 NativeAppWindow::~NativeAppWindow() {
 }
 
-Evas_Object* NativeAppWindow::createWindowInternal() {
+Evas_Object* NativeAppWindow::CreateWindowInternal() {
   elm_config_preferred_engine_set("opengl_x11");
   return elm_win_add(NULL, "wrt-widget", ELM_WIN_BASIC);
 }
index 6efa75b..0fa2395 100644 (file)
@@ -14,7 +14,7 @@ class NativeAppWindow: public NativeWindow {
   NativeAppWindow();
   virtual ~NativeAppWindow();
  protected:
-  Evas_Object* createWindowInternal();  // override
+  Evas_Object* CreateWindowInternal();  // override
 };
 
 }  // namespace wrt
index aa66515..7f2043d 100755 (executable)
@@ -40,7 +40,7 @@ void NativeWindow::Initialize() {
   uint16_t pid = getpid();
 
   // window
-  window_ = createWindowInternal();
+  window_ = CreateWindowInternal();
   elm_win_conformant_set(window_, EINA_TRUE);
   int w, h;
 #if defined(HAVE_X11)
@@ -56,9 +56,9 @@ void NativeWindow::Initialize() {
   evas_object_resize(window_, w, h);
   elm_win_autodel_set(window_, EINA_TRUE);
   evas_object_smart_callback_add(window_, "delete,request",
-                                 didDeleteRequested, this);
+                                 DidDeleteRequested, this);
   evas_object_smart_callback_add(window_, "profile,changed",
-                                 didProfileChanged, this);
+                                 DidProfileChanged, this);
 
   #define EVAS_SIZE_EXPAND_FILL(obj) \
     evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); \
@@ -150,13 +150,13 @@ void NativeWindow::Initialize() {
   initialized_ = true;
 }
 
-void NativeWindow::didDeleteRequested(void* /*data*/,
+void NativeWindow::DidDeleteRequested(void* /*data*/,
     Evas_Object* /*obj*/, void* /*event_info*/) {
   LoggerD("didDeleteRequested");
   elm_exit();
 }
 
-void NativeWindow::didProfileChanged(void* data,
+void NativeWindow::DidProfileChanged(void* data,
     Evas_Object* /*obj*/, void* /*event_info*/) {
   LoggerD("didProfileChanged");
 }
@@ -202,10 +202,6 @@ void NativeWindow::RemoveRotationHandler(int id) {
   handler_table_.erase(id);
 }
 
-int NativeWindow::rotation() const {
-  return rotation_;
-}
-
 void NativeWindow::SetRotationLock(int degree) {
   rotation_ = degree%360;
   elm_win_wm_rotation_preferred_rotation_set(window_, rotation_);
index 9965e46..5a79a52 100755 (executable)
@@ -26,16 +26,16 @@ class NativeWindow {
   void SetAutoRotation();
   int AddRotationHandler(RotationHandler handler);
   void RemoveRotationHandler(int id);
-  int rotation() const;
+  int rotation() const { return rotation_; }
   void Show();
 
  protected:
-  virtual Evas_Object* createWindowInternal() = 0;
+  virtual Evas_Object* CreateWindowInternal() = 0;
 
  private:
-  static void didDeleteRequested(void* data, Evas_Object* obj,
+  static void DidDeleteRequested(void* data, Evas_Object* obj,
                                  void* event_info);
-  static void didProfileChanged(void* data, Evas_Object* obj, void* event_info);
+  static void DidProfileChanged(void* data, Evas_Object* obj, void* event_info);
   void DidRotation(int degree);
   void DidFocusChanged(bool got);
 
index e884482..d8dc69b 100755 (executable)
@@ -162,11 +162,17 @@ void WebApplication::OnClosedWebView(WebView * view) {
 }
 
 std::string WebApplication::GetDataPath() const {
-  // TODO(sngn.lee): To be Implements
+  // TODO(sngn.lee): To be implemented
   return std::string("./");
 }
 
 void WebApplication::OnRendered(WebView* view) {
 }
 
+void WebApplication::OnReceivedWrtMessage(
+    WebView* view,
+    const Ewk_IPC_Wrt_Message_Data& message) {
+  // TODO(wy80.choi): To be implemented
+}
+
 }  // namespace wrt
index e70f1bb..d419865 100755 (executable)
@@ -7,6 +7,7 @@
 
 #include <string>
 #include <list>
+
 #include "runtime/web_view.h"
 
 class Ewk_Context;
@@ -31,6 +32,8 @@ class WebApplication : public WebView::EventListener {
   virtual void OnCreatedNewWebView(WebView* view, WebView* new_view);
   virtual void OnClosedWebView(WebView * view);
   virtual void OnRendered(WebView* view);
+  virtual void OnReceivedWrtMessage(WebView* view,
+                                    const Ewk_IPC_Wrt_Message_Data& message);
 
  private:
   void ClearViewStack();
index d012080..959225b 100755 (executable)
@@ -266,6 +266,22 @@ void WebView::Initialize() {
     localfile_exceeded_callback,
     NULL);
 
+  // wrt,message
+  auto wrt_message_callback = [](void* user_data,
+                                 Evas_Object*,
+                                 void* event_info) {
+    WebView* self = static_cast<WebView*>(user_data);
+    Ewk_IPC_Wrt_Message_Data* msg =
+        static_cast<Ewk_IPC_Wrt_Message_Data*>(event_info);
+    if (self->listener_)
+      self->listener_->OnReceivedWrtMessage(self, *msg);
+  };
+  evas_object_smart_callback_add(ewk_view_,
+                                 "wrt,message",
+                                 wrt_message_callback,
+                                 this);
+
+  // rotation support
   ewk_view_orientation_send(ewk_view_, ToWebRotation(window_->rotation()));
   rotation_handler_id_ = window_->AddRotationHandler(
                                   std::bind(&WebView::OnRotation,
index bee55a8..fb538d9 100755 (executable)
@@ -4,8 +4,10 @@
 
 #ifndef WRT_RUNTIME_WEB_VIEW_H_
 #define WRT_RUNTIME_WEB_VIEW_H_
+
 #include <Elementary.h>
 #include <efl_assist.h>
+#include <ewk_ipc_message.h>
 #include <string>
 
 class Ewk_Context;
@@ -25,12 +27,14 @@ class WebView {
                                      WebView* /*new_view*/) {}
     virtual void OnClosedWebView(WebView* /*view*/) {}
     virtual void OnCrashed(WebView* /*view*/) {}
-    virtual bool OnDidOpenWindow(WebView* /*view*/,
-                                 const std::string& /*url*/) { return true; }
-    virtual bool OnDidNavigation(WebView* /*view*/,
-                                 const std::string& /*url*/) { return true; }
-    virtual void OnHardwareKey(WebView* /*void*/,
-                               const std::string& /*keyname*/) {}
+    virtual bool OnDidOpenWindow(
+        WebView* /*view*/, const std::string& /*url*/) { return true; }
+    virtual bool OnDidNavigation(
+        WebView* /*view*/, const std::string& /*url*/) { return true; }
+    virtual void OnHardwareKey(
+        WebView* /*view*/, const std::string& /*keyname*/) {}
+    virtual void OnReceivedWrtMessage(
+        WebView* /*view*/, const Ewk_IPC_Wrt_Message_Data& /*msg*/) {}
   };
 
   WebView(wrt::NativeWindow* window, Ewk_Context* context);