From f95603be440503ae853f0daa92f1bb6c36348207 Mon Sep 17 00:00:00 2001 From: deepti Date: Wed, 11 Jul 2018 16:09:49 +0530 Subject: [PATCH 01/16] Implementation of Resume and Suspend function. Created IPC for Resume and Suspend operation to reach at Chromium level. Change-Id: I2a38c77f225b102da14607b3a5dde787c78e697a Signed-off-by: deepti --- atom/browser/browser.cc | 18 ++++++++++++++---- atom/common/api/api_messages.h | 7 ++++++- atom/renderer/atom_render_view_observer.cc | 20 ++++++++++++++++++++ atom/renderer/atom_render_view_observer.h | 3 ++- tizen/browser/tizen_browser_parts.cc | 16 +++++++++++++++- tizen/browser/tizen_browser_parts.h | 4 +++- 6 files changed, 60 insertions(+), 8 deletions(-) diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index dcfc6bc..0cd2e39 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -18,6 +18,8 @@ #include "base/threading/thread_task_runner_handle.h" #include "brightray/browser/brightray_paths.h" #include "content/public/browser/render_frame_host.h" +#include "content/public/browser/render_view_host.h" + #if defined(OS_TIZEN) #include "tizen/common/command_line.h" #include "tizen/common/application_data.h" @@ -264,14 +266,22 @@ void Browser::OnWindowAllClosed() { #if defined(OS_TIZEN) void Browser::Hide() { NativeWindow *last_window = WindowList::GetLastWindow(); - if (last_window) - last_window->NotifySuspend(); + if (!last_window) + return; + + last_window->NotifySuspend(); + auto rvh = last_window->web_contents()->GetRenderViewHost(); + atom::Browser::Get()->Suspend(rvh); } void Browser::Show() { NativeWindow *last_window = WindowList::GetLastWindow(); - if (last_window) - last_window->NotifyResume(); + if (!last_window) + return; + + last_window->NotifyResume(); + auto rvh = last_window->web_contents()->GetRenderViewHost(); + atom::Browser::Get()->Resume(rvh); } void Browser::AppControl(std::unique_ptr appcontrol) { diff --git a/atom/common/api/api_messages.h b/atom/common/api/api_messages.h index 44e8ad6..8335a4e 100644 --- a/atom/common/api/api_messages.h +++ b/atom/common/api/api_messages.h @@ -71,4 +71,9 @@ IPC_SYNC_MESSAGE_ROUTED0_2(WrtViewMsg_GetCSP, std::string) IPC_MESSAGE_ROUTED1(WrtViewMsg_SetLongPolling, - unsigned long) \ No newline at end of file + unsigned long) + +IPC_MESSAGE_ROUTED0(WrtViewMsg_SuspendScheduledTask) +IPC_MESSAGE_ROUTED0(WrtViewMsg_ResumeScheduledTasks) + + diff --git a/atom/renderer/atom_render_view_observer.cc b/atom/renderer/atom_render_view_observer.cc index 8923fdf..a608567 100644 --- a/atom/renderer/atom_render_view_observer.cc +++ b/atom/renderer/atom_render_view_observer.cc @@ -139,12 +139,32 @@ bool AtomRenderViewObserver::OnMessageReceived(const IPC::Message& message) { IPC_BEGIN_MESSAGE_MAP(AtomRenderViewObserver, message) IPC_MESSAGE_HANDLER(AtomViewMsg_Message, OnBrowserMessage) IPC_MESSAGE_HANDLER(WrtViewMsg_SetLongPolling, OnSetLongPolling) + IPC_MESSAGE_HANDLER(WrtViewMsg_SuspendScheduledTask, OnSuspendScheduledTasks) + IPC_MESSAGE_HANDLER(WrtViewMsg_ResumeScheduledTasks, OnResumeScheduledTasks) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; } +void AtomRenderViewObserver::OnSuspendScheduledTasks() { + if (!document_created_) + return; + + blink::WebView* view = render_view()->GetWebView(); + if (view) + view->suspendScheduledTasks(); +} + +void AtomRenderViewObserver::OnResumeScheduledTasks() { + if (!document_created_) + return; + + blink::WebView* view = render_view()->GetWebView(); + if (view) + view->resumeScheduledTasks(); +} + void AtomRenderViewObserver::OnDestruct() { delete this; } diff --git a/atom/renderer/atom_render_view_observer.h b/atom/renderer/atom_render_view_observer.h index cd69e2a..00cfb3b 100644 --- a/atom/renderer/atom_render_view_observer.h +++ b/atom/renderer/atom_render_view_observer.h @@ -21,7 +21,8 @@ class AtomRenderViewObserver : public content::RenderViewObserver { public: explicit AtomRenderViewObserver(content::RenderView* render_view, AtomRendererClient* renderer_client); - + void OnSuspendScheduledTasks(); + void OnResumeScheduledTasks(); protected: virtual ~AtomRenderViewObserver(); diff --git a/tizen/browser/tizen_browser_parts.cc b/tizen/browser/tizen_browser_parts.cc index d037cfc..10dd2f6 100644 --- a/tizen/browser/tizen_browser_parts.cc +++ b/tizen/browser/tizen_browser_parts.cc @@ -73,4 +73,18 @@ void TizenBrowserParts::RenderViewCreated(content::RenderViewHost* render_view_h SetLongPollingTimeout(render_view_host); } -} \ No newline at end of file +void TizenBrowserParts::Suspend(content::RenderViewHost* rvh) { + if(!rvh) + return; + + rvh->Send(new WrtViewMsg_SuspendScheduledTask(rvh->GetRoutingID())); +} + +void TizenBrowserParts::Resume(content::RenderViewHost* rvh) { + if(!rvh) + return; + + rvh->Send(new WrtViewMsg_ResumeScheduledTasks(rvh->GetRoutingID())); +} + +} diff --git a/tizen/browser/tizen_browser_parts.h b/tizen/browser/tizen_browser_parts.h index 4f6d552..a280f2f 100644 --- a/tizen/browser/tizen_browser_parts.h +++ b/tizen/browser/tizen_browser_parts.h @@ -32,6 +32,8 @@ class TizenBrowserParts { virtual void Launch(std::unique_ptr appcontrol) = 0; virtual bool launched() const = 0; void RenderViewCreated(content::RenderViewHost* render_view_host); + void Suspend(content::RenderViewHost* rvh); + void Resume(content::RenderViewHost* rvh); void GetCSP(std::string &csp_rule, std::string &csp_report_rule); void Initialize(); @@ -51,4 +53,4 @@ class TizenBrowserParts { } // namespace tizen -#endif // TIZEN_BROWSER_TIZEN_BROWSER_PARTS_H_ \ No newline at end of file +#endif // TIZEN_BROWSER_TIZEN_BROWSER_PARTS_H_ -- 2.7.4 From 94d8b24ad8eb21b8212252f9a84899b8d2ab741e Mon Sep 17 00:00:00 2001 From: Venugopal S M Date: Fri, 13 Jul 2018 13:57:35 +0530 Subject: [PATCH 02/16] fixup! Implementation of Appcontrol functionalities For sending IPC only a valid webview is needed. There is No need to check document element existence. Change-Id: Ie30738e685fc89ce1586b2ee2a23612563a36c39 Signed-off-by: Venugopal S M --- atom/renderer/atom_render_view_observer.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/atom/renderer/atom_render_view_observer.cc b/atom/renderer/atom_render_view_observer.cc index a608567..3870e61 100644 --- a/atom/renderer/atom_render_view_observer.cc +++ b/atom/renderer/atom_render_view_observer.cc @@ -211,9 +211,6 @@ void AtomRenderViewObserver::SetContentSecurityPolicy(blink::WebLocalFrame* fram } void AtomRenderViewObserver::OnSetLongPolling(unsigned long timeout) { - if (!document_created_) - return; - blink::WebView* view = render_view()->GetWebView(); if (!view) return; -- 2.7.4 From 2a3df2cf595d83d769d317c1296d5f8e00b6e57f Mon Sep 17 00:00:00 2001 From: "surya.kumar7" Date: Fri, 13 Jul 2018 21:55:29 +0530 Subject: [PATCH 03/16] Handle Navigation policy from crosswalk-tizen Before making navigations and creating new windows, WRT should authorise based on its policy(WARP) and determine whether navigation should be allowed or not Change-Id: I9816958da6d9900a8436aba8e246e377ab327fc9 Signed-off-by: surya.kumar7 --- atom/browser/api/atom_api_web_contents.cc | 4 +++ atom/browser/atom_browser_client.cc | 7 +++++ atom/browser/atom_browser_client.h | 1 + tizen/browser/tizen_browser_parts.cc | 44 +++++++++++++++++++++++++++++++ tizen/browser/tizen_browser_parts.h | 1 + 5 files changed, 57 insertions(+) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 43b1940..4365e2e 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -1036,6 +1036,10 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) { return; } + if (!atom::Browser::Get()->ShouldAllowNavigation(url.spec())) { + return; + } + content::NavigationController::LoadURLParams params(url); GURL http_referrer; diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index 9408fcf..6fefad7 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -324,6 +324,9 @@ bool AtomBrowserClient::CanCreateWindow( bool* no_javascript_access) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); + if (!atom::Browser::Get()->ShouldAllowNavigation(target_url.spec())) + return false; + if (IsRendererSandboxed(render_process_id)) { *no_javascript_access = false; return true; @@ -345,6 +348,10 @@ bool AtomBrowserClient::CanCreateWindow( return false; } +bool AtomBrowserClient::ShouldAllowOpenURL(content::SiteInstance* site_instance, const GURL& url) { + return atom::Browser::Get()->ShouldAllowNavigation(url.spec()); +} + void AtomBrowserClient::GetAdditionalAllowedSchemesForFileSystem( std::vector* additional_schemes) { auto schemes_list = api::GetStandardSchemes(); diff --git a/atom/browser/atom_browser_client.h b/atom/browser/atom_browser_client.h index a794fba..4d6d3df 100644 --- a/atom/browser/atom_browser_client.h +++ b/atom/browser/atom_browser_client.h @@ -100,6 +100,7 @@ class AtomBrowserClient : public brightray::BrowserClient, bool* no_javascript_access) override; void GetAdditionalAllowedSchemesForFileSystem( std::vector* schemes) override; + bool ShouldAllowOpenURL(content::SiteInstance* site_instance, const GURL& url) override; // brightray::BrowserClient: brightray::BrowserMainParts* OverrideCreateBrowserMainParts( diff --git a/tizen/browser/tizen_browser_parts.cc b/tizen/browser/tizen_browser_parts.cc index 10dd2f6..326e5cd 100644 --- a/tizen/browser/tizen_browser_parts.cc +++ b/tizen/browser/tizen_browser_parts.cc @@ -16,6 +16,7 @@ #include "atom/common/api/api_messages.h" #include "base/logging.h" +#include "common/string_utils.h" #include "tizen/browser/tizen_browser_parts.h" namespace tizen { @@ -25,6 +26,28 @@ namespace { const char* kDefaultCSPRule = "default-src *; script-src 'self'; style-src 'self'; object-src 'none';"; +static bool ProcessWellKnownScheme(const std::string& url) { + if (common::utils::StartsWith(url, "file:") || + common::utils::StartsWith(url, "app:") || + common::utils::StartsWith(url, "data:") || + common::utils::StartsWith(url, "http:") || + common::utils::StartsWith(url, "https:") || + common::utils::StartsWith(url, "widget:") || + common::utils::StartsWith(url, "about:") || + common::utils::StartsWith(url, "blob:")) { + return false; + } + + std::unique_ptr request( + common::AppControl::MakeAppcontrolFromURL(url)); + if (request.get() == NULL || !request->LaunchRequest()) { + LOG(ERROR) << "Fail to send appcontrol request: " << url; + } + + // Should return true, to stop the WebEngine progress step about this URL + return true; +} + } // namespace TizenBrowserParts::TizenBrowserParts() @@ -87,4 +110,25 @@ void TizenBrowserParts::Resume(content::RenderViewHost* rvh) { rvh->Send(new WrtViewMsg_ResumeScheduledTasks(rvh->GetRoutingID())); } +bool TizenBrowserParts::ShouldAllowNavigation(const std::string &url) { + // scheme handling + // except(file , http, https, app) pass to appcontrol and return false + if (ProcessWellKnownScheme(url)) { + return false; + } + + // send launch request for blocked URL to guarrenty backward-compatibility. + if (resource_manager_->AllowNavigation(url)) { + return true; + } else { + LOG(ERROR) << "URL is blocked. send launch request for URL : " << url; + std::unique_ptr request( + common::AppControl::MakeAppcontrolFromURL(url)); + if (request.get() == NULL || !request->LaunchRequest()) { + LOG(ERROR) << "Fail to send appcontrol request: " << url; + } + return false; + } } + +} // namespace tizen diff --git a/tizen/browser/tizen_browser_parts.h b/tizen/browser/tizen_browser_parts.h index a280f2f..09d6934 100644 --- a/tizen/browser/tizen_browser_parts.h +++ b/tizen/browser/tizen_browser_parts.h @@ -35,6 +35,7 @@ class TizenBrowserParts { void Suspend(content::RenderViewHost* rvh); void Resume(content::RenderViewHost* rvh); void GetCSP(std::string &csp_rule, std::string &csp_report_rule); + bool ShouldAllowNavigation(const std::string &url); void Initialize(); protected: -- 2.7.4 From e4822027e3fe7953899547fdd64cbb2e6a76d8c3 Mon Sep 17 00:00:00 2001 From: Venugopal S M Date: Fri, 13 Jul 2018 15:16:34 +0530 Subject: [PATCH 04/16] Enable video hole for TV Chromium on TV uses video hole feature for video playback. This way rendering overhead is reduced. This commit enables video hole feature. Change-Id: Ib293e22ac44663e78020a670d0da79232dbdee45 Signed-off-by: Venugopal S M --- atom/common/api/api_messages.h | 4 ++++ atom/renderer/atom_render_view_observer.cc | 11 +++++++++++ atom/renderer/atom_render_view_observer.h | 4 ++++ efl/build/system.gyp | 21 +++++++++++++++++++++ packaging/electron-efl.spec | 1 + tizen/browser/tizen_browser_parts.cc | 27 ++++++++++++++++++++++++++- tizen/browser/tizen_browser_parts.h | 8 ++++++-- tizen/common.gypi | 1 + wrt.gyp | 2 ++ 9 files changed, 76 insertions(+), 3 deletions(-) diff --git a/atom/common/api/api_messages.h b/atom/common/api/api_messages.h index 8335a4e..befa474 100644 --- a/atom/common/api/api_messages.h +++ b/atom/common/api/api_messages.h @@ -76,4 +76,8 @@ IPC_MESSAGE_ROUTED1(WrtViewMsg_SetLongPolling, IPC_MESSAGE_ROUTED0(WrtViewMsg_SuspendScheduledTask) IPC_MESSAGE_ROUTED0(WrtViewMsg_ResumeScheduledTasks) +#if defined(TIZEN_VIDEO_HOLE) +IPC_MESSAGE_ROUTED1(WrtViewMsg_EnableVideoHole, + bool) +#endif diff --git a/atom/renderer/atom_render_view_observer.cc b/atom/renderer/atom_render_view_observer.cc index 3870e61..d0ae784 100644 --- a/atom/renderer/atom_render_view_observer.cc +++ b/atom/renderer/atom_render_view_observer.cc @@ -141,6 +141,9 @@ bool AtomRenderViewObserver::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(WrtViewMsg_SetLongPolling, OnSetLongPolling) IPC_MESSAGE_HANDLER(WrtViewMsg_SuspendScheduledTask, OnSuspendScheduledTasks) IPC_MESSAGE_HANDLER(WrtViewMsg_ResumeScheduledTasks, OnResumeScheduledTasks) +#if defined(TIZEN_VIDEO_HOLE) + IPC_MESSAGE_HANDLER(WrtViewMsg_EnableVideoHole, OnEnableVideoHole) +#endif IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -217,4 +220,12 @@ void AtomRenderViewObserver::OnSetLongPolling(unsigned long timeout) { view->setLongPollingGlobalTimeout(timeout); } +#if defined(TIZEN_VIDEO_HOLE) +void AtomRenderViewObserver::OnEnableVideoHole(bool is_enabled) { + blink::WebView* view = render_view()->GetWebView(); + if (view) + view->setVideoHoleForRender(is_enabled); +} +#endif + } // namespace atom diff --git a/atom/renderer/atom_render_view_observer.h b/atom/renderer/atom_render_view_observer.h index 00cfb3b..0d89cbf 100644 --- a/atom/renderer/atom_render_view_observer.h +++ b/atom/renderer/atom_render_view_observer.h @@ -44,6 +44,10 @@ class AtomRenderViewObserver : public content::RenderViewObserver { void SetContentSecurityPolicy(blink::WebLocalFrame* frame); void OnSetLongPolling(unsigned long); +#if defined(TIZEN_VIDEO_HOLE) + void OnEnableVideoHole(bool is_enabled); +#endif + AtomRendererClient* renderer_client_; // Whether the document object has been created. diff --git a/efl/build/system.gyp b/efl/build/system.gyp index 32c429f..c15c218 100644 --- a/efl/build/system.gyp +++ b/efl/build/system.gyp @@ -218,5 +218,26 @@ }], ], }, # capi-appfw-application + { + 'target_name': 'capi-media-player', + 'type': 'none', + 'conditions': [ + ['tizen_product_tv==1', { + 'direct_dependent_settings': { + 'cflags': [ + '(atom::WindowList::GetLastWindow()) + ->evas_object(); + + // arg1 -> Evas object, + // arg2 -> 0 : WINDOWLESS_MODE_NORMAL, + // 1 : WINDOWLESS_MODE_FULL_SCREEN + media::MediaPlayerEfl::SetSharedVideoWindowHandle(window_obj, 0); + + // For TV video hole is enabled by default. + render_view_host->Send( + new WrtViewMsg_EnableVideoHole(render_view_host->GetRoutingID(), true)); +} +#endif + void TizenBrowserParts::SetLongPollingTimeout(content::RenderViewHost* rvh) { auto setting = app_data_->setting_info(); if (setting.get() != NULL && @@ -94,6 +116,9 @@ void TizenBrowserParts::SetLongPollingTimeout(content::RenderViewHost* rvh) { void TizenBrowserParts::RenderViewCreated(content::RenderViewHost* render_view_host) { SetLongPollingTimeout(render_view_host); +#if defined(TIZEN_VIDEO_HOLE) + EnableVideoHole(render_view_host); +#endif } void TizenBrowserParts::Suspend(content::RenderViewHost* rvh) { diff --git a/tizen/browser/tizen_browser_parts.h b/tizen/browser/tizen_browser_parts.h index 09d6934..3ef4c97 100644 --- a/tizen/browser/tizen_browser_parts.h +++ b/tizen/browser/tizen_browser_parts.h @@ -20,8 +20,8 @@ #include "content/public/browser/render_view_host.h" #include "tizen/common/app_control.h" #include "tizen/common/application_data.h" -#include "tizen/common/resource_manager.h" #include "tizen/common/locale_manager.h" +#include "tizen/common/resource_manager.h" namespace tizen { @@ -34,7 +34,7 @@ class TizenBrowserParts { void RenderViewCreated(content::RenderViewHost* render_view_host); void Suspend(content::RenderViewHost* rvh); void Resume(content::RenderViewHost* rvh); - void GetCSP(std::string &csp_rule, std::string &csp_report_rule); + void GetCSP(std::string& csp_rule, std::string& csp_report_rule); bool ShouldAllowNavigation(const std::string &url); void Initialize(); @@ -44,6 +44,10 @@ class TizenBrowserParts { virtual ~TizenBrowserParts() {} private: +#if defined(TIZEN_VIDEO_HOLE) + void EnableVideoHole(content::RenderViewHost* render_view_host); +#endif + void SetLongPollingTimeout(content::RenderViewHost* render_view_host); common::ApplicationData* app_data_; diff --git a/tizen/common.gypi b/tizen/common.gypi index 5ec020d..ec9cc58 100644 --- a/tizen/common.gypi +++ b/tizen/common.gypi @@ -33,6 +33,7 @@ 'target_defaults': { 'defines': [ 'OS_TIZEN_TV_PRODUCT', + 'TIZEN_VIDEO_HOLE', ], }, }], # tizen_product_tv==1 diff --git a/wrt.gyp b/wrt.gyp index 2410d1c..5941ad9 100644 --- a/wrt.gyp +++ b/wrt.gyp @@ -212,6 +212,8 @@ }], ['tizen_product_tv==1', { 'dependencies': [ + # `media_player_efl.h` internally includes `player.h`. + '<(DEPTH)/efl/build/system.gyp:capi-media-player', '<(DEPTH)/efl/build/system.gyp:vd-win-util', ], }], -- 2.7.4 From e61917a8bd5143003372e5a237cdb1a8a5e7d556 Mon Sep 17 00:00:00 2001 From: "surya.kumar7" Date: Wed, 18 Jul 2018 19:17:06 +0530 Subject: [PATCH 05/16] Register "chrome-extension://" as a recognized scheme in WARP Extensions use "chrome-extension://" scheme which is not supported by WARP and was forwarding the requests to the platform. Extended support to the new scheme Change-Id: I245b3384dec5666122a1acef3e59d939f7de70b0 Signed-off-by: surya.kumar7 --- tizen/browser/tizen_browser_parts.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tizen/browser/tizen_browser_parts.cc b/tizen/browser/tizen_browser_parts.cc index 13ceaf7..41bf8d5 100644 --- a/tizen/browser/tizen_browser_parts.cc +++ b/tizen/browser/tizen_browser_parts.cc @@ -39,7 +39,8 @@ static bool ProcessWellKnownScheme(const std::string& url) { common::utils::StartsWith(url, "https:") || common::utils::StartsWith(url, "widget:") || common::utils::StartsWith(url, "about:") || - common::utils::StartsWith(url, "blob:")) { + common::utils::StartsWith(url, "blob:") || + common::utils::StartsWith(url, "chrome-extension:")) { return false; } @@ -137,7 +138,7 @@ void TizenBrowserParts::Resume(content::RenderViewHost* rvh) { bool TizenBrowserParts::ShouldAllowNavigation(const std::string &url) { // scheme handling - // except(file , http, https, app) pass to appcontrol and return false + // except(file , http, https, app, chrome-extension) pass to appcontrol and return false if (ProcessWellKnownScheme(url)) { return false; } -- 2.7.4 From 841ff51e3a389bf60476264e99f64c3e24dd0caf Mon Sep 17 00:00:00 2001 From: "surya.kumar7" Date: Fri, 29 Jun 2018 22:49:29 +0530 Subject: [PATCH 06/16] Run Tizen Webapps in single process mode Since Tizen Web Apps don't need node support on the renderer side, removed node dependency on the renderer and made it run in single process Cherry-picked from: https://review.tizen.org/gerrit/#/c/176224/ Change-Id: I4d0cd00862538ac85dab5b321e8ab4fbf91f0b4b Signed-off-by: surya.kumar7 --- atom/app/node_main.cc | 8 ++-- atom/browser/api/atom_api_app.cc | 16 +++++--- atom/browser/api/atom_api_auto_updater.cc | 4 +- atom/browser/api/atom_api_menu.cc | 4 +- atom/browser/api/atom_api_protocol.cc | 4 +- atom/browser/api/atom_api_session.cc | 4 +- atom/browser/api/atom_api_web_contents.cc | 16 +++++--- atom/browser/api/atom_api_window.cc | 4 +- atom/browser/api/event_emitter.h | 7 +++- atom/browser/api/frame_subscriber.cc | 4 +- atom/browser/api/save_page_handler.cc | 4 +- atom/browser/atom_blob_reader.cc | 4 +- atom/browser/atom_browser_main_parts.cc | 10 +++-- atom/browser/atom_download_manager_delegate.cc | 7 +++- atom/browser/browser.cc | 9 ++++- atom/browser/javascript_environment.cc | 7 +++- atom/browser/javascript_environment.h | 3 +- atom/browser/net/js_asker.cc | 4 +- atom/browser/node_debugger.cc | 4 +- atom/browser/node_debugger.h | 2 +- atom/common/api/locker.cc | 7 +++- atom/common/api/locker.h | 3 +- atom/common/native_mate_converters/callback.cc | 3 +- atom/common/native_mate_converters/callback.h | 6 ++- atom/common/node_bindings.cc | 2 +- atom/renderer/atom_renderer_client.cc | 17 +++++++-- .../printing/print_preview_message_handler.cc | 4 +- tizen/common/common.gyp | 2 + tizen/common/env_variables.cc | 3 ++ tizen/common/env_variables.h | 8 ++++ tizen/src/wrt_main.cc | 43 +++++++++++++++++++++- vendor/node/src/node.cc | 15 ++++---- vendor/node/src/node.h | 5 ++- 33 files changed, 185 insertions(+), 58 deletions(-) create mode 100644 tizen/common/env_variables.cc create mode 100644 tizen/common/env_variables.h diff --git a/atom/app/node_main.cc b/atom/app/node_main.cc index 9e80ef2..dbfbfae 100644 --- a/atom/app/node_main.cc +++ b/atom/app/node_main.cc @@ -44,7 +44,7 @@ int NodeMain(int argc, char *argv[]) { int exec_argc; const char** exec_argv; - node::Init(&argc, const_cast(argv), &exec_argc, &exec_argv); + // node::Init(&argc, const_cast(argv), &exec_argc, &exec_argv); not called node::IsolateData isolate_data(gin_env.isolate(), loop); node::Environment* env = node::CreateEnvironment( @@ -52,9 +52,9 @@ int NodeMain(int argc, char *argv[]) { exec_argc, exec_argv); // Start our custom debugger implementation. - NodeDebugger node_debugger(gin_env.isolate()); - if (node_debugger.IsRunning()) - env->AssignToContext(v8::Debug::GetDebugContext(gin_env.isolate())); + // NodeDebugger node_debugger(gin_env.isolate()); not called + // if (node_debugger.IsRunning()) + // env->AssignToContext(v8::Debug::GetDebugContext(gin_env.isolate())); mate::Dictionary process(gin_env.isolate(), env->process_object()); #if defined(OS_WIN) diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 638a769..1471c86 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -42,6 +42,7 @@ #include "native_mate/dictionary.h" #include "native_mate/object_template_builder.h" #include "net/ssl/ssl_cert_request_info.h" +#include "tizen/common/env_variables.h" #include "ui/base/l10n/l10n_util.h" #include "ui/gfx/image/image.h" @@ -476,7 +477,8 @@ int ImportIntoCertStore( void OnIconDataAvailable(v8::Isolate* isolate, const App::FileIconCallback& callback, gfx::Image* icon) { - v8::Locker locker(isolate); + if (!::tizen::is_single_process) + v8::Locker locker(isolate); v8::HandleScope handle_scope(isolate); if (icon && !icon->IsEmpty()) { @@ -567,7 +569,8 @@ void App::OnContinueUserActivity( void App::OnLogin(LoginHandler* login_handler, const base::DictionaryValue& request_details) { - v8::Locker locker(isolate()); + if (!::tizen::is_single_process) + v8::Locker locker(isolate()); v8::HandleScope handle_scope(isolate()); bool prevent_default = Emit( "login", @@ -589,7 +592,8 @@ void App::OnCreateWindow( const scoped_refptr& body, int render_process_id, int render_frame_id) { - v8::Locker locker(isolate()); + if (!::tizen::is_single_process) + v8::Locker locker(isolate()); v8::HandleScope handle_scope(isolate()); content::RenderFrameHost* rfh = content::RenderFrameHost::FromID(render_process_id, render_frame_id); @@ -616,7 +620,8 @@ void App::AllowCertificateError( bool expired_previous_decision, const base::Callback& callback) { - v8::Locker locker(isolate()); + if (!::tizen::is_single_process) + v8::Locker locker(isolate()); v8::HandleScope handle_scope(isolate()); bool prevent_default = Emit("certificate-error", WebContents::CreateFrom(isolate(), web_contents), @@ -882,7 +887,8 @@ void App::GetFileIcon(const base::FilePath& path, IconLoader::IconSize icon_size; FileIconCallback callback; - v8::Locker locker(isolate()); + if (!::tizen::is_single_process) + v8::Locker locker(isolate()); v8::HandleScope handle_scope(isolate()); base::FilePath normalized_path = path.NormalizePathSeparators(); diff --git a/atom/browser/api/atom_api_auto_updater.cc b/atom/browser/api/atom_api_auto_updater.cc index c23e488..2c6cd3e 100644 --- a/atom/browser/api/atom_api_auto_updater.cc +++ b/atom/browser/api/atom_api_auto_updater.cc @@ -13,6 +13,7 @@ #include "base/time/time.h" #include "native_mate/dictionary.h" #include "native_mate/object_template_builder.h" +#include "tizen/common/env_variables.h" namespace mate { @@ -45,7 +46,8 @@ AutoUpdater::~AutoUpdater() { } void AutoUpdater::OnError(const std::string& message) { - v8::Locker locker(isolate()); + if (!::tizen::is_single_process) + v8::Locker locker(isolate()); v8::HandleScope handle_scope(isolate()); auto error = v8::Exception::Error(mate::StringToV8(isolate(), message)); mate::EmitEvent( diff --git a/atom/browser/api/atom_api_menu.cc b/atom/browser/api/atom_api_menu.cc index da208b3..77314d7 100644 --- a/atom/browser/api/atom_api_menu.cc +++ b/atom/browser/api/atom_api_menu.cc @@ -12,6 +12,7 @@ #include "native_mate/constructor.h" #include "native_mate/dictionary.h" #include "native_mate/object_template_builder.h" +#include "tizen/common/env_variables.h" #include "atom/common/node_includes.h" @@ -58,7 +59,8 @@ bool Menu::GetAcceleratorForCommandIdWithParams( int command_id, bool use_default_accelerator, ui::Accelerator* accelerator) const { - v8::Locker locker(isolate()); + if (!::tizen::is_single_process) + v8::Locker locker(isolate()); v8::HandleScope handle_scope(isolate()); v8::Local val = get_accelerator_.Run( command_id, use_default_accelerator); diff --git a/atom/browser/api/atom_api_protocol.cc b/atom/browser/api/atom_api_protocol.cc index e3b15ed..35bdf24 100644 --- a/atom/browser/api/atom_api_protocol.cc +++ b/atom/browser/api/atom_api_protocol.cc @@ -19,6 +19,7 @@ #include "base/strings/string_util.h" #include "content/public/browser/child_process_security_policy.h" #include "native_mate/dictionary.h" +#include "tizen/common/env_variables.h" #include "url/url_util.h" using content::BrowserThread; @@ -153,7 +154,8 @@ void Protocol::OnIOCompleted( if (callback.is_null()) return; - v8::Locker locker(isolate()); + if (!::tizen::is_single_process) + v8::Locker locker(isolate()); v8::HandleScope handle_scope(isolate()); if (error == PROTOCOL_OK) { diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index 83d103a..bb3161b 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -49,6 +49,7 @@ #include "net/url_request/static_http_user_agent_settings.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_getter.h" +#include "tizen/common/env_variables.h" #include "ui/base/l10n/l10n_util.h" using atom::api::Cookies; @@ -459,7 +460,8 @@ void Session::OnDownloadCreated(content::DownloadManager* manager, if (item->IsSavePackageDownload()) return; - v8::Locker locker(isolate()); + if (!::tizen::is_single_process) + v8::Locker locker(isolate()); v8::HandleScope handle_scope(isolate()); auto handle = DownloadItem::Create(isolate(), item); if (item->GetState() == content::DownloadItem::INTERRUPTED) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 4365e2e..99cb90a 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -77,6 +77,7 @@ #include "net/url_request/url_request_context.h" #include "third_party/WebKit/public/platform/WebInputEvent.h" #include "third_party/WebKit/public/web/WebFindOptions.h" +#include "tizen/common/env_variables.h" #include "ui/display/screen.h" #if defined(USE_EFL) @@ -466,7 +467,8 @@ void WebContents::WebContentsCreated(content::WebContents* source_contents, const std::string& frame_name, const GURL& target_url, content::WebContents* new_contents) { - v8::Locker locker(isolate()); + if (!::tizen::is_single_process) + v8::Locker locker(isolate()); v8::HandleScope handle_scope(isolate()); auto api_web_contents = CreateFrom(isolate(), new_contents, BROWSER_WINDOW); Emit("-web-contents-created", api_web_contents, target_url, frame_name); @@ -478,7 +480,8 @@ void WebContents::AddNewContents(content::WebContents* source, const gfx::Rect& initial_rect, bool user_gesture, bool* was_blocked) { - v8::Locker locker(isolate()); + if (!::tizen::is_single_process) + v8::Locker locker(isolate()); v8::HandleScope handle_scope(isolate()); auto api_web_contents = CreateFrom(isolate(), new_contents); if (Emit("-add-new-contents", api_web_contents, disposition, user_gesture, @@ -630,7 +633,8 @@ void WebContents::FindReply(content::WebContents* web_contents, if (!final_update) return; - v8::Locker locker(isolate()); + if (!::tizen::is_single_process) + v8::Locker locker(isolate()); v8::HandleScope handle_scope(isolate()); mate::Dictionary result = mate::Dictionary::CreateEmpty(isolate()); result.Set("requestId", request_id); @@ -886,7 +890,8 @@ void WebContents::DevToolsFocused() { } void WebContents::DevToolsOpened() { - v8::Locker locker(isolate()); + if (!::tizen::is_single_process) + v8::Locker locker(isolate()); v8::HandleScope handle_scope(isolate()); auto handle = WebContents::CreateFrom( isolate(), managed_web_contents()->GetDevToolsWebContents()); @@ -906,7 +911,8 @@ void WebContents::DevToolsOpened() { } void WebContents::DevToolsClosed() { - v8::Locker locker(isolate()); + if (!::tizen::is_single_process) + v8::Locker locker(isolate()); v8::HandleScope handle_scope(isolate()); devtools_web_contents_.Reset(); diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index db323ae..d4a975b 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -23,6 +23,7 @@ #include "content/public/common/content_switches.h" #include "native_mate/constructor.h" #include "native_mate/dictionary.h" +#include "tizen/common/env_variables.h" #include "ui/gfx/geometry/rect.h" #if defined(TOOLKIT_VIEWS) @@ -163,7 +164,8 @@ void Window::WillCloseWindow(bool* prevent_default) { void Window::WillDestroyNativeObject() { // Close all child windows before closing current window. - v8::Locker locker(isolate()); + if (!::tizen::is_single_process) + v8::Locker locker(isolate()); v8::HandleScope handle_scope(isolate()); for (v8::Local value : child_windows_.Values(isolate())) { mate::Handle child; diff --git a/atom/browser/api/event_emitter.h b/atom/browser/api/event_emitter.h index ead3bed..b3884b7 100644 --- a/atom/browser/api/event_emitter.h +++ b/atom/browser/api/event_emitter.h @@ -9,6 +9,7 @@ #include "atom/common/api/event_emitter_caller.h" #include "native_mate/wrappable.h" +#include "tizen/common/env_variables.h" namespace content { class WebContents; @@ -77,7 +78,8 @@ class EventEmitter : public Wrappable { content::WebContents* sender, IPC::Message* message, const Args&... args) { - v8::Locker locker(isolate()); + if (!::tizen::is_single_process) + v8::Locker locker(isolate()); v8::HandleScope handle_scope(isolate()); v8::Local event = internal::CreateJSEvent( isolate(), GetWrapper(), sender, message); @@ -93,7 +95,8 @@ class EventEmitter : public Wrappable { bool EmitWithEvent(const base::StringPiece& name, v8::Local event, const Args&... args) { - v8::Locker locker(isolate()); + if (!::tizen::is_single_process) + v8::Locker locker(isolate()); v8::HandleScope handle_scope(isolate()); EmitEvent(isolate(), GetWrapper(), name, event, args...); return event->Get( diff --git a/atom/browser/api/frame_subscriber.cc b/atom/browser/api/frame_subscriber.cc index b5009e1..e4386c5 100644 --- a/atom/browser/api/frame_subscriber.cc +++ b/atom/browser/api/frame_subscriber.cc @@ -7,6 +7,7 @@ #include "atom/common/native_mate_converters/gfx_converter.h" #include "base/bind.h" #include "content/public/browser/render_widget_host.h" +#include "tizen/common/env_variables.h" #include "ui/display/display.h" #include "ui/display/screen.h" @@ -71,7 +72,8 @@ void FrameSubscriber::OnFrameDelivered(const FrameCaptureCallback& callback, if (response != content::ReadbackResponse::READBACK_SUCCESS) return; - v8::Locker locker(isolate_); + if (!::tizen::is_single_process) + v8::Locker locker(isolate_); v8::HandleScope handle_scope(isolate_); size_t rgb_arr_size = bitmap.width() * bitmap.height() * diff --git a/atom/browser/api/save_page_handler.cc b/atom/browser/api/save_page_handler.cc index e07ec3a..a5541e3 100644 --- a/atom/browser/api/save_page_handler.cc +++ b/atom/browser/api/save_page_handler.cc @@ -10,6 +10,7 @@ #include "base/callback.h" #include "base/files/file_path.h" #include "content/public/browser/web_contents.h" +#include "tizen/common/env_variables.h" namespace atom { @@ -55,7 +56,8 @@ bool SavePageHandler::Handle(const base::FilePath& full_path, void SavePageHandler::OnDownloadUpdated(content::DownloadItem* item) { if (item->IsDone()) { v8::Isolate* isolate = v8::Isolate::GetCurrent(); - v8::Locker locker(isolate); + if (!::tizen::is_single_process) + v8::Locker locker(isolate); v8::HandleScope handle_scope(isolate); if (item->GetState() == content::DownloadItem::COMPLETE) { callback_.Run(v8::Null(isolate)); diff --git a/atom/browser/atom_blob_reader.cc b/atom/browser/atom_blob_reader.cc index fd251c7..42ee96b 100644 --- a/atom/browser/atom_blob_reader.cc +++ b/atom/browser/atom_blob_reader.cc @@ -12,6 +12,7 @@ #include "storage/browser/blob/blob_reader.h" #include "storage/browser/blob/blob_storage_context.h" #include "storage/browser/fileapi/file_system_context.h" +#include "tizen/common/env_variables.h" #include "atom/common/node_includes.h" @@ -32,7 +33,8 @@ void RunCallbackInUI( DCHECK_CURRENTLY_ON(BrowserThread::UI); v8::Isolate* isolate = v8::Isolate::GetCurrent(); - v8::Locker locker(isolate); + if (!::tizen::is_single_process) + v8::Locker locker(isolate); v8::HandleScope handle_scope(isolate); if (blob_data) { v8::Local buffer = node::Buffer::New(isolate, diff --git a/atom/browser/atom_browser_main_parts.cc b/atom/browser/atom_browser_main_parts.cc index 3ea0c3e..10d8583 100644 --- a/atom/browser/atom_browser_main_parts.cc +++ b/atom/browser/atom_browser_main_parts.cc @@ -87,13 +87,14 @@ AtomBrowserMainParts::AtomBrowserMainParts() atom_bindings_ = std::move(self_atom_bindings); js_env_ = std::move(self_js_env); + js_env_->SetupLocker(); node_debugger_ = std::move(self_node_debugger); bridge_task_runner_ = self_bridge_task_runner; node_env_ = std::move(self_node_env); } else { browser_.reset(new Browser); node_bindings_.reset(NodeBindings::Create(NodeBindings::BROWSER)); - atom_bindings_.reset(new AtomBindings(uv_default_loop())); + atom_bindings_.reset(new AtomBindings(node_bindings_->uv_loop())); } self_ = this; // Register extension scheme as web safe scheme. @@ -140,10 +141,10 @@ void AtomBrowserMainParts::SetNodeEnvironment() { self_js_env.reset(new atom::JavascriptEnvironment); self_node_bindings.reset(atom::NodeBindings::Create(atom::NodeBindings::BROWSER)); - self_atom_bindings.reset(new atom::AtomBindings(uv_default_loop())); + self_atom_bindings.reset(new atom::AtomBindings(self_node_bindings->uv_loop())); self_node_bindings->Initialize(); - self_node_debugger.reset(new atom::NodeDebugger(self_js_env->isolate())); + self_node_debugger.reset(new atom::NodeDebugger(self_js_env->isolate(), self_node_bindings->uv_loop())); env_ = self_node_bindings->CreateEnvironment(self_js_env->context()); self_node_env.reset(new atom::NodeEnvironment(env_)); @@ -196,11 +197,12 @@ void AtomBrowserMainParts::PostEarlyInitialization() { // The ProxyResolverV8 has setup a complete V8 environment, in order to // avoid conflicts we only initialize our V8 environment after that. js_env_.reset(new JavascriptEnvironment); + js_env_->SetupLocker(); node_bindings_->Initialize(); // Support the "--debug" switch. - node_debugger_.reset(new NodeDebugger(js_env_->isolate())); + node_debugger_.reset(new NodeDebugger(js_env_->isolate(), node_bindings_->uv_loop())); // Create the global environment. node::Environment* env = diff --git a/atom/browser/atom_download_manager_delegate.cc b/atom/browser/atom_download_manager_delegate.cc index ccbc434..dc42d4e 100644 --- a/atom/browser/atom_download_manager_delegate.cc +++ b/atom/browser/atom_download_manager_delegate.cc @@ -18,6 +18,7 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/download_manager.h" #include "net/base/filename_util.h" +#include "tizen/common/env_variables.h" namespace atom { @@ -38,7 +39,8 @@ AtomDownloadManagerDelegate::~AtomDownloadManagerDelegate() { void AtomDownloadManagerDelegate::GetItemSavePath(content::DownloadItem* item, base::FilePath* path) { v8::Isolate* isolate = v8::Isolate::GetCurrent(); - v8::Locker locker(isolate); + if (!::tizen::is_single_process) + v8::Locker locker(isolate); v8::HandleScope handle_scope(isolate); api::DownloadItem* download = api::DownloadItem::FromWrappedClass(isolate, item); @@ -102,7 +104,8 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated( path.DirName()); v8::Isolate* isolate = v8::Isolate::GetCurrent(); - v8::Locker locker(isolate); + if (!::tizen::is_single_process) + v8::Locker locker(isolate); v8::HandleScope handle_scope(isolate); api::DownloadItem* download_item = api::DownloadItem::FromWrappedClass( isolate, item); diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index 0cd2e39..dcbe344 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -27,6 +27,8 @@ #include "wgt_manifest_handlers/launch_screen_handler.h" #endif // defined(OS_TIZEN) +#include "tizen/common/env_variables.h" + namespace atom { Browser::Browser() @@ -118,8 +120,13 @@ void Browser::Shutdown() { observer.OnQuit(); if (base::ThreadTaskRunnerHandle::IsSet()) { - base::ThreadTaskRunnerHandle::Get()->PostTask( + if (::tizen::is_single_process) { + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), base::TimeDelta::FromSeconds(1)); + } else { + base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); + } ui_app_exit(); } else { // There is no message loop available so we are in early stage. diff --git a/atom/browser/javascript_environment.cc b/atom/browser/javascript_environment.cc index b3e01c1..7ee10c1 100644 --- a/atom/browser/javascript_environment.cc +++ b/atom/browser/javascript_environment.cc @@ -11,6 +11,7 @@ #include "content/public/common/content_switches.h" #include "gin/array_buffer.h" #include "gin/v8_initializer.h" +#include "tizen/common/env_variables.h" #include "atom/common/node_includes.h" @@ -20,7 +21,6 @@ JavascriptEnvironment::JavascriptEnvironment() : initialized_(Initialize()), isolate_(isolate_holder_.isolate()), isolate_scope_(isolate_), - locker_(isolate_), handle_scope_(isolate_), context_(isolate_, v8::Context::New(isolate_)), context_scope_(v8::Local::New(isolate_, context_)) { @@ -34,6 +34,11 @@ void JavascriptEnvironment::OnMessageLoopDestroying() { isolate_holder_.RemoveRunMicrotasksObserver(); } +void JavascriptEnvironment::SetupLocker() { + if (!::tizen::is_single_process) + locker_.reset(new v8::Locker(isolate_)); +} + bool JavascriptEnvironment::Initialize() { auto cmd = base::CommandLine::ForCurrentProcess(); diff --git a/atom/browser/javascript_environment.h b/atom/browser/javascript_environment.h index 43a7295..5887353 100644 --- a/atom/browser/javascript_environment.h +++ b/atom/browser/javascript_environment.h @@ -21,6 +21,7 @@ class JavascriptEnvironment { void OnMessageLoopCreated(); void OnMessageLoopDestroying(); + void SetupLocker(); v8::Isolate* isolate() const { return isolate_; } v8::Local context() const { @@ -34,7 +35,7 @@ class JavascriptEnvironment { gin::IsolateHolder isolate_holder_; v8::Isolate* isolate_; v8::Isolate::Scope isolate_scope_; - v8::Locker locker_; + std::unique_ptr locker_; v8::HandleScope handle_scope_; v8::UniquePersistent context_; v8::Context::Scope context_scope_; diff --git a/atom/browser/net/js_asker.cc b/atom/browser/net/js_asker.cc index 67fb578..81f3918 100644 --- a/atom/browser/net/js_asker.cc +++ b/atom/browser/net/js_asker.cc @@ -8,6 +8,7 @@ #include "atom/common/native_mate_converters/callback.h" #include "atom/common/native_mate_converters/v8_value_converter.h" +#include "tizen/common/env_variables.h" namespace atom { @@ -48,7 +49,8 @@ void AskForOptions(v8::Isolate* isolate, const BeforeStartCallback& before_start, const ResponseCallback& callback) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - v8::Locker locker(isolate); + if (!::tizen::is_single_process) + v8::Locker locker(isolate); v8::HandleScope handle_scope(isolate); v8::Local context = isolate->GetCurrentContext(); v8::Context::Scope context_scope(context); diff --git a/atom/browser/node_debugger.cc b/atom/browser/node_debugger.cc index 9fdeb60..6d4fd84 100644 --- a/atom/browser/node_debugger.cc +++ b/atom/browser/node_debugger.cc @@ -28,7 +28,7 @@ const char* kContentLength = "Content-Length"; } // namespace -NodeDebugger::NodeDebugger(v8::Isolate* isolate) +NodeDebugger::NodeDebugger(v8::Isolate* isolate, uv_loop_t* loop_) : isolate_(isolate), thread_("NodeDebugger"), content_length_(-1), @@ -54,7 +54,7 @@ NodeDebugger::NodeDebugger(v8::Isolate* isolate) v8::Debug::SetMessageHandler(isolate_, DebugMessageHandler); weak_up_ui_handle_.data = this; - uv_async_init(uv_default_loop(), &weak_up_ui_handle_, ProcessMessageInUI); + uv_async_init(loop_, &weak_up_ui_handle_, ProcessMessageInUI); // Start a new IO thread. base::Thread::Options options; diff --git a/atom/browser/node_debugger.h b/atom/browser/node_debugger.h index 118812a..4889fb2 100644 --- a/atom/browser/node_debugger.h +++ b/atom/browser/node_debugger.h @@ -19,7 +19,7 @@ namespace atom { // Add support for node's "--debug" switch. class NodeDebugger : public net::test_server::StreamListenSocket::Delegate { public: - explicit NodeDebugger(v8::Isolate* isolate); + explicit NodeDebugger(v8::Isolate* isolate, uv_loop_t* loop_); virtual ~NodeDebugger(); bool IsRunning() const; diff --git a/atom/common/api/locker.cc b/atom/common/api/locker.cc index fe0b234..09a72fa 100644 --- a/atom/common/api/locker.cc +++ b/atom/common/api/locker.cc @@ -3,12 +3,17 @@ // found in the LICENSE.chromium file. #include "atom/common/api/locker.h" +#include "base/logging.h" +#include "tizen/common/env_variables.h" namespace mate { Locker::Locker(v8::Isolate* isolate) { - if (IsBrowserProcess()) + if (::tizen::is_single_process) + return; + if (IsBrowserProcess()) { locker_.reset(new v8::Locker(isolate)); + } } Locker::~Locker() { diff --git a/atom/common/api/locker.h b/atom/common/api/locker.h index e64ef18..0a9eb26 100644 --- a/atom/common/api/locker.h +++ b/atom/common/api/locker.h @@ -8,6 +8,7 @@ #include #include "base/macros.h" +#include "tizen/common/env_variables.h" #include "v8/include/v8.h" namespace mate { @@ -20,7 +21,7 @@ class Locker { // Returns whether current process is browser process, currently we detect it // by checking whether current has used V8 Lock, but it might be a bad idea. - static inline bool IsBrowserProcess() { return v8::Locker::IsActive(); } + static inline bool IsBrowserProcess() { if (::tizen::is_single_process) return true; return v8::Locker::IsActive(); } private: void* operator new(size_t size); diff --git a/atom/common/native_mate_converters/callback.cc b/atom/common/native_mate_converters/callback.cc index a6a500b..611e19c 100644 --- a/atom/common/native_mate_converters/callback.cc +++ b/atom/common/native_mate_converters/callback.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "atom/common/native_mate_converters/callback.h" +#include "tizen/common/env_variables.h" using content::BrowserThread; @@ -60,7 +61,7 @@ v8::Local BindFunctionWith(v8::Isolate* isolate, struct DeleteOnUIThread { template static void Destruct(const T* x) { - if (Locker::IsBrowserProcess() && + if ((::tizen::is_single_process || Locker::IsBrowserProcess()) && !BrowserThread::CurrentlyOn(BrowserThread::UI)) { BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, x); } else { diff --git a/atom/common/native_mate_converters/callback.h b/atom/common/native_mate_converters/callback.h index 28bff3c..fb802a0 100644 --- a/atom/common/native_mate_converters/callback.h +++ b/atom/common/native_mate_converters/callback.h @@ -46,7 +46,8 @@ struct V8FunctionInvoker(ArgTypes...)> { static v8::Local Go(v8::Isolate* isolate, const SafeV8Function& function, ArgTypes... raw) { - Locker locker(isolate); + if (!::tizen::is_single_process) + Locker locker(isolate); v8::EscapableHandleScope handle_scope(isolate); if (!function.IsAlive()) return v8::Null(isolate); @@ -66,7 +67,8 @@ struct V8FunctionInvoker { static void Go(v8::Isolate* isolate, const SafeV8Function& function, ArgTypes... raw) { - Locker locker(isolate); + if (!::tizen::is_single_process) + Locker locker(isolate); v8::HandleScope handle_scope(isolate); if (!function.IsAlive()) return; diff --git a/atom/common/node_bindings.cc b/atom/common/node_bindings.cc index e61b6eb..fe04520 100644 --- a/atom/common/node_bindings.cc +++ b/atom/common/node_bindings.cc @@ -141,7 +141,7 @@ void NodeBindings::Initialize() { // Init node. // (we assume node::Init would not modify the parameters under embedded mode). - node::Init(nullptr, nullptr, nullptr, nullptr); + node::Init(nullptr, nullptr, nullptr, nullptr, uv_loop_); #if defined(OS_WIN) // uv_init overrides error mode to suppress the default crash dialog, bring diff --git a/atom/renderer/atom_renderer_client.cc b/atom/renderer/atom_renderer_client.cc index 87be391..1e55cce 100644 --- a/atom/renderer/atom_renderer_client.cc +++ b/atom/renderer/atom_renderer_client.cc @@ -34,6 +34,7 @@ #include "native_mate/dictionary.h" #include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" +#include "tizen/common/env_variables.h" #include "atom/common/node_includes.h" @@ -60,9 +61,11 @@ const char** StringVectorToArgArray( } // namespace AtomRendererClient::AtomRendererClient() - : node_integration_initialized_(false), - node_bindings_(NodeBindings::Create(NodeBindings::RENDERER)), - atom_bindings_(new AtomBindings(uv_default_loop())) { + : node_integration_initialized_(false) { + if (!::tizen::is_single_process) { + node_bindings_.reset(NodeBindings::Create(NodeBindings::RENDERER)); + atom_bindings_.reset(new AtomBindings(node_bindings_->uv_loop())); + } isolated_world_ = base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kContextIsolation); } @@ -114,6 +117,8 @@ void AtomRendererClient::RenderViewCreated(content::RenderView* render_view) { void AtomRendererClient::RunScriptsAtDocumentStart( content::RenderFrame* render_frame) { + if (::tizen::is_single_process) + return; // Inform the document start pharse. node::Environment* env = node_bindings_->uv_env(); if (env) { @@ -124,6 +129,8 @@ void AtomRendererClient::RunScriptsAtDocumentStart( void AtomRendererClient::RunScriptsAtDocumentEnd( content::RenderFrame* render_frame) { + if (::tizen::is_single_process) + return; // Inform the document end pharse. node::Environment* env = node_bindings_->uv_env(); if (env) { @@ -142,6 +149,8 @@ void AtomRendererClient::DidCreateScriptContext( render_frame->GetWebFrame()->document().baseURL().string().utf8().c_str()); } #endif + if (::tizen::is_single_process) + return; // Only allow node integration for the main frame, unless it is a devtools // extension page. if (!render_frame->IsMainFrame() && !IsDevToolsExtension(render_frame)) @@ -180,6 +189,8 @@ void AtomRendererClient::WillReleaseScriptContext( if (widget_) widget_->StopSession(context); #endif + if (::tizen::is_single_process) + return; // Only allow node integration for the main frame, unless it is a devtools // extension page. if (!render_frame->IsMainFrame() && !IsDevToolsExtension(render_frame)) diff --git a/chromium_src/chrome/browser/printing/print_preview_message_handler.cc b/chromium_src/chrome/browser/printing/print_preview_message_handler.cc index 7e44f64..6da9d44 100644 --- a/chromium_src/chrome/browser/printing/print_preview_message_handler.cc +++ b/chromium_src/chrome/browser/printing/print_preview_message_handler.cc @@ -17,6 +17,7 @@ #include "printing/page_size_margins.h" #include "printing/print_job_constants.h" #include "printing/pdf_metafile_skia.h" +#include "tizen/common/env_variables.h" #include "atom/common/node_includes.h" @@ -127,7 +128,8 @@ void PrintPreviewMessageHandler::RunPrintToPDFCallback( DCHECK_CURRENTLY_ON(BrowserThread::UI); v8::Isolate* isolate = v8::Isolate::GetCurrent(); - v8::Locker locker(isolate); + if (!::tizen::is_single_process) + v8::Locker locker(isolate); v8::HandleScope handle_scope(isolate); if (data) { v8::Local buffer = node::Buffer::New(isolate, diff --git a/tizen/common/common.gyp b/tizen/common/common.gyp index 7706dd2..637f5c4 100644 --- a/tizen/common/common.gyp +++ b/tizen/common/common.gyp @@ -28,6 +28,8 @@ 'app_db_sqlite.h', 'application_data.h', 'application_data.cc', + 'env_variables.h', + 'env_variables.cc', 'locale_manager.h', 'locale_manager.cc', 'resource_manager.h', diff --git a/tizen/common/env_variables.cc b/tizen/common/env_variables.cc new file mode 100644 index 0000000..cab1fa0 --- /dev/null +++ b/tizen/common/env_variables.cc @@ -0,0 +1,3 @@ +namespace tizen { + bool is_single_process = false; +} \ No newline at end of file diff --git a/tizen/common/env_variables.h b/tizen/common/env_variables.h new file mode 100644 index 0000000..4dd6207 --- /dev/null +++ b/tizen/common/env_variables.h @@ -0,0 +1,8 @@ +#ifndef TIZEN_ENV_VARIABLES +#define TIZEN_ENV_VARIABLES + +namespace tizen { + extern bool is_single_process; +} + +#endif // TIZEN_ENV_VARIABLES \ No newline at end of file diff --git a/tizen/src/wrt_main.cc b/tizen/src/wrt_main.cc index 3bfb612..35027bd 100644 --- a/tizen/src/wrt_main.cc +++ b/tizen/src/wrt_main.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "wrt_main.h" +#include "tizen/common/env_variables.h" #include #include "atom/app/atom_main_delegate.h" // NOLINT @@ -28,12 +29,40 @@ namespace { +bool block_single_process = false; // set to true to disable single process mode altogether + // Default command line flags for all profiles and platforms const char* kDefaultCommandLineFlags[] = { "allow-file-access-from-files", "enable-tizen-app-container", + "allow-universal-access-from-files", + "single-process", + "no-sandbox", + "no-zygote", }; +const int kElectronArgsCount = 2; +const int kTizenWebappArgsCount = 6; + +bool isElectronWebApp() { + auto app_data = common::ApplicationDataManager::GetCurrentAppData(); + if (app_data) { + if (app_data->content_info()) { + std::string startUrl = app_data->content_info()->src(); + if (std::string::npos != startUrl.find(".json")) { + return true; + } + } + } + return false; +} + +bool IsBrowserProcess() { + auto command_line = base::CommandLine::ForCurrentProcess(); + std::string process_type = command_line->GetSwitchValueASCII("type"); + return process_type.empty(); +} + } // namespace #define REFERENCE_MODULE(name) \ @@ -92,9 +121,19 @@ int main(int argc, char* argv[]) { // Add params for EFL port base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); + int args_count = kElectronArgsCount; + if (IsBrowserProcess()) { + if (!block_single_process && !isElectronWebApp()) { + LOG(ERROR) << "will run in single process mode"; + tizen::is_single_process = true; + args_count = kTizenWebappArgsCount; + } else LOG(ERROR) << "will run in non-single process mode"; + } else LOG(ERROR) << "not a browser process"; + static std::vector flags; - for (auto arg : kDefaultCommandLineFlags) - command_line->AppendSwitch(const_cast(arg)); + for (int i = 0; i < args_count; ++i) + command_line->AppendSwitch(const_cast(kDefaultCommandLineFlags[i])); + efl::AppendPortParams(*command_line); atom::AtomMainDelegate delegate; diff --git a/vendor/node/src/node.cc b/vendor/node/src/node.cc index aca7991..4b54bf8 100644 --- a/vendor/node/src/node.cc +++ b/vendor/node/src/node.cc @@ -4232,9 +4232,10 @@ inline void PlatformInit() { void Init(int* argc, const char** argv, int* exec_argc, - const char*** exec_argv) { + const char*** exec_argv, + uv_loop_t* uv_loop_) { // Initialize prog_start_time to get relative uptime. - prog_start_time = static_cast(uv_now(uv_default_loop())); + prog_start_time = static_cast(uv_now(uv_loop_)); if (g_upstream_node_mode) { // No indent to minimize diff. // Make inherited handles noninheritable. @@ -4243,7 +4244,7 @@ void Init(int* argc, // init async debug messages dispatching // Main thread uses uv_default_loop - CHECK_EQ(0, uv_async_init(uv_default_loop(), + CHECK_EQ(0, uv_async_init(uv_loop_, &dispatch_debug_messages_async, DispatchDebugMessagesAsyncCallback)); uv_unref(reinterpret_cast(&dispatch_debug_messages_async)); @@ -4290,7 +4291,7 @@ void Init(int* argc, // performance penalty of frequent EINTR wakeups when the profiler is running. // Only do this for v8.log profiling, as it breaks v8::CpuProfiler users. if (v8_is_profiling) { - uv_loop_configure(uv_default_loop(), UV_LOOP_BLOCK_SIGNAL, SIGPROF); + uv_loop_configure(uv_loop_, UV_LOOP_BLOCK_SIGNAL, SIGPROF); } #endif @@ -4439,7 +4440,7 @@ void FreeEnvironment(Environment* env) { } -inline int Start(Isolate* isolate, IsolateData* isolate_data, +inline int Start(Isolate* isolate, IsolateData* isolate_data, // not called int argc, const char* const* argv, int exec_argc, const char* const* exec_argv) { HandleScope handle_scope(isolate); @@ -4500,7 +4501,7 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data, return exit_code; } -inline int Start(uv_loop_t* event_loop, +inline int Start(uv_loop_t* event_loop, // not called int argc, const char* const* argv, int exec_argc, const char* const* exec_argv) { Isolate::CreateParams params; @@ -4562,7 +4563,7 @@ int Start(int argc, char** argv) { // optional, in case you're wondering. int exec_argc; const char** exec_argv; - Init(&argc, const_cast(argv), &exec_argc, &exec_argv); + // Init(&argc, const_cast(argv), &exec_argc, &exec_argv); #if HAVE_OPENSSL if (const char* extra = secure_getenv("NODE_EXTRA_CA_CERTS")) diff --git a/vendor/node/src/node.h b/vendor/node/src/node.h index f136158..bac44b0 100644 --- a/vendor/node/src/node.h +++ b/vendor/node/src/node.h @@ -189,10 +189,11 @@ NODE_EXTERN extern bool g_standalone_mode; NODE_EXTERN extern bool g_upstream_node_mode; NODE_EXTERN int Start(int argc, char *argv[]); -NODE_EXTERN void Init(int* argc, +NODE_EXTERN void Init(int* argc, // apart from NodeBindings::Initialize(), no one seems to call const char** argv, int* exec_argc, - const char*** exec_argv); + const char*** exec_argv, + uv_loop_t* uv_loop_); class IsolateData; class Environment; -- 2.7.4 From 90cd327c18a51380adab2331d6d4adc11b0f4538 Mon Sep 17 00:00:00 2001 From: Soorya R Date: Fri, 20 Jul 2018 19:34:34 +0530 Subject: [PATCH 07/16] Initial implementation of watch app Change-Id: Id5ee0d012756014f94c646504255b15476acb063 Signed-off-by: Soorya R --- atom/app/runtime.cc | 18 +++-- atom/app/watch_runtime.cc | 149 ++++++++++++++++++++++++++++++++++++++ atom/app/watch_runtime.h | 51 +++++++++++++ atom/browser/native_window_efl.cc | 26 +++++++ atom/browser/native_window_efl.h | 3 + efl/build/system.gyp | 42 +++++++++++ packaging/electron-efl.spec | 2 + wrt.gyp | 4 + 8 files changed, 287 insertions(+), 8 deletions(-) create mode 100644 atom/app/watch_runtime.cc create mode 100644 atom/app/watch_runtime.h diff --git a/atom/app/runtime.cc b/atom/app/runtime.cc index ad61e2d..fcfda5e 100644 --- a/atom/app/runtime.cc +++ b/atom/app/runtime.cc @@ -16,7 +16,11 @@ #include "atom/app/runtime.h" #include "atom/app/ui_runtime.h" +#include "atom/app/watch_runtime.h" +#include "atom/browser/native_window_efl.h" #include "base/logging.h" +#include "efl/window_factory.h" +#include "tizen/common/application_data.h" namespace runtime { @@ -31,15 +35,13 @@ std::unique_ptr Runtime::MakeRuntime(content::ContentMainParams *params else if (app_data->app_type() == common::ApplicationData::IME) { return std::unique_ptr(new ImeRuntime(app_data)); } -#endif // IME_FEATURE_SUPPORT -#ifdef WATCH_FACE_FEATURE_SUPPORT - else if (app_data->app_type() == common::ApplicationData::WATCH) { - return std::unique_ptr(new WatchRuntime(app_data)); - } -#endif // WATCH_FACE_FEATURE_SUPPORT - else { */ +#endif // IME_FEATURE_SUPPORT */ + auto app_data = common::ApplicationDataManager::GetCurrentAppData(); + efl::WindowFactory::SetDelegate(&atom::NativeWindowEfl::GetHostWindowDelegate); + if (app_data->app_type() == common::ApplicationData::WATCH) + return std::unique_ptr(new WatchRuntime(params)); + else return std::unique_ptr(new UiRuntime(params)); - //} } } // namespace runtime diff --git a/atom/app/watch_runtime.cc b/atom/app/watch_runtime.cc new file mode 100644 index 0000000..1309b53 --- /dev/null +++ b/atom/app/watch_runtime.cc @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +#include "atom/app/atom_main_delegate.h" +#include "atom/app/watch_runtime.h" +#include "atom/browser/atom_browser_client.h" +#include "atom/browser/atom_browser_main_parts.h" +#include "atom/browser/browser.h" +#include "atom/common/atom_command_line.h" +#include "base/logging.h" +#include "content/public/app/content_main.h" +#include "gin/v8_initializer.h" +#include "tizen/common/app_control.h" +#include "tizen/common/app_db.h" +#include "tizen/common/application_data.h" +#include "tizen/common/command_line.h" +#include "tizen/common/constants.h" + +namespace runtime { + +WatchRuntime::WatchRuntime(content::ContentMainParams *params) + : _params(params) { + // This line's position is essential as this creates the Browser + // object which is needed later on by watch_runtime in its watch_loop callbacks + atom::AtomBrowserMainParts::SetNodeEnvironment(); +} + +WatchRuntime::~WatchRuntime() { +} + +void WatchRuntime::SetParam(content::ContentMainParams *params) { + if (_params) + LOG(ERROR) << "Use SetParam only when params is null"; + else + _params = params; +} + +bool WatchRuntime::OnCreate() { + auto appdata = common::ApplicationDataManager::GetCurrentAppData(); + if (appdata->splash_screen_info()) { + atom::Browser* browser_model = atom::Browser::Get(); + browser_model->SetSplashScreen(); + } + + return true; +} + +void WatchRuntime::OnTerminate() { + LOG(ERROR) << "OnTerminate()"; + atom::Browser *browser_model = atom::Browser::Get(); +} + +void WatchRuntime::OnPause() { + LOG(ERROR) << "OnPause()"; + atom::Browser *browser_model = atom::Browser::Get(); + browser_model->Hide(); +} + +void WatchRuntime::OnResume() { + LOG(ERROR) << "OnResume()"; + atom::Browser *browser_model = atom::Browser::Get(); + browser_model->Show(); +} + +void WatchRuntime::OnAppControl(app_control_h app_control) { + LOG(ERROR) << "OnAppControl()"; + std::unique_ptr + appcontrol(new common::AppControl(app_control)); + common::AppDB* appdb = common::AppDB::GetInstance(); + appdb->Set(kAppDBRuntimeSection, kAppDBRuntimeBundle, + appcontrol->encoded_bundle()); + atom::Browser *browser_model = atom::Browser::Get(); + if (browser_model->launched()) { + browser_model->AppControl(std::move(appcontrol)); + } else { + browser_model->Initialize(); + browser_model->Launch(std::move(appcontrol)); + } +} + +void WatchRuntime::OnLanguageChanged(const std::string& language) { + LOG(ERROR) << "OnLanguageChanged()"; +} + +void WatchRuntime::OnLowMemory() { + LOG(ERROR) << "OnLowMemory()"; +} + +int WatchRuntime::Exec() { + watch_app_lifecycle_callback_s ops = {NULL, NULL, NULL, NULL, NULL}; + + // onCreate + ops.create = [](int width, int height, void *data) -> bool { + LOG(ERROR) << "Create Tizen App."; + WatchRuntime *runtime = (WatchRuntime*)data; + runtime->OnCreate(); + content::ContentMain(*runtime->_params); + return true; + }; + + // onTerminate + ops.terminate = [](void* data) -> void { + LOG(ERROR) << "Terminate Tizen App."; + WatchRuntime *runtime = (WatchRuntime*)data; + runtime->OnTerminate(); + }; + + // onPause + ops.pause = [](void* data) -> void { + LOG(ERROR) << "Pause Tizen App."; + WatchRuntime *runtime = (WatchRuntime*)data; + runtime->OnPause(); + }; + + // onResume + ops.resume = [](void* data) -> void { + LOG(ERROR) << "Resume Tizen App."; + WatchRuntime *runtime = (WatchRuntime*)data; + runtime->OnResume(); + }; + + // onAppControl + ops.app_control = [](app_control_h app_control, void* data) -> void { + LOG(ERROR) << "app_control Tizen App."; + WatchRuntime *runtime = (WatchRuntime*)data; + runtime->OnAppControl(app_control); + }; + + return watch_app_main(_params->argc, const_cast(_params->argv), &ops, this); +} +} //namespace diff --git a/atom/app/watch_runtime.h b/atom/app/watch_runtime.h new file mode 100644 index 0000000..43636bc --- /dev/null +++ b/atom/app/watch_runtime.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WATCH_RUNTIME_H_ +#define WATCH_RUNTIME_H_ + +#include +#include +#include +#include "atom/app/runtime.h" +#include "content/public/app/content_main.h" + +namespace runtime { + +class WatchRuntime : public Runtime { + public: + WatchRuntime(content::ContentMainParams *params); + virtual ~WatchRuntime(); + + virtual int Exec(); + virtual void SetParam(content::ContentMainParams *params); + + protected: + virtual bool OnCreate(); + virtual void OnTerminate(); + virtual void OnPause(); + virtual void OnResume(); + virtual void OnAppControl(app_control_h app_control); + virtual void OnLanguageChanged(const std::string& language); + virtual void OnLowMemory(); + + private: + content::ContentMainParams *_params; +}; + +} // namespace runtime + +#endif // XWALK_RUNTIME_BROWSER_WATCH_RUNTIME_H_ diff --git a/atom/browser/native_window_efl.cc b/atom/browser/native_window_efl.cc index bcbe509..b71e563 100644 --- a/atom/browser/native_window_efl.cc +++ b/atom/browser/native_window_efl.cc @@ -5,11 +5,14 @@ #include "atom/browser/native_window_efl.h" #include +#include +#include #include "atom/common/options_switches.h" #include "base/command_line.h" #include "content/public/browser/web_contents.h" #include "efl/window_factory.h" +#include "tizen/common/application_data.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/size.h" #include "ui/gfx/image/image.h" @@ -31,6 +34,7 @@ namespace atom { namespace { +std::map window_map_; const int kDefaultWindowWidthDip = 800; const int kDefaultWindowHeightDip = 600; @@ -58,6 +62,28 @@ const char* kMenuKeyEventScript = #endif } +Evas_Object* NativeWindowEfl::GetHostWindowDelegate(const content::WebContents* web_contents) { + LOG(ERROR) << "NativeWindowEfl::GetHostWindowDelegate"; + if (window_map_.find(web_contents) != window_map_.end()) + return window_map_[web_contents]; + + Evas_Object* win = NULL; + auto app_data = common::ApplicationDataManager::GetCurrentAppData(); + if (app_data->app_type() == common::ApplicationData::WATCH) { + elm_config_accel_preference_set("opengl"); + watch_app_get_elm_win(&win); + elm_win_alpha_set(win, EINA_TRUE); + evas_object_render_op_set(win, EVAS_RENDER_COPY); + } + else { + win = elm_win_util_standard_add("", ""); + elm_win_autodel_set(win, EINA_TRUE); + } + + window_map_[web_contents] = win; + return win; +} + NativeWindowEfl::NativeWindowEfl( brightray::InspectableWebContents* inspectable_web_contents, const mate::Dictionary& options, diff --git a/atom/browser/native_window_efl.h b/atom/browser/native_window_efl.h index b7f4024..5d93937 100644 --- a/atom/browser/native_window_efl.h +++ b/atom/browser/native_window_efl.h @@ -6,6 +6,7 @@ #define ATOM_BROWSER_NATIVE_WINDOW_EFL_H_ #include "atom/browser/native_window.h" +#include "content/public/browser/web_contents_delegate.h" #include @@ -26,6 +27,8 @@ class NativeWindowEfl : public NativeWindow { const mate::Dictionary& options, NativeWindow* parent); + static Evas_Object* GetHostWindowDelegate(const content::WebContents*); + void Close() override; void CloseImmediately() override; void Focus(bool focus) override; diff --git a/efl/build/system.gyp b/efl/build/system.gyp index c15c218..2d41270 100644 --- a/efl/build/system.gyp +++ b/efl/build/system.gyp @@ -239,5 +239,47 @@ }], ], }, # capi-media-player + { + 'target_name': 'capi-appfw-watch-application', + 'type': 'none', + 'conditions': [ + ['is_tizen==1', { + 'direct_dependent_settings': { + 'cflags': [ + ' Date: Mon, 23 Jul 2018 18:46:46 +0900 Subject: [PATCH 08/16] Change extension activate timing Before this patch, Web App crashed when any extension was installed because of calling function from window pointer which is casted from NULL. Now activation is called after Window is completly constructed. Change-Id: Ie1fd74f7d8a29a91a11ca7c3a6e668e7b10d5335 Signed-off-by: ws29.jung --- wrt/src/runtime.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wrt/src/runtime.js b/wrt/src/runtime.js index d0e5460..a49487d 100755 --- a/wrt/src/runtime.js +++ b/wrt/src/runtime.js @@ -69,11 +69,12 @@ class Runtime { if (!options.noExtensions && wrt.appID !== 'NVPDzvckj9.RuntimeAddonSetting') { _this.extensionManager.build(); } - _this.extensionManager.activateAll(app); if (wrt.isElectronLaunch()) { + _this.extensionManager.activateAll(app); return; } _this.webApplication = new WebApplication(options); + _this.extensionManager.activateAll(app); }); } onPause(web_window_id) { -- 2.7.4 From 6f627f5360b740e5a2c4211d743dd190af7b8202 Mon Sep 17 00:00:00 2001 From: "surya.kumar7" Date: Mon, 23 Jul 2018 20:44:18 +0530 Subject: [PATCH 09/16] Set Default TTS voice as Female/en_US To resemeble crosswalk, set default TTS voice as Female/en_US in TtsDispatcher's construction Change-Id: I4a5e8d1a1813fbd52f8780ac5b353ead777c069d Signed-off-by: surya.kumar7 --- chromium_src/chrome/common/tts_utterance_request.cc | 9 +++++++++ chromium_src/chrome/common/tts_utterance_request.h | 2 ++ chromium_src/chrome/renderer/tts_dispatcher.cc | 12 ++++++++++++ 3 files changed, 23 insertions(+) diff --git a/chromium_src/chrome/common/tts_utterance_request.cc b/chromium_src/chrome/common/tts_utterance_request.cc index a2e3e7f..bb16da9 100644 --- a/chromium_src/chrome/common/tts_utterance_request.cc +++ b/chromium_src/chrome/common/tts_utterance_request.cc @@ -19,6 +19,15 @@ TtsVoice::TtsVoice() is_default(false) { } +TtsVoice::TtsVoice(std::string voice_uri, std::string name, std::string lang, + bool local_service, bool is_default) + : voice_uri(voice_uri), + name(name), + lang(lang), + local_service(local_service), + is_default(is_default) { +} + TtsVoice::~TtsVoice() { } diff --git a/chromium_src/chrome/common/tts_utterance_request.h b/chromium_src/chrome/common/tts_utterance_request.h index a4b4cab..1c5e829 100644 --- a/chromium_src/chrome/common/tts_utterance_request.h +++ b/chromium_src/chrome/common/tts_utterance_request.h @@ -25,6 +25,8 @@ struct TtsUtteranceRequest { struct TtsVoice { TtsVoice(); + TtsVoice(std::string voice_uri, std::string name, std::string lang, + bool local_service, bool is_default); ~TtsVoice(); std::string voice_uri; diff --git a/chromium_src/chrome/renderer/tts_dispatcher.cc b/chromium_src/chrome/renderer/tts_dispatcher.cc index 0d3b97c..e574de0 100644 --- a/chromium_src/chrome/renderer/tts_dispatcher.cc +++ b/chromium_src/chrome/renderer/tts_dispatcher.cc @@ -21,11 +21,23 @@ using blink::WebSpeechSynthesisVoice; using blink::WebString; using blink::WebVector; +namespace { + +static const std::vector& getDefaultVoiceList() { + static std::vector default_voices( + 1, TtsVoice("localhost:Female/en_US", "Female", "en_US", false, false)); + + return default_voices; +} + +} // namespace + int TtsDispatcher::next_utterance_id_ = 1; TtsDispatcher::TtsDispatcher(WebSpeechSynthesizerClient* client) : synthesizer_client_(client) { RenderThread::Get()->AddObserver(this); + OnSetVoiceList(getDefaultVoiceList()); } TtsDispatcher::~TtsDispatcher() { -- 2.7.4 From 91ac680a6fbd51c6c23e1fdb374ecb83ca3ffd43 Mon Sep 17 00:00:00 2001 From: "min7.choi" Date: Thu, 19 Jul 2018 18:59:53 +0900 Subject: [PATCH 10/16] Fixed using BackKey to navigate back to the page Implemented with remote url, backward compatibility. Change-Id: I8d04f3d04b02c907b8c1c4b6e0759a7181297384 Signed-off-by: min7.choi --- atom/browser/native_window_efl.cc | 41 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/atom/browser/native_window_efl.cc b/atom/browser/native_window_efl.cc index b71e563..54589a6 100644 --- a/atom/browser/native_window_efl.cc +++ b/atom/browser/native_window_efl.cc @@ -23,6 +23,7 @@ #include "base/strings/utf_string_conversions.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/render_frame_host.h" +#include "tizen/common/application_data.h" #endif #if defined(OS_TIZEN_TV_PRODUCT) @@ -38,6 +39,9 @@ std::map window_map_; const int kDefaultWindowWidthDip = 800; const int kDefaultWindowHeightDip = 600; +const char* kFileScheme = "file"; +const std::string kViewmodeTypeWindowed = "windowed"; + #if defined(OS_TIZEN) const char* kBackKeyEventScript = "(function(){" @@ -456,24 +460,55 @@ NativeWindow* NativeWindow::Create( #if defined(OS_TIZEN) // static void NativeWindowEfl::HWBackKeyCallback(void* data, Evas_Object*, void*) { + + auto app_data_ = common::ApplicationDataManager::GetCurrentAppData(); + + bool enabled = app_data_->setting_info() != NULL + ? app_data_->setting_info()->hwkey_enabled() + : true; + if(!enabled) + return; + NativeWindow* thiz = static_cast(data); // TODO: We need to consider to clear selection or exit fullscreen // before send JS custom event. content::RenderFrameHost* rfh = thiz->web_contents()->GetMainFrame(); + if (rfh) { rfh->ExecuteJavaScriptWithUserGestureForTests( base::UTF8ToUTF16(kBackKeyEventScript)); } - if (thiz->web_contents()->GetController().CanGoBack()) + + std::string scheme = thiz->web_contents()->GetURL().scheme(); + + if ((app_data_->setting_info() != NULL && + app_data_->setting_info()->backbutton_presence()) || + (app_data_->widget_info() != NULL && + app_data_->widget_info()->view_modes() == kViewmodeTypeWindowed) || + (scheme != kFileScheme)) { + if (thiz->web_contents()->GetController().CanGoBack()) + thiz->web_contents()->GetController().GoBack(); + else + thiz->Close(); + } else { thiz->web_contents()->GetController().GoBack(); - else - thiz->Close(); + } + } // static void NativeWindowEfl::HWMoreKeyCallback(void* data, Evas_Object*, void*) { NativeWindow* thiz = static_cast(data); content::RenderFrameHost* rfh = thiz->web_contents()->GetMainFrame(); + + auto app_data_ = common::ApplicationDataManager::GetCurrentAppData(); + + bool enabled = app_data_->setting_info() != NULL + ? app_data_->setting_info()->hwkey_enabled() + : true; + if(!enabled) + return; + if (rfh) { rfh->ExecuteJavaScriptWithUserGestureForTests( base::UTF8ToUTF16(kMenuKeyEventScript)); -- 2.7.4 From acf2b97425e14613f6623d1205195bd01715dae1 Mon Sep 17 00:00:00 2001 From: "k2.nagaraju" Date: Thu, 19 Jul 2018 18:05:53 +0530 Subject: [PATCH 11/16] |did-frame-rendered| used for optimize launching time Change-Id: I22de24a81b98401f02be6cb53bdd08a8e1db2de3 Signed-off-by: k2.nagaraju --- atom/browser/api/atom_api_web_contents.cc | 11 ++++++++++- atom/browser/api/atom_api_web_contents.h | 3 ++- wrt/src/web_window.js | 6 +++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 99cb90a..fccae5a 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -283,7 +283,8 @@ WebContents::WebContents(v8::Isolate* isolate, type_(type), request_id_(0), background_throttling_(true), - enable_devtools_(true) { + enable_devtools_(true), + notify_ready_state_(false) { if (type == REMOTE) { web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent()); Init(isolate); @@ -746,7 +747,15 @@ void WebContents::DidFailLoad(content::RenderFrameHost* render_frame_host, Emit("did-fail-load", error_code, error_description, url, is_main_frame); } +void WebContents::DidRenderFrame() { + if (!notify_ready_state_) { + notify_ready_state_ = true; + Emit("did-frame-rendered"); + } +} + void WebContents::DidStartLoading() { + notify_ready_state_ = false; #if defined(OS_TIZEN) if (owner_window() && !owner_window()->IsVisible()) { std::string scheme = web_contents()->GetURL().scheme(); diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 6d50694..48d23e8 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -352,7 +352,7 @@ class WebContents : public mate::TrackableObject, void DevToolsFocused() override; void DevToolsOpened() override; void DevToolsClosed() override; - + void DidRenderFrame() override; private: struct LoadURLParams { LoadURLParams() : params(GURL()), id(0) {} @@ -412,6 +412,7 @@ class WebContents : public mate::TrackableObject, // Whether to enable devtools. bool enable_devtools_; + bool notify_ready_state_; // Container to hold url parms for deferred load when // there is a pending navigation entry. diff --git a/wrt/src/web_window.js b/wrt/src/web_window.js index 039b294..cb1f8ee 100644 --- a/wrt/src/web_window.js +++ b/wrt/src/web_window.js @@ -129,13 +129,17 @@ class WebWindow { }); this.mainWindow.webContents.on('did-finish-load', function() { webwindow_debug('WebWindow : webContents did-finish-load'); + app.emit(IPC_MESSAGE.WEBCONTENTS.DID_FINISH_LOAD, self.mainWindow.id); + }); + this.mainWindow.webContents.on('did-frame-rendered', function() { + webwindow_debug('WebWindow : webContents did-frame-rendered'); wrt.hideSplashScreen(1); if(!options.show){ webwindow_debug('WebWindow : browserWindow show options is ',options.show); + options.show = true; self.show(); } - app.emit(IPC_MESSAGE.WEBCONTENTS.DID_FINISH_LOAD, self.mainWindow.id); }); this.mainWindow.webContents.on('did-fail-load', function(event, errorCode, errorDescription, validatedUrl) { webwindow_debug('WebWindow : webContents did-fail-load'); -- 2.7.4 From 22c43587f5c2acb7b37aaea180289b8472031435 Mon Sep 17 00:00:00 2001 From: guneet1995 Date: Mon, 23 Jul 2018 15:09:18 +0530 Subject: [PATCH 12/16] Resize |web_view_| as soon as it is initialized. |web_view_| is resized with |window_| dimensions as soon as it is initialized in native_window_efl.cc. If resize occurs at a later point, then window.innerHeight and window.innerWidth are zero. Change-Id: Ibf7542e546de4efdd2bf77b13934a2fa862401c5 Signed-off-by: guneet1995 --- atom/browser/native_window_efl.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/atom/browser/native_window_efl.cc b/atom/browser/native_window_efl.cc index 54589a6..d032579 100644 --- a/atom/browser/native_window_efl.cc +++ b/atom/browser/native_window_efl.cc @@ -36,8 +36,8 @@ namespace atom { namespace { std::map window_map_; -const int kDefaultWindowWidthDip = 800; -const int kDefaultWindowHeightDip = 600; +int window_width_; +int window_height_; const char* kFileScheme = "file"; const std::string kViewmodeTypeWindowed = "windowed"; @@ -99,10 +99,10 @@ NativeWindowEfl::NativeWindowEfl( DCHECK(window_); + elm_win_screen_size_get(window_, NULL, NULL, &window_width_, &window_height_); evas_object_smart_callback_add(window_, "delete,request", OnWindowDeleteRequest, this); - evas_object_resize(window_, kDefaultWindowWidthDip, - kDefaultWindowHeightDip); + evas_object_resize(window_, window_width_, window_height_); Evas_Object* box = elm_box_add(window_); evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL); @@ -115,6 +115,8 @@ NativeWindowEfl::NativeWindowEfl( evas_object_size_hint_weight_set(web_view_, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_box_pack_end(box, web_view_); + evas_object_resize(web_view_, window_width_, window_height_); + web_contents()->Focus(); #if defined(OS_TIZEN) -- 2.7.4 From a2c77acec5ed4b2a1044c706f3086d7bca8ba0c3 Mon Sep 17 00:00:00 2001 From: "ws29.jung" Date: Tue, 24 Jul 2018 18:01:22 +0900 Subject: [PATCH 13/16] Fix WebApp crash with installed extension on TV (multiprocess) Earlier then this patch, there was fix up patch for same issue but only applied with Tizen WebApp. (d8c2683) This patch moves extension activation on 'browser-window-created' callback so now BrowserWindow construction is guaranteed before activation for both Tizen and Electron Web App type. Change-Id: I94405ead5ef6188da09faaac91f976307fae3a3b Signed-off-by: ws29.jung --- wrt/src/runtime.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wrt/src/runtime.js b/wrt/src/runtime.js index a49487d..ae01bb3 100755 --- a/wrt/src/runtime.js +++ b/wrt/src/runtime.js @@ -42,6 +42,10 @@ class Runtime { return runtime_debug('browser-window-focus'); }); app.on('browser-window-created', function() { + if (!_this.isLaunched) { + _this.extensionManager.activateAll(app); + _this.isLaunched = true; + } return runtime_debug('browser-window-created'); }); app.on('gpu-process-crashed', function() { @@ -70,11 +74,9 @@ class Runtime { _this.extensionManager.build(); } if (wrt.isElectronLaunch()) { - _this.extensionManager.activateAll(app); return; } _this.webApplication = new WebApplication(options); - _this.extensionManager.activateAll(app); }); } onPause(web_window_id) { -- 2.7.4 From 8ffefbeddaef8bee3697a9e1bd9e4f0b81e6e714 Mon Sep 17 00:00:00 2001 From: Soorya R Date: Tue, 24 Jul 2018 20:13:06 +0530 Subject: [PATCH 14/16] fixup! Initial implementation of watch app This CL fixes the crash that occurs when MakeRuntime is called during prelaunch phase. Change-Id: I685a0ea66fbdf21081a583781095755cd15ac799 Signed-off-by: Soorya R --- atom/app/runtime.cc | 5 +++++ atom/app/runtime.h | 1 + atom/app/ui_runtime.cc | 17 ++++++----------- atom/app/watch_runtime.cc | 3 --- tizen/src/wrt_main.cc | 10 +++++----- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/atom/app/runtime.cc b/atom/app/runtime.cc index fcfda5e..c089436 100644 --- a/atom/app/runtime.cc +++ b/atom/app/runtime.cc @@ -17,6 +17,7 @@ #include "atom/app/runtime.h" #include "atom/app/ui_runtime.h" #include "atom/app/watch_runtime.h" +#include "atom/browser/atom_browser_main_parts.h" #include "atom/browser/native_window_efl.h" #include "base/logging.h" #include "efl/window_factory.h" @@ -24,6 +25,10 @@ namespace runtime { +Runtime::Runtime() { + atom::AtomBrowserMainParts::SetNodeEnvironment(); +} + Runtime::~Runtime() { } diff --git a/atom/app/runtime.h b/atom/app/runtime.h index a5bcbc2..c5552fb 100644 --- a/atom/app/runtime.h +++ b/atom/app/runtime.h @@ -27,6 +27,7 @@ namespace runtime { class Runtime { public: + Runtime(); virtual ~Runtime() = 0; virtual int Exec() = 0; diff --git a/atom/app/ui_runtime.cc b/atom/app/ui_runtime.cc index b38b7ed..c078f65 100644 --- a/atom/app/ui_runtime.cc +++ b/atom/app/ui_runtime.cc @@ -20,28 +20,23 @@ #include "atom/app/atom_main_delegate.h" #include "atom/app/ui_runtime.h" -#include "atom/browser/browser.h" #include "atom/browser/atom_browser_client.h" #include "atom/browser/atom_browser_main_parts.h" +#include "atom/browser/browser.h" #include "atom/common/atom_command_line.h" #include "base/logging.h" #include "content/public/app/content_main.h" -#include "tizen/common/app_db.h" +#include "gin/v8_initializer.h" #include "tizen/common/app_control.h" -#include "tizen/common/constants.h" +#include "tizen/common/app_db.h" #include "tizen/common/application_data.h" #include "tizen/common/command_line.h" - -#include "gin/v8_initializer.h" +#include "tizen/common/constants.h" namespace runtime { -UiRuntime::UiRuntime(content::ContentMainParams *params) { - _params = params; - - // This line's position is essential as this creates the Browser - // object which is needed later on by ui_runtime in its ui_loop callbacks - atom::AtomBrowserMainParts::SetNodeEnvironment(); +UiRuntime::UiRuntime(content::ContentMainParams *params) + : _params(params) { } UiRuntime::~UiRuntime() { diff --git a/atom/app/watch_runtime.cc b/atom/app/watch_runtime.cc index 1309b53..58b4204 100644 --- a/atom/app/watch_runtime.cc +++ b/atom/app/watch_runtime.cc @@ -38,9 +38,6 @@ namespace runtime { WatchRuntime::WatchRuntime(content::ContentMainParams *params) : _params(params) { - // This line's position is essential as this creates the Browser - // object which is needed later on by watch_runtime in its watch_loop callbacks - atom::AtomBrowserMainParts::SetNodeEnvironment(); } WatchRuntime::~WatchRuntime() { diff --git a/tizen/src/wrt_main.cc b/tizen/src/wrt_main.cc index 35027bd..c32c287 100644 --- a/tizen/src/wrt_main.cc +++ b/tizen/src/wrt_main.cc @@ -10,6 +10,7 @@ #include "content/public/app/content_main.h" #include "atom/app/node_main.h" +#include "atom/browser/atom_browser_main_parts.h" #include "atom/common/atom_command_line.h" #include "base/at_exit.h" #include "base/i18n/icu_util.h" @@ -73,7 +74,6 @@ REFERENCE_MODULE(wrt); #if defined(OS_TIZEN) bool g_initialized_ = false; -std::unique_ptr runtime_; // For debug purpose only. // TODO: To be removed later @@ -106,6 +106,7 @@ int main(int argc, char* argv[]) { base::CommandLine::Init(argc, argv); } + std::unique_ptr runtime_; common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess(); std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/wrt"); @@ -144,9 +145,8 @@ int main(int argc, char* argv[]) { #if defined(OS_TIZEN) if (hasTizenPackageID(argc,argv)) { // TODO: Check to be removed later elm_init(argc, argv); - if (!g_initialized_) { - runtime_ = runtime::Runtime::MakeRuntime(¶ms); - } else { + runtime_ = runtime::Runtime::MakeRuntime(¶ms); + if (g_initialized_) { runtime_->SetParam(¶ms); } return runtime_->Exec(); @@ -172,7 +172,7 @@ int main(int argc, const char* argv[]) { params.argc = argc; params.argv = const_cast(argv); atom::AtomCommandLine::Init(argc, argv); - runtime_ = runtime::Runtime::MakeRuntime(nullptr); + atom::AtomBrowserMainParts::SetNodeEnvironment(); tizen::PreloadManager::GetInstance()->CreateCacheComponent(); return 0; }; -- 2.7.4 From 3465b7713914a4290070d2ff6fcc19b1ac317a11 Mon Sep 17 00:00:00 2001 From: "k2.nagaraju" Date: Tue, 24 Jul 2018 18:05:27 +0530 Subject: [PATCH 15/16] Add tizen tts support Electron currently uses the chromium tts engine. Added tizen tts support. Change-Id: Ie7e0231f2cc2a280a3c0c4d4df72c18378ee6193 Signed-off-by: k2.nagaraju --- atom/browser/atom_browser_client.cc | 11 ++++++++++- atom/common/common_message_generator.h | 4 +++- atom/renderer/renderer_client_base.cc | 9 +++++++++ efl/build/system.gyp | 21 ++++++++++++++++++++ filenames.gypi | 36 ++++++++++++++++++++-------------- packaging/electron-efl.spec | 1 + wrt.gyp | 1 + 7 files changed, 66 insertions(+), 17 deletions(-) diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index 6fefad7..1f5aee5 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -28,7 +28,6 @@ #include "chrome/browser/printing/printing_message_filter.h" #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h" #include "chrome/browser/renderer_host/pepper/widevine_cdm_message_filter.h" -#include "chrome/browser/speech/tts_message_filter.h" #include "content/common/resource_request_body_impl.h" #include "content/public/browser/browser_ppapi_host.h" #include "content/public/browser/client_certificate_delegate.h" @@ -44,6 +43,12 @@ #include "ui/base/l10n/l10n_util.h" #include "v8/include/v8.h" +#if defined(OS_TIZEN) +#include "content/browser/speech/tts_message_filter_efl.h" +#else +#include "chrome/browser/speech/tts_message_filter.h" +#endif + namespace atom { namespace { @@ -130,7 +135,11 @@ void AtomBrowserClient::RenderProcessWillLaunch( content::RenderProcessHost* host) { int process_id = host->GetID(); host->AddFilter(new printing::PrintingMessageFilter(process_id)); +#if defined(OS_TIZEN) + host->AddFilter(new content::TtsMessageFilterEfl()); +#else host->AddFilter(new TtsMessageFilter(process_id, host->GetBrowserContext())); +#endif host->AddFilter( new WidevineCdmMessageFilter(process_id, host->GetBrowserContext())); diff --git a/atom/common/common_message_generator.h b/atom/common/common_message_generator.h index a63c40b..f2c65cd 100644 --- a/atom/common/common_message_generator.h +++ b/atom/common/common_message_generator.h @@ -6,7 +6,9 @@ #include "atom/common/api/api_messages.h" #include "chrome/common/print_messages.h" -#include "chrome/common/tts_messages.h" #include "chrome/common/widevine_cdm_messages.h" #include "chrome/common/chrome_utility_messages.h" #include "components/pdf/common/pdf_messages.h" +#if !defined(OS_TIZEN) +#include "chrome/common/tts_messages.h" +#endif diff --git a/atom/renderer/renderer_client_base.cc b/atom/renderer/renderer_client_base.cc index 4d3675e..51720d0 100644 --- a/atom/renderer/renderer_client_base.cc +++ b/atom/renderer/renderer_client_base.cc @@ -36,6 +36,11 @@ #include "base/strings/sys_string_conversions.h" #endif +#if defined(OS_TIZEN) +#include "content/common/tts_messages_efl.h" +#include "content/renderer/tts_dispatcher_efl.h" +#endif + #if defined(OS_WIN) #include #endif @@ -160,7 +165,11 @@ void RendererClientBase::DidClearWindowObject( blink::WebSpeechSynthesizer* RendererClientBase::OverrideSpeechSynthesizer( blink::WebSpeechSynthesizerClient* client) { +#if defined(OS_TIZEN) + return new content::TtsDispatcherEfl(client); +#else return new TtsDispatcher(client); +#endif } bool RendererClientBase::OverrideCreatePlugin( diff --git a/efl/build/system.gyp b/efl/build/system.gyp index 2d41270..ebbc965 100644 --- a/efl/build/system.gyp +++ b/efl/build/system.gyp @@ -281,5 +281,26 @@ }], ], }, # appcore-watch + { + 'target_name': 'tts', + 'type': 'none', + 'conditions': [ + ['is_tizen==1', { + 'direct_dependent_settings': { + 'cflags': [ + ' Date: Wed, 25 Jul 2018 03:55:58 +0000 Subject: [PATCH 16/16] Revert "Set Default TTS voice as Female/en_US" This change is not needed. On tizen, we need to use CAPI framework for TTS. This reverts commit 6f627f5360b740e5a2c4211d743dd190af7b8202. Change-Id: I4ba520063aa0b04d8fc4a48c03a20b01de1a4ab3 Signed-off-by: Venugopal S M --- chromium_src/chrome/common/tts_utterance_request.cc | 9 --------- chromium_src/chrome/common/tts_utterance_request.h | 2 -- chromium_src/chrome/renderer/tts_dispatcher.cc | 12 ------------ 3 files changed, 23 deletions(-) diff --git a/chromium_src/chrome/common/tts_utterance_request.cc b/chromium_src/chrome/common/tts_utterance_request.cc index bb16da9..a2e3e7f 100644 --- a/chromium_src/chrome/common/tts_utterance_request.cc +++ b/chromium_src/chrome/common/tts_utterance_request.cc @@ -19,15 +19,6 @@ TtsVoice::TtsVoice() is_default(false) { } -TtsVoice::TtsVoice(std::string voice_uri, std::string name, std::string lang, - bool local_service, bool is_default) - : voice_uri(voice_uri), - name(name), - lang(lang), - local_service(local_service), - is_default(is_default) { -} - TtsVoice::~TtsVoice() { } diff --git a/chromium_src/chrome/common/tts_utterance_request.h b/chromium_src/chrome/common/tts_utterance_request.h index 1c5e829..a4b4cab 100644 --- a/chromium_src/chrome/common/tts_utterance_request.h +++ b/chromium_src/chrome/common/tts_utterance_request.h @@ -25,8 +25,6 @@ struct TtsUtteranceRequest { struct TtsVoice { TtsVoice(); - TtsVoice(std::string voice_uri, std::string name, std::string lang, - bool local_service, bool is_default); ~TtsVoice(); std::string voice_uri; diff --git a/chromium_src/chrome/renderer/tts_dispatcher.cc b/chromium_src/chrome/renderer/tts_dispatcher.cc index e574de0..0d3b97c 100644 --- a/chromium_src/chrome/renderer/tts_dispatcher.cc +++ b/chromium_src/chrome/renderer/tts_dispatcher.cc @@ -21,23 +21,11 @@ using blink::WebSpeechSynthesisVoice; using blink::WebString; using blink::WebVector; -namespace { - -static const std::vector& getDefaultVoiceList() { - static std::vector default_voices( - 1, TtsVoice("localhost:Female/en_US", "Female", "en_US", false, false)); - - return default_voices; -} - -} // namespace - int TtsDispatcher::next_utterance_id_ = 1; TtsDispatcher::TtsDispatcher(WebSpeechSynthesizerClient* client) : synthesizer_client_(client) { RenderThread::Get()->AddObserver(this); - OnSetVoiceList(getDefaultVoiceList()); } TtsDispatcher::~TtsDispatcher() { -- 2.7.4