Merge "Cleanup code to remove warning messages at buildtime." into devel/wrt2
authorWonYoung Choi <wy80.choi@samsung.com>
Wed, 29 Apr 2015 05:32:54 +0000 (14:32 +0900)
committerGerrit Code Review <gerrit@tizensrc>
Wed, 29 Apr 2015 05:32:54 +0000 (14:32 +0900)
packaging/wrt.spec
src/runtime/CMakeLists.txt
src/runtime/native_window.h
src/runtime/web_application.cc
src/runtime/web_application.h
src/runtime/web_view_impl.cc
src/runtime/web_view_impl.h

index 7efc609..d3ba278 100755 (executable)
@@ -27,6 +27,7 @@ BuildRequires: pkgconfig(cert-svc)
 BuildRequires: pkgconfig(uuid)
 BuildRequires: pkgconfig(gio-2.0)
 BuildRequires: pkgconfig(aul)
+BuildRequires: pkgconfig(ecore)
 BuildRequires: boost-devel
 %if %{with x}
 BuildRequires: pkgconfig(ecore-x)
index d6cd9ed..c69904c 100755 (executable)
@@ -28,6 +28,7 @@ PKG_CHECK_MODULES(TARGET_RUNTIME_DEPS
   deviced
   capi-system-runtime-info
   aul
+  ecore
   REQUIRED
 )
 
index e13f033..45c7fc7 100755 (executable)
@@ -30,6 +30,7 @@ class NativeWindow {
   void Show();
   void Active();
   void InActive();
+  // TODO(sngn.lee): FullScreen(bool enable);
 
  protected:
   virtual Evas_Object* CreateWindowInternal() = 0;
index 02c292f..ea77dd4 100755 (executable)
@@ -5,6 +5,7 @@
 #include "runtime/web_application.h"
 
 #include <app.h>
+#include <Ecore.h>
 #include <ewk_chromium.h>
 #include <algorithm>
 #include <memory>
@@ -125,13 +126,28 @@ bool WebApplication::Initialize() {
   // TODO(sngn.lee): set default from config.xml
   // locale_manager_->SetDefaultLocale(const  string & locale);
 
+  // TODO(sngn.lee): Download interface
+  // ewk_context_did_start_download_callback_set
+
+  // TODO(sngn.lee): always enable "mediastream,record"
+  // TODO(sngn.lee): always enable "encrypted,database"
+  // TODO(sngn.lee): check csp element in config.xml and enable - "csp"
+  // TODO(sngn.lee): Check Backround support and enable - "visibility,suspend"
+  // TODO(sngn.lee): Check Backround support and enable - "background,music"
+  // TODO(sngn.lee): Check setting rotation value and enable "rotation,lock"
+  // TODO(sngn.lee): always enable "fullscreen"
+  // TODO(sngn.lee): check "sound-mode":"exclusive" - in tizen:setting
+  //                 and enable - "sound,mode"
+  // TODO(sngn.lee): check "background-vibration":"enable" - in tizen:setting
+  //                 and enable - "background,vibration"
+
   return true;
 }
 
 void WebApplication::Launch(std::unique_ptr<wrt::AppControl> appcontrol) {
   resource_manager_->set_app_control(appcontrol.get());
   WebView* view = new WebView(window_, ewk_context_);
-  view->SetEventListener(this);
+  SetupWebView(view);
 
   // send widget info to injected bundle
   // TODO(wy80.choi): ewk_send_widget_info should be fixed to receive uuid of
@@ -182,7 +198,8 @@ void WebApplication::AppControl(std::unique_ptr<wrt::AppControl> appcontrol) {
     // Reset to context
     ClearViewStack();
     WebView* view = new WebView(window_, ewk_context_);
-    view->SetEventListener(this);
+    SetupWebView(view);
+
     view->LoadUrl(resource_manager_->GetStartURL());
     view_stack_.push_front(view);
     window_->SetContent(view->evas_object());
@@ -251,6 +268,7 @@ void WebApplication::OnCreatedNewWebView(WebView* /*view*/, WebView* new_view) {
   if (view_stack_.size() > 0 && view_stack_.front() != NULL)
     view_stack_.front()->SetVisibility(false);
 
+  SetupWebView(new_view);
   view_stack_.push_front(new_view);
   window_->SetContent(new_view->evas_object());
 }
@@ -278,7 +296,12 @@ void WebApplication::OnClosedWebView(WebView * view) {
     window_->SetContent(view_stack_.front()->evas_object());
   }
 
-  delete view;
+  // Delete after the callback context(for ewk view) was not used
+  ecore_idler_add([](void* view) {
+      WebView* obj = static_cast<WebView*>(view);
+      delete view;
+      return EINA_FALSE;
+    }, view);
 }
 
 void WebApplication::OnReceivedWrtMessage(
@@ -381,4 +404,17 @@ void WebApplication::LaunchInspector(wrt::AppControl* appcontrol) {
   appcontrol->Reply(data);
 }
 
+void WebApplication::SetupWebView(WebView* view) {
+  view->SetEventListener(this);
+  // TODO(sngn.lee): set UserAgent to WebView
+  // TODO(sngn.lee): set CSP
+}
+
+bool WebApplication::OnDidNavigation(WebView* view, const std::string& url) {
+  // TODO(sngn.lee): scheme handling
+  // except(file , http, https, app) pass to appcontrol and return false
+  return true;
+}
+
+
 }  // namespace wrt
index 1226e3b..32e13cf 100755 (executable)
@@ -53,6 +53,8 @@ class WebApplication : public WebView::EventListener {
   virtual void OnLanguageChanged();
   virtual void OnLowMemory();
   virtual bool OnContextMenuDisabled(WebView* view);
+  virtual bool OnDidNavigation(WebView* view, const std::string& url);
+
 
   std::string uuid() const { return uuid_; }
 
@@ -62,6 +64,7 @@ class WebApplication : public WebView::EventListener {
   void ClearViewStack();
   void SendAppControlEvent();
   void LaunchInspector(wrt::AppControl* appcontrol);
+  void SetupWebView(WebView* view);
 
   bool launched_;
   bool debug_mode_;
index 870fc93..c3e2adc 100755 (executable)
@@ -94,6 +94,20 @@ void WebViewImpl::Initialize() {
   InitConsoleMessageCallback();
   InitCustomContextMenuCallback();
   InitRotationCallback();
+  InitWindowCreateCallback();
+
+  // TODO(sngn.lee): "request,certificate,confirm" certification popup
+  // TODO(sngn.lee): ewk_view_notification_permission_callback_set
+  // TODO(sngn.lee): "notification,show"
+  // TODO(sngn.lee): "notification,cancel"
+  // TODO(sngn.lee): "create,window"
+  // TODO(sngn.lee): "close,window"
+  // TODO(sngn.lee): "fullscreen,enterfullscreen"
+  // TODO(sngn.lee): "fullscreen,exitfullscreen"
+  // TODO(sngn.lee): "protocolhandler,registration,requested"
+  //                  custom protocol handler
+  // TODO(sngn.lee): ewk_view_geolocation_permission_callback_set
+  // TODO(sngn.lee): ewk_view_user_media_permission_callback_set
 
   // Show webview
   evas_object_show(ewk_view_);
@@ -260,6 +274,9 @@ void WebViewImpl::InitPolicyDecideCallback() {
 }
 
 void WebViewImpl::InitQuotaExceededCallback() {
+  // TODO(sngn.lee): Need callback interface - OnQutaExceed
+  // check http://tizen.org/privilege/unlimitedstorage
+
   // callback for database quota exceeded
   auto database_exceeded_callback = [](Evas_Object* view,
                                        Ewk_Security_Origin* origin,
@@ -432,6 +449,40 @@ void WebViewImpl::InitRotationCallback() {
                                   std::placeholders::_1));
 }
 
+void WebViewImpl::InitWindowCreateCallback() {
+  auto create_callback = [](void* user_data,
+                            Evas_Object*,
+                            void* event_info) {
+    WebViewImpl* self = static_cast<WebViewImpl*>(user_data);
+    if (!self->listener_) {
+      return;
+    }
+    WebView* new_view = new WebView(self->window_, self->context_);
+    self->listener_->OnCreatedNewWebView(self->view_, new_view);
+  };
+
+  auto close_callback = [](void* user_data,
+                            Evas_Object*,
+                            void*) {
+    WebViewImpl* self = static_cast<WebViewImpl*>(user_data);
+    if (!self->listener_) {
+      return;
+    }
+    self->listener_->OnClosedWebView(self->view_);
+  };
+  evas_object_smart_callback_add(ewk_view_,
+                                 "create,window",
+                                 create_callback,
+                                 this);
+  evas_object_smart_callback_add(ewk_view_,
+                                 "close,window",
+                                 close_callback,
+                                 this);
+
+  smart_callbacks_["create,window"] = create_callback;
+  smart_callbacks_["close,window"] = close_callback;
+}
+
 std::string WebViewImpl::GetUrl() {
   return std::string(ewk_view_url_get(ewk_view_));
 }
index 3a89b96..a83c6d2 100755 (executable)
@@ -51,6 +51,7 @@ class WebViewImpl {
   void InitConsoleMessageCallback();
   void InitCustomContextMenuCallback();
   void InitRotationCallback();
+  void InitWindowCreateCallback();
 
   NativeWindow* window_;
   Ewk_Context* context_;