From bc8a0f7c2d571df8c4a71fa12769978875dca8ac Mon Sep 17 00:00:00 2001 From: "k2.nagaraju" Date: Fri, 20 Apr 2018 09:56:52 +0530 Subject: [PATCH] Fix for supporting TCT - 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 --- atom/browser/api/atom_api_pwrt.cc | 12 ++++++++++-- atom/browser/api/atom_api_web_contents.cc | 23 +++++++++++++++++++---- atom/browser/browser.cc | 2 +- atom/renderer/atom_renderer_client.cc | 24 +++++++++++++----------- wrt/src/web_window.js | 4 ++++ 5 files changed, 47 insertions(+), 18 deletions(-) diff --git a/atom/browser/api/atom_api_pwrt.cc b/atom/browser/api/atom_api_pwrt.cc index aa7b785..d23679c 100644 --- a/atom/browser/api/atom_api_pwrt.cc +++ b/atom/browser/api/atom_api_pwrt.cc @@ -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 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 ""; } diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index cac60af..d81d2cb 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -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(); } diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index fc2c7a4..b26b0e6 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -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 { diff --git a/atom/renderer/atom_renderer_client.cc b/atom/renderer/atom_renderer_client.cc index aa3b881..87be391 100644 --- a/atom/renderer/atom_renderer_client.cc +++ b/atom/renderer/atom_renderer_client.cc @@ -134,6 +134,14 @@ void AtomRendererClient::RunScriptsAtDocumentEnd( void AtomRendererClient::DidCreateScriptContext( v8::Handle 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 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, diff --git a/wrt/src/web_window.js b/wrt/src/web_window.js index 06b1f31..95476d8 100644 --- a/wrt/src/web_window.js +++ b/wrt/src/web_window.js @@ -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, -- 2.7.4