Merge "Cleanup code to remove warning messages at buildtime." into devel/wrt2
[platform/framework/web/nwrt.git] / src / runtime / web_application.cc
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