Fix for supporting TCT 68/176568/6
authork2.nagaraju <k2.nagaraju@samsung.com>
Fri, 20 Apr 2018 04:26:52 +0000 (09:56 +0530)
committerPrathmesh <prathmesh.m@samsung.com>
Tue, 5 Jun 2018 07:33:05 +0000 (13:03 +0530)
- As node and jquery are having issues, disable node integration for Tizen apps
- Handle Tizen Exit event
- Allow loading of device API's in both main frame and iframe

Change-Id: I3e69b28462761c270862eb47bb37defe37923ea0
Signed-off-by: Prathmesh <prathmesh.m@samsung.com>
atom/browser/api/atom_api_pwrt.cc
atom/browser/api/atom_api_web_contents.cc
atom/browser/browser.cc
atom/renderer/atom_renderer_client.cc
wrt/src/web_window.js

index aa7b785..d23679c 100644 (file)
@@ -35,8 +35,16 @@ std::string PWRT::GetPath() {
     auto appdata_manager = common::ApplicationDataManager::GetInstance();
     common::ApplicationData* app_data = appdata_manager->GetApplicationData(appid);
     // TODO: Use resource-manager's GetStartResource() for localized urls
-    std::string app_path = "file://" + app_data->application_path() + app_data->content_info()->src();
-    return app_path;
+    // atom::Browser *browser_model = atom::Browser::Get();
+    // std::unique_ptr<common::ResourceManager::Resource> res = browser_model->resource_manager_->GetStartResource(appcontrol.get());
+    if (app_data) {
+      std::string app_path = "file://" + app_data->application_path();
+      if (app_data->content_info())
+        app_path += app_data->content_info()->src();
+      else
+        app_path += "index.html";
+      return app_path;
+    }
   }
   return "";
 }
index cac60af..d81d2cb 100644 (file)
@@ -14,6 +14,7 @@
 #include "atom/browser/atom_browser_client.h"
 #include "atom/browser/atom_browser_context.h"
 #include "atom/browser/atom_browser_main_parts.h"
+#include "atom/browser/browser.h"
 #include "atom/browser/lib/bluetooth_chooser.h"
 #include "atom/browser/native_window.h"
 #include "atom/browser/net/atom_network_delegate.h"
@@ -526,7 +527,7 @@ void WebContents::MoveContents(content::WebContents* source,
 
 void WebContents::CloseContents(content::WebContents* source) {
   Emit("close");
-
+  LOG(ERROR) << __FUNCTION__;
   if ((type_ == BROWSER_WINDOW || type_ == OFF_SCREEN) && owner_window())
     owner_window()->CloseContents(source);
 }
@@ -918,16 +919,29 @@ void WebContents::OnWrtPluginSyncMessage(const Ewk_Wrt_Message_Data& data,
 
 void WebContents::HandleWrtPluginMessage(Ewk_Wrt_Message_Data* msg) {
   Eina_Stringshare* msg_type = ewk_ipc_wrt_message_data_type_get(msg);
-
+  LOG(INFO) << msg_type;
 #define TYPE_BEGIN(x) (!strncmp(msg_type, x, strlen(x)))
 #define TYPE_IS(x) (!strcmp(msg_type, x))
-
   if (TYPE_BEGIN("xwalk://")) {
     auto extension_server = extensions::XWalkExtensionServer::GetInstance();
     extension_server->HandleIPCMessage(msg);
   } else {
-    // implement in future
+    Eina_Stringshare* msg_id = msg->GetId();
+    Eina_Stringshare* msg_ref_id = msg->GetReferenceId();
+    Eina_Stringshare* msg_value = msg->GetValue();
+    if (TYPE_IS("tizen://exit")) {
+      atom::Browser *browser_model = atom::Browser::Get();
+      browser_model->Shutdown();
+    }
+
+    eina_stringshare_del(msg_ref_id);
+    eina_stringshare_del(msg_id);
+    eina_stringshare_del(msg_value);
   }
+#undef TYPE_IS
+#undef TYPE_BEGIN
+
+  eina_stringshare_del(msg_type);
 }
 
 bool WebContents::OnMessageReceived(const IPC::Message& message) {
@@ -1090,6 +1104,7 @@ bool WebContents::IsWaitingForResponse() const {
 }
 
 void WebContents::Stop() {
+  LOG(ERROR) << __FUNCTION__;
   web_contents()->Stop();
 }
 
index fc2c7a4..b26b0e6 100644 (file)
@@ -131,7 +131,7 @@ void Browser::SetElectronAppLaunch() {
     std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/electron");
     auto appdata_manager = common::ApplicationDataManager::GetInstance();
     common::ApplicationData* app_data = appdata_manager->GetApplicationData(appid);
-    if (!strcmp(app_data->content_info()->src().c_str(), "package.json")) {
+    if (app_data->content_info() && !strcmp(app_data->content_info()->src().c_str(), "package.json")) {
       is_electron_launch_ = true;
     }
   } else {
index aa3b881..87be391 100644 (file)
@@ -134,6 +134,14 @@ void AtomRendererClient::RunScriptsAtDocumentEnd(
 
 void AtomRendererClient::DidCreateScriptContext(
     v8::Handle<v8::Context> context, content::RenderFrame* render_frame) {
+  // Tizen device API is required both for main frame and iFrames
+#if defined(USE_EFL)
+  if (widget_) {
+    const content::RenderView* render_view = render_frame->GetRenderView();
+    widget_->StartSession(context, render_view->GetRoutingID(),
+                        render_frame->GetWebFrame()->document().baseURL().string().utf8().c_str());
+  }
+#endif
   // Only allow node integration for the main frame, unless it is a devtools
   // extension page.
   if (!render_frame->IsMainFrame() && !IsDevToolsExtension(render_frame))
@@ -163,17 +171,15 @@ void AtomRendererClient::DidCreateScriptContext(
     // Give the node loop a run to make sure everything is ready.
     node_bindings_->RunMessageLoop();
   }
-#if defined(USE_EFL)
-  if (widget_) {
-    const content::RenderView* render_view = render_frame->GetRenderView();
-    widget_->StartSession(context, render_view->GetRoutingID(),
-                        render_frame->GetWebFrame()->document().baseURL().string().utf8().c_str());
-  }
-#endif
 }
 
 void AtomRendererClient::WillReleaseScriptContext(
     v8::Handle<v8::Context> context, content::RenderFrame* render_frame) {
+  // Required both for main/sub and iframe
+#if defined(USE_EFL)
+  if (widget_)
+    widget_->StopSession(context);
+#endif
   // Only allow node integration for the main frame, unless it is a devtools
   // extension page.
   if (!render_frame->IsMainFrame() && !IsDevToolsExtension(render_frame))
@@ -190,10 +196,6 @@ void AtomRendererClient::WillReleaseScriptContext(
   // Destroy the node environment.
   node::FreeEnvironment(env);
   atom_bindings_->EnvironmentDestroyed(env);
-#if defined(USE_EFL)
-  if (widget_)
-    widget_->StopSession(context);
-#endif
 }
 
 bool AtomRendererClient::ShouldFork(blink::WebLocalFrame* frame,
index 06b1f31..95476d8 100644 (file)
@@ -29,6 +29,10 @@ class WebWindow {
         return {
             fullscreen: false,
             show: false,
+            webPreferences: {
+                nodeIntegration: false,
+                nodeIntegrationInWorker: false
+            },
             'web-preferences': {
                 'direct-write': true,
                 'subpixel-font-scaling': false,