From e2d42b261f17377d8acb44d744d591ff151ac62d Mon Sep 17 00:00:00 2001 From: "min7.choi" Date: Thu, 19 Apr 2018 19:30:05 +0900 Subject: [PATCH 01/16] Implement splash screen Implementation of splash screen used in tizen. now the hide screen is only implemented in complete. first-paint and costom will be implemented later. Also, the window state of the splash screen will be implemented later Change-Id: I444f1be7dd04be46d5cd8edca5e022616d9020ff Signed-off-by: min7.choi --- atom/app/ui_runtime.cc | 16 ++- atom/browser/api/atom_api_pwrt.cc | 7 ++ atom/browser/api/atom_api_pwrt.h | 1 + atom/browser/browser.cc | 37 ++++++ atom/browser/browser.h | 12 ++ atom/browser/splash_screen.cc | 238 ++++++++++++++++++++++++++++++++++++++ atom/browser/splash_screen.h | 69 +++++++++++ wrt.gyp | 2 + wrt/src/web_window.js | 4 +- 9 files changed, 384 insertions(+), 2 deletions(-) create mode 100755 atom/browser/splash_screen.cc create mode 100755 atom/browser/splash_screen.h diff --git a/atom/app/ui_runtime.cc b/atom/app/ui_runtime.cc index 959e4ac..e13e1bf 100644 --- a/atom/app/ui_runtime.cc +++ b/atom/app/ui_runtime.cc @@ -29,6 +29,8 @@ #include "tizen/common/app_db.h" #include "tizen/common/app_control.h" #include "tizen/common/constants.h" +#include "tizen/common/application_data.h" +#include "tizen/common/command_line.h" #include "gin/v8_initializer.h" @@ -51,6 +53,17 @@ void UiRuntime::SetParam(content::ContentMainParams *params) { } bool UiRuntime::OnCreate() { + common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess(); + std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/electron"); + + auto appdata_manager = common::ApplicationDataManager::GetInstance(); + common::ApplicationData* appdata = appdata_manager->GetApplicationData(appid); + + if(appdata->splash_screen_info()){ + atom::Browser* browser_model = atom::Browser::Get(); + browser_model->SetSplashScreen(); + } + return true; } @@ -72,7 +85,7 @@ void UiRuntime::OnResume() { } void UiRuntime::OnAppControl(app_control_h app_control) { - LOG(ERROR) << "OnAppControl()"; + LOG(ERROR) << "OnAppControl()"; std::unique_ptr appcontrol(new common::AppControl(app_control)); common::AppDB* appdb = common::AppDB::GetInstance(); @@ -102,6 +115,7 @@ int UiRuntime::Exec() { ops.create = [](void* data) -> bool { LOG(ERROR) << "Create Tizen App."; UiRuntime *runtime = (UiRuntime*)data; + runtime->OnCreate(); content::ContentMain(*runtime->_params); return true; }; diff --git a/atom/browser/api/atom_api_pwrt.cc b/atom/browser/api/atom_api_pwrt.cc index 30213c5..aa7b785 100644 --- a/atom/browser/api/atom_api_pwrt.cc +++ b/atom/browser/api/atom_api_pwrt.cc @@ -56,6 +56,12 @@ bool PWRT::isElectronLaunch() { return Browser::Get()->is_electron_launch(); } +void PWRT::HideSplashScreen(int reason) { + LOG(ERROR) << "PWRT::HideSplashScreen"; + atom::Browser *browser_model = atom::Browser::Get(); + browser_model->HideSplashScreen(reason); +} + void PWRT::Log(const std::string& message) { std::string output = "[JS LOG] " + message; dlog_print(DLOG_ERROR, "WRT", output.c_str()); @@ -78,6 +84,7 @@ void PWRT::BuildPrototype( .SetMethod("getPath", &PWRT::GetPath) .SetMethod("isTizenWebApp", &PWRT::isTizenWebApp) .SetMethod("isElectronLaunch", &PWRT::isElectronLaunch) + .SetMethod("hideSplashScreen", &PWRT::HideSplashScreen) .SetMethod("log", &PWRT::Log); } diff --git a/atom/browser/api/atom_api_pwrt.h b/atom/browser/api/atom_api_pwrt.h index 8b67cc2..ab25f34 100644 --- a/atom/browser/api/atom_api_pwrt.h +++ b/atom/browser/api/atom_api_pwrt.h @@ -20,6 +20,7 @@ class PWRT : public mate::TrackableObject { std::string GetPath(); bool isTizenWebApp(); bool isElectronLaunch(); + void HideSplashScreen(int reason); void Log(const std::string& message); protected: diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index 771cbee..3ebba72 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -16,7 +16,14 @@ #include "base/run_loop.h" #include "base/threading/thread_task_runner_handle.h" #include "brightray/browser/brightray_paths.h" + +#if defined(OS_TIZEN) #include "tizen/common/command_line.h" +#include "tizen/common/application_data.h" +#include +#include "wgt_manifest_handlers/launch_screen_handler.h" +#endif // defined(OS_TIZEN) + namespace atom { Browser::Browser() @@ -277,4 +284,34 @@ void Browser::Launch(std::unique_ptr appcontrol) { //To do:Implementation of relaunching of app } +#if defined(OS_TIZEN) +void Browser::SetSplashScreen() { + common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess(); + std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/electron"); + + auto appdata_manager = common::ApplicationDataManager::GetInstance(); + common::ApplicationData* appdata = appdata_manager->GetApplicationData(appid); + + Evas_Object* window_ = elm_win_util_standard_add("", ""); + + splash_screen_.reset( + new SplashScreen( + window_, appdata->splash_screen_info(), appdata->application_path())); +} + +void Browser::HideSplashScreen(int reason) { + common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess(); + std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/electron"); + + auto appdata_manager = common::ApplicationDataManager::GetInstance(); + common::ApplicationData* appdata = appdata_manager->GetApplicationData(appid); + + if(appdata->splash_screen_info() == NULL) { + return; + } + + splash_screen_->HideSplashScreen(reason); +} +#endif // defined(OS_TIZEN) + } // namespace atom diff --git a/atom/browser/browser.h b/atom/browser/browser.h index dfc4831..362bfaf 100644 --- a/atom/browser/browser.h +++ b/atom/browser/browser.h @@ -20,6 +20,10 @@ #include "tizen/common/application_data.h" #include "tizen/common/resource_manager.h" #include "tizen/common/locale_manager.h" +#if defined(OS_TIZEN) +#include "atom/browser/splash_screen.h" +#endif // defined(OS_TIZEN) + #if defined(OS_WIN) #include "base/files/file_path.h" @@ -48,6 +52,10 @@ class Browser : public WindowListObserver { std::unique_ptr resource_manager_; std::unique_ptr locale_manager_; +#if defined(OS_TIZEN) + std::unique_ptr splash_screen_; +#endif // defined(OS_TIZEN) + void Initialize(); // Try to close all windows and quit the application. @@ -117,6 +125,10 @@ class Browser : public WindowListObserver { void Show(); void AppControl(std::unique_ptr appcontrol); void Launch(std::unique_ptr appcontrol); +#if defined(OS_TIZEN) + void SetSplashScreen(); + void HideSplashScreen(int reason); +#endif // defined(OS_TIZEN) #if defined(OS_MACOSX) // Hide the application. diff --git a/atom/browser/splash_screen.cc b/atom/browser/splash_screen.cc new file mode 100755 index 0000000..d6c1751 --- /dev/null +++ b/atom/browser/splash_screen.cc @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2015 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 "atom/browser/splash_screen.h" + +#include +#include +#include + +#include + +#include "tizen/common/logger.h" + +//using ScreenOrientation = runtime::NativeWindow::ScreenOrientation; + +namespace { + +enum class BorderOption { REPEAT = 1, STRETCH, ROUND }; + +// To do : The orientation will be implemented later. + +/*wgt::parse::ScreenOrientation ChooseOrientation( + const std::map& splash_map, + ScreenOrientation screen_orientation) { + auto orientation_pair = splash_map.end(); + + if (screen_orientation == + runtime::NativeWindow::ScreenOrientation::PORTRAIT_PRIMARY || + screen_orientation == + runtime::NativeWindow::ScreenOrientation::PORTRAIT_SECONDARY) { + orientation_pair = + splash_map.find(wgt::parse::ScreenOrientation::PORTRAIT); + } else { + orientation_pair = + splash_map.find(wgt::parse::ScreenOrientation::LANDSCAPE); + } + if (orientation_pair == splash_map.end()) + orientation_pair = splash_map.find(wgt::parse::ScreenOrientation::AUTO); + + if (orientation_pair != splash_map.end()) return orientation_pair->first; + return wgt::parse::ScreenOrientation::NONE; +}*/ + +bool ParseImageBorder(const std::vector& borders, + std::vector* border_values, + std::vector* border_options) { + std::map scaling_string; + scaling_string["repeat"] = BorderOption::REPEAT; + scaling_string["stretch"] = BorderOption::STRETCH; + scaling_string["round"] = BorderOption::ROUND; + + for (const auto& border : borders) { + std::string::size_type px_index = border.find("px"); + if (px_index != std::string::npos) { + std::string border_value(border.begin(), border.begin() + px_index); + border_values->push_back(std::atoi(border_value.c_str())); + } + for (const auto& border_string_val : scaling_string) { + std::string::size_type index = border.find(border_string_val.first); + if (index != std::string::npos) { + border_options->push_back(border_string_val.second); + } + } + } + + LOGGER(DEBUG) << "Image border values:"; + for (const auto& border_value : *border_values) { + LOGGER(DEBUG) << border_value; + } + LOGGER(DEBUG) << "Image border scaling values:"; + for (const auto& border_option : *border_options) { + LOGGER(DEBUG) << static_cast(border_option); + } + + return !border_values->empty() && !border_options->empty(); +} + +} // namespace + +namespace atom { + +SplashScreen::SplashScreen( + Evas_Object* window, + //runtime::NativeWindow* window, + std::shared_ptr ss_info, + const std::string& app_path) + : ss_info_(ss_info), + window_(window), + image_(nullptr), + background_(nullptr), + background_image_(nullptr), + is_active_(false) { + if (ss_info == nullptr) return; + + auto splash_map = ss_info->launch_screen_data(); + /*auto used_orientation = + ChooseOrientation(splash_map, window->orientation()); + if (used_orientation == wgt::parse::ScreenOrientation::NONE) return; */ + + auto dimensions = GetDimensions(window); + + // To do : The orientation will be implemented later. + SetBackground(splash_map[wgt::parse::ScreenOrientation::AUTO], window, + dimensions, app_path); + SetImage(splash_map[wgt::parse::ScreenOrientation::AUTO], window, + dimensions, app_path); + is_active_ = true; +} + +void SplashScreen::HideSplashScreen(int reason) { + + if (!is_active_) return; + if (reason == HideReason::RENDERED && + ss_info_->ready_when() != wgt::parse::ReadyWhen::FIRSTPAINT) { + return; + } + if (reason == HideReason::LOADFINISHED && + ss_info_->ready_when() != wgt::parse::ReadyWhen::COMPLETE) { + return; + } + if (reason == HideReason::CUSTOM && + ss_info_->ready_when() != wgt::parse::ReadyWhen::CUSTOM) { + return; + } + + evas_object_hide(background_); + evas_object_hide(image_); + evas_object_hide(window_); + evas_object_del(background_); + evas_object_del(image_); + evas_object_hide(window_); + background_ = nullptr; + image_ = nullptr; + window_ = nullptr; + is_active_ = false; +} + +std::pair SplashScreen::GetDimensions(Evas_Object* window) { + int w, h; + elm_win_screen_size_get(window, NULL, NULL, &w, &h); + evas_object_resize(background_, w, h); + return std::make_pair(w, h); +} + +void SplashScreen::SetBackground( + const wgt::parse::LaunchScreenData& splash_data, Evas_Object* parent, + const SplashScreenBound& bound, const std::string& app_path) { + background_ = elm_bg_add(parent); + if (!background_) return; + evas_object_resize(background_, bound.first, bound.second); + + if (splash_data.background_color != nullptr) { + elm_bg_color_set(background_, + splash_data.background_color->red, + splash_data.background_color->green, + splash_data.background_color->blue); + } + + std::vector border_values; + std::vector border_options; + + if (!splash_data.background_images.empty() && + ParseImageBorder( + splash_data.image_border, &border_values, &border_options)) { + const std::string& background_image_path = + splash_data.background_images.front().first; + + background_image_ = elm_image_add(background_); + evas_object_image_file_set(background_image_, + (app_path + background_image_path).c_str(), + NULL); + elm_image_aspect_fixed_set(background_image_, 0); + evas_object_image_border_center_fill_set(background_image_, + EVAS_BORDER_FILL_DEFAULT); + + evas_object_resize(background_image_, bound.first, bound.second); + + int border_l, border_r, border_t, border_b; + switch (border_values.size()) { + case 1: + border_l = border_r = border_t = border_b = -border_values[0]; + break; + case 2: + border_t = border_b = border_values[0]; + border_l = border_r = border_values[1]; + break; + case 4: + border_t = border_values[0]; + border_r = border_values[1]; + border_b = border_values[2]; + border_l = border_values[3]; + break; + default: + border_l = border_r = border_t = border_b = 0; + } + evas_object_image_border_set(background_image_, + border_l, + border_r, + border_t, + border_b); + // TODO(a.szulakiewi): add scaling of horizontal and vertical borders + } + + evas_object_show(background_); + evas_object_show(background_image_); + evas_object_show(parent); +} + +void SplashScreen::SetImage( + const wgt::parse::LaunchScreenData& splash_data, Evas_Object* parent, + const SplashScreenBound& bound, const std::string& app_path) { + if (!background_) return; + image_ = elm_image_add(background_); + if (!image_) return; + + if (splash_data.images.empty()) return; + + const std::string& image_path = splash_data.images.front().first; + elm_image_file_set(image_, (app_path + image_path).c_str(), NULL); + evas_object_resize(image_, bound.first, bound.second); + evas_object_show(image_); + evas_object_show(parent); +} +} // namespace atom diff --git a/atom/browser/splash_screen.h b/atom/browser/splash_screen.h new file mode 100755 index 0000000..593ff06 --- /dev/null +++ b/atom/browser/splash_screen.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2015 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 XWALK_RUNTIME_BROWSER_SPLASH_SCREEN_H_ +#define XWALK_RUNTIME_BROWSER_SPLASH_SCREEN_H_ + +#include +#include +#include +#include +#include + +#include +#include "wgt_manifest_handlers/launch_screen_handler.h" + +enum HideReason { RENDERED, LOADFINISHED, CUSTOM }; + +namespace atom { + +enum class ScreenOrientation { + PORTRAIT_PRIMARY = 0, + PORTRAIT_SECONDARY = 1, + LANDSCAPE_PRIMARY = 2, + LANDSCAPE_SECONDARY = 3, + NATURAL = 4, + ANY = 5 +}; + +class SplashScreen { + public: + typedef std::pair SplashScreenBound; + + SplashScreen(Evas_Object* window, + std::shared_ptr ss_info, + const std::string& app_path); + void HideSplashScreen(int reason); + + private: + std::pair GetDimensions(Evas_Object* window); + void SetBackground(const wgt::parse::LaunchScreenData& splash_data, + Evas_Object* parent, const SplashScreenBound& bound, + const std::string& app_path); + + void SetImage(const wgt::parse::LaunchScreenData& splash_data, + Evas_Object* parent, const SplashScreenBound& bound, + const std::string& app_path); + + std::shared_ptr ss_info_; + Evas_Object* window_; + Evas_Object* image_; + Evas_Object* background_; + Evas_Object* background_image_; + bool is_active_; +}; +} // namespace atom +#endif // XWALK_RUNTIME_BROWSER_SPLASH_SCREEN_H_ diff --git a/wrt.gyp b/wrt.gyp index 54377cf..d8528b0 100644 --- a/wrt.gyp +++ b/wrt.gyp @@ -27,6 +27,8 @@ 'tizen/src/wrt_main.h', 'tizen/loader/prelauncher.h', 'tizen/loader/prelauncher.cc', + 'atom/browser/splash_screen.h', + 'atom/browser/splash_screen.cc', ], 'include_dirs': [ 'tizen/src', diff --git a/wrt/src/web_window.js b/wrt/src/web_window.js index 5258234..06b1f31 100644 --- a/wrt/src/web_window.js +++ b/wrt/src/web_window.js @@ -1,5 +1,5 @@ 'use strict'; -const {BrowserWindow, app} = require('electron'); +const {BrowserWindow, app, pwrt} = require('electron'); const IPC_MESSAGE = require('./ipc_message'); const WAS_EVENT = require('./was_event'); const events = require('./events'); @@ -121,6 +121,8 @@ class WebWindow { }); this.mainWindow.webContents.on('did-finish-load', function() { webwindow_debug('WebWindow : webContents did-finish-load'); + pwrt.hideSplashScreen(1); + if(!options.show){ webwindow_debug('WebWindow : browserWindow show options is ',options.show); self.show(); -- 2.7.4 From 45869969409a9fc62ee794439931e8fc33d38599 Mon Sep 17 00:00:00 2001 From: "surya.kumar7" Date: Tue, 15 May 2018 13:44:21 +0530 Subject: [PATCH 02/16] Set default encoding for WebContents as UTF-8 Currently, the default encoding being used is ISO-8859-1 which is a single-byte encoding and is capable of only supporting limited symbols. Change it to UTF-8(multi byte encoding) just like in crosswalk to extend support for more symbols Change-Id: I92e70445ca668c8db8c258e4ad1a6d41816dd2fb Signed-off-by: surya.kumar7 --- atom/browser/atom_browser_client.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index ebbd54a..9408fcf 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -54,6 +54,8 @@ bool g_suppress_renderer_process_restart = false; // Custom schemes to be registered to handle service worker. std::string g_custom_service_worker_schemes = ""; +const std::string kDefaultEncoding = "UTF-8"; + void Noop(scoped_refptr) { } @@ -161,6 +163,7 @@ void AtomBrowserClient::OverrideWebkitPrefs( prefs->allow_file_access_from_file_urls = true; prefs->experimental_webgl_enabled = true; prefs->allow_running_insecure_content = false; + prefs->default_encoding = kDefaultEncoding; // Custom preferences of guest page. auto web_contents = content::WebContents::FromRenderViewHost(host); -- 2.7.4 From 08923900ea8c54f7fd42a85ace2bff2fa7fa08fb Mon Sep 17 00:00:00 2001 From: deepti Date: Fri, 11 May 2018 16:39:46 +0530 Subject: [PATCH 03/16] Initial Implementation of AppControl Function Handled condition of resetting app. Implemented SendAppControlEvent() for execution of AppControlEventscript. Change-Id: I98b9420a6f5076de598dbdbbdd0968806fc1f34f Signed-off-by: deepti --- atom/browser/browser.cc | 51 ++++++++++++++++++++++++++++++++++++++++++--- atom/browser/browser.h | 1 + atom/browser/window_list.cc | 7 +++++++ atom/browser/window_list.h | 2 +- 4 files changed, 57 insertions(+), 4 deletions(-) diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index 3ebba72..9efce42 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -14,9 +14,12 @@ #include "base/files/file_util.h" #include "base/path_service.h" #include "base/run_loop.h" +#include "base/strings/string16.h" +#include "base/strings/utf_string_conversions.h" +#include "base/values.h" #include "base/threading/thread_task_runner_handle.h" #include "brightray/browser/brightray_paths.h" - +#include "content/public/browser/render_frame_host.h" #if defined(OS_TIZEN) #include "tizen/common/command_line.h" #include "tizen/common/application_data.h" @@ -43,6 +46,19 @@ Browser::~Browser() { WindowList::RemoveObserver(this); } +const char* kAppControlMain = "http://tizen.org/appcontrol/operation/main"; +const char* kAppControlEventScript = + "(function(){" + "var __event = document.createEvent(\"CustomEvent\");\n" + "__event.initCustomEvent(\"appcontrol\", true, true, null);\n" + "document.dispatchEvent(__event);\n" + "\n" + "for(var i=0; i < window.frames.length; i++)\n" + "{ window.frames[i].document.dispatchEvent(__event); }" + "})()"; +const char* kDefaultCSPRule = + "default-src *; script-src 'self'; style-src 'self'; object-src 'none';"; + // static Browser* Browser::Get() { if (AtomBrowserMainParts::Get()) @@ -276,14 +292,43 @@ void Browser::AppControl(std::unique_ptr appcontrol) { std::unique_ptr res = resource_manager_->GetStartResource(appcontrol.get()); bool do_reset = res->should_reset(); -//To do: Implementation of reset case according to parsed config file parameter. + NativeWindow *last_window= WindowList::GetLastWindow(); + std::string localized_page = res->uri(); + if(!do_reset) + { + std::string current_page=last_window->web_contents()->GetURL().spec(); + if (current_page != localized_page) { + do_reset = true; + } else { + SendAppControlEvent(); + } + } + if (do_reset && (appcontrol->operation() == kAppControlMain)) { + do_reset = false; + SendAppControlEvent(); + } + if (do_reset) { + //To do :Implementation of ClearViewStack(), SetupWebWindow(),SetupWebWindowCompatibilitySettings() function + } +} + +void Browser::SendAppControlEvent() { + std::vector WindowVector; + WindowVector=WindowList::GetWindows(); + NativeWindow *last_window= WindowList::GetLastWindow(); + if (WindowVector.size() > 0 && last_window != NULL) { + content::RenderFrameHost* rfh = last_window->web_contents()->GetMainFrame(); + if (rfh) { + rfh->ExecuteJavaScriptWithUserGestureForTests( + base::UTF8ToUTF16(kAppControlEventScript)); + } + } } void Browser::Launch(std::unique_ptr appcontrol) { launched_ = true; //To do:Implementation of relaunching of app } - #if defined(OS_TIZEN) void Browser::SetSplashScreen() { common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess(); diff --git a/atom/browser/browser.h b/atom/browser/browser.h index 362bfaf..c089fff 100644 --- a/atom/browser/browser.h +++ b/atom/browser/browser.h @@ -125,6 +125,7 @@ class Browser : public WindowListObserver { void Show(); void AppControl(std::unique_ptr appcontrol); void Launch(std::unique_ptr appcontrol); + void SendAppControlEvent(); #if defined(OS_TIZEN) void SetSplashScreen(); void HideSplashScreen(int reason); diff --git a/atom/browser/window_list.cc b/atom/browser/window_list.cc index 374389e..39b91b2 100644 --- a/atom/browser/window_list.cc +++ b/atom/browser/window_list.cc @@ -32,6 +32,13 @@ WindowList::WindowVector WindowList::GetWindows() { } // static +NativeWindow* WindowList::GetLastWindow() { + if (!IsEmpty()) + return GetInstance()->windows_.back(); + else return NULL; +} + +// static bool WindowList::IsEmpty() { return GetInstance()->windows_.empty(); } diff --git a/atom/browser/window_list.h b/atom/browser/window_list.h index e336c80..bffac13 100644 --- a/atom/browser/window_list.h +++ b/atom/browser/window_list.h @@ -22,7 +22,7 @@ class WindowList { static WindowVector GetWindows(); static bool IsEmpty(); - + static NativeWindow* GetLastWindow(); // Adds or removes |window| from the list it is associated with. static void AddWindow(NativeWindow* window); static void RemoveWindow(NativeWindow* window); -- 2.7.4 From 4739f2e776784e72a8eace33defb27e85f161b63 Mon Sep 17 00:00:00 2001 From: "surya.kumar7" Date: Mon, 7 May 2018 17:06:57 +0530 Subject: [PATCH 04/16] Add preload manager and invoke preloadable objects in prelaunch phase Preloading the below engine independent components is giving ~50ms improvement in app launch: xwalk extension server AtomContentClient AtomBrowserClient Change-Id: Iee9bc108aeed0414962b301345c799807dfd043d Signed-off-by: surya.kumar7 --- atom/app/atom_main_delegate.cc | 20 +++++++++++++++-- atom/app/atom_main_delegate.h | 2 ++ atom/app/ui_runtime.cc | 2 ++ atom/browser/atom_browser_main_parts.cc | 9 ++++---- filenames.gypi | 2 ++ tizen/browser/preload_manager.cc | 40 +++++++++++++++++++++++++++++++++ tizen/browser/preload_manager.h | 35 +++++++++++++++++++++++++++++ tizen/src/wrt_main.cc | 2 ++ 8 files changed, 106 insertions(+), 6 deletions(-) create mode 100644 tizen/browser/preload_manager.cc create mode 100644 tizen/browser/preload_manager.h diff --git a/atom/app/atom_main_delegate.cc b/atom/app/atom_main_delegate.cc index 32e6ecf..b88049f 100644 --- a/atom/app/atom_main_delegate.cc +++ b/atom/app/atom_main_delegate.cc @@ -48,8 +48,13 @@ void InvalidParameterHandler(const wchar_t*, const wchar_t*, const wchar_t*, } #endif +bool g_prelaunch_ = false; +std::unique_ptr g_atom_content_client_; +std::unique_ptr g_atom_browser_client_; + } // namespace + AtomMainDelegate::AtomMainDelegate() { } @@ -162,7 +167,9 @@ void AtomMainDelegate::PreSandboxStartup() { } content::ContentBrowserClient* AtomMainDelegate::CreateContentBrowserClient() { - browser_client_.reset(new AtomBrowserClient); + if (!g_prelaunch_) + browser_client_.reset(new AtomBrowserClient); + else browser_client_.reset(g_atom_browser_client_.release()); return browser_client_.get(); } @@ -205,7 +212,16 @@ bool AtomMainDelegate::DelaySandboxInitialization( std::unique_ptr AtomMainDelegate::CreateContentClient() { - return std::unique_ptr(new AtomContentClient); + if (!g_prelaunch_) + return std::unique_ptr(new AtomContentClient); + else return std::unique_ptr(g_atom_content_client_.release()); +} + +// static +void AtomMainDelegate::Preload() { + g_atom_content_client_.reset(new AtomContentClient); + g_atom_browser_client_.reset(new AtomBrowserClient); + g_prelaunch_ = true; } } // namespace atom diff --git a/atom/app/atom_main_delegate.h b/atom/app/atom_main_delegate.h index 64207ae..d768ddf 100644 --- a/atom/app/atom_main_delegate.h +++ b/atom/app/atom_main_delegate.h @@ -17,6 +17,8 @@ class AtomMainDelegate : public brightray::MainDelegate { AtomMainDelegate(); ~AtomMainDelegate(); + static void Preload(); + protected: // content::ContentMainDelegate: bool BasicStartupComplete(int* exit_code) override; diff --git a/atom/app/ui_runtime.cc b/atom/app/ui_runtime.cc index e13e1bf..27f7e0e 100644 --- a/atom/app/ui_runtime.cc +++ b/atom/app/ui_runtime.cc @@ -39,6 +39,8 @@ 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(); } diff --git a/atom/browser/atom_browser_main_parts.cc b/atom/browser/atom_browser_main_parts.cc index f718f86..3ea0c3e 100644 --- a/atom/browser/atom_browser_main_parts.cc +++ b/atom/browser/atom_browser_main_parts.cc @@ -61,11 +61,8 @@ void Erase(T* container, typename T::iterator iter) { container->erase(iter); } -} // namespace - -// static +// static - lines have been moved to limit their visibility only to this file bool g_prelaunch = false; -AtomBrowserMainParts* AtomBrowserMainParts::self_ = nullptr; node::Environment* env_ = nullptr; scoped_refptr self_bridge_task_runner; std::unique_ptr self_browser; @@ -75,6 +72,10 @@ std::unique_ptr self_atom_bindings; std::unique_ptr self_node_env; std::unique_ptr self_node_debugger; +} // namespace + +AtomBrowserMainParts* AtomBrowserMainParts::self_ = nullptr; + AtomBrowserMainParts::AtomBrowserMainParts() : fake_browser_process_(new BrowserProcess), exit_code_(nullptr), diff --git a/filenames.gypi b/filenames.gypi index 8408b27..0535fab 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -636,6 +636,8 @@ 'chromium_src/net/test/embedded_test_server/stream_listen_socket.h', 'chromium_src/net/test/embedded_test_server/tcp_listen_socket.cc', 'chromium_src/net/test/embedded_test_server/tcp_listen_socket.h', + 'tizen/browser/preload_manager.cc', + 'tizen/browser/preload_manager.h', '<@(native_mate_files)', '<(SHARED_INTERMEDIATE_DIR)/atom_natives.h', '<(SHARED_INTERMEDIATE_DIR)/grit/pdf_viewer_resources_map.cc', diff --git a/tizen/browser/preload_manager.cc b/tizen/browser/preload_manager.cc new file mode 100644 index 0000000..18c645d --- /dev/null +++ b/tizen/browser/preload_manager.cc @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2015 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 "tizen/browser/preload_manager.h" + +#include "atom/app/atom_main_delegate.h" +#include "extensions/common/xwalk_extension_server.h" + +namespace tizen { + +PreloadManager* PreloadManager::GetInstance() { + static PreloadManager instance; + return &instance; +} + +PreloadManager::PreloadManager() { +} + +void PreloadManager::CreateCacheComponent() { + // Load extensions in the preload step + auto extension_server = extensions::XWalkExtensionServer::GetInstance(); + extension_server->Preload(); + + atom::AtomMainDelegate::Preload(); +} + +} // namespace tizen diff --git a/tizen/browser/preload_manager.h b/tizen/browser/preload_manager.h new file mode 100644 index 0000000..4f06612 --- /dev/null +++ b/tizen/browser/preload_manager.h @@ -0,0 +1,35 @@ +/* + * 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 TIZEN_BROWSER_PRELOAD_MANAGER_H_ +#define TIZEN_BROWSER_PRELOAD_MANAGER_H_ + +#include + + +namespace tizen { +class PreloadManager { + public: + static PreloadManager* GetInstance(); + void CreateCacheComponent(); + + private: + PreloadManager(); +}; + +} // namespace tizen + +#endif // TIZEN_BROWSER_PRELOAD_MANAGER_H_ diff --git a/tizen/src/wrt_main.cc b/tizen/src/wrt_main.cc index 0bf3635..8c8052b 100644 --- a/tizen/src/wrt_main.cc +++ b/tizen/src/wrt_main.cc @@ -44,6 +44,7 @@ #include "tizen/common/application_data.h" #include "tizen/common/command_line.h" #include "tizen/loader/prelauncher.h" +#include "tizen/browser/preload_manager.h" #endif namespace { @@ -236,6 +237,7 @@ int main(int argc, const char* argv[]) { params.argv = const_cast(argv); atom::AtomCommandLine::Init(argc, argv); runtime_ = runtime::Runtime::MakeRuntime(nullptr); + tizen::PreloadManager::GetInstance()->CreateCacheComponent(); return 0; }; auto did_launch = [](const std::string& app_path) { -- 2.7.4 From 1ab663ee093e7a138f14727859f8bc46fad21cd0 Mon Sep 17 00:00:00 2001 From: deepti Date: Wed, 23 May 2018 10:54:04 +0530 Subject: [PATCH 05/16] Refactored code by removing extra check for vector size in SendAppControlEvent function. Removed extra header files and made proper indent. Change-Id: I21281e5009e9c5c3ed7d404f9a0ced7a4c273a7b Signed-off-by: deepti --- atom/browser/browser.cc | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index 9efce42..7e87db2 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -14,9 +14,7 @@ #include "base/files/file_util.h" #include "base/path_service.h" #include "base/run_loop.h" -#include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" -#include "base/values.h" #include "base/threading/thread_task_runner_handle.h" #include "brightray/browser/brightray_paths.h" #include "content/public/browser/render_frame_host.h" @@ -292,37 +290,33 @@ void Browser::AppControl(std::unique_ptr appcontrol) { std::unique_ptr res = resource_manager_->GetStartResource(appcontrol.get()); bool do_reset = res->should_reset(); - NativeWindow *last_window= WindowList::GetLastWindow(); + NativeWindow *last_window = WindowList::GetLastWindow(); std::string localized_page = res->uri(); - if(!do_reset) - { - std::string current_page=last_window->web_contents()->GetURL().spec(); - if (current_page != localized_page) { - do_reset = true; - } else { - SendAppControlEvent(); - } - } + if (!do_reset) { + std::string current_page = last_window->web_contents()->GetURL().spec(); + if (current_page != localized_page) + do_reset = true; + else + SendAppControlEvent(); + } if (do_reset && (appcontrol->operation() == kAppControlMain)) { do_reset = false; SendAppControlEvent(); } - if (do_reset) { - //To do :Implementation of ClearViewStack(), SetupWebWindow(),SetupWebWindowCompatibilitySettings() function - } + if (do_reset) + //To do :Implementation of ClearViewStack(), SetupWebWindow(),SetupWebWindowCompatibilitySettings() function } void Browser::SendAppControlEvent() { - std::vector WindowVector; - WindowVector=WindowList::GetWindows(); - NativeWindow *last_window= WindowList::GetLastWindow(); - if (WindowVector.size() > 0 && last_window != NULL) { - content::RenderFrameHost* rfh = last_window->web_contents()->GetMainFrame(); - if (rfh) { + NativeWindow *last_window = WindowList::GetLastWindow(); + + if (last_window != NULL) { + content::RenderFrameHost* rfh = last_window->web_contents()->GetMainFrame(); + if (rfh) { rfh->ExecuteJavaScriptWithUserGestureForTests( - base::UTF8ToUTF16(kAppControlEventScript)); + base::UTF8ToUTF16(kAppControlEventScript)); } - } + } } void Browser::Launch(std::unique_ptr appcontrol) { -- 2.7.4 From cf48ec941673a8449feac35a2c93075e8317f2c5 Mon Sep 17 00:00:00 2001 From: deepti Date: Mon, 4 Jun 2018 12:56:11 +0530 Subject: [PATCH 06/16] fixup! Refactored code by removing extra check for vector size in SendAppControlEvent function. Removed extra header files and made proper indent. The original patch has build error and this fixes the same. Change-Id: I912029c37dd5085a2dd2792c3ac22485ab58bc19 Signed-off-by: deepti --- atom/browser/browser.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index 7e87db2..fc2c7a4 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -303,8 +303,9 @@ void Browser::AppControl(std::unique_ptr appcontrol) { do_reset = false; SendAppControlEvent(); } - if (do_reset) + if (do_reset) { //To do :Implementation of ClearViewStack(), SetupWebWindow(),SetupWebWindowCompatibilitySettings() function + } } void Browser::SendAppControlEvent() { -- 2.7.4 From 63823db6a5a7f0630479bb7b9c2d3b181ed74e3e Mon Sep 17 00:00:00 2001 From: "k2.nagaraju" Date: Fri, 11 May 2018 15:29:28 +0530 Subject: [PATCH 07/16] Expose the visibility of classes of chromium for web device api. removed duplicate code from WRT Change-Id: I41ddadd07ef4cdf961a4a470ae311351235b9028 Signed-off-by: k2.nagaraju --- atom/browser/api/atom_api_web_contents.cc | 18 +-- atom/browser/api/atom_api_web_contents.h | 8 +- atom/common/api/api_messages.h | 23 +-- atom/renderer/atom_renderer_client.cc | 18 +-- atom/renderer/atom_renderer_client.h | 2 +- packaging/electron-efl.spec | 3 - tizen/common/common.gyp | 2 - tizen/common/wrt_message_data.cc | 38 ----- tizen/common/wrt_message_data.h | 26 ---- tizen/extensions/common/xwalk_extension_server.cc | 51 +++---- tizen/extensions/common/xwalk_extension_server.h | 17 ++- tizen/extensions/extensions.gyp | 2 + tizen/extensions/renderer/runtime_ipc_client.cc | 54 +++---- tizen/extensions/renderer/runtime_ipc_client.h | 5 +- .../xwalk_extension_renderer_controller.cc | 8 +- .../renderer/xwalk_extension_renderer_controller.h | 5 +- tizen/renderer/injected_bundle.cc | 5 +- tizen/wrt/chromium_wrt.gyp | 55 ------- tizen/wrt/dynamicplugin.cc | 89 ----------- tizen/wrt/dynamicplugin.h | 46 ------ tizen/wrt/v8widget.cc | 92 ------------ tizen/wrt/v8widget.h | 41 ------ tizen/wrt/wrt_dynamicplugin.cc | 164 --------------------- tizen/wrt/wrt_dynamicplugin.h | 71 --------- tizen/wrt/wrt_file_protocol_handler.cc | 110 -------------- tizen/wrt/wrt_file_protocol_handler.h | 46 ------ tizen/wrt/wrt_widget_host.cc | 164 --------------------- tizen/wrt/wrt_widget_host.h | 89 ----------- tizen/wrt/wrtwidget.cc | 97 ------------ tizen/wrt/wrtwidget.h | 45 ------ .../ewk/efl_integration/private/ewk_wrt_private.h | 2 +- .../ewk/efl_integration/wrt/wrt_widget_host.h | 2 +- .../tizen_src/ewk/efl_integration/wrt/wrtwidget.h | 2 +- wrt.gyp | 2 +- 34 files changed, 104 insertions(+), 1298 deletions(-) delete mode 100644 tizen/common/wrt_message_data.cc delete mode 100644 tizen/common/wrt_message_data.h delete mode 100644 tizen/wrt/chromium_wrt.gyp delete mode 100644 tizen/wrt/dynamicplugin.cc delete mode 100644 tizen/wrt/dynamicplugin.h delete mode 100644 tizen/wrt/v8widget.cc delete mode 100644 tizen/wrt/v8widget.h delete mode 100644 tizen/wrt/wrt_dynamicplugin.cc delete mode 100644 tizen/wrt/wrt_dynamicplugin.h delete mode 100644 tizen/wrt/wrt_file_protocol_handler.cc delete mode 100644 tizen/wrt/wrt_file_protocol_handler.h delete mode 100644 tizen/wrt/wrt_widget_host.cc delete mode 100644 tizen/wrt/wrt_widget_host.h delete mode 100644 tizen/wrt/wrtwidget.cc delete mode 100644 tizen/wrt/wrtwidget.h diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 8474a5b..cac60af 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -903,21 +903,21 @@ void WebContents::DevToolsClosed() { Emit("devtools-closed"); } -void WebContents::OnWrtPluginMessage(const Wrt_Message_Data& data) { - Wrt_Message_Data tmp = data; +void WebContents::OnWrtPluginMessage(const Ewk_Wrt_Message_Data& data) { + Ewk_Wrt_Message_Data tmp = data; HandleWrtPluginMessage(&tmp); } -void WebContents::OnWrtPluginSyncMessage(const Wrt_Message_Data& data, +void WebContents::OnWrtPluginSyncMessage(const Ewk_Wrt_Message_Data& data, IPC::Message* reply) { - Wrt_Message_Data tmp = data; + Ewk_Wrt_Message_Data tmp = data; HandleWrtPluginMessage(&tmp); - EwkHostMsg_WrtSyncMessage::WriteReplyParams(reply, tmp.value); + AtomHostMsg_WrtSyncMessage::WriteReplyParams(reply, tmp.value); Send(reply); } -void WebContents::HandleWrtPluginMessage(Wrt_Message_Data* msg) { - Eina_Stringshare* msg_type = msg->GetType(); +void WebContents::HandleWrtPluginMessage(Ewk_Wrt_Message_Data* msg) { + Eina_Stringshare* msg_type = ewk_ipc_wrt_message_data_type_get(msg); #define TYPE_BEGIN(x) (!strncmp(msg_type, x, strlen(x))) #define TYPE_IS(x) (!strcmp(msg_type, x)) @@ -940,8 +940,8 @@ bool WebContents::OnMessageReceived(const IPC::Message& message) { OnSetTemporaryZoomLevel) IPC_MESSAGE_HANDLER_DELAY_REPLY(AtomViewHostMsg_GetZoomLevel, OnGetZoomLevel) - IPC_MESSAGE_HANDLER(EwkHostMsg_WrtMessage, OnWrtPluginMessage) - IPC_MESSAGE_HANDLER_DELAY_REPLY(EwkHostMsg_WrtSyncMessage, OnWrtPluginSyncMessage) + IPC_MESSAGE_HANDLER(AtomHostMsg_WrtMessage, OnWrtPluginMessage) + IPC_MESSAGE_HANDLER_DELAY_REPLY(AtomHostMsg_WrtSyncMessage, OnWrtPluginSyncMessage) // FIXME: Disable OnCursorChange due to stach_chk_fail crash. // IPC_MESSAGE_HANDLER_CODE(ViewHostMsg_SetCursor, OnCursorChange, // handled = false) diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 4407b3c..ef1578c 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -18,7 +18,7 @@ #include "content/public/browser/web_contents_observer.h" #include "content/public/common/favicon_url.h" #include "native_mate/handle.h" -#include "tizen/common/wrt_message_data.h" +#include "tizen_src/ewk/efl_integration/private/ewk_wrt_private.h" #include "ui/gfx/image/image.h" namespace blink { @@ -218,10 +218,10 @@ class WebContents : public mate::TrackableObject, v8::Local Debugger(v8::Isolate* isolate); WebContentsZoomController* GetZoomController() { return zoom_controller_; } - void OnWrtPluginMessage(const Wrt_Message_Data& data); - void OnWrtPluginSyncMessage(const Wrt_Message_Data& data, + void OnWrtPluginMessage(const Ewk_Wrt_Message_Data& data); + void OnWrtPluginSyncMessage(const Ewk_Wrt_Message_Data& data, IPC::Message* reply); - void HandleWrtPluginMessage(Wrt_Message_Data* msg); + void HandleWrtPluginMessage(Ewk_Wrt_Message_Data* msg); protected: WebContents(v8::Isolate* isolate, content::WebContents* web_contents, diff --git a/atom/common/api/api_messages.h b/atom/common/api/api_messages.h index cffc9df..5052c40 100644 --- a/atom/common/api/api_messages.h +++ b/atom/common/api/api_messages.h @@ -9,7 +9,7 @@ #include "base/values.h" #include "content/public/common/common_param_traits.h" #include "ipc/ipc_message_macros.h" -#include "tizen/common/wrt_message_data.h" +#include "tizen_src/ewk/efl_integration/private/ewk_wrt_private.h" #include "ui/gfx/ipc/gfx_param_traits.h" // The message starter should be declared in ipc/ipc_message_start.h. Since @@ -22,7 +22,7 @@ IPC_STRUCT_TRAITS_BEGIN(atom::DraggableRegion) IPC_STRUCT_TRAITS_MEMBER(bounds) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(Wrt_Message_Data) +IPC_STRUCT_TRAITS_BEGIN(Ewk_Wrt_Message_Data) IPC_STRUCT_TRAITS_MEMBER(type) IPC_STRUCT_TRAITS_MEMBER(value) IPC_STRUCT_TRAITS_MEMBER(id) @@ -58,20 +58,9 @@ IPC_SYNC_MESSAGE_ROUTED1_1(AtomViewHostMsg_SetTemporaryZoomLevel, // Sent by renderer to get the zoom level. IPC_SYNC_MESSAGE_ROUTED0_1(AtomViewHostMsg_GetZoomLevel, double /* result */) -IPC_MESSAGE_ROUTED1(EwkHostMsg_WrtMessage, - Wrt_Message_Data /* data */) +IPC_MESSAGE_ROUTED1(AtomHostMsg_WrtMessage, + Ewk_Wrt_Message_Data /* data */) -IPC_MESSAGE_CONTROL1(WrtMsg_SendWrtMessage, - Wrt_Message_Data /* data */) - -IPC_MESSAGE_CONTROL2(WrtMsg_ParseUrl, - int, // result: request_id - GURL) // result: url - -IPC_MESSAGE_CONTROL2(WrtMsg_ParseUrlResponse, - int, // result: request_id - GURL) // result: url - -IPC_SYNC_MESSAGE_ROUTED1_1(EwkHostMsg_WrtSyncMessage, - Wrt_Message_Data /* data */, +IPC_SYNC_MESSAGE_ROUTED1_1(AtomHostMsg_WrtSyncMessage, + Ewk_Wrt_Message_Data /* data */, std::string /*result*/) diff --git a/atom/renderer/atom_renderer_client.cc b/atom/renderer/atom_renderer_client.cc index 77b5eb0..aa3b881 100644 --- a/atom/renderer/atom_renderer_client.cc +++ b/atom/renderer/atom_renderer_client.cc @@ -13,6 +13,7 @@ #include "content/common/wrt/wrt_url_parse.h" #include "content/public/renderer/render_thread.h" #include "content/public/renderer/render_view.h" +#include "tizen_src/ewk/efl_integration/wrt/wrtwidget.h" #include "third_party/WebKit/public/web/WebView.h" #endif #include "atom_natives.h" // NOLINT: This file is generated with js2c @@ -58,22 +59,6 @@ const char** StringVectorToArgArray( } // namespace -class WrtUrlParseImpl : public content::WrtUrlParseBase { - public: - WrtUrlParseImpl(WrtWidget* wrt_widget) : wrt_widget_(wrt_widget) {} - GURL parseUrl(const GURL& old_url) const override { - if (!wrt_widget_->IsWidgetInfoSet()) - return old_url; - GURL new_url; - bool is_decrypted_file = false; - wrt_widget_->ParseUrl(old_url, new_url, is_decrypted_file); - return new_url; - } - - private: - WrtWidget* wrt_widget_; -}; - AtomRendererClient::AtomRendererClient() : node_integration_initialized_(false), node_bindings_(NodeBindings::Create(NodeBindings::RENDERER)), @@ -105,7 +90,6 @@ void AtomRendererClient::RenderThreadStarted() { widget_.reset(wrt_widget); content::RenderThread* thread = content::RenderThread::Get(); thread->AddObserver(wrt_widget->GetObserver()); - wrt_url_parser_.reset(new WrtUrlParseImpl(wrt_widget)); std::string theme = command_line->GetSwitchValueASCII("widget-theme"); std::string encoded_bundle = command_line->GetSwitchValueASCII("widget-encoded-bundle"); std::string scale = command_line->GetSwitchValueASCII("widget-scale"); diff --git a/atom/renderer/atom_renderer_client.h b/atom/renderer/atom_renderer_client.h index 0e623b5..2818ecc 100644 --- a/atom/renderer/atom_renderer_client.h +++ b/atom/renderer/atom_renderer_client.h @@ -9,7 +9,7 @@ #include #include "atom/renderer/renderer_client_base.h" -#include "tizen/wrt/wrtwidget.h" +#include "tizen_src/ewk/efl_integration/wrt/wrtwidget.h" namespace atom { diff --git a/packaging/electron-efl.spec b/packaging/electron-efl.spec index bafe82b..7e464c1 100755 --- a/packaging/electron-efl.spec +++ b/packaging/electron-efl.spec @@ -140,8 +140,6 @@ mkdir -p %{buildroot}%{extension_path} install -p -m 644 %{_out}/lib/libxwalk_extension_shared.so %{buildroot}%{_libdir} # xwalk_injected_bundle install -p -m 755 %{_out}/lib/libxwalk_injected_bundle.so %{buildroot}%{_libdir} -# wrt chromium shared -install -p -m 644 %{_out}/lib/libchromium_wrt_shared.so %{buildroot}%{_libdir} %post # Owner account can't write /opt/usr/home/owner/data/org.tizen.electron-efl # which is created in 'install'. So we should copy resources in 'post'. @@ -174,4 +172,3 @@ rm -fr %{buildroot} %attr(644,root,root) %{_libdir}/libwrt_common.so %attr(644,root,root) %{_libdir}/libxwalk_extension_shared.so %attr(644,root,root) %{_libdir}/libxwalk_injected_bundle.so -%attr(644,root,root) %{_libdir}/libchromium_wrt_shared.so diff --git a/tizen/common/common.gyp b/tizen/common/common.gyp index be5a8ec..7706dd2 100644 --- a/tizen/common/common.gyp +++ b/tizen/common/common.gyp @@ -34,8 +34,6 @@ 'resource_manager.cc', 'platform_info.h', 'platform_info.cc', - 'wrt_message_data.h', - 'wrt_message_data.cc', ], 'cflags': [ '-fvisibility=default', diff --git a/tizen/common/wrt_message_data.cc b/tizen/common/wrt_message_data.cc deleted file mode 100644 index 7b60902..0000000 --- a/tizen/common/wrt_message_data.cc +++ /dev/null @@ -1,38 +0,0 @@ -#include "wrt_message_data.h" - -Wrt_Message_Data::Wrt_Message_Data() {} - -Wrt_Message_Data::~Wrt_Message_Data() {} - -Eina_Stringshare* Wrt_Message_Data::GetType() const { - return eina_stringshare_add(type.c_str()); -} - -void Wrt_Message_Data::SetType(const char* val) { - type = val; -} - -Eina_Stringshare* Wrt_Message_Data::GetValue() const { - return eina_stringshare_add(value.c_str()); -} - -void Wrt_Message_Data::SetValue(const char* val) { - value = val; -} - -Eina_Stringshare* Wrt_Message_Data::GetId() const { - return eina_stringshare_add(id.c_str()); -} - -void Wrt_Message_Data::SetId(const char* val) { - id = val; -} - -Eina_Stringshare* Wrt_Message_Data::GetReferenceId() const { - return eina_stringshare_add(reference_id.c_str()); -} - -void Wrt_Message_Data::SetReferenceId(const char* val) { - reference_id = val; -} - diff --git a/tizen/common/wrt_message_data.h b/tizen/common/wrt_message_data.h deleted file mode 100644 index 81e7213..0000000 --- a/tizen/common/wrt_message_data.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef WRT_MESSAGE_DATA_H -#define WRT_MESSAGE_DATA_H - -#include -#include - -struct Wrt_Message_Data { - std::string type; - std::string value; - std::string id; - std::string reference_id; - - Wrt_Message_Data(); - ~Wrt_Message_Data(); - const Eina_Stringshare* GetType() const; - void SetType(const char* val); - const Eina_Stringshare* GetValue() const; - void SetValue(const char* val); - const Eina_Stringshare* GetId() const; - void SetId(const char* val); - const Eina_Stringshare* GetReferenceId() const; - void SetReferenceId(const char* val); -}; - -#endif // WRT_MESSAGE_DATA_H - diff --git a/tizen/extensions/common/xwalk_extension_server.cc b/tizen/extensions/common/xwalk_extension_server.cc index 3cf0acd..06c45e0 100644 --- a/tizen/extensions/common/xwalk_extension_server.cc +++ b/tizen/extensions/common/xwalk_extension_server.cc @@ -15,7 +15,7 @@ #include "content/public/browser/render_process_host.h" #include "extensions/common/constants.h" #include "extensions/common/xwalk_extension_manager.h" -#include "wrt/wrt_widget_host.h" +#include "tizen_src/ewk/efl_integration/wrt/wrt_widget_host.h" namespace extensions { @@ -83,12 +83,12 @@ std::string XWalkExtensionServer::CreateInstance( instance_id = common::utils::GenerateUUID(); instance->SetPostMessageCallback( [this, instance_id](const std::string& msg) { - Wrt_Message_Data* ans = new Wrt_Message_Data(); - ans->SetType(kMethodPostMessageToJS); - ans->SetId(instance_id.c_str()); - ans->SetValue(msg.c_str()); + Ewk_IPC_Wrt_Message_Data* ans = ewk_ipc_wrt_message_data_new(); + ewk_ipc_wrt_message_data_type_set(ans, kMethodPostMessageToJS); + ewk_ipc_wrt_message_data_id_set(ans, instance_id.c_str()); + ewk_ipc_wrt_message_data_value_set(ans, msg.c_str()); WrtWidgetHost::Get()->SendWrtMessage(*ans); - delete ans; + ewk_ipc_wrt_message_data_del(ans); }); instances_[instance_id] = instance; @@ -103,12 +103,13 @@ std::string XWalkExtensionServer::CreateInstance( return instance_id; } -void XWalkExtensionServer::HandleIPCMessage(Wrt_Message_Data* data) { +void XWalkExtensionServer::HandleIPCMessage(Ewk_IPC_Wrt_Message_Data* data) { if (!data) { LOGGER(ERROR) << "Invalid parameter. data is NULL."; return; } - Eina_Stringshare* msg_type = data->GetType(); + + Eina_Stringshare* msg_type = ewk_ipc_wrt_message_data_type_get(data); #define TYPE_IS(x) (!strcmp(msg_type, x)) if (TYPE_IS(kMethodGetExtensions)) { @@ -129,27 +130,27 @@ void XWalkExtensionServer::HandleIPCMessage(Wrt_Message_Data* data) { #undef TYPE_IS } -void XWalkExtensionServer::HandleGetExtensions(Wrt_Message_Data* data) { +void XWalkExtensionServer::HandleGetExtensions(Ewk_IPC_Wrt_Message_Data* data) { Json::Value reply = GetExtensions(); Json::FastWriter writer; std::string reply_str = writer.write(reply); - data->SetValue(reply_str.c_str()); + ewk_ipc_wrt_message_data_value_set(data, reply_str.c_str()); } void XWalkExtensionServer::HandleCreateInstance( - Wrt_Message_Data* data) { - Eina_Stringshare* extension_name = data->GetValue(); + Ewk_IPC_Wrt_Message_Data* data) { + Eina_Stringshare* extension_name = ewk_ipc_wrt_message_data_value_get(data); std::string instance_id = CreateInstance(extension_name); - data->SetValue(instance_id.c_str()); + ewk_ipc_wrt_message_data_value_set(data, instance_id.c_str()); eina_stringshare_del(extension_name); } void XWalkExtensionServer::HandleDestroyInstance( - Wrt_Message_Data* data) { - Eina_Stringshare* instance_id = data->GetId(); + Ewk_IPC_Wrt_Message_Data* data) { + Eina_Stringshare* instance_id = ewk_ipc_wrt_message_data_id_get(data); auto it = instances_.find(instance_id); if (it != instances_.end()) { @@ -164,12 +165,12 @@ void XWalkExtensionServer::HandleDestroyInstance( } void XWalkExtensionServer::HandlePostMessageToNative( - Wrt_Message_Data* data) { - Eina_Stringshare* instance_id = data->GetId(); + Ewk_IPC_Wrt_Message_Data* data) { + Eina_Stringshare* instance_id = ewk_ipc_wrt_message_data_id_get(data); auto it = instances_.find(instance_id); if (it != instances_.end()) { - Eina_Stringshare* msg = data->GetValue(); + Eina_Stringshare* msg = ewk_ipc_wrt_message_data_value_get(data); XWalkExtensionInstance* instance = it->second; instance->HandleMessage(msg); eina_stringshare_del(msg); @@ -181,19 +182,19 @@ void XWalkExtensionServer::HandlePostMessageToNative( } void XWalkExtensionServer::HandleSendSyncMessageToNative( - Wrt_Message_Data* data) { - Eina_Stringshare* instance_id = data->GetId(); + Ewk_IPC_Wrt_Message_Data* data) { + Eina_Stringshare* instance_id = ewk_ipc_wrt_message_data_id_get(data); auto it = instances_.find(instance_id); if (it != instances_.end()) { - Eina_Stringshare* msg = data->GetValue(); + Eina_Stringshare* msg = ewk_ipc_wrt_message_data_value_get(data); XWalkExtensionInstance* instance = it->second; std::string reply; instance->SetSendSyncReplyCallback([&reply](const std::string& msg) { reply = msg; }); instance->HandleSyncMessage(msg); - data->SetValue(reply.c_str()); + ewk_ipc_wrt_message_data_value_set(data, reply.c_str()); eina_stringshare_del(msg); } else { LOGGER(ERROR) << "No such instance '" << instance_id << "'"; @@ -203,12 +204,12 @@ void XWalkExtensionServer::HandleSendSyncMessageToNative( } void XWalkExtensionServer::HandleGetAPIScript( - Wrt_Message_Data* data) { - Eina_Stringshare* extension_name = data->GetValue(); + Ewk_IPC_Wrt_Message_Data* data) { + Eina_Stringshare* extension_name = ewk_ipc_wrt_message_data_value_get(data); std::string api = GetAPIScript(extension_name); - data->SetValue(api.c_str()); + ewk_ipc_wrt_message_data_value_set(data, api.c_str()); eina_stringshare_del(extension_name); } diff --git a/tizen/extensions/common/xwalk_extension_server.h b/tizen/extensions/common/xwalk_extension_server.h index 7a45752..a778a5b 100644 --- a/tizen/extensions/common/xwalk_extension_server.h +++ b/tizen/extensions/common/xwalk_extension_server.h @@ -5,11 +5,12 @@ #ifndef XWALK_EXTENSIONS_XWALK_EXTENSION_SERVER_H_ #define XWALK_EXTENSIONS_XWALK_EXTENSION_SERVER_H_ +#include +#include #include #include #include -#include "common/wrt_message_data.h" #include "extensions/common/xwalk_extension_manager.h" #include "extensions/common/xwalk_extension_instance.h" @@ -24,7 +25,7 @@ class XWalkExtensionServer { std::string GetAPIScript(const std::string& extension_name); std::string CreateInstance(const std::string& extension_name); - void HandleIPCMessage(Wrt_Message_Data* data); + void HandleIPCMessage(Ewk_IPC_Wrt_Message_Data* data); void Shutdown(); void LoadUserExtensions(const std::string app_path); @@ -33,12 +34,12 @@ class XWalkExtensionServer { XWalkExtensionServer(); virtual ~XWalkExtensionServer(); - void HandleGetExtensions(Wrt_Message_Data* data); - void HandleCreateInstance(Wrt_Message_Data* data); - void HandleDestroyInstance(Wrt_Message_Data* data); - void HandlePostMessageToNative(Wrt_Message_Data* data); - void HandleSendSyncMessageToNative(Wrt_Message_Data* data); - void HandleGetAPIScript(Wrt_Message_Data* data); + void HandleGetExtensions(Ewk_IPC_Wrt_Message_Data* data); + void HandleCreateInstance(Ewk_IPC_Wrt_Message_Data* data); + void HandleDestroyInstance(Ewk_IPC_Wrt_Message_Data* data); + void HandlePostMessageToNative(Ewk_IPC_Wrt_Message_Data* data); + void HandleSendSyncMessageToNative(Ewk_IPC_Wrt_Message_Data* data); + void HandleGetAPIScript(Ewk_IPC_Wrt_Message_Data* data); typedef std::map InstanceMap; diff --git a/tizen/extensions/extensions.gyp b/tizen/extensions/extensions.gyp index 163361d..652dfd1 100644 --- a/tizen/extensions/extensions.gyp +++ b/tizen/extensions/extensions.gyp @@ -49,6 +49,8 @@ '.', '../..', '<(libchromiumcontent_src_dir)', + '<(libchromiumcontent_src_dir)/tizen_src/ewk/efl_integration', + '<(libchromiumcontent_src_dir)/tizen_src/chromium_impl', '<(SHARED_INTERMEDIATE_DIR)', '<(libchromiumcontent_src_dir)/gen', '<(libchromiumcontent_src_dir)/third_party/skia/include/config', diff --git a/tizen/extensions/renderer/runtime_ipc_client.cc b/tizen/extensions/renderer/runtime_ipc_client.cc index f64676b..036dc7f 100644 --- a/tizen/extensions/renderer/runtime_ipc_client.cc +++ b/tizen/extensions/renderer/runtime_ipc_client.cc @@ -115,16 +115,16 @@ void RuntimeIPCClient::SendMessage(v8::Handle context, return; } - Wrt_Message_Data* msg = new Wrt_Message_Data(); - msg->SetType(type.c_str()); - msg->SetId(id.c_str()); - msg->SetValue(value.c_str()); - msg->SetReferenceId(ref_id.c_str()); + Ewk_IPC_Wrt_Message_Data* msg = ewk_ipc_wrt_message_data_new(); + ewk_ipc_wrt_message_data_type_set(msg, type.c_str()); + ewk_ipc_wrt_message_data_id_set(msg, id.c_str()); + ewk_ipc_wrt_message_data_reference_id_set(msg, ref_id.c_str()); + ewk_ipc_wrt_message_data_value_set(msg, value.c_str()); content::RenderView* render_view = content::RenderView::FromRoutingID(routing_id); render_view->Send( - new EwkHostMsg_WrtMessage(render_view->GetRoutingID(), *msg)); - delete msg; + new AtomHostMsg_WrtMessage(render_view->GetRoutingID(), *msg)); + ewk_ipc_wrt_message_data_del(msg); } std::string RuntimeIPCClient::SendSyncMessage(v8::Handle context, @@ -151,20 +151,22 @@ std::string RuntimeIPCClient::SendSyncMessage(v8::Handle context, return std::string(); } - Wrt_Message_Data* msg = new Wrt_Message_Data(); - msg->SetType(type.c_str()); - msg->SetId(id.c_str()); - msg->SetValue(value.c_str()); - msg->SetReferenceId(ref_id.c_str()); + Ewk_IPC_Wrt_Message_Data* msg = ewk_ipc_wrt_message_data_new(); + ewk_ipc_wrt_message_data_type_set(msg, type.c_str()); + ewk_ipc_wrt_message_data_id_set(msg, id.c_str()); + ewk_ipc_wrt_message_data_reference_id_set(msg, ref_id.c_str()); + ewk_ipc_wrt_message_data_value_set(msg, value.c_str()); + content::RenderView* render_view = content::RenderView::FromRoutingID(routing_id); render_view->Send( - new EwkHostMsg_WrtSyncMessage(render_view->GetRoutingID(), *msg, &msg->value)); - Eina_Stringshare* msg_value = msg->GetValue(); + new AtomHostMsg_WrtSyncMessage(render_view->GetRoutingID(), *msg, &msg->value)); + + Eina_Stringshare* msg_value = ewk_ipc_wrt_message_data_value_get(msg); std::string result(msg_value); eina_stringshare_del(msg_value); - delete msg; + ewk_ipc_wrt_message_data_del(msg); return result; } @@ -181,27 +183,29 @@ void RuntimeIPCClient::SendAsyncMessage(v8::Handle context, std::string msg_id = common::utils::GenerateUUID(); - Wrt_Message_Data* msg = new Wrt_Message_Data(); - msg->SetType(type.c_str()); - msg->SetId(msg_id.c_str()); - msg->SetValue(value.c_str()); + Ewk_IPC_Wrt_Message_Data* msg = ewk_ipc_wrt_message_data_new(); + ewk_ipc_wrt_message_data_id_set(msg, msg_id.c_str()); + ewk_ipc_wrt_message_data_type_set(msg, type.c_str()); + ewk_ipc_wrt_message_data_value_set(msg, value.c_str()); + content::RenderView* render_view = content::RenderView::FromRoutingID(routing_id); render_view->Send( - new EwkHostMsg_WrtMessage(render_view->GetRoutingID(), *msg)); + new AtomHostMsg_WrtMessage(render_view->GetRoutingID(), *msg)); + callbacks_[msg_id] = callback; - delete msg; + ewk_ipc_wrt_message_data_del(msg); } void RuntimeIPCClient::HandleMessageFromRuntime( - const Wrt_Message_Data* msg) { + const Ewk_IPC_Wrt_Message_Data* msg) { if (msg == NULL) { LOGGER(ERROR) << "received message is NULL"; return; } - Eina_Stringshare* msg_refid = msg->GetReferenceId(); + Eina_Stringshare* msg_refid = ewk_ipc_wrt_message_data_reference_id_get(msg); if (msg_refid == NULL || !strcmp(msg_refid, "")) { if (msg_refid) eina_stringshare_del(msg_refid); @@ -216,8 +220,8 @@ void RuntimeIPCClient::HandleMessageFromRuntime( return; } - Eina_Stringshare* msg_type = msg->GetType(); - Eina_Stringshare* msg_value = msg->GetValue(); + Eina_Stringshare* msg_type = ewk_ipc_wrt_message_data_type_get(msg); + Eina_Stringshare* msg_value = ewk_ipc_wrt_message_data_value_get(msg); ReplyCallback func = it->second; if (func) { diff --git a/tizen/extensions/renderer/runtime_ipc_client.h b/tizen/extensions/renderer/runtime_ipc_client.h index 8f40d16..ab28489 100644 --- a/tizen/extensions/renderer/runtime_ipc_client.h +++ b/tizen/extensions/renderer/runtime_ipc_client.h @@ -17,12 +17,13 @@ #ifndef XWALK_EXTENSIONS_RENDERER_RUNTIME_IPC_CLIENT_H_ #define XWALK_EXTENSIONS_RENDERER_RUNTIME_IPC_CLIENT_H_ +#include +#include #include #include #include #include -#include "common/wrt_message_data.h" namespace extensions { @@ -82,7 +83,7 @@ class RuntimeIPCClient { const std::string& type, const std::string& value, ReplyCallback callback); - void HandleMessageFromRuntime(const Wrt_Message_Data* msg); + void HandleMessageFromRuntime(const Ewk_Wrt_Message_Data* msg); int GetRoutingId(v8::Handle context); diff --git a/tizen/extensions/renderer/xwalk_extension_renderer_controller.cc b/tizen/extensions/renderer/xwalk_extension_renderer_controller.cc index 982ab23..2c0a6e2 100644 --- a/tizen/extensions/renderer/xwalk_extension_renderer_controller.cc +++ b/tizen/extensions/renderer/xwalk_extension_renderer_controller.cc @@ -100,14 +100,14 @@ void XWalkExtensionRendererController::WillReleaseScriptContext( } void XWalkExtensionRendererController::OnReceivedIPCMessage( - const Wrt_Message_Data* data) { + const Ewk_IPC_Wrt_Message_Data* data) { - Eina_Stringshare* type = data->GetType(); + Eina_Stringshare* type = ewk_ipc_wrt_message_data_type_get(data); #define TYPE_BEGIN(x) (!strncmp(type, x, strlen(x))) if (TYPE_BEGIN("xwalk://")) { - Eina_Stringshare* id = data->GetId(); - Eina_Stringshare* msg = data->GetValue(); + Eina_Stringshare* id = ewk_ipc_wrt_message_data_id_get(data); + Eina_Stringshare* msg = ewk_ipc_wrt_message_data_value_get(data); extensions_client_->OnReceivedIPCMessage(id, msg); eina_stringshare_del(id); eina_stringshare_del(msg); diff --git a/tizen/extensions/renderer/xwalk_extension_renderer_controller.h b/tizen/extensions/renderer/xwalk_extension_renderer_controller.h index 8fe5ff4..86e66fb 100644 --- a/tizen/extensions/renderer/xwalk_extension_renderer_controller.h +++ b/tizen/extensions/renderer/xwalk_extension_renderer_controller.h @@ -6,11 +6,12 @@ #ifndef XWALK_EXTENSIONS_RENDERER_XWALK_EXTENSION_RENDERER_CONTROLLER_H_ #define XWALK_EXTENSIONS_RENDERER_XWALK_EXTENSION_RENDERER_CONTROLLER_H_ +#include +#include #include #include #include -#include "common/wrt_message_data.h" namespace extensions { @@ -24,7 +25,7 @@ class XWalkExtensionRendererController { void DidCreateScriptContext(v8::Handle context); void WillReleaseScriptContext(v8::Handle context); - void OnReceivedIPCMessage(const Wrt_Message_Data* data); + void OnReceivedIPCMessage(const Ewk_Wrt_Message_Data* data); void InitializeExtensionClient(); void LoadUserExtensions(const std::string app_path); diff --git a/tizen/renderer/injected_bundle.cc b/tizen/renderer/injected_bundle.cc index cce38e6..e3ee3c9 100644 --- a/tizen/renderer/injected_bundle.cc +++ b/tizen/renderer/injected_bundle.cc @@ -15,6 +15,8 @@ */ #include +#include +#include #include #include #include @@ -28,7 +30,6 @@ #include "common/profiler.h" #include "common/resource_manager.h" #include "common/string_utils.h" -#include "common/wrt_message_data.h" #include "extensions/renderer/runtime_ipc_client.h" #include "extensions/renderer/widget_module.h" #include "extensions/renderer/xwalk_extension_renderer_controller.h" @@ -172,7 +173,7 @@ extern "C" void DynamicDatabaseAttach(int /*attach*/) { // LOGGER(DEBUG) << "InjectedBundle::DynamicDatabaseAttach !!"; } -extern "C" void DynamicOnIPCMessage(const Wrt_Message_Data& data) { +extern "C" void DynamicOnIPCMessage(const Ewk_Wrt_Message_Data& data) { SCOPE_PROFILE(); extensions::XWalkExtensionRendererController& controller = extensions::XWalkExtensionRendererController::GetInstance(); diff --git a/tizen/wrt/chromium_wrt.gyp b/tizen/wrt/chromium_wrt.gyp deleted file mode 100644 index 4680117..0000000 --- a/tizen/wrt/chromium_wrt.gyp +++ /dev/null @@ -1,55 +0,0 @@ -{ - 'includes':[ - '../build/common.gypi', - ], - 'targets': [ - { - 'target_name': 'chromium_wrt_shared', - 'type': 'shared_library', - 'sources': [ - "dynamicplugin.cc", - "dynamicplugin.h", - "v8widget.cc", - "v8widget.h", - "wrtwidget.cc", - "wrtwidget.h", - "wrt_dynamicplugin.cc", - "wrt_dynamicplugin.h", - "wrt_file_protocol_handler.cc", - "wrt_file_protocol_handler.h", - "wrt_widget_host.cc", - "wrt_widget_host.h", - ], - 'cflags': [ - '-fvisibility=default', - ], - 'variables': { - 'packages': [ - 'chromium-efl', - 'elementary', - ], - }, - 'include_dirs': [ - '.', - '../', - '../..', - '../tizen', - '<(libchromiumcontent_src_dir)', - '<(SHARED_INTERMEDIATE_DIR)', - '<(libchromiumcontent_src_dir)/gen', - '<(libchromiumcontent_src_dir)/third_party/skia/include/config', - '<(libchromiumcontent_src_dir)/third_party/skia/include/core', - ], - 'direct_dependent_settings': { -# 'libraries': [ -# '-lchromium_wrt_shared', -# ], - 'variables': { - 'packages': [ - 'jsoncpp', - ], - }, - }, - }, # end of target 'xwalk_extension_static' - ], # end of targets -} diff --git a/tizen/wrt/dynamicplugin.cc b/tizen/wrt/dynamicplugin.cc deleted file mode 100644 index 9512d3e..0000000 --- a/tizen/wrt/dynamicplugin.cc +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2014 Samsung Electronics. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "dynamicplugin.h" - -#include - -#include "base/command_line.h" -#include "base/logging.h" - -namespace { -const char* const VERSION_FUNCTION = "DynamicPluginVersion"; -const char* const START_SESSION_FUNCTION = "DynamicPluginStartSession"; -const char* const STOP_SESSION_FUNCTION = "DynamicPluginStopSession"; -} - -DynamicPlugin::DynamicPlugin() - : m_handle_(0), - m_version_(0), - m_versionFunction_(0), - m_startSession_(0), - m_stopSession_(0) { - const base::CommandLine& commandLine = - *base::CommandLine::ForCurrentProcess(); - std::string injectedBundlePath = - commandLine.GetSwitchValueASCII("injected-bundle-path"); - if (injectedBundlePath.empty()) { - return; - } - m_handle_ = dlopen(injectedBundlePath.c_str(), RTLD_LAZY); - if (!m_handle_) { - LOG(ERROR) << "No handle to " << injectedBundlePath.c_str() << " " - << dlerror() << "\n"; - return; - } - - *reinterpret_cast(&m_versionFunction_) = - dlsym(m_handle_, VERSION_FUNCTION); - if (!m_versionFunction_) { - LOG(ERROR) << "No " << VERSION_FUNCTION << " symbol found!\n"; - } else { - m_version_ = m_versionFunction_(); - if (m_version_ != 0 && m_version_ != 1) { - LOG(ERROR) << "Unknown plugin version: " << m_version_ << "!\n"; - return; - } - } - - *reinterpret_cast(&m_startSession_) = - dlsym(m_handle_, START_SESSION_FUNCTION); - if (!m_startSession_) { - LOG(ERROR) << "No " << START_SESSION_FUNCTION << " symbol found!\n"; - } - *reinterpret_cast(&m_stopSession_) = - dlsym(m_handle_, STOP_SESSION_FUNCTION); - if (!m_stopSession_) { - LOG(ERROR) << "No " << STOP_SESSION_FUNCTION << " symbol found!\n"; - } -} - -void DynamicPlugin::startSession(const char* sessionId, - v8::Handle context, - int routingHandle, - const void* sessionBlob) { - if (!m_startSession_) - return; - - m_startSession_(sessionId, context, routingHandle, sessionBlob); -} - -void DynamicPlugin::stopSession(const char* sessionId, - v8::Handle context) { - if (!m_stopSession_) - return; - - m_stopSession_(sessionId, context); -} - -DynamicPlugin::~DynamicPlugin() { - if (m_handle_) - dlclose(m_handle_); -} - -DynamicPlugin& DynamicPlugin::instance() { - static DynamicPlugin dynamicPlugin; - return dynamicPlugin; -} - diff --git a/tizen/wrt/dynamicplugin.h b/tizen/wrt/dynamicplugin.h deleted file mode 100644 index 46a1963..0000000 --- a/tizen/wrt/dynamicplugin.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2014, 2016 Samsung Electronics. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WRT_DYNAMICPLUGIN_H_ -#define WRT_DYNAMICPLUGIN_H_ - -#include -#include "base/macros.h" -#include "v8/include/v8.h" - -typedef unsigned int (*versionFunction)(void); - -typedef void (*startSessionFunction)(const char* sessionId, - v8::Handle context, - int routingHandle, - const void* sessionBlob); - -typedef void (*stopSessionFunction)(const char* sessionId, - v8::Handle context); - -class DynamicPlugin { - public: - void startSession(const char* sessionId, - v8::Handle context, - int routingHandle, - const void* sessionBlob); - void stopSession(const char* sessionId, v8::Handle context); - - virtual ~DynamicPlugin(); - - static DynamicPlugin& instance(); - - protected: - DynamicPlugin(); - DynamicPlugin(const DynamicPlugin&); - DynamicPlugin& operator=(const DynamicPlugin&); - - void* m_handle_; - unsigned int m_version_; - versionFunction m_versionFunction_; - startSessionFunction m_startSession_; - stopSessionFunction m_stopSession_; -}; - -#endif // WRT_DYNAMICPLUGIN_H_ diff --git a/tizen/wrt/v8widget.cc b/tizen/wrt/v8widget.cc deleted file mode 100644 index ef721b8..0000000 --- a/tizen/wrt/v8widget.cc +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2014, 2015 Samsung Electronics. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "v8widget.h" - -#include "base/logging.h" -#include "dynamicplugin.h" -#if defined(OS_TIZEN_TV_PRODUCT) -#include "wrt/hbbtv_dynamicplugin.h" -#endif -#include "wrt_dynamicplugin.h" - -V8Widget::V8Widget(Type type) : type_(type) {} - -V8Widget::~V8Widget() {} - -void V8Widget::SetId(const std::string& id) { - id_ = id; -} - -V8Widget::Type V8Widget::GetType() const { - return type_; -} - -bool V8Widget::ParseUrl(const GURL& url, - GURL& new_url, - bool& is_decrypted_file) { - if (!id_.empty()) { - std::string old_url = url.possibly_invalid_spec(); - std::string s_new_url; - if (type_ == V8Widget::Type::WRT) - WrtDynamicPlugin::instance().parseURL(&old_url, &s_new_url, id_.c_str(), - &is_decrypted_file); - -#if defined(OS_TIZEN_TV_PRODUCT) - if (type_ == V8Widget::Type::HBBTV) - HbbTVDynamicPlugin::instance().parseURL(&old_url, &s_new_url, id_.c_str(), - &is_decrypted_file); -#endif - - if (!s_new_url.empty()) { - new_url = GURL(s_new_url); - return true; - } - } - return false; -} - -#if defined(OS_TIZEN_TV_PRODUCT) -bool V8Widget::GetFileDecryptedDataBuffer(const GURL& url, - std::vector* data) { - if (!id_.empty()) { - std::string str_url = url.possibly_invalid_spec(); - if (type_ == V8Widget::Type::WRT) - return WrtDynamicPlugin::instance().getFileDecryptedDataBuffer(&str_url, - data); - - if (type_ == V8Widget::Type::HBBTV) - return HbbTVDynamicPlugin::instance().getFileDecryptedDataBuffer(&str_url, - data); - } - return false; -} -#endif - -void V8Widget::StopSession(v8::Handle context) { - if (!id_.empty() && !context.IsEmpty()) { - if (type_ == V8Widget::Type::WRT) - WrtDynamicPlugin::instance().stopSession(id_.c_str(), context); - -#if defined(OS_TIZEN_TV_PRODUCT) - if (type_ == V8Widget::Type::HBBTV) - HbbTVDynamicPlugin::instance().stopSession(id_.c_str(), context); -#endif - } -} - -void V8Widget::StartSession(v8::Handle context, - int routingHandle, - const void* sessionBlob) { - if (!id_.empty() && !context.IsEmpty()) { - if (type_ == V8Widget::Type::WRT) - NOTREACHED(); - -#if defined(OS_TIZEN_TV_PRODUCT) - if (type_ == V8Widget::Type::HBBTV) - HbbTVDynamicPlugin::instance().startSession(id_.c_str(), context, - routingHandle, sessionBlob); -#endif - } -} diff --git a/tizen/wrt/v8widget.h b/tizen/wrt/v8widget.h deleted file mode 100644 index 2b843a3..0000000 --- a/tizen/wrt/v8widget.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2014, 2015 Samsung Electronics. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WRT_V8WIDGET_H_ -#define WRT_V8WIDGET_H_ - -#include - -#include "content/public/renderer/render_thread_observer.h" -#include "url/gurl.h" -#include "v8/include/v8.h" - -// Have to be created on the RenderThread. -class V8Widget { - public: - enum class Type { HBBTV, WRT }; - - explicit V8Widget(Type type); - virtual ~V8Widget() = 0; - - void SetId(const std::string& id); - Type GetType() const; - - virtual void StartSession(v8::Handle, - int routingHandle, - const void* sessionBlob); - - virtual void StopSession(v8::Handle); - - bool ParseUrl(const GURL& url, GURL& new_url, bool& is_decrypted_file); - -#if defined(OS_TIZEN_TV_PRODUCT) - bool GetFileDecryptedDataBuffer(const GURL& url, std::vector* data); -#endif - protected: - std::string id_; - Type type_; -}; - -#endif // WRT_V8WIDGET_H_ diff --git a/tizen/wrt/wrt_dynamicplugin.cc b/tizen/wrt/wrt_dynamicplugin.cc deleted file mode 100644 index 68cf087..0000000 --- a/tizen/wrt/wrt_dynamicplugin.cc +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright 2014 Samsung Electronics. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "wrt_dynamicplugin.h" - -#include - -#include "base/command_line.h" -#include "base/logging.h" - -namespace { -const char* const URL_PARSING_FUNCTION = "DynamicUrlParsing"; -const char* const SET_WIDGET_INFO_FUNCTION = "DynamicSetWidgetInfo"; -const char* const DATABASE_ATTACH_FUNCTION = "DynamicDatabaseAttach"; -#if defined(OS_TIZEN_TV_PRODUCT) -const char* const TVURL_PARSING_FUNCTION = "DynamicTVUrlParsing"; -const char* const GET_FILEDECRYPTED_DATABUFFER = - "DynamicGetFileDecryptedDataBuffer"; -#endif - -typedef void (*startSessionFun_v0)(const char* tizen_app_id, - v8::Handle context, - int routingHandle, - double scaleFactor, - const char* encodedBundle, - const char* theme, - const char* baseURL); -} // namespace - -WrtDynamicPlugin::WrtDynamicPlugin() - : DynamicPlugin(), - m_parseURL_(0), - m_setWidgetInfo_(0), - m_databaseAttach_(0), -#if defined(OS_TIZEN_TV_PRODUCT) - m_getFileDecryptedDataBuffer_(0), - m_parseTVURL_(0), -#endif - m_onIPCMessage_(0) { - *reinterpret_cast(&m_parseURL_) = - dlsym(m_handle_, URL_PARSING_FUNCTION); - if (!m_parseURL_) { - LOG(ERROR) << "No " << URL_PARSING_FUNCTION << " symbol found!\n"; - } - *reinterpret_cast(&m_setWidgetInfo_) = - dlsym(m_handle_, SET_WIDGET_INFO_FUNCTION); - if (!m_setWidgetInfo_) { - LOG(ERROR) << "No " << SET_WIDGET_INFO_FUNCTION << " symbol found!"; - } - *reinterpret_cast(&m_databaseAttach_) = - dlsym(m_handle_, DATABASE_ATTACH_FUNCTION); - if (!m_databaseAttach_) { - LOG(ERROR) << "No " << DATABASE_ATTACH_FUNCTION << " symbol found!\n"; - return; - } - *reinterpret_cast(&m_onIPCMessage_) = - dlsym(m_handle_, "DynamicOnIPCMessage"); - if (!m_onIPCMessage_) { - LOG(ERROR) << "No DynamicOnIPCMessage symbol found!\n"; - } - m_databaseAttach_(1); - -#if defined(OS_TIZEN_TV_PRODUCT) - *reinterpret_cast(&m_parseTVURL_) = - dlsym(m_handle_, TVURL_PARSING_FUNCTION); - if (!m_parseTVURL_) { - LOG(ERROR) << "No " << TVURL_PARSING_FUNCTION << " symbol found!\n"; - } - *reinterpret_cast(&m_getFileDecryptedDataBuffer_) = - dlsym(m_handle_, GET_FILEDECRYPTED_DATABUFFER); - if (!m_getFileDecryptedDataBuffer_) { - LOG(ERROR) << "No " << GET_FILEDECRYPTED_DATABUFFER << " symbol found!\n"; - } -#endif -} - -void WrtDynamicPlugin::startSession(const char* tizen_app_id, - v8::Handle context, - int routingHandle, - double scaleFactor, - const char* encodedBundle, - const char* theme, - const char* baseURL) { - if (!m_startSession_ || !m_databaseAttach_) - return; - switch (m_version_) { - case 0: { - auto startSession_v0 = - reinterpret_cast(m_startSession_); - startSession_v0(tizen_app_id, context, routingHandle, scaleFactor, - encodedBundle, theme, baseURL); - break; - } - case 1: { - DynamicPlugin::startSession(tizen_app_id, context, routingHandle, - baseURL); - break; - } - default: - return; - } -} - -void WrtDynamicPlugin::stopSession(const char* tizen_app_id, - v8::Handle context) { - if (!m_stopSession_ || !m_databaseAttach_) - return; - DynamicPlugin::stopSession(tizen_app_id, context); -} - -void WrtDynamicPlugin::parseURL(std::string* old_url, - std::string* new_url, - const char* tizen_app_id, - bool* is_decrypted_file) { -#if defined(OS_TIZEN_TV_PRODUCT) - if (!m_databaseAttach_) - return; - if (m_parseTVURL_) { - m_parseTVURL_(old_url, new_url, tizen_app_id, is_decrypted_file); - return; - } - if (m_parseURL_) { - m_parseURL_(old_url, new_url, tizen_app_id); - *is_decrypted_file = false; - } -#else - if (!m_parseURL_ || !m_databaseAttach_) - return; - m_parseURL_(old_url, new_url, tizen_app_id); -#endif -} - -#if defined(OS_TIZEN_TV_PRODUCT) -bool WrtDynamicPlugin::getFileDecryptedDataBuffer(const std::string* url, - std::vector* data) { - if (!m_getFileDecryptedDataBuffer_) - return false; - return m_getFileDecryptedDataBuffer_(url, data); -} -#endif - -void WrtDynamicPlugin::setWidgetInfo(const std::string& tizen_app_id) { - if (!m_setWidgetInfo_) - return; - m_setWidgetInfo_(tizen_app_id.c_str()); -} - -WrtDynamicPlugin::~WrtDynamicPlugin() { - if (m_databaseAttach_) - m_databaseAttach_(0); -} - -WrtDynamicPlugin& WrtDynamicPlugin::instance() { - static WrtDynamicPlugin dynamicPlugin; - return dynamicPlugin; -} - -void WrtDynamicPlugin::messageReceived(const Wrt_Message_Data& data) { - if (!m_onIPCMessage_) - return; - - m_onIPCMessage_(data); -} diff --git a/tizen/wrt/wrt_dynamicplugin.h b/tizen/wrt/wrt_dynamicplugin.h deleted file mode 100644 index 9554b4d..0000000 --- a/tizen/wrt/wrt_dynamicplugin.h +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2014 Samsung Electronics. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WRT_WRT_DYNAMICPLUGIN_H_ -#define WRT_WRT_DYNAMICPLUGIN_H_ - -#include -#include -#include "dynamicplugin.h" -#include "v8/include/v8.h" -#include "common/wrt_message_data.h" - -typedef void (*onIPCMessageFun)(const Wrt_Message_Data& data); -#if defined(OS_TIZEN_TV_PRODUCT) -typedef void (*TVParseUrlFun)(std::string* old_url, - std::string* new_url, - const char* tizen_app_id, - bool* is_decrypted_file); -typedef bool (*getFileDecryptedDataBufferFun)(const std::string* url, - std::vector* data); -#endif -typedef void (*parseUrlFun)(std::string* old_url, - std::string* new_url, - const char* tizen_app_id); -typedef void (*setWidgetInfoFun)(const char* tizen_app_id); -typedef void (*databaseAttachFun)(int databaseAttach); - -class WrtDynamicPlugin : public DynamicPlugin { - public: - void startSession(const char* tizen_app_id, - v8::Handle context, - int routingHandle, - double scaleFactor, - const char* encodedBundle, - const char* theme, - const char* baseURL); - void stopSession(const char* tizen_app_id, v8::Handle context); - - void parseURL(std::string* old_url, - std::string* new_url, - const char* tizen_app_id, - bool* is_decrypted_file); - -#if defined(OS_TIZEN_TV_PRODUCT) - bool getFileDecryptedDataBuffer(const std::string* url, - std::vector* data); -#endif - - void setWidgetInfo(const std::string& tizen_app_id); - void messageReceived(const Wrt_Message_Data& data); - - static WrtDynamicPlugin& instance(); - ~WrtDynamicPlugin() override; - - private: - WrtDynamicPlugin(); - - parseUrlFun m_parseURL_; - setWidgetInfoFun m_setWidgetInfo_; - databaseAttachFun m_databaseAttach_; -#if defined(OS_TIZEN_TV_PRODUCT) - getFileDecryptedDataBufferFun m_getFileDecryptedDataBuffer_; - TVParseUrlFun m_parseTVURL_; -#endif - onIPCMessageFun m_onIPCMessage_; - - DISALLOW_COPY_AND_ASSIGN(WrtDynamicPlugin); -}; - -#endif // WRT_WRT_DYNAMICPLUGIN_H_ diff --git a/tizen/wrt/wrt_file_protocol_handler.cc b/tizen/wrt/wrt_file_protocol_handler.cc deleted file mode 100644 index 5a8ba30..0000000 --- a/tizen/wrt/wrt_file_protocol_handler.cc +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) 2014,2015 Samsung Electronics. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "wrt_file_protocol_handler.h" - -#include "base/command_line.h" -//#include "common/content_switches_efl.h" -#include "content/public/common/content_client.h" -#include "content/public/renderer/content_renderer_client.h" -#include "net/base/filename_util.h" -#include "net/url_request/url_request_data_job.h" -#include "net/url_request/url_request_error_job.h" -#include "net/url_request/url_request_file_dir_job.h" -#include "net/url_request/url_request_file_job.h" -#include "net/url_request/url_request_simple_job.h" -#include "wrt_dynamicplugin.h" - -namespace net { - -class WrtURLRequestDataJob : public URLRequestSimpleJob { - public: - /* LCOV_EXCL_START */ - WrtURLRequestDataJob(URLRequest* request, - NetworkDelegate* network_delegate, - const GURL& data_url) - : URLRequestSimpleJob(request, network_delegate) { - data_url_ = data_url; - } - /* LCOV_EXCL_STOP */ - - int GetData(std::string* mime_type, - std::string* charset, - std::string* data, - const CompletionCallback& callback) const override; - - private: - ~WrtURLRequestDataJob() override {} // LCOV_EXCL_LINE - GURL data_url_; -}; - -/* LCOV_EXCL_START */ -int WrtURLRequestDataJob::GetData(std::string* mime_type, - std::string* charset, - std::string* data, - const CompletionCallback& callback) const { - if (!data_url_.is_valid()) - return ERR_INVALID_URL; - - return URLRequestDataJob::BuildResponse(data_url_, mime_type, charset, data, - nullptr); -} - -bool WrtFileProtocolHandler::GetWrtParsedUrl(const GURL& url, - GURL& parsed_url) const { - static std::string tizen_app_id = - base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( - "widget-id"); - if (!tizen_app_id.empty()) { - bool is_decrypted_file; - std::string url_str = url.possibly_invalid_spec(); - std::string parsed_url_str; - WrtDynamicPlugin::instance().parseURL( - &url_str, &parsed_url_str, tizen_app_id.c_str(), &is_decrypted_file); - if (!parsed_url_str.empty()) { - parsed_url = GURL(parsed_url_str); - return true; - } - } - return false; -} -/* LCOV_EXCL_STOP */ - -URLRequestJob* WrtFileProtocolHandler::MaybeCreateJob( - URLRequest* request, - NetworkDelegate* network_delegate) const { - GURL parsed_url; - if (GetWrtParsedUrl(request->url(), parsed_url)) { - // Data URI scheme for WRT encryption content - if (parsed_url.SchemeIs(url::kDataScheme)) - return new WrtURLRequestDataJob(request, network_delegate, parsed_url); - } else - parsed_url = request->url(); - - base::FilePath file_path; - const bool is_file = FileURLToFilePath(parsed_url, &file_path); - - // Check file access permissions. - if (!network_delegate || - !network_delegate->CanAccessFile(*request, file_path)) { - return new URLRequestErrorJob(request, network_delegate, ERR_ACCESS_DENIED); - } - - // We need to decide whether to create URLRequestFileJob for file access or - // URLRequestFileDirJob for directory access. To avoid accessing the - // filesystem, we only look at the path string here. - // The code in the URLRequestFileJob::Start() method discovers that a path, - // which doesn't end with a slash, should really be treated as a directory, - // and it then redirects to the URLRequestFileDirJob. - if (is_file && file_path.EndsWithSeparator() && file_path.IsAbsolute()) { - return new URLRequestFileDirJob(request, network_delegate, file_path); - } - - // Use a regular file request job for all non-directories (including invalid - // file names). - return new URLRequestFileJob(request, network_delegate, file_path, - file_task_runner_); -} - -} // namespace diff --git a/tizen/wrt/wrt_file_protocol_handler.h b/tizen/wrt/wrt_file_protocol_handler.h deleted file mode 100644 index 6fab49f..0000000 --- a/tizen/wrt/wrt_file_protocol_handler.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) 2014,2015 Samsung Electronics. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WRT_FILE_PROTOCOL_HANDLER -#define WRT_FILE_PROTOCOL_HANDLER - -#include "base/memory/ref_counted.h" -#include "net/url_request/url_request_job_factory.h" - -class GURL; - -namespace base { -class TaskRunner; -} - -namespace net { - -class NetworkDelegate; -class URLRequestJob; - -class WrtFileProtocolHandler - : public URLRequestJobFactory::ProtocolHandler { - public: - explicit WrtFileProtocolHandler( - const scoped_refptr& file_task_runner) - : file_task_runner_(file_task_runner) {} - ~WrtFileProtocolHandler() override {} - URLRequestJob* MaybeCreateJob( - URLRequest* request, - NetworkDelegate* network_delegate) const override; - /* LCOV_EXCL_START */ - bool IsSafeRedirectTarget(const GURL& location) const override { - return false; - } - /* LCOV_EXCL_STOP */ - - private: - bool GetWrtParsedUrl(const GURL& url, GURL& parsed_url) const; - const scoped_refptr file_task_runner_; - DISALLOW_COPY_AND_ASSIGN(WrtFileProtocolHandler); -}; - -} // namespace net - -#endif // WRT_FILE_PROTOCOL_HANDLER diff --git a/tizen/wrt/wrt_widget_host.cc b/tizen/wrt/wrt_widget_host.cc deleted file mode 100644 index d33c513..0000000 --- a/tizen/wrt/wrt_widget_host.cc +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright (c) 2014,2015 Samsung Electronics. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "wrt_widget_host.h" - -#include "base/lazy_instance.h" -//#include "common/render_messages_ewk.h" -#include "atom/common/api/api_messages.h" -#include "content/public/browser/browser_message_filter.h" -#include "content/public/browser/render_process_host.h" -#include "content/public/browser/resource_request_info.h" -//#include "ipc/ipc_message_macros.h" -//#include "ipc_message_start_ewk.h" -#include "net/url_request/url_request.h" -#include "url/gurl.h" - -namespace { -// TODO(z.kostrzewa) I would prefer not make it a singleton, check out -// if it can't be a member of ContentMainDelegateEfl (but keep the static -// getter, maybe?). -base::LazyInstance > g_wrt_widget_host = - LAZY_INSTANCE_INITIALIZER; - -bool SendToAllRenderers(IPC::Message* message) { - bool result = false; - content::RenderProcessHost::iterator it = - content::RenderProcessHost::AllHostsIterator(); - while (!it.IsAtEnd()) { - if (it.GetCurrentValue()->Send(new IPC::Message(*message))) - result = true; - it.Advance(); - } - delete message; - return result; -} - -bool SendToRenderer(int renderer_id, IPC::Message* message) { - return content::RenderProcessHost::FromID(renderer_id)->Send(message); -} -} - -class WrtWidgetHostMessageFilter : public content::BrowserMessageFilter { - public: - explicit WrtWidgetHostMessageFilter(WrtWidgetHost* wrt_widget_host); - - private: - ~WrtWidgetHostMessageFilter() override {} - bool OnMessageReceived(const IPC::Message& message) override; - - WrtWidgetHost* wrt_widget_host_; -}; - -WrtWidgetHostMessageFilter::WrtWidgetHostMessageFilter( - WrtWidgetHost* wrt_widget_host) - : content::BrowserMessageFilter(ShellMsgStart), - wrt_widget_host_(wrt_widget_host) { -} - -bool WrtWidgetHostMessageFilter::OnMessageReceived(const IPC::Message& message) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(WrtWidgetHostMessageFilter, message) - IPC_MESSAGE_FORWARD(WrtMsg_ParseUrlResponse, wrt_widget_host_, WrtWidgetHost::OnUrlRetrieved) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -WrtWidgetHost* WrtWidgetHost::Get() { - // TODO(z.kostrzewa) LazyInstance is thread-safe but creating - // WrtWidgetHost is not - make it thread-safe. - if (!g_wrt_widget_host.Get().get()) - g_wrt_widget_host.Get().reset(new WrtWidgetHost); - return g_wrt_widget_host.Get().get(); -} - -WrtWidgetHost::WrtWidgetHost() - : message_filter_(new WrtWidgetHostMessageFilter(this)) { -} - -WrtWidgetHost::~WrtWidgetHost() {} - -void WrtWidgetHost::GetUrlForRequest( - net::URLRequest* request, - base::Callback callback) { - // TODO(z.kostrzewa) Check on which thread(s) callbacks_ is touched - // and provide synchronization if required (either via a lock or - // by assuring that it is referenced only on one thread) - int callback_id = callback_id_generator_.GetNext(); - callbacks_[callback_id] = callback; - - int renderer_id, frame_id; - if (content::ResourceRequestInfo::GetRenderFrameForRequest(request, &renderer_id, - &frame_id)) - if (SendToRenderer(renderer_id, new WrtMsg_ParseUrl(callback_id, request->url()))) - return; - - callbacks_.erase(callback_id); - callback.Run(GURL()); -} - -void WrtWidgetHost::SendWrtMessage( - const Wrt_Message_Data& message) { - SendToAllRenderers(new WrtMsg_SendWrtMessage(message)); -} - -// It's only used by the wrt_file_protocol_handler which is not going to be used in the future -// Candidate for deletion. -bool WrtWidgetHost::InWrt() const { - return false; -} - -// It's only used by the wrt_file_protocol_handler which is not going to be used in the future -// Candidate for deletion. -std::string WrtWidgetHost::TizenAppId() const { -#if defined(OS_TIZEN_TV_PRODUCT) - return tizen_app_id_; -#else - return std::string(); -#endif -} - -void WrtWidgetHost::OnUrlRetrieved(int callback_id, const GURL& url) { - callbacks_type::iterator it = callbacks_.find(callback_id); - if (callbacks_.end() == it) - return; - - callbacks_type::mapped_type callback = it->second; - callbacks_.erase(callback_id); - callback.Run(url); -} - -#if defined(OS_TIZEN_TV_PRODUCT) -void WrtWidgetHost::SetTizenAppId(const std::string& tizen_app_id) { - tizen_app_id_ = tizen_app_id; -} - -bool WrtWidgetHost::ShouldAllowRequest(const net::URLRequest& request) { - if (tizen_app_id_.empty() || !check_accessiable_path_callback_) - return true; - - return check_accessiable_path_callback_->TriggerCallback(request.url().spec(), - tizen_app_id_); -} - -bool EwkCheckAccessiablePathCallback::TriggerCallback( - const std::string& url_spec, - const std::string& tizen_app_id) const { - if (!callback_) - return true; - - Eina_Bool result = - (*callback_)(tizen_app_id.c_str(), url_spec.c_str(), user_data_); - return result == EINA_TRUE; -} - -void WrtWidgetHost::SetCheckAccessiablePathCallback( - Ewk_Context_Check_Accessible_Path_Callback callback, - void* user_data) { - check_accessiable_path_callback_.reset( - new EwkCheckAccessiablePathCallback(callback, user_data)); -} -#endif - diff --git a/tizen/wrt/wrt_widget_host.h b/tizen/wrt/wrt_widget_host.h deleted file mode 100644 index 11161da..0000000 --- a/tizen/wrt/wrt_widget_host.h +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) 2014,2015 Samsung Electronics. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WRT_HOST_H -#define WRT_HOST_H - -#include -#include - -#include "base/atomic_sequence_num.h" -#include "base/callback.h" -#include "content/public/browser/browser_message_filter.h" -#include "common/wrt_message_data.h" -#if defined(OS_TIZEN_TV_PRODUCT) -#include "public/ewk_context_product.h" -#endif - -namespace net { -class URLRequest; -} - -class GURL; - -class WrtWidgetHostMessageFilter; - -#if defined(OS_TIZEN_TV_PRODUCT) -class EwkCheckAccessiablePathCallback { - public: - EwkCheckAccessiablePathCallback( - Ewk_Context_Check_Accessible_Path_Callback callback, - void* user_data) - : callback_(callback), user_data_(user_data) {} - bool TriggerCallback(const std::string& url_spec, - const std::string& tizen_app_id) const; - - private: - Ewk_Context_Check_Accessible_Path_Callback callback_; - void* user_data_; -}; -#endif - -class WrtWidgetHost { - public: - static WrtWidgetHost* Get(); - - ~WrtWidgetHost(); - - void GetUrlForRequest(net::URLRequest* request, - base::Callback callback); - - void SendWrtMessage(const Wrt_Message_Data& message); - - bool InWrt() const; - - std::string TizenAppId() const; - -#if defined(OS_TIZEN_TV_PRODUCT) - void SetTizenAppId(const std::string& tizen_app_id); - bool ShouldAllowRequest(const net::URLRequest& request); - - void SetCheckAccessiablePathCallback( - Ewk_Context_Check_Accessible_Path_Callback callback, - void* user_data); -#endif - - private: - friend class WrtWidgetHostMessageFilter; - - typedef std::map > callbacks_type; - - WrtWidgetHost(); - - void OnUrlRetrieved(int callback_id, const GURL& url); - - scoped_refptr message_filter_; - base::AtomicSequenceNumber callback_id_generator_; - callbacks_type callbacks_; - -#if defined(OS_TIZEN_TV_PRODUCT) - std::string tizen_app_id_; - std::unique_ptr check_accessiable_path_callback_; -#endif - - DISALLOW_COPY_AND_ASSIGN(WrtWidgetHost); -}; - - -#endif diff --git a/tizen/wrt/wrtwidget.cc b/tizen/wrt/wrtwidget.cc deleted file mode 100644 index 6c877c6..0000000 --- a/tizen/wrt/wrtwidget.cc +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2014, 2015 Samsung Electronics. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "wrtwidget.h" - -//#include "common/render_messages_ewk.h" -#include "atom/common/api/api_messages.h" -#include "content/public/renderer/render_thread.h" -#include "ipc/ipc_sync_channel.h" -#include "wrt_dynamicplugin.h" - -// TODO(z.kostrzewa) -// Why it can't be implemented as IPC::ChannelProxy::MessageFilter (?) -// Tried that and it seems that Observer starts receiving messages earlier than -// MessageFilter what is crucial for message that sets widget handle -class WrtRenderThreadObserver : public content::RenderThreadObserver { - public: - explicit WrtRenderThreadObserver(WrtWidget* wrt_widget) - : wrt_widget_(wrt_widget), - channel_(content::RenderThread::Get()->GetChannel()) - { } - - bool OnControlMessageReceived(const IPC::Message& message) override { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(WrtRenderThreadObserver, message) - IPC_MESSAGE_FORWARD(WrtMsg_SendWrtMessage, wrt_widget_, WrtWidget::MessageReceived) - IPC_MESSAGE_HANDLER(WrtMsg_ParseUrl, ParseUrl) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; - } - - private: - void ParseUrl(int request_id, const GURL& url) { - GURL response; - bool is_decrypted_file = false; - wrt_widget_->ParseUrl(url, response, is_decrypted_file); - Send(new WrtMsg_ParseUrlResponse(request_id, response)); - } - - void Send(IPC::Message* message) { - if (channel_) - channel_->Send(message); - else - delete message; - } - - WrtWidget* wrt_widget_; - IPC::SyncChannel* channel_; -}; - -WrtWidget::WrtWidget() - : V8Widget(V8Widget::Type::WRT), - scale_(0), - observer_(new WrtRenderThreadObserver(this)) { - DCHECK(content::RenderThread::Get()) - << "WrtWidget must be constructed on the render thread"; -} - -WrtWidget::~WrtWidget() { - delete observer_; -} - -content::RenderThreadObserver* WrtWidget::GetObserver() { - return observer_; -} - -void WrtWidget::SetWidgetInfo(const std::string& tizen_app_id, - double scaleFactor, - const std::string& theme, - const std::string& encodedBundle) { - id_ = tizen_app_id; - scale_ = scaleFactor; - theme_ = theme; - encodedBundle_ = encodedBundle; - WrtDynamicPlugin::instance().setWidgetInfo(id_); -} - -bool WrtWidget::IsWidgetInfoSet() const { - return !id_.empty(); -} - -void WrtWidget::StartSession(v8::Handle context, - int routingHandle, - const void* sessionBlob) { - if (!id_.empty() && !context.IsEmpty()) { - WrtDynamicPlugin::instance().startSession( - id_.c_str(), context, routingHandle, scale_, encodedBundle_.c_str(), - theme_.c_str(), reinterpret_cast(sessionBlob)); - } -} - -void WrtWidget::MessageReceived(const Wrt_Message_Data& data) { - if (!id_.empty()) - WrtDynamicPlugin::instance().messageReceived(data); -} diff --git a/tizen/wrt/wrtwidget.h b/tizen/wrt/wrtwidget.h deleted file mode 100644 index 28af8cb..0000000 --- a/tizen/wrt/wrtwidget.h +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2014, 2015 Samsung Electronics. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WRT_WRTWIDGET_H_ -#define WRT_WRTWIDGET_H_ - -#include - -#include "content/public/renderer/render_thread_observer.h" -#include "url/gurl.h" -#include "v8widget.h" -#include "common/wrt_message_data.h" - -class WrtRenderThreadObserver; - -// Have to be created on the RenderThread. -class WrtWidget : public V8Widget { - public: - WrtWidget(); - ~WrtWidget() override; - - content::RenderThreadObserver* GetObserver(); - - void SetWidgetInfo(const std::string& tizen_app_id, - double scaleFactor, - const std::string& theme, - const std::string& encodedBundle); - - bool IsWidgetInfoSet() const; - - void MessageReceived(const Wrt_Message_Data& data); - - void StartSession(v8::Handle, - int routingHandle, - const void* sessionBlob) override; - - private: - double scale_; - std::string encodedBundle_; - std::string theme_; - WrtRenderThreadObserver* observer_; -}; - -#endif // WRT_WRTWIDGET_H_ diff --git a/vendor/brightray/vendor/libchromiumcontent/src/tizen_src/ewk/efl_integration/private/ewk_wrt_private.h b/vendor/brightray/vendor/libchromiumcontent/src/tizen_src/ewk/efl_integration/private/ewk_wrt_private.h index c0d5208..2f60494 100644 --- a/vendor/brightray/vendor/libchromiumcontent/src/tizen_src/ewk/efl_integration/private/ewk_wrt_private.h +++ b/vendor/brightray/vendor/libchromiumcontent/src/tizen_src/ewk/efl_integration/private/ewk_wrt_private.h @@ -7,7 +7,7 @@ #include -struct Ewk_Wrt_Message_Data { +struct __attribute__((visibility("default"))) Ewk_Wrt_Message_Data { std::string type; std::string value; std::string id; diff --git a/vendor/brightray/vendor/libchromiumcontent/src/tizen_src/ewk/efl_integration/wrt/wrt_widget_host.h b/vendor/brightray/vendor/libchromiumcontent/src/tizen_src/ewk/efl_integration/wrt/wrt_widget_host.h index ad087e9..01f01c7 100644 --- a/vendor/brightray/vendor/libchromiumcontent/src/tizen_src/ewk/efl_integration/wrt/wrt_widget_host.h +++ b/vendor/brightray/vendor/libchromiumcontent/src/tizen_src/ewk/efl_integration/wrt/wrt_widget_host.h @@ -41,7 +41,7 @@ class EwkCheckAccessiablePathCallback { }; #endif -class WrtWidgetHost { +class __attribute__((visibility("default"))) WrtWidgetHost { public: static WrtWidgetHost* Get(); diff --git a/vendor/brightray/vendor/libchromiumcontent/src/tizen_src/ewk/efl_integration/wrt/wrtwidget.h b/vendor/brightray/vendor/libchromiumcontent/src/tizen_src/ewk/efl_integration/wrt/wrtwidget.h index 45c2c93..4e504e0 100644 --- a/vendor/brightray/vendor/libchromiumcontent/src/tizen_src/ewk/efl_integration/wrt/wrtwidget.h +++ b/vendor/brightray/vendor/libchromiumcontent/src/tizen_src/ewk/efl_integration/wrt/wrtwidget.h @@ -16,7 +16,7 @@ struct Ewk_Wrt_Message_Data; class WrtRenderThreadObserver; // Have to be created on the RenderThread. -class WrtWidget : public V8Widget { +class __attribute__((visibility("default"))) WrtWidget : public V8Widget { public: WrtWidget(); ~WrtWidget() override; diff --git a/wrt.gyp b/wrt.gyp index d8528b0..663ee2c 100644 --- a/wrt.gyp +++ b/wrt.gyp @@ -15,7 +15,6 @@ '<(DEPTH)/tizen/loader/loader.gyp:wrt-loader', '<(DEPTH)/tizen/extensions/extensions.gyp:xwalk_extension_shared', '<(DEPTH)/tizen/renderer/injected_bundle.gyp:xwalk_injected_bundle', - '<(DEPTH)/tizen/wrt/chromium_wrt.gyp:chromium_wrt_shared', '<(DEPTH)/efl/build/system.gyp:ecore', '<(DEPTH)/efl/build/system.gyp:launchpad', '<(DEPTH)/efl/build/system.gyp:capi-appfw-application', @@ -130,6 +129,7 @@ '<(libchromiumcontent_src_dir)/components/cdm', '<(libchromiumcontent_src_dir)/third_party/widevine', '<(libchromiumcontent_src_dir)/tizen_src/chromium_impl', + '<(libchromiumcontent_src_dir)/tizen_src/ewk/efl_integration', ], 'direct_dependent_settings': { 'include_dirs': [ -- 2.7.4 From 4bd93d1032d91f60d9f256bb0dff60f52647dcf9 Mon Sep 17 00:00:00 2001 From: "k2.nagaraju" Date: Mon, 4 Jun 2018 15:08:54 +0530 Subject: [PATCH 08/16] fixup! Expose the visibility of classes of chromium for web device api. Change-Id: Iba81e14e308e17fbfa29aad2c1515b2e4a8c2496 Signed-off-by: k2.nagaraju --- atom/renderer/atom_renderer_client.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/atom/renderer/atom_renderer_client.h b/atom/renderer/atom_renderer_client.h index 2818ecc..1a67a85 100644 --- a/atom/renderer/atom_renderer_client.h +++ b/atom/renderer/atom_renderer_client.h @@ -44,8 +44,7 @@ class AtomRendererClient : public RendererClientBase { DISABLE, }; std::unique_ptr widget_; - std::unique_ptr wrt_url_parser_; - // content::ContentRendererClient: + void RenderThreadStarted() override; void RenderFrameCreated(content::RenderFrame*) override; void RenderViewCreated(content::RenderView*) override; -- 2.7.4 From 45a7143e1856bcf59f0bf72655b83b5c055f7295 Mon Sep 17 00:00:00 2001 From: "jaekuk, lee" Date: Tue, 5 Jun 2018 10:28:38 +0900 Subject: [PATCH 09/16] Implement Runtime Add-on Change-Id: I3d5017a68ba43af8f4efff05069667a35d236e97 Signed-off-by: jaekuk, lee --- wrt/src/extension_manager.js | 2 +- wrt/src/runtime.js | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) mode change 100644 => 100755 wrt/src/runtime.js diff --git a/wrt/src/extension_manager.js b/wrt/src/extension_manager.js index 21c8cd0..1b9b965 100755 --- a/wrt/src/extension_manager.js +++ b/wrt/src/extension_manager.js @@ -14,7 +14,7 @@ var EXTENSIONS_PATH = process.env.WAS_EXTENSIONS_PATH; if (!EXTENSIONS_PATH) { var resourcePath = __dirname.split('app.asar')[0]; extension_debug('WARNING! WAS_EXTENSIONS_PATH not set - extensions cannot be loaded'); - EXTENSIONS_PATH = path.join(resourcePath, 'wrt_support/extensions'); + EXTENSIONS_PATH = path.join(resourcePath, 'runtime_addon'); extension_debug('Temporarily set WAS_EXTENSIONS_PATH=' + EXTENSIONS_PATH); } diff --git a/wrt/src/runtime.js b/wrt/src/runtime.js old mode 100644 new mode 100755 index 0bdaa49..2c1a1de --- a/wrt/src/runtime.js +++ b/wrt/src/runtime.js @@ -1,4 +1,6 @@ 'use strict'; +const EXTENSIONS_PATH = process.env.WAS_EXTENSIONS_PATH; +const ExtensionManager = require('./extension_manager'); const {app, ipcMain, pwrt} = require('electron'); const IPC_MESSAGE = require('./ipc_message'); const WAS_EVENT = require('./was_event'); @@ -13,15 +15,21 @@ class Runtime { this.quitting = false; this.handleWasEvents(); this.handleIpcMessages(); + this.extensionManager = null; this.isLaunched = false; var _this = this; + app.on('will-finish-launching', function() { + return runtime_debug('will-finish-launching'); + }); app.on('before-quit', function(event) { runtime_debug('before-quit'); - _this.quitting = true; + return _this.quitting = true; }); app.on('will-quit', function(event) { runtime_debug('will-quit'); + this.extensionManager.deactivateAll(app); + return _this.killAllProcesses(); }); app.on('quit', function(event) { return runtime_debug('quit'); @@ -56,10 +64,16 @@ class Runtime { }); app.on('ready', function(event) { runtime_debug('ready'); + this.extensionManager = new ExtensionManager(EXTENSIONS_PATH); + if (!options.noExtensions) { + this.extensionManager.build(); + } if (pwrt.isElectronLaunch()) { + this.extensionManager.activateAll(app); return; } this.webApplication = new WebApplication(options); + this.extensionManager.activateAll(app); }); } onPause(web_window_id) { @@ -81,6 +95,7 @@ class Runtime { onAppControl() {} onLanguageChanged() {} onLowMemory() {} + killAllProcesses() {} handleWasEvents() { var _this = this; events.on(WAS_EVENT.WEBAPPLICATION.RESUME, (sender, id) => { @@ -152,6 +167,23 @@ class Runtime { runtime_debug('handleWasMessages: destroyed ' + id); return app.emit(IPC_MESSAGE.WEBCONTENTS.DESTROYED, id); }); + ipcMain.on(IPC_MESSAGE.EXTENSIONS.INSTALLED, (sender, name) => { + runtime_debug('handleIpcMessages: INSTALLED ' + name); + this.extensionManager.build(); + return this.extensionManager.activate(app, name); + }); + ipcMain.on(IPC_MESSAGE.EXTENSIONS.UNINSTALLED, (sender, name) => { + runtime_debug('handleIpcMessages: UNINSTALLED ' + name); + return this.extensionManager.deactivate(app, name); + }); + ipcMain.on(IPC_MESSAGE.EXTENSIONS.ACTIVATE, (sender, name) => { + runtime_debug('handleIpcMessages: ACTIVATE ' + name); + return this.extensionManager.activate(app, name); + }); + ipcMain.on(IPC_MESSAGE.EXTENSIONS.DEACTIVATE, (sender, name) => { + runtime_debug('handleIpcMessages: DEACTIVATE ' + name); + return this.extensionManager.deactivate(app, name); + }); } } module.exports = Runtime; -- 2.7.4 From bc8a0f7c2d571df8c4a71fa12769978875dca8ac Mon Sep 17 00:00:00 2001 From: "k2.nagaraju" Date: Fri, 20 Apr 2018 09:56:52 +0530 Subject: [PATCH 10/16] 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 From 3ddf2519d1ceb796ce881390185c59bbb595f9eb Mon Sep 17 00:00:00 2001 From: Prathmesh Date: Thu, 7 Jun 2018 12:43:41 +0530 Subject: [PATCH 11/16] Add widget object to electron interface - Generate the idls - Build extension independently and add to extension libs Change-Id: Ida4361a75267341ffca46c4d96369a973311e839 Signed-off-by: Prathmesh --- packaging/electron-efl.spec | 9 ++++- tizen/build/common.gypi | 2 +- tizen/extensions/extensions.gyp | 21 ++++++++++ tizen/tools/generate_api.py | 25 ++++++++++++ tizen/tools/mergejs.py | 89 +++++++++++++++++++++++++++++++++++++++++ wrt.gyp | 7 ++++ 6 files changed, 151 insertions(+), 2 deletions(-) create mode 100644 tizen/tools/generate_api.py create mode 100644 tizen/tools/mergejs.py diff --git a/packaging/electron-efl.spec b/packaging/electron-efl.spec index 7e464c1..93ce41f 100755 --- a/packaging/electron-efl.spec +++ b/packaging/electron-efl.spec @@ -70,13 +70,14 @@ cp %{SOURCE1001} . %define _pkgid org.tizen.%{name} %define _xmldir %TZ_SYS_RO_PACKAGES %define _out out.tizen/out/D +%define extension_path %{_libdir}/tizen-extensions-crosswalk DEFINE_ARGS=" libchromiumcontent_component=1 use_efl=1 is_tizen=1 injected_bundle_path=%{_libdir}/libxwalk_injected_bundle.so - extension_path=%{_libdir}/tizen-extensions-crosswalk + extension_path=%{extension_path} " %if "%{?TIZEN_PRODUCT_TV}" == "1" DEFINE_ARGS+=" @@ -140,6 +141,10 @@ mkdir -p %{buildroot}%{extension_path} install -p -m 644 %{_out}/lib/libxwalk_extension_shared.so %{buildroot}%{_libdir} # xwalk_injected_bundle install -p -m 755 %{_out}/lib/libxwalk_injected_bundle.so %{buildroot}%{_libdir} +# widget plugin +install -p -m 644 %{_out}/lib/libwidget_plugin.so %{buildroot}%{extension_path} +install -p -m 644 %{_out}/gen/widget.json %{buildroot}%{extension_path} + %post # Owner account can't write /opt/usr/home/owner/data/org.tizen.electron-efl # which is created in 'install'. So we should copy resources in 'post'. @@ -172,3 +177,5 @@ rm -fr %{buildroot} %attr(644,root,root) %{_libdir}/libwrt_common.so %attr(644,root,root) %{_libdir}/libxwalk_extension_shared.so %attr(644,root,root) %{_libdir}/libxwalk_injected_bundle.so +%attr(644,root,root) %{extension_path}/libwidget_plugin.so +%attr(644,root,root) %{extension_path}/widget.json diff --git a/tizen/build/common.gypi b/tizen/build/common.gypi index 8b70ac2..6b4560f 100644 --- a/tizen/build/common.gypi +++ b/tizen/build/common.gypi @@ -30,7 +30,7 @@ 'includes': [ 'cynara-client.gypi', 'pkg-config.gypi', -# 'xwalk_js2c.gypi', + 'xwalk_js2c.gypi', ], 'include_dirs': [ '../', diff --git a/tizen/extensions/extensions.gyp b/tizen/extensions/extensions.gyp index 652dfd1..db9f91c 100644 --- a/tizen/extensions/extensions.gyp +++ b/tizen/extensions/extensions.gyp @@ -67,5 +67,26 @@ }, }, }, # end of target 'xwalk_extension_static' + { + 'target_name': 'widget_plugin', + 'type': 'shared_library', + 'sources': [ + 'internal/widget/widget_api.js', + 'internal/widget/widget_extension.cc', + ], + 'variables': { + 'packages': [ + 'dlog', + ], + }, + 'copies': [ + { + 'destination': '<(SHARED_INTERMEDIATE_DIR)', + 'files': [ + 'internal/widget/widget.json' + ], + }, + ], + }, # end of target 'widget_plugin' ], # end of targets } diff --git a/tizen/tools/generate_api.py b/tizen/tools/generate_api.py new file mode 100644 index 0000000..b50adea --- /dev/null +++ b/tizen/tools/generate_api.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python + +# Copyright (c) 2013 Intel Corporation. All rights reserved. +# Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import os +import sys +import subprocess + +TEMPLATE = """\ +extern const char %s[]; +const char %s[] = { %s, 0 }; +""" + +js_code = sys.argv[1] +cmd = "python " + os.path.dirname(__file__) + "/mergejs.py -f" + js_code +lines = subprocess.check_output(cmd, shell=True) +c_code = ', '.join(str(ord(c)) for c in lines) + +symbol_name = sys.argv[2] +output = open(sys.argv[3], "w") +output.write(TEMPLATE % (symbol_name, symbol_name, c_code)) +output.close() diff --git a/tizen/tools/mergejs.py b/tizen/tools/mergejs.py new file mode 100644 index 0000000..fc3dc96 --- /dev/null +++ b/tizen/tools/mergejs.py @@ -0,0 +1,89 @@ +#!/usr/bin/env python + +# Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved. + +import fileinput +import sys +import getopt +import glob +import os + +class Utils: + reqfiles = [] + searchfile = '*_api.js' + startwith = "//= require('" + endwith = "')" + code = "" + + @classmethod + def get_require(self, s): + try: + start = s.index(self.startwith) + len(self.startwith) + end = s.index(self.endwith, start) + filename = s[start:end] + self.reqfiles.append(filename) + except ValueError: + return "" + + @classmethod + def find_require(self): + p = os.path.join('./', self.searchfile) + filenames = glob.glob(self.searchfile) + for fname in filenames: + with open(fname, 'r') as myfile: + for line in myfile: + self.get_require(line) + + @classmethod + def print_lines(self, filename): + with open(filename, 'r') as file: + for line in file: + self.code += line + + @classmethod + def merge_js_files(self, path): + self.find_require() + if len(self.reqfiles) == 0: + s = os.path.join('./', self.searchfile) + sfiles = glob.glob(s) + for fname in sfiles: + self.print_lines(fname) + else: + js = '*.js' + p = os.path.join(path, js) + filenames = glob.glob(p) + for fname in self.reqfiles: + fname = path + '/' + fname + if fname in filenames: + self.print_lines(fname) + + @classmethod + def main(self, argv): + path = 'js' + try: + opts, args = getopt.getopt(argv,"hf:p:",["file=", "path="]) + except getopt.GetoptError: + print __file__ + ' -h' + sys.exit() + if len(argv) > 0: + for opt, arg in opts: + if opt in ("-h"): + print 'Help:' + print '' + print __file__ + '-f -p ' + print '' + print ' \t \t\t ' + print '-f \t --file \t Name of the file where script searching for require files:' + print '\t \t \t ' + self.startwith + 'file_name.js' + self.endwith + print '-p \t --path \t Path to "' + path + '" directory' + print '' + sys.exit() + elif opt in ("-f", "--file"): + self.searchfile = arg + elif opt in ("-p", "--path"): + path = arg + self.merge_js_files(path) + print self.code + +if Utils.__module__ == "__main__": + Utils.main(sys.argv[1:]) diff --git a/wrt.gyp b/wrt.gyp index 663ee2c..38a9337 100644 --- a/wrt.gyp +++ b/wrt.gyp @@ -203,5 +203,12 @@ }, ], }, # target electron_shell_copy + { + 'target_name': 'extension_wrt', + 'type': 'none', + 'dependencies': [ + '<(DEPTH)/tizen/extensions/extensions.gyp:widget_plugin', + ], + }, # end of target 'extension_wrt' ], } -- 2.7.4 From 5a2855d676bcf03507e8f0fc1e74313527cf1a3d Mon Sep 17 00:00:00 2001 From: Prathmesh Date: Thu, 7 Jun 2018 16:31:50 +0530 Subject: [PATCH 12/16] Fix build error in widget object module - Ideally widget module needs to be built separately and not included in "wrt". Same is there in xwalk. - But in electron currently, the build system is tightly coupled with wrt executable, so no module can be build as static_lib separately. - Currently coping widget_object in lib directory so that "wrt" exe will not give linking error. - Need to find way to build widget object as static lib without directly linking to "wrt" exe Change-Id: Ia5a5584f5b2165c1be5b5bd9eafc49a3d45ef195 Signed-off-by: Prathmesh --- packaging/electron-efl.spec | 2 ++ wrt.gyp | 8 +------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/packaging/electron-efl.spec b/packaging/electron-efl.spec index 93ce41f..4f7009a 100755 --- a/packaging/electron-efl.spec +++ b/packaging/electron-efl.spec @@ -143,6 +143,7 @@ install -p -m 644 %{_out}/lib/libxwalk_extension_shared.so %{buildroot}%{_libdir install -p -m 755 %{_out}/lib/libxwalk_injected_bundle.so %{buildroot}%{_libdir} # widget plugin install -p -m 644 %{_out}/lib/libwidget_plugin.so %{buildroot}%{extension_path} +install -p -m 644 %{_out}/lib/libwidget_plugin.so %{buildroot}%{_libdir} install -p -m 644 %{_out}/gen/widget.json %{buildroot}%{extension_path} %post @@ -177,5 +178,6 @@ rm -fr %{buildroot} %attr(644,root,root) %{_libdir}/libwrt_common.so %attr(644,root,root) %{_libdir}/libxwalk_extension_shared.so %attr(644,root,root) %{_libdir}/libxwalk_injected_bundle.so +%attr(644,root,root) %{_libdir}/libwidget_plugin.so %attr(644,root,root) %{extension_path}/libwidget_plugin.so %attr(644,root,root) %{extension_path}/widget.json diff --git a/wrt.gyp b/wrt.gyp index 38a9337..73af0b5 100644 --- a/wrt.gyp +++ b/wrt.gyp @@ -14,6 +14,7 @@ '<(DEPTH)/tizen/common/common.gyp:wrt_common', '<(DEPTH)/tizen/loader/loader.gyp:wrt-loader', '<(DEPTH)/tizen/extensions/extensions.gyp:xwalk_extension_shared', + '<(DEPTH)/tizen/extensions/extensions.gyp:widget_plugin', '<(DEPTH)/tizen/renderer/injected_bundle.gyp:xwalk_injected_bundle', '<(DEPTH)/efl/build/system.gyp:ecore', '<(DEPTH)/efl/build/system.gyp:launchpad', @@ -203,12 +204,5 @@ }, ], }, # target electron_shell_copy - { - 'target_name': 'extension_wrt', - 'type': 'none', - 'dependencies': [ - '<(DEPTH)/tizen/extensions/extensions.gyp:widget_plugin', - ], - }, # end of target 'extension_wrt' ], } -- 2.7.4 From 82c0194dbc7c3c332bc5d2f1823cb3363e9bb9ef Mon Sep 17 00:00:00 2001 From: Prathmesh Date: Fri, 8 Jun 2018 12:10:04 +0530 Subject: [PATCH 13/16] Add splash screen object to electron interface - Build and generate idl's - Make splash screen object avaliable Change-Id: I01785552dad600a38b5e13485bfbdabfc6ba68a1 Signed-off-by: Prathmesh --- packaging/electron-efl.spec | 15 +++++++++++++-- tizen/extensions/extensions.gyp | 21 +++++++++++++++++++++ wrt.gyp | 1 + 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/packaging/electron-efl.spec b/packaging/electron-efl.spec index 4f7009a..91e9ae0 100755 --- a/packaging/electron-efl.spec +++ b/packaging/electron-efl.spec @@ -143,8 +143,15 @@ install -p -m 644 %{_out}/lib/libxwalk_extension_shared.so %{buildroot}%{_libdir install -p -m 755 %{_out}/lib/libxwalk_injected_bundle.so %{buildroot}%{_libdir} # widget plugin install -p -m 644 %{_out}/lib/libwidget_plugin.so %{buildroot}%{extension_path} -install -p -m 644 %{_out}/lib/libwidget_plugin.so %{buildroot}%{_libdir} install -p -m 644 %{_out}/gen/widget.json %{buildroot}%{extension_path} +# Need to remove the below line later +install -p -m 644 %{_out}/lib/libwidget_plugin.so %{buildroot}%{_libdir} + +# screen_plugin +install -p -m 644 %{_out}/lib/libsplash_screen_plugin.so %{buildroot}%{extension_path} +install -p -m 644 %{_out}/gen/splash_screen.json %{buildroot}%{extension_path} +# Need to remove the below line later +install -p -m 644 %{_out}/lib/libsplash_screen_plugin.so %{buildroot}%{_libdir} %post # Owner account can't write /opt/usr/home/owner/data/org.tizen.electron-efl @@ -178,6 +185,10 @@ rm -fr %{buildroot} %attr(644,root,root) %{_libdir}/libwrt_common.so %attr(644,root,root) %{_libdir}/libxwalk_extension_shared.so %attr(644,root,root) %{_libdir}/libxwalk_injected_bundle.so -%attr(644,root,root) %{_libdir}/libwidget_plugin.so %attr(644,root,root) %{extension_path}/libwidget_plugin.so %attr(644,root,root) %{extension_path}/widget.json +%attr(644,root,root) %{extension_path}/libsplash_screen_plugin.so +%attr(644,root,root) %{extension_path}/splash_screen.json +# Need to remove these below lines later +%attr(644,root,root) %{_libdir}/libwidget_plugin.so +%attr(644,root,root) %{_libdir}/libsplash_screen_plugin.so diff --git a/tizen/extensions/extensions.gyp b/tizen/extensions/extensions.gyp index db9f91c..d22c755 100644 --- a/tizen/extensions/extensions.gyp +++ b/tizen/extensions/extensions.gyp @@ -88,5 +88,26 @@ }, ], }, # end of target 'widget_plugin' + { + 'target_name': 'splash_screen_plugin', + 'type': 'shared_library', + 'sources': [ + 'internal/splash_screen/splash_screen_api.js', + 'internal/splash_screen/splash_screen_extension.cc', + ], + 'variables': { + 'packages': [ + 'dlog', + ], + }, + 'copies': [ + { + 'destination': '<(SHARED_INTERMEDIATE_DIR)', + 'files': [ + 'internal/splash_screen/splash_screen.json' + ], + }, + ], + }, # end of target 'splash_screen_plugin' ], # end of targets } diff --git a/wrt.gyp b/wrt.gyp index 73af0b5..eef72f2 100644 --- a/wrt.gyp +++ b/wrt.gyp @@ -15,6 +15,7 @@ '<(DEPTH)/tizen/loader/loader.gyp:wrt-loader', '<(DEPTH)/tizen/extensions/extensions.gyp:xwalk_extension_shared', '<(DEPTH)/tizen/extensions/extensions.gyp:widget_plugin', + '<(DEPTH)/tizen/extensions/extensions.gyp:splash_screen_plugin', '<(DEPTH)/tizen/renderer/injected_bundle.gyp:xwalk_injected_bundle', '<(DEPTH)/efl/build/system.gyp:ecore', '<(DEPTH)/efl/build/system.gyp:launchpad', -- 2.7.4 From 475a0fa2d8341b1aad49dbbb0060912e763c404e Mon Sep 17 00:00:00 2001 From: SangYong Park Date: Mon, 9 Apr 2018 19:57:11 +0900 Subject: [PATCH 14/16] Initial service app implementation . add wrt-service executable . change PWRT mate type to EventEmitter (TrackableObject cannot be instantiated without chromium.) Change-Id: I2464fc12da1dcb7b85e70fcda950dd894222653f Signed-off-by: SangYong Park --- atom/app/ui_runtime.cc | 8 +- atom/browser/api/atom_api_pwrt.cc | 117 --------------- atom/browser/api/atom_api_pwrt.h | 38 ----- atom/browser/browser.cc | 40 ++--- atom/browser/browser.h | 21 +-- atom/common/node_bindings.cc | 4 +- lib/browser/api/module-list.js | 3 +- lib/browser/api/pwrt.js | 3 - lib/browser/init.js | 15 -- packaging/dbus.service | 5 + packaging/electron-efl.spec | 29 ++-- packaging/systemd.service | 10 ++ tizen/common.gypi | 7 +- tizen/common/application_data.cc | 70 +++++---- tizen/common/application_data.h | 23 +-- tizen/common/logger.h | 2 +- tizen/extensions/common/xwalk_extension_server.cc | 1 - tizen/extensions/extensions.gyp | 2 +- tizen/loader/wrt_loader.cc | 2 +- tizen/renderer/injected_bundle.cc | 9 +- tizen/src/app/service_main.cc | 95 ++++++++++++ tizen/src/browser/api/wrt_api_core.cc | 122 ++++++++++++++++ tizen/src/browser/api/wrt_api_core.h | 42 ++++++ tizen/src/browser/wrt_ipc.cc | 170 ++++++++++++++++++++++ tizen/src/browser/wrt_ipc.h | 48 ++++++ tizen/src/browser/wrt_service.cc | 75 ++++++++++ tizen/src/browser/wrt_service.h | 47 ++++++ tizen/src/wrt_main.cc | 136 ++--------------- vendor/node/src/node.cc | 7 + wrt.gyp | 33 ++++- wrt/browser/wrt.js | 21 +++ wrt/service/main.js | 15 ++ wrt/src/main.js | 3 +- wrt/src/runtime.js | 9 +- wrt/src/web_window.js | 8 +- 35 files changed, 805 insertions(+), 435 deletions(-) delete mode 100644 atom/browser/api/atom_api_pwrt.cc delete mode 100644 atom/browser/api/atom_api_pwrt.h delete mode 100644 lib/browser/api/pwrt.js create mode 100644 packaging/dbus.service create mode 100644 packaging/systemd.service create mode 100644 tizen/src/app/service_main.cc create mode 100644 tizen/src/browser/api/wrt_api_core.cc create mode 100644 tizen/src/browser/api/wrt_api_core.h create mode 100644 tizen/src/browser/wrt_ipc.cc create mode 100644 tizen/src/browser/wrt_ipc.h create mode 100644 tizen/src/browser/wrt_service.cc create mode 100644 tizen/src/browser/wrt_service.h create mode 100644 wrt/browser/wrt.js create mode 100644 wrt/service/main.js diff --git a/atom/app/ui_runtime.cc b/atom/app/ui_runtime.cc index 27f7e0e..9bde160 100644 --- a/atom/app/ui_runtime.cc +++ b/atom/app/ui_runtime.cc @@ -55,12 +55,7 @@ void UiRuntime::SetParam(content::ContentMainParams *params) { } bool UiRuntime::OnCreate() { - common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess(); - std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/electron"); - - auto appdata_manager = common::ApplicationDataManager::GetInstance(); - common::ApplicationData* appdata = appdata_manager->GetApplicationData(appid); - + auto appdata = common::ApplicationDataManager::GetCurrentAppData(); if(appdata->splash_screen_info()){ atom::Browser* browser_model = atom::Browser::Get(); browser_model->SetSplashScreen(); @@ -71,7 +66,6 @@ bool UiRuntime::OnCreate() { void UiRuntime::OnTerminate() { LOG(ERROR) << "OnTerminate()"; - atom::Browser *browser_model = atom::Browser::Get(); } void UiRuntime::OnPause() { diff --git a/atom/browser/api/atom_api_pwrt.cc b/atom/browser/api/atom_api_pwrt.cc deleted file mode 100644 index d23679c..0000000 --- a/atom/browser/api/atom_api_pwrt.cc +++ /dev/null @@ -1,117 +0,0 @@ -#include "atom/browser/api/atom_api_pwrt.h" - -#include "atom/browser/browser.h" -#include "native_mate/dictionary.h" -#include "base/logging.h" - -#include "atom/common/node_includes.h" -#include "tizen/common/application_data.h" -#include "tizen/common/command_line.h" -#include - -namespace atom { - -namespace api { - -PWRT::PWRT(v8::Isolate* isolate) { - LOG(ERROR) << "PWRT::PWRT"; - Init(isolate); -} - -PWRT::~PWRT() { - LOG(ERROR) << "PWRT::~PWRT"; -} - -std::string PWRT::GetMessage() { - LOG(ERROR) << "PWRT::GetMessage"; - return "message from C++"; -} - -std::string PWRT::GetPath() { - LOG(ERROR) << "PWRT::GetPath"; - common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess(); - if (runtime_cmd) { - std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/electron"); - auto appdata_manager = common::ApplicationDataManager::GetInstance(); - common::ApplicationData* app_data = appdata_manager->GetApplicationData(appid); - // TODO: Use resource-manager's GetStartResource() for localized urls - // 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 ""; -} - -bool PWRT::isTizenWebApp() { - LOG(ERROR) << "PWRT::isTizenWebApp"; - common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess(); - std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/electron"); - if (appid != "electron") { // TODO: Any better distinguishing feature? - return true; - } else { - return false; - } -} - -bool PWRT::isElectronLaunch() { - return Browser::Get()->is_electron_launch(); -} - -void PWRT::HideSplashScreen(int reason) { - LOG(ERROR) << "PWRT::HideSplashScreen"; - atom::Browser *browser_model = atom::Browser::Get(); - browser_model->HideSplashScreen(reason); -} - -void PWRT::Log(const std::string& message) { - std::string output = "[JS LOG] " + message; - dlog_print(DLOG_ERROR, "WRT", output.c_str()); -} - -// static -mate::Handle PWRT::Create(v8::Isolate* isolate) { - LOG(ERROR) << "PWRT::Create"; - return mate::CreateHandle(isolate, new PWRT(isolate)); -} - -// static -void PWRT::BuildPrototype( - v8::Isolate* isolate, v8::Local prototype) { - LOG(ERROR) << "PWRT::BuildPrototype"; - prototype->SetClassName(mate::StringToV8(isolate, "PWRT")); - // TODO: Needs adding necessary interface methods - mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate()) - .SetMethod("getMessage", &PWRT::GetMessage) - .SetMethod("getPath", &PWRT::GetPath) - .SetMethod("isTizenWebApp", &PWRT::isTizenWebApp) - .SetMethod("isElectronLaunch", &PWRT::isElectronLaunch) - .SetMethod("hideSplashScreen", &PWRT::HideSplashScreen) - .SetMethod("log", &PWRT::Log); -} - -} // namespace api - -} // namespace atom - - -namespace { - -void Initialize(v8::Local exports, v8::Local unused, - v8::Local context, void* priv) { - LOG(ERROR) << "PWRT::Initialize"; - v8::Isolate* isolate = context->GetIsolate(); - mate::Dictionary dict(isolate, exports); - // TODO: Expose this attribute only for Tizen web apps - dict.Set("pwrt", atom::api::PWRT::Create(isolate)); -} - -} // namespace - -NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_pwrt, Initialize) diff --git a/atom/browser/api/atom_api_pwrt.h b/atom/browser/api/atom_api_pwrt.h deleted file mode 100644 index ab25f34..0000000 --- a/atom/browser/api/atom_api_pwrt.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef ATOM_BROWSER_API_ATOM_API_PWRT_H_ -#define ATOM_BROWSER_API_ATOM_API_PWRT_H_ - -#include "atom/browser/api/trackable_object.h" -#include "base/compiler_specific.h" -#include "native_mate/handle.h" - -namespace atom { - -namespace api { - -class PWRT : public mate::TrackableObject { - public: - static mate::Handle Create(v8::Isolate* isolate); - - static void BuildPrototype(v8::Isolate* isolate, - v8::Local prototype); - - std::string GetMessage(); - std::string GetPath(); - bool isTizenWebApp(); - bool isElectronLaunch(); - void HideSplashScreen(int reason); - void Log(const std::string& message); - - protected: - explicit PWRT(v8::Isolate* isolate); - ~PWRT() override; - - private: - DISALLOW_COPY_AND_ASSIGN(PWRT); -}; - -} // namespace api - -} // namespace atom - -#endif // ATOM_BROWSER_API_ATOM_API_PWRT_H_ diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index b26b0e6..1110602 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -30,13 +30,13 @@ namespace atom { Browser::Browser() : is_quiting_(false), #if defined(OS_TIZEN) + locale_manager_(new common::LocaleManager()), + launched_(false), is_electron_launch_(false), #endif is_exiting_(false), is_ready_(false), - is_shutdown_(false), - launched_(false), - locale_manager_(new common::LocaleManager()) { + is_shutdown_(false) { WindowList::AddObserver(this); } @@ -127,10 +127,7 @@ void Browser::Shutdown() { #if defined(OS_TIZEN) void Browser::SetElectronAppLaunch() { if (!is_electron_launch_) { - common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess(); - std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/electron"); - auto appdata_manager = common::ApplicationDataManager::GetInstance(); - common::ApplicationData* app_data = appdata_manager->GetApplicationData(appid); + auto app_data = common::ApplicationDataManager::GetCurrentAppData(); if (app_data->content_info() && !strcmp(app_data->content_info()->src().c_str(), "package.json")) { is_electron_launch_ = true; } @@ -274,16 +271,8 @@ void Browser::Show() { } void Browser::Initialize() { - common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess(); - std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/electron"); - //TODO: update the appid from binary name to electron - if (appid != "electron") { - auto appdata_manager = common::ApplicationDataManager::GetInstance(); - common::ApplicationData* appdata = appdata_manager->GetApplicationData(appid); - - resource_manager_.reset( - new common::ResourceManager(appdata, locale_manager_.get())); - } + auto appdata = common::ApplicationDataManager::GetCurrentAppData(); + resource_manager_.reset(new common::ResourceManager(appdata, locale_manager_.get())); } void Browser::AppControl(std::unique_ptr appcontrol) { @@ -324,14 +313,10 @@ void Browser::Launch(std::unique_ptr appcontrol) { launched_ = true; //To do:Implementation of relaunching of app } + #if defined(OS_TIZEN) void Browser::SetSplashScreen() { - common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess(); - std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/electron"); - - auto appdata_manager = common::ApplicationDataManager::GetInstance(); - common::ApplicationData* appdata = appdata_manager->GetApplicationData(appid); - + auto appdata = common::ApplicationDataManager::GetCurrentAppData(); Evas_Object* window_ = elm_win_util_standard_add("", ""); splash_screen_.reset( @@ -340,13 +325,8 @@ void Browser::SetSplashScreen() { } void Browser::HideSplashScreen(int reason) { - common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess(); - std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/electron"); - - auto appdata_manager = common::ApplicationDataManager::GetInstance(); - common::ApplicationData* appdata = appdata_manager->GetApplicationData(appid); - - if(appdata->splash_screen_info() == NULL) { + auto appdata = common::ApplicationDataManager::GetCurrentAppData(); + if (!appdata->splash_screen_info()) { return; } diff --git a/atom/browser/browser.h b/atom/browser/browser.h index c089fff..0e759e6 100644 --- a/atom/browser/browser.h +++ b/atom/browser/browser.h @@ -50,13 +50,6 @@ class Browser : public WindowListObserver { static Browser* Get(); - std::unique_ptr resource_manager_; - std::unique_ptr locale_manager_; -#if defined(OS_TIZEN) - std::unique_ptr splash_screen_; -#endif // defined(OS_TIZEN) - - void Initialize(); // Try to close all windows and quit the application. void Quit(); @@ -254,8 +247,6 @@ class Browser : public WindowListObserver { bool is_quiting_; - bool launched_; - private: // WindowListObserver implementations: void OnWindowCloseCancelled(NativeWindow* window) override; @@ -268,6 +259,14 @@ class Browser : public WindowListObserver { // Observers of the browser. base::ObserverList observers_; +#if defined(OS_TIZEN) + std::unique_ptr resource_manager_; + std::unique_ptr locale_manager_; + std::unique_ptr splash_screen_; + bool launched_; + bool is_electron_launch_; +#endif + // Whether `app.exit()` has been called bool is_exiting_; @@ -277,10 +276,6 @@ class Browser : public WindowListObserver { // The browser is being shutdown. bool is_shutdown_; -#if defined(OS_TIZEN) - bool is_electron_launch_; -#endif - std::string version_override_; std::string name_override_; diff --git a/atom/common/node_bindings.cc b/atom/common/node_bindings.cc index 2a9c057..e61b6eb 100644 --- a/atom/common/node_bindings.cc +++ b/atom/common/node_bindings.cc @@ -47,7 +47,6 @@ REFERENCE_MODULE(atom_browser_net); REFERENCE_MODULE(atom_browser_power_monitor); REFERENCE_MODULE(atom_browser_power_save_blocker); REFERENCE_MODULE(atom_browser_protocol); -REFERENCE_MODULE(atom_browser_pwrt); REFERENCE_MODULE(atom_browser_render_process_preferences); REFERENCE_MODULE(atom_browser_session); REFERENCE_MODULE(atom_browser_system_preferences); @@ -84,8 +83,7 @@ std::unique_ptr StringVectorToArgArray( base::FilePath GetResourcesPath(bool is_browser) { #if defined(OS_TIZEN) - // TODO: We should fix hardcoded path. - return base::FilePath("/opt/usr/home/owner/data/electron"); + return base::FilePath(FILE_PATH_LITERAL(TIZEN_RESOURCE_PATH)); #endif auto command_line = base::CommandLine::ForCurrentProcess(); base::FilePath exec_path(command_line->GetProgram()); diff --git a/lib/browser/api/module-list.js b/lib/browser/api/module-list.js index fcc07b3..64b2829 100644 --- a/lib/browser/api/module-list.js +++ b/lib/browser/api/module-list.js @@ -21,6 +21,5 @@ module.exports = [ {name: 'Tray', file: 'tray'}, {name: 'webContents', file: 'web-contents'}, // The internal modules, invisible unless you know their names. - {name: 'NavigationController', file: 'navigation-controller', private: true}, - {name: 'pwrt', file: 'pwrt', private: true} + {name: 'NavigationController', file: 'navigation-controller', private: true} ] diff --git a/lib/browser/api/pwrt.js b/lib/browser/api/pwrt.js deleted file mode 100644 index 0019884..0000000 --- a/lib/browser/api/pwrt.js +++ /dev/null @@ -1,3 +0,0 @@ -const {pwrt} = process.atomBinding('pwrt'); - -module.exports = pwrt diff --git a/lib/browser/init.js b/lib/browser/init.js index 6c8ac89..cfcf26f 100644 --- a/lib/browser/init.js +++ b/lib/browser/init.js @@ -42,21 +42,6 @@ if (process.platform === 'win32') { process.stdout.write = process.stderr.write = streamWrite } -let {pwrt} = require('electron'); -console.log = console.error = console.warn = function(...args) { - pwrt.log(util.format(...args)); -}; -process.stdout.write = process.stderr.write = function (chunk, encoding, callback) { - if (Buffer.isBuffer(chunk)) { - chunk = chunk.toString(encoding) - } - pwrt.log(chunk) - if (callback) { - callback() - } - return true -} - // Don't quit on fatal error. process.on('uncaughtException', function (error) { // Do nothing if the user has a custom uncaught exception handler. diff --git a/packaging/dbus.service b/packaging/dbus.service new file mode 100644 index 0000000..5d1ba5e --- /dev/null +++ b/packaging/dbus.service @@ -0,0 +1,5 @@ +[D-BUS Service] +Name=org.tizen.wrt +User=owner +Exec=/bin/false +SystemdService=wrt.service diff --git a/packaging/electron-efl.spec b/packaging/electron-efl.spec index 91e9ae0..fad12e0 100755 --- a/packaging/electron-efl.spec +++ b/packaging/electron-efl.spec @@ -70,12 +70,14 @@ cp %{SOURCE1001} . %define _pkgid org.tizen.%{name} %define _xmldir %TZ_SYS_RO_PACKAGES %define _out out.tizen/out/D +%define _resourcedir /opt/usr/home/owner/data/wrt %define extension_path %{_libdir}/tizen-extensions-crosswalk DEFINE_ARGS=" libchromiumcontent_component=1 use_efl=1 is_tizen=1 + tizen_resource_path=%{_resourcedir} injected_bundle_path=%{_libdir}/libxwalk_injected_bundle.so extension_path=%{extension_path} " @@ -124,16 +126,22 @@ install -m 0644 packaging/%{_pkgid}.png %{buildroot}/%{_icondir} install -m 0755 %{_out}/lib/libnode.so %{buildroot}/%{_libdir} install -m 0755 %{_out}/wrt-loader %{buildroot}/%{_bindir} install -m 0755 %{_out}/wrt %{buildroot}/%{_bindir} +install -m 0755 %{_out}/wrt-service %{buildroot}/%{_bindir} ln -s %{_bindir}/wrt %{buildroot}%{_bindir}/wrt-client -ln -s %{_bindir}/wrt %{buildroot}%{_bindir}/xwalk_runtime # install resource. -mkdir -p %{buildroot}/opt/usr/home/owner/data/org.tizen.electron-efl -install -m 0755 %{_out}/resources/electron.asar %{buildroot}/opt/usr/home/owner/data/org.tizen.electron-efl +mkdir -p %{buildroot}%{_resourcedir} +install -m 0755 %{_out}/resources/electron.asar %{buildroot}%{_resourcedir} ./node_modules/asar/bin/asar p wrt %{_out}/resources/app.asar -install -m 0755 %{_out}/resources/app.asar %{buildroot}/opt/usr/home/owner/data/org.tizen.electron-efl +install -m 0755 %{_out}/resources/app.asar %{buildroot}%{_resourcedir} + +mkdir -p %{buildroot}%{_unitdir_user} +install -m 0644 packaging/systemd.service %{buildroot}%{_unitdir_user}/wrt.service + +mkdir -p %{buildroot}%{_datadir}/dbus-1/services +install -m 0644 packaging/dbus.service %{buildroot}%{_datadir}/dbus-1/services/org.tizen.wrt.service # injected bundle and extensions mkdir -p %{buildroot}%{extension_path} @@ -154,33 +162,28 @@ install -p -m 644 %{_out}/gen/splash_screen.json %{buildroot}%{extension_path} install -p -m 644 %{_out}/lib/libsplash_screen_plugin.so %{buildroot}%{_libdir} %post -# Owner account can't write /opt/usr/home/owner/data/org.tizen.electron-efl -# which is created in 'install'. So we should copy resources in 'post'. -cp -rf /opt/usr/home/owner/data/org.tizen.electron-efl /opt/usr/home/owner/data/electron -chown -R owner:users /opt/usr/home/owner/data/electron -rm -rf /opt/usr/home/owner/data/org.tizen.electron-efl - # FIXME: Until electron-efl is released to platform, # following command is needed to set wrt-loader # as cap_setgid,cap_sys_admin+ei. /usr/share/security-config/set_capability %postun -rm -rf /opt/usr/home/owner/data/electron %clean rm -fr %{buildroot} %files %manifest packaging/electron-efl.manifest -/opt/usr/home/owner/data/org.tizen.electron-efl/* +%{_resourcedir}/* %{_icondir}/%{_pkgid}.png %{_libdir}/libnode.so %{_xmldir}/%{_pkgid}.xml +%{_unitdir_user}/wrt.service +%{_datadir}/dbus-1/services/org.tizen.wrt.service %attr(755,root,root) %{_bindir}/wrt %attr(755,root,root) %{_bindir}/wrt-client +%attr(755,root,root) %{_bindir}/wrt-service %attr(755,root,root) %{_bindir}/wrt-loader -%attr(755,root,root) %{_bindir}/xwalk_runtime %attr(644,root,root) %{_datadir}/aul/wrt.loader %attr(644,root,root) %{_libdir}/libwrt_common.so %attr(644,root,root) %{_libdir}/libxwalk_extension_shared.so diff --git a/packaging/systemd.service b/packaging/systemd.service new file mode 100644 index 0000000..774fa29 --- /dev/null +++ b/packaging/systemd.service @@ -0,0 +1,10 @@ +[Unit] +Description=WRT daemon + +[Service] +Type=dbus +BusName=org.tizen.wrt +ExecStart=/usr/bin/wrt-service + +[Install] +WantedBy=default.target diff --git a/tizen/common.gypi b/tizen/common.gypi index b0c2055..5ec020d 100644 --- a/tizen/common.gypi +++ b/tizen/common.gypi @@ -7,6 +7,7 @@ 'clang%': 0, 'use_efl%': 0, 'is_tizen%': 0, + 'tizen_resource_path%': '', 'tizen_product_tv%': 0, }, 'conditions': [ @@ -16,16 +17,12 @@ 'USE_EFL', ], }, - 'variables': { - 'js_sources': [ - '<(DEPTH)/lib/browser/api/pwrt.js', - ], - }, }], # use_efl==1 ['is_tizen==1', { 'target_defaults': { 'defines': [ 'OS_TIZEN', + 'TIZEN_RESOURCE_PATH="<(tizen_resource_path)"', ], }, 'variables': { diff --git a/tizen/common/application_data.cc b/tizen/common/application_data.cc index 48b4f3a..13ecf5c 100644 --- a/tizen/common/application_data.cc +++ b/tizen/common/application_data.cc @@ -43,14 +43,10 @@ const char* kWearableClockCategory = "http://tizen.org/category/wearable_clock"; } // namespace -ApplicationData::ApplicationData(const std::string& appid) - : app_id_(appid), loaded_(false) { +ApplicationData::ApplicationData(const std::string& app_id) { SCOPE_PROFILE(); - char* res_path = app_get_resource_path(); - if (res_path != NULL) { - application_path_ = std::string(res_path) + kWgtPath + kPathSeparator; - free(res_path); - } + if (init()) + app_id_ = app_id; } ApplicationData::~ApplicationData() {} @@ -118,6 +114,19 @@ std::shared_ptr ApplicationData::csp_report_info() return csp_report_info_; } +const wgt::parse::ServiceInfo* ApplicationData::service_info() const { + if (!service_list_) + return nullptr; + auto iter = service_list_->services.begin(); + auto end = service_list_->services.end(); + for (; iter != end; ++iter) { + if (app_id_ == iter->id()) { + return &*iter; + } + } + return nullptr; +} + const std::string ApplicationData::pkg_id() const { if (pkg_id_.empty()) { app_info_h app_info; @@ -153,13 +162,12 @@ ApplicationData::AppType ApplicationData::GetAppType() { return UI; } -bool ApplicationData::LoadManifestData() { - if (loaded_) { - return true; +bool ApplicationData::init() { + std::unique_ptr res_path(app_get_resource_path()); + if (res_path) { + application_path_ = std::string(res_path.get()) + kWgtPath + kPathSeparator; } - SCOPE_PROFILE(); - std::string config_xml_path(application_path_ + kConfigXml); if (!utils::Exists(config_xml_path)) { LOGGER(ERROR) << "Failed to load manifest data : No such file '" @@ -227,6 +235,9 @@ bool ApplicationData::LoadManifestData() { widget_config_parser->GetManifestData( wgt::parse::CSPInfo::Report_only_key())); + service_list_ = std::static_pointer_cast( + widget_config_parser->GetManifestData(wgt::parse::ServiceInfo::Key())); + // Set default empty object if (widget_info_.get() == NULL) { widget_info_.reset(new wgt::parse::WidgetInfo); @@ -236,28 +247,35 @@ bool ApplicationData::LoadManifestData() { } app_type_ = GetAppType(); - loaded_ = true; return true; } // static -ApplicationDataManager* ApplicationDataManager::GetInstance() { - static ApplicationDataManager self; - return &self; +ApplicationDataManager& ApplicationDataManager::GetInstance() { + static ApplicationDataManager manager; + return manager; } -ApplicationDataManager::ApplicationDataManager() {} - -ApplicationDataManager::~ApplicationDataManager() {} - -ApplicationData* ApplicationDataManager::GetApplicationData( - const std::string& appid) { - auto it = cache_.find(appid); - if (it == cache_.end()) { - cache_[appid].reset(new ApplicationData(appid)); +// static +ApplicationData* ApplicationDataManager::SetCurrentAppID( + const std::string& app_id) { + ApplicationDataManager& manager = GetInstance(); + auto it = manager.cache_.find(app_id); + if (it == manager.cache_.end()) { + std::unique_ptr data(new ApplicationData(app_id)); + if (!data->app_id().empty()) { + manager.cache_[app_id] = std::move(data); + manager.current_ = manager.cache_[app_id].get(); + } } - return cache_[appid].get(); + return manager.cache_[app_id].get(); +} + +// static +ApplicationData* ApplicationDataManager::GetCurrentAppData() { + ApplicationDataManager& manager = GetInstance(); + return manager.current_; } } // namespace common diff --git a/tizen/common/application_data.h b/tizen/common/application_data.h index 8f43cae..0429eb0 100644 --- a/tizen/common/application_data.h +++ b/tizen/common/application_data.h @@ -43,11 +43,9 @@ class ApplicationData { public: enum AppType { UI = 0, IME, WATCH }; - explicit ApplicationData(const std::string& appid); + explicit ApplicationData(const std::string& app_id); ~ApplicationData(); - bool LoadManifestData(); - std::shared_ptr app_control_info_list() const; std::shared_ptr category_info_list() @@ -66,6 +64,7 @@ class ApplicationData { std::shared_ptr warp_info() const; std::shared_ptr csp_info() const; std::shared_ptr csp_report_info() const; + const wgt::parse::ServiceInfo* service_info() const; const std::string application_path() const { return application_path_; } const std::string pkg_id() const; @@ -73,6 +72,9 @@ class ApplicationData { ApplicationData::AppType app_type() { return app_type_; } private: + bool init(); + ApplicationData::AppType GetAppType(); + std::shared_ptr app_control_info_list_; std::shared_ptr category_info_list_; std::shared_ptr meta_data_info_; @@ -88,26 +90,27 @@ class ApplicationData { std::shared_ptr warp_info_; std::shared_ptr csp_info_; std::shared_ptr csp_report_info_; - ApplicationData::AppType GetAppType(); + std::shared_ptr service_list_; std::string application_path_; mutable std::string pkg_id_; std::string app_id_; ApplicationData::AppType app_type_; - bool loaded_; }; class ApplicationDataManager { public: - static ApplicationDataManager* GetInstance(); - - ApplicationData* GetApplicationData(const std::string& appid); + static ApplicationData* SetCurrentAppID(const std::string& app_id); + static ApplicationData* GetCurrentAppData(); private: - ApplicationDataManager(); - virtual ~ApplicationDataManager(); + static ApplicationDataManager& GetInstance(); + + ApplicationDataManager() : current_(nullptr) {}; + virtual ~ApplicationDataManager() {}; std::map> cache_; + ApplicationData* current_; }; } // namespace common diff --git a/tizen/common/logger.h b/tizen/common/logger.h index bce7013..029db80 100644 --- a/tizen/common/logger.h +++ b/tizen/common/logger.h @@ -21,7 +21,7 @@ #include #undef LOGGER_TAG -#define LOGGER_TAG "ELECTRON" +#define LOGGER_TAG "WRT" #define _LOGGER_LOG(prio, fmt, args...) \ LOG_(LOG_ID_MAIN, prio, LOGGER_TAG, fmt, ##args) diff --git a/tizen/extensions/common/xwalk_extension_server.cc b/tizen/extensions/common/xwalk_extension_server.cc index 06c45e0..4c3b9fd 100644 --- a/tizen/extensions/common/xwalk_extension_server.cc +++ b/tizen/extensions/common/xwalk_extension_server.cc @@ -8,7 +8,6 @@ #include -#include "atom/common/api/api_messages.h" #include "common/logger.h" #include "common/profiler.h" #include "common/string_utils.h" diff --git a/tizen/extensions/extensions.gyp b/tizen/extensions/extensions.gyp index d22c755..ed7b380 100644 --- a/tizen/extensions/extensions.gyp +++ b/tizen/extensions/extensions.gyp @@ -43,6 +43,7 @@ 'packages': [ 'chromium-efl', 'elementary', + 'jsoncpp', ], }, 'include_dirs': [ @@ -62,7 +63,6 @@ # ], 'variables': { 'packages': [ - 'jsoncpp', ], }, }, diff --git a/tizen/loader/wrt_loader.cc b/tizen/loader/wrt_loader.cc index 1e756e0..1d37333 100644 --- a/tizen/loader/wrt_loader.cc +++ b/tizen/loader/wrt_loader.cc @@ -22,7 +22,7 @@ int main(int argc, char* argv[]) { dlog_print(DLOG_INFO, "CHROMIUM", "Begin wrt-loader"); void* handle = dlopen("/usr/bin/wrt", RTLD_NOW); if (!handle) { - dlog_print(DLOG_ERROR, "CHROMIUM", "Failed to load electorn"); + dlog_print(DLOG_ERROR, "CHROMIUM", "Failed to load wrt (%s)", dlerror()); return false; } diff --git a/tizen/renderer/injected_bundle.cc b/tizen/renderer/injected_bundle.cc index e3ee3c9..c7e5061 100644 --- a/tizen/renderer/injected_bundle.cc +++ b/tizen/renderer/injected_bundle.cc @@ -52,11 +52,8 @@ class BundleGlobalData { void Initialize(const std::string& app_id) { PreInitialize(); - auto appdata_manager = common::ApplicationDataManager::GetInstance(); - common::ApplicationData* app_data = - appdata_manager->GetApplicationData(app_id); + auto app_data = common::ApplicationDataManager::SetCurrentAppID(app_id); - app_data->LoadManifestData(); // PreInitialized locale_manager_.reset(new common::LocaleManager); locale_manager_->EnableAutoUpdate(true); if (app_data->widget_info() != NULL && @@ -100,9 +97,7 @@ extern "C" void DynamicSetWidgetInfo(const char* tizen_id) { runtime::BundleGlobalData::GetInstance()->Initialize(tizen_id); extensions::XWalkExtensionRendererController& controller = extensions::XWalkExtensionRendererController::GetInstance(); - auto appdata_manager = common::ApplicationDataManager::GetInstance(); - common::ApplicationData* app_data = - appdata_manager->GetApplicationData(tizen_id); + auto app_data = common::ApplicationDataManager::GetCurrentAppData(); controller.LoadUserExtensions(app_data->application_path()); } diff --git a/tizen/src/app/service_main.cc b/tizen/src/app/service_main.cc new file mode 100644 index 0000000..4c1d84a --- /dev/null +++ b/tizen/src/app/service_main.cc @@ -0,0 +1,95 @@ +#include + +#include "atom/app/node_main.h" +#include "base/at_exit.h" +#include "base/files/file_path.h" +#include "base/i18n/icu_util.h" +#include "base/logging.h" +#include "base/path_service.h" +#include "tizen/common/application_data.h" +#include "tizen/src/browser/wrt_ipc.h" +#include "tizen/src/browser/wrt_service.h" +#include "vendor/node/deps/uv/include/uv.h" + +#define REFERENCE_MODULE(name) \ + extern "C" void _register_ ## name(void); \ + void (*wrt_register_ ## name)(void) = _register_ ## name +REFERENCE_MODULE(atom_common_asar); +REFERENCE_MODULE(wrt); +#undef REFERENCE_MODULE + +int ServiceDaemon() { + tizen::ServiceManager::Get(); + + uv_thread_t dbus_thread; + uv_thread_create(&dbus_thread, [](void* data) { + tizen::IPC ipc(true); + ipc.AddMessageHandler("StartService", [](const char*, const char* app_id, const tizen::IPC::Message& message) { + tizen::ServiceManager::Get()->Prepare(app_id, message.Sender()); + }); + ipc.Listen(); + }, nullptr); + + base::i18n::InitializeICU(); + base::AtExitManager atexit_manager; + + PathService::Override(base::DIR_EXE, base::FilePath("/usr/lib/chromium-efl/")); + + std::string resource_path(TIZEN_RESOURCE_PATH); + resource_path += "/app.asar/service/main.js"; + + char* arguments[] = { "wrtd", const_cast(resource_path.c_str()) }; + atom::NodeMain(sizeof(arguments) / sizeof(char*), arguments); + + LOG(ERROR) << "WRT deamon is terminated"; + return 0; +} + +int ServiceClient(const std::string& app_id) { + tizen::IPC ipc; + if (!ipc.SendMessage("StartService", app_id.c_str())) { + return 1; + } + + ipc.AddMessageHandler("ReadFile", [](const char*, const char* argument, const tizen::IPC::Message& message) { + std::string file(argument); + auto app_data = common::ApplicationDataManager::GetCurrentAppData(); + base::FilePath path(app_data->application_path()); + if (file.empty()) { + const wgt::parse::ServiceInfo* info = app_data->service_info(); + if (info) + path = path.Append(info->content()); + } else { + path = path.Append(file); + } + + std::ifstream in(path.value(), std::ios::in); + std::string content; + if (in) { + in.seekg(0, std::ios::end); + content.resize(in.tellg()); + in.seekg(0, std::ios::beg); + in.read(&content[0], content.size()); + in.close(); + } + + message.Reply(content.c_str()); + }); + ipc.AddMessageHandler("Done", [](const char*, const char*, const tizen::IPC::Message&) { + //dbus_connection_close(connection); // TODO : App is relaunched by platfrom after exit. + }); + + ipc.Listen(); + return 0; +} + +int main(int argc, char* argv[]) { + std::string app_id(basename(argv[0])); + if (common::ApplicationDataManager::SetCurrentAppID(app_id)) { + return ServiceClient(app_id); + } else { + return ServiceDaemon(); + } + + return 0; +} diff --git a/tizen/src/browser/api/wrt_api_core.cc b/tizen/src/browser/api/wrt_api_core.cc new file mode 100644 index 0000000..51f0f00 --- /dev/null +++ b/tizen/src/browser/api/wrt_api_core.cc @@ -0,0 +1,122 @@ +#include "tizen/src/browser/api/wrt_api_core.h" + +#include + +#include "atom/browser/browser.h" +#include "atom/common/node_includes.h" +#include "base/files/file_path.h" +#include "base/logging.h" +#include "native_mate/dictionary.h" +#include "tizen/common/application_data.h" +#include "tizen/common/command_line.h" +#include "tizen/src/browser/wrt_service.h" + +namespace tizen { + +namespace api { + +WebRuntime* WebRuntime::instance_ = nullptr; + +WebRuntime::WebRuntime(v8::Isolate* isolate) { + Init(isolate); + instance_ = this; +} + +WebRuntime::~WebRuntime() { + instance_ = nullptr; +} + +std::string WebRuntime::GetMessage() const { + return "message from C++"; +} + +std::string WebRuntime::GetPath() const { + auto app_data = common::ApplicationDataManager::GetCurrentAppData(); + if (!app_data) { + return std::string(); + } + // TODO: Use resource-manager's GetStartResource() for localized urls + base::FilePath path(app_data->application_path()); + if (app_data->content_info()) { + path = path.Append(app_data->content_info()->src()); + } else { + path = path.Append("index.html"); + } + std::string app_path = "file://" + path.value(); + return app_path; +} + +bool WebRuntime::isTizenWebApp() const { + common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess(); + if (!runtime_cmd) + return false; + std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/electron"); + if (appid != "electron") { // TODO: Any better distinguishing feature? + return true; + } else { + return false; + } +} + +bool WebRuntime::isElectronLaunch() const { + return atom::Browser::Get()->is_electron_launch(); +} + +void WebRuntime::HideSplashScreen(int reason) { + atom::Browser* browser_model = atom::Browser::Get(); + browser_model->HideSplashScreen(reason); +} + +void WebRuntime::Log(const std::string& message) const { + std::string output = "[JS LOG] " + message; + dlog_print(DLOG_INFO, "WRT", output.c_str()); +} + +std::string WebRuntime::ReadService(const std::string& app_id) const { + tizen::Service* service = tizen::ServiceManager::Get()->GetService(app_id); + if (!service) { + isolate()->ThrowException(v8::Exception::Error(mate::StringToV8( + isolate(), "Fail to find service app."))); + return std::string(); + } + return service->ReadFile(std::string()); +} + +// static +mate::Handle WebRuntime::Create(v8::Isolate* isolate) { + return mate::CreateHandle(isolate, new WebRuntime(isolate)); +} + +// static +void WebRuntime::BuildPrototype( + v8::Isolate* isolate, v8::Local prototype) { + prototype->SetClassName(mate::StringToV8(isolate, "WRT")); + // TODO: Needs adding necessary interface methods + mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate()) + .SetMethod("getMessage", &WebRuntime::GetMessage) + .SetMethod("getPath", &WebRuntime::GetPath) + .SetMethod("isTizenWebApp", &WebRuntime::isTizenWebApp) + .SetMethod("isElectronLaunch", &WebRuntime::isElectronLaunch) + .SetMethod("hideSplashScreen", &WebRuntime::HideSplashScreen) + .SetMethod("log", &WebRuntime::Log) + .SetMethod("readService", &WebRuntime::ReadService); +} + +} // namespace api + +} // namespace tizen + + +namespace { + +void Initialize(v8::Local exports, v8::Local unused, + v8::Local context, void* priv) { + v8::Isolate* isolate = context->GetIsolate(); + mate::Dictionary dict(isolate, exports); + // TODO: Expose this attribute only for Tizen web apps + dict.Set("wrt", tizen::api::WebRuntime::Create(isolate)); +} + +} // namespace + +NODE_MODULE_CONTEXT_AWARE_BUILTIN(wrt, Initialize) diff --git a/tizen/src/browser/api/wrt_api_core.h b/tizen/src/browser/api/wrt_api_core.h new file mode 100644 index 0000000..6c27987 --- /dev/null +++ b/tizen/src/browser/api/wrt_api_core.h @@ -0,0 +1,42 @@ +#ifndef BROWSER_API_WRT_API_CORE_H_ +#define BROWSER_API_WRT_API_CORE_H_ + +#include "atom/browser/api/event_emitter.h" +#include "native_mate/handle.h" + +namespace tizen { + +namespace api { + +class WebRuntime : public mate::EventEmitter { + public: + static mate::Handle Create(v8::Isolate* isolate); + + static void BuildPrototype(v8::Isolate* isolate, + v8::Local prototype); + + static WebRuntime* GetInstance() { return instance_; } + + protected: + explicit WebRuntime(v8::Isolate* isolate); + ~WebRuntime() override; + + private: + std::string GetMessage() const; + std::string GetPath() const; + bool isTizenWebApp() const; + bool isElectronLaunch() const; + void HideSplashScreen(int reason); + void Log(const std::string& message) const; + std::string ReadService(const std::string& app_id) const; + + static WebRuntime* instance_; + + DISALLOW_COPY_AND_ASSIGN(WebRuntime); +}; + +} // namespace api + +} // namespace tizen + +#endif // BROWSER_API_WRT_API_CORE_H_ diff --git a/tizen/src/browser/wrt_ipc.cc b/tizen/src/browser/wrt_ipc.cc new file mode 100644 index 0000000..72af83a --- /dev/null +++ b/tizen/src/browser/wrt_ipc.cc @@ -0,0 +1,170 @@ +#include "tizen/src/browser/wrt_ipc.h" + +#include "base/logging.h" + +namespace tizen { + +#define WRT_DBUS_NAME "org.tizen.wrt" +#define WRT_DBUS_PATH "/org/tizen/wrt" + +IPC::Message::Message(DBusConnection* connection, DBusMessage* message) + : connection_(connection), message_(message) {} + +const char* IPC::Message::Sender() const { + return dbus_message_get_sender(message_); +} + +void IPC::Message::Reply(const char* argument) const { + DBusMessage* reply = dbus_message_new_method_return(message_); + dbus_message_append_args(reply, DBUS_TYPE_STRING, &argument, DBUS_TYPE_INVALID); + dbus_connection_send(connection_, reply, nullptr); + dbus_message_unref(reply); +} + +IPC::IPC(bool is_daemon) { + DBusError error; + dbus_error_init(&error); + + connection_ = dbus_bus_get_private(DBUS_BUS_SESSION, &error); + if (!connection_) { + LOG(ERROR) << "DBus connection error : " << error.message; + dbus_error_free(&error); + } + + if (is_daemon) { + int result = dbus_bus_request_name(connection_, WRT_DBUS_NAME, DBUS_NAME_FLAG_DO_NOT_QUEUE, &error); + if (dbus_error_is_set(&error)) { + LOG(ERROR) << "Fail to request name : " << error.message; + dbus_error_free(&error); + return; + } + if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { + LOG(ERROR) << "Fail to become owner"; + return; + } + } +} + +IPC::~IPC() { + dbus_connection_close(connection_); + dbus_connection_unref(connection_); +} + +// static +DBusHandlerResult IPC::OnMessage(DBusConnection* connection, DBusMessage* message, void* user_data) { + int type = dbus_message_get_type(message); + if (type != DBUS_MESSAGE_TYPE_METHOD_CALL) { + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + + std::string interface = dbus_message_get_interface(message); + if (interface != WRT_DBUS_NAME) { + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + + std::string member = dbus_message_get_member(message); + IPC* ipc = reinterpret_cast(user_data); + auto iterator = ipc->message_handlers_.find(member); + if (iterator != ipc->message_handlers_.end()) { + DBusError error; + dbus_error_init(&error); + char* argument = nullptr; + if (!dbus_message_get_args(message, &error, DBUS_TYPE_STRING, &argument, DBUS_TYPE_INVALID)) { + LOG(ERROR) << "dbus message reply is not valid"; + dbus_error_free(&error); + } + + auto handler = iterator->second; + handler(member.c_str(), argument, Message(ipc->connection_, message)); + } + + return DBUS_HANDLER_RESULT_HANDLED; +} + +void IPC::AddMessageHandler(const char* type, MessageHandler handler) { + if (message_handlers_.empty()) { + if (!dbus_connection_add_filter(connection_, OnMessage, this, nullptr)) { + LOG(ERROR) << "Fail to add message handler"; + return; + } + } + message_handlers_[type] = handler; +} + +void IPC::Listen() { + while (dbus_connection_read_write_dispatch(connection_, -1)) { + ; // empty loop body + } +} + +DBusMessage* IPC::InternalSendMessage(const char* receiver, const char* type, const char* argument, bool need_reply) { + DBusMessage* message = dbus_message_new_method_call(receiver, WRT_DBUS_PATH, WRT_DBUS_NAME, type); + if (!message) { + LOG(ERROR) << "Fail to create dbus message"; + return nullptr; + } + + if (!dbus_message_append_args(message, DBUS_TYPE_STRING, &argument, DBUS_TYPE_INVALID)) { + LOG(ERROR) << "Fail to append dbus message argument"; + return nullptr; + } + + DBusError error; + dbus_error_init(&error); + if (need_reply) { + DBusMessage* reply = dbus_connection_send_with_reply_and_block(connection_, message, -1, &error); + dbus_message_unref(message); + if (!reply) { + LOG(ERROR) << "Fail to receive dbus message reply"; + dbus_error_free(&error); + return nullptr; + } + message = reply; + } else { + dbus_connection_send(connection_, message, nullptr); + dbus_connection_flush(connection_); + } + if (dbus_error_is_set(&error)) { + LOG(ERROR) << "Fail to send message : " << error.message; + dbus_error_free(&error); + return nullptr; + } + + return message; +} + +bool IPC::SendMessage(const char* type, const char* argument) { + return SendMessage(WRT_DBUS_NAME, type, argument); +} + +bool IPC::SendMessage(const char* receiver, const char* type, const char* argument) { + DBusMessage* message = InternalSendMessage(receiver, type, argument, false); + if (!message) { + return false; + } + dbus_message_unref(message); + return true; +} + +bool IPC::SendMessageAndWaitReply(const char* receiver, const char* type, const char* argument, std::string& reply_argument) { + DBusMessage* reply = InternalSendMessage(receiver, type, argument, true); + if (!reply) { + return false; + } + + if (dbus_message_get_type(reply) != DBUS_MESSAGE_TYPE_ERROR) { + DBusError error; + dbus_error_init(&error); + char* buffer = nullptr; + if (!dbus_message_get_args(reply, &error, DBUS_TYPE_STRING, &buffer, DBUS_TYPE_INVALID)) { + LOG(ERROR) << "dbus message reply is not valid"; + dbus_error_free(&error); + return false; + } + reply_argument = buffer; + } + dbus_message_unref(reply); + return true; +} + +} // namespace tizen diff --git a/tizen/src/browser/wrt_ipc.h b/tizen/src/browser/wrt_ipc.h new file mode 100644 index 0000000..51c5511 --- /dev/null +++ b/tizen/src/browser/wrt_ipc.h @@ -0,0 +1,48 @@ +#ifndef BROWSER_WRT_IPC_H_ +#define BROWSER_WRT_IPC_H_ + +#include +#include +#include +#include + +namespace tizen { + +class IPC { + public: + IPC(bool is_daemon = false); + ~IPC(); + + class Message { + public: + Message(DBusConnection* connection, DBusMessage* message); + + const char* Sender() const; + void Reply(const char* argument) const; + + private: + DBusConnection* connection_; + DBusMessage* message_; + }; + + typedef std::function MessageHandler; + + void AddMessageHandler(const char* type, MessageHandler handler); + void Listen(); + + bool SendMessage(const char* type, const char* argument); + bool SendMessage(const char* receiver, const char* type, const char* argument); + bool SendMessageAndWaitReply(const char* receiver, const char* type, const char* argument, std::string& reply_argument); + + private: + static DBusHandlerResult OnMessage(DBusConnection* connection, DBusMessage* message, void* user_data); + + DBusMessage* InternalSendMessage(const char* receiver, const char* type, const char* argument, bool need_reply); + + DBusConnection* connection_; + std::map message_handlers_; +}; + +} // namespace tizen + +#endif // BROWSER_WRT_IPC_H_ diff --git a/tizen/src/browser/wrt_service.cc b/tizen/src/browser/wrt_service.cc new file mode 100644 index 0000000..c3f6314 --- /dev/null +++ b/tizen/src/browser/wrt_service.cc @@ -0,0 +1,75 @@ +#include "tizen/src/browser/wrt_service.h" + +#include "base/logging.h" +#include "tizen/src/browser/api/wrt_api_core.h" + +namespace tizen { + +Service::Service(std::string source_name) + : source_name_(source_name) {} + +const std::string Service::ReadFile(const std::string file) { + std::string content; + ServiceManager::Get()->ipc_.SendMessageAndWaitReply(source_name_.c_str(), "ReadFile", file.c_str(), content); + return content; +} + +ServiceManager::ServiceManager() { + uv_async_init(uv_default_loop(), &handle_, OnMainThread); + handle_.data = this; + uv_mutex_init(&mutex_); +} + +ServiceManager::~ServiceManager() { + uv_close(reinterpret_cast(&handle_), nullptr); + uv_mutex_destroy(&mutex_); +} + +// static +ServiceManager* ServiceManager::Get() { + static ServiceManager* manager = nullptr; + if (!manager) { + manager = new ServiceManager; + } + return manager; +} + +Service* ServiceManager::GetService(const std::string app_id) { + auto iter = services_.find(app_id); + if (iter == services_.end()) { + return nullptr; + } + return iter->second; +} + +void ServiceManager::Prepare(const std::string app_id, const std::string source_name) { + Service* service = new Service(source_name); + uv_mutex_lock(&mutex_); + prepared_services_.push_back(app_id); + services_[app_id] = service; + uv_mutex_unlock(&mutex_); + uv_async_send(&handle_); +} + +// static +void ServiceManager::OnMainThread(uv_async_t* handle) { + ServiceManager* manager = reinterpret_cast(handle->data); + std::vector services; + + auto wrt = tizen::api::WebRuntime::GetInstance(); + if (!wrt) { + LOG(ERROR) << "JS WRT object is not created"; + return; + } + + uv_mutex_lock(&manager->mutex_); + services.swap(manager->prepared_services_); + uv_mutex_unlock(&manager->mutex_); + + for (auto it = services.begin(); it != services.end(); it++) { + std::string app_id = *it; + wrt->Emit("start-service", app_id); + } +} + +} // namespace tizen diff --git a/tizen/src/browser/wrt_service.h b/tizen/src/browser/wrt_service.h new file mode 100644 index 0000000..bc41981 --- /dev/null +++ b/tizen/src/browser/wrt_service.h @@ -0,0 +1,47 @@ +#ifndef BROWSER_WRT_SERVICE_H_ +#define BROWSER_WRT_SERVICE_H_ + +#include +#include +#include + +#include "tizen/src/browser/wrt_ipc.h" +#include "vendor/node/deps/uv/include/uv.h" + +namespace tizen { + +class Service { + public: + Service(std::string source_name); + + const std::string ReadFile(const std::string file); + + private: + const std::string source_name_; +}; + +class ServiceManager { + public: + static ServiceManager* Get(); + + Service* GetService(const std::string app_id); + void Prepare(const std::string app_id, const std::string source_name); + + private: + ServiceManager(); + ~ServiceManager(); + + static void OnMainThread(uv_async_t* handle); + + friend class Service; + + uv_async_t handle_; + uv_mutex_t mutex_; + std::vector prepared_services_; + std::map services_; + IPC ipc_; +}; + +} // namespace tizen + +#endif // BROWSER_WRT_SERVICE_H_ diff --git a/tizen/src/wrt_main.cc b/tizen/src/wrt_main.cc index 8c8052b..fc0320d 100644 --- a/tizen/src/wrt_main.cc +++ b/tizen/src/wrt_main.cc @@ -5,37 +5,16 @@ #include "wrt_main.h" #include - -#if defined(OS_WIN) -#include // windows.h must be included first - -#include -#include -#include - -#include "atom/app/atom_main_delegate.h" -#include "atom/common/crash_reporter/win/crash_service_main.h" -#include "base/environment.h" -#include "base/process/launch.h" -#include "base/win/windows_version.h" -#include "content/public/app/sandbox_helper_win.h" -#include "sandbox/win/src/sandbox_types.h" -#elif defined(OS_LINUX) // defined(OS_WIN) #include "atom/app/atom_main_delegate.h" // NOLINT #include "content/public/app/content_main.h" -#else // defined(OS_LINUX) -#include "atom/app/atom_library_main.h" -#endif // defined(OS_MACOSX) - -#if defined(USE_EFL) -#include "efl/init.h" -#endif #include "atom/app/node_main.h" #include "atom/common/atom_command_line.h" #include "base/at_exit.h" #include "base/i18n/icu_util.h" +#include "efl/init.h" + #if defined(OS_TIZEN) #include @@ -49,94 +28,19 @@ namespace { -const char* kRunAsNode = "ELECTRON_RUN_AS_NODE"; - // Default command line flags for all profiles and platforms const char* kDefaultCommandLineFlags[] = { "allow-file-access-from-files", "enable-tizen-app-container", }; -bool IsEnvSet(const char* name) { -#if defined(OS_WIN) - size_t required_size; - getenv_s(&required_size, nullptr, 0, name); - return required_size != 0; -#else - char* indicator = getenv(name); - return indicator && indicator[0] != '\0'; -#endif -} - } // namespace -#if defined(OS_WIN) -int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) { - int argc = 0; - wchar_t** wargv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); - - bool run_as_node = IsEnvSet(kRunAsNode); - - // Make sure the output is printed to console. - if (run_as_node || !IsEnvSet("ELECTRON_NO_ATTACH_CONSOLE")) - base::RouteStdioToConsole(false); - - // Convert argv to to UTF8 - char** argv = new char*[argc]; - for (int i = 0; i < argc; i++) { - // Compute the size of the required buffer - DWORD size = WideCharToMultiByte(CP_UTF8, - 0, - wargv[i], - -1, - NULL, - 0, - NULL, - NULL); - if (size == 0) { - // This should never happen. - fprintf(stderr, "Could not convert arguments to utf8."); - exit(1); - } - // Do the actual conversion - argv[i] = new char[size]; - DWORD result = WideCharToMultiByte(CP_UTF8, - 0, - wargv[i], - -1, - argv[i], - size, - NULL, - NULL); - if (result == 0) { - // This should never happen. - fprintf(stderr, "Could not convert arguments to utf8."); - exit(1); - } - } - - if (run_as_node) { - // Now that argv conversion is done, we can finally start. - base::AtExitManager atexit_manager; - base::i18n::InitializeICU(); - return atom::NodeMain(argc, argv); - } else if (IsEnvSet("ELECTRON_INTERNAL_CRASH_SERVICE")) { - return crash_service::Main(cmd); - } - - sandbox::SandboxInterfaceInfo sandbox_info = {0}; - content::InitializeSandboxInfo(&sandbox_info); - atom::AtomMainDelegate delegate; - - content::ContentMainParams params(&delegate); - params.instance = instance; - params.sandbox_info = &sandbox_info; - atom::AtomCommandLine::Init(argc, argv); - atom::AtomCommandLine::InitW(argc, wargv); - return content::ContentMain(params); -} - -#elif defined(OS_LINUX) // defined(OS_WIN) +#define REFERENCE_MODULE(name) \ + extern "C" void _register_ ## name(void); \ + void (*wrt_register_ ## name)(void) = _register_ ## name +REFERENCE_MODULE(wrt); +#undef REFERENCE_MODULE #if defined(OS_TIZEN) bool g_initialized_ = false; @@ -159,13 +63,7 @@ int main(int argc, char* argv[]) { #endif for (int i = 0; i < argc; ++i) LOG(ERROR) << "argv[" << i << "] : " << argv[i]; - if (IsEnvSet(kRunAsNode)) { - base::i18n::InitializeICU(); - base::AtExitManager atexit_manager; - return atom::NodeMain(argc, const_cast(argv)); - } -#if defined(USE_EFL) if (!common::CommandLine::Init(argc, argv)) { common::CommandLine::Reset(); common::CommandLine::Init(argc, argv); @@ -175,16 +73,13 @@ int main(int argc, char* argv[]) { base::CommandLine::Reset(); base::CommandLine::Init(argc, argv); } + common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess(); std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/wrt"); // load manifest if (appid != "wrt") { // TODO: Any better way to distinguish? - auto appdata_manager = common::ApplicationDataManager::GetInstance(); - common::ApplicationData* appdata = appdata_manager->GetApplicationData(appid); - if (!appdata->LoadManifestData()) { - return false; - } + common::ApplicationDataManager::SetCurrentAppID(appid); } if (!g_initialized_) { if (efl::Initialize(argc, const_cast(argv))) @@ -198,7 +93,6 @@ int main(int argc, char* argv[]) { for (auto arg : kDefaultCommandLineFlags) command_line->AppendSwitch(const_cast(arg)); efl::AppendPortParams(*command_line); -#endif atom::AtomMainDelegate delegate; content::ContentMainParams params(&delegate); @@ -250,15 +144,3 @@ int main(int argc, const char* argv[]) { } } #endif - -#else // defined(OS_LINUX) - -int main(int argc, const char* argv[]) { - if (IsEnvSet(kRunAsNode)) { - return AtomInitializeICUandStartNode(argc, const_cast(argv)); - } - - return AtomMain(argc, argv); -} - -#endif // defined(OS_MACOSX) diff --git a/vendor/node/src/node.cc b/vendor/node/src/node.cc index 66233d4..aca7991 100644 --- a/vendor/node/src/node.cc +++ b/vendor/node/src/node.cc @@ -94,6 +94,10 @@ typedef int mode_t; extern char **environ; #endif +#if defined(OS_TIZEN) +#include +#endif + namespace node { using v8::Array; @@ -273,6 +277,9 @@ static void PrintErrorString(const char* format, ...) { // Don't include the null character in the output CHECK_GT(n, 0); WriteConsoleW(stderr_handle, wbuf.data(), n - 1, nullptr, nullptr); +#elif defined(OS_TIZEN) + dlog_print(DLOG_ERROR, "WRT", "[Node.js ERROR]"); + dlog_vprint(DLOG_ERROR, "WRT", format, ap); #else vfprintf(stderr, format, ap); #endif diff --git a/wrt.gyp b/wrt.gyp index eef72f2..32f0a97 100644 --- a/wrt.gyp +++ b/wrt.gyp @@ -11,9 +11,9 @@ '<(DEPTH)/electron.gyp:js2asar', '<(DEPTH)/electron.gyp:app2asar', 'wrt_lib', + 'wrt-service', '<(DEPTH)/tizen/common/common.gyp:wrt_common', '<(DEPTH)/tizen/loader/loader.gyp:wrt-loader', - '<(DEPTH)/tizen/extensions/extensions.gyp:xwalk_extension_shared', '<(DEPTH)/tizen/extensions/extensions.gyp:widget_plugin', '<(DEPTH)/tizen/extensions/extensions.gyp:splash_screen_plugin', '<(DEPTH)/tizen/renderer/injected_bundle.gyp:xwalk_injected_bundle', @@ -28,8 +28,6 @@ 'tizen/src/wrt_main.h', 'tizen/loader/prelauncher.h', 'tizen/loader/prelauncher.cc', - 'atom/browser/splash_screen.h', - 'atom/browser/splash_screen.cc', ], 'include_dirs': [ 'tizen/src', @@ -45,9 +43,28 @@ 'cflags_cc': [ '-fPIC' ], }, # target wrt { + 'target_name': 'wrt-service', + 'type': 'executable', + 'dependencies': [ + 'wrt_lib', + '<(DEPTH)/efl/build/system.gyp:capi-appfw-application', + '<(DEPTH)/tizen/common/common.gyp:wrt_common', + ], + 'sources': [ + 'tizen/src/app/service_main.cc', + ], + 'include_dirs': [ + 'tizen/src', + ], + 'includes': [ + 'tizen/build/common.gypi', + ], + }, # target wrt-service + { 'target_name': 'wrt_lib', 'type': 'static_library', 'dependencies': [ + '<(DEPTH)/tizen/extensions/extensions.gyp:xwalk_extension_shared', 'electron.gyp:atom_js2c', 'vendor/pdf_viewer/pdf_viewer.gyp:pdf_viewer', 'vendor/brightray/brightray.gyp:brightray', @@ -82,14 +99,14 @@ 'atom/app/ui_runtime.h', 'atom/browser/api/atom_api_menu_efl.cc', 'atom/browser/api/atom_api_menu_efl.h', - 'atom/browser/api/atom_api_pwrt.cc', - 'atom/browser/api/atom_api_pwrt.h', 'atom/browser/api/atom_api_web_contents_efl.cc', 'atom/browser/common_web_contents_delegate_efl.cc', 'atom/browser/native_browser_view_efl.cc', 'atom/browser/native_browser_view_efl.h', 'atom/browser/native_window_efl.cc', 'atom/browser/native_window_efl.h', + 'atom/browser/splash_screen.h', + 'atom/browser/splash_screen.cc', 'atom/browser/ui/accelerator_util_efl.cc', 'atom/browser/ui/drag_util_efl.cc', 'atom/browser/ui/file_dialog_efl.cc', @@ -99,6 +116,12 @@ 'chromium_src/chrome/browser/extensions/global_shortcut_listener_ozone.cc', 'chromium_src/chrome/browser/extensions/global_shortcut_listener_ozone.h', 'chromium_src/chrome/browser/icon_loader_efllinux.cc', + 'tizen/src/browser/api/wrt_api_core.cc', + 'tizen/src/browser/api/wrt_api_core.h', + 'tizen/src/browser/wrt_ipc.cc', + 'tizen/src/browser/wrt_ipc.h', + 'tizen/src/browser/wrt_service.cc', + 'tizen/src/browser/wrt_service.h', ], 'sources/': [ # chromium-efl supports only tizen webrtc using CAPI diff --git a/wrt/browser/wrt.js b/wrt/browser/wrt.js new file mode 100644 index 0000000..36b4035 --- /dev/null +++ b/wrt/browser/wrt.js @@ -0,0 +1,21 @@ +const {wrt} = process.binding('wrt'); +const {EventEmitter} = require('events') +const util = require('util') + +Object.setPrototypeOf(Object.getPrototypeOf(wrt), EventEmitter.prototype) + +module.exports = wrt + +console.log = console.error = console.warn = function(...args) { + wrt.log(util.format(...args)); +}; +process.stdout.write = process.stderr.write = function (chunk, encoding, callback) { + if (Buffer.isBuffer(chunk)) { + chunk = chunk.toString(encoding) + } + wrt.log(chunk) + if (callback) { + callback() + } + return true +} diff --git a/wrt/service/main.js b/wrt/service/main.js new file mode 100644 index 0000000..264669c --- /dev/null +++ b/wrt/service/main.js @@ -0,0 +1,15 @@ +'use strict'; + +const wrt = require('../browser/wrt'); +const vm = require('vm'); + +wrt.on('start-service', (event, appID) => { + console.log('start service app : ' + appID); + let sandbox = { console: console }; + let options = { filename: appID }; + vm.runInNewContext(wrt.readService(appID), sandbox, options); +}) + +process.on('exit', (code) => { + console.log('Exit with code : ' + code); +}) diff --git a/wrt/src/main.js b/wrt/src/main.js index c1045a5..e1ee03f 100644 --- a/wrt/src/main.js +++ b/wrt/src/main.js @@ -1,6 +1,5 @@ 'use strict'; -const {pwrt} = require('electron'); const path_debug = require('debug')('MAIN'); const runtime = require('./runtime'); const yargs = require('yargs'); @@ -32,7 +31,7 @@ let parseCommandLine = function() { return { appID: args.a, devMode: args.d, - path: args.p ? args.p : pwrt.getPath(), + path: args.p, windowSize: args.s }; }; diff --git a/wrt/src/runtime.js b/wrt/src/runtime.js index 2c1a1de..e9a6ead 100755 --- a/wrt/src/runtime.js +++ b/wrt/src/runtime.js @@ -1,11 +1,12 @@ 'use strict'; const EXTENSIONS_PATH = process.env.WAS_EXTENSIONS_PATH; const ExtensionManager = require('./extension_manager'); -const {app, ipcMain, pwrt} = require('electron'); +const {app, ipcMain} = require('electron'); const IPC_MESSAGE = require('./ipc_message'); const WAS_EVENT = require('./was_event'); const WebApplication = require('./web_application'); const events = require('./events'); +const wrt = require('../browser/wrt'); const runtime_debug = require('debug')('RUNTIME'); const try_debug = require('debug')('TRY'); @@ -51,9 +52,9 @@ class Runtime { }); app.on('will-finish-launching', function(event) { runtime_debug('will-finish-launching'); - if (pwrt.isElectronLaunch()) { + if (wrt.isElectronLaunch()) { console.log("Electron App launch"); - let filePath = pwrt.getPath(); + let filePath = wrt.getPath(); let pkgJson = require(filePath.substr(7, filePath.length - 12)); let mainJsPath = filePath.substr(7, filePath.length - 19) + (pkgJson.main || 'index.js'); @@ -68,7 +69,7 @@ class Runtime { if (!options.noExtensions) { this.extensionManager.build(); } - if (pwrt.isElectronLaunch()) { + if (wrt.isElectronLaunch()) { this.extensionManager.activateAll(app); return; } diff --git a/wrt/src/web_window.js b/wrt/src/web_window.js index 95476d8..fe6c3b9 100644 --- a/wrt/src/web_window.js +++ b/wrt/src/web_window.js @@ -1,8 +1,9 @@ 'use strict'; -const {BrowserWindow, app, pwrt} = require('electron'); +const {BrowserWindow, app} = require('electron'); const IPC_MESSAGE = require('./ipc_message'); const WAS_EVENT = require('./was_event'); const events = require('./events'); +const wrt = require('../browser/wrt'); const target_debug = require('debug')('TARGET'); const webwindow_debug = require('debug')('WEBWINDOW'); @@ -125,7 +126,7 @@ class WebWindow { }); this.mainWindow.webContents.on('did-finish-load', function() { webwindow_debug('WebWindow : webContents did-finish-load'); - pwrt.hideSplashScreen(1); + wrt.hideSplashScreen(1); if(!options.show){ webwindow_debug('WebWindow : browserWindow show options is ',options.show); @@ -221,8 +222,7 @@ class WebWindow { if (path && (path.trim() != '')) { this.mainWindow.loadURL(path); } else { - const {pwrt} = require('electron'); -        this.mainWindow.loadURL(pwrt.getPath()); +        this.mainWindow.loadURL(wrt.getPath()); } } show() { -- 2.7.4 From 992f0affc8602d20f2901b18724c88c5a5df663e Mon Sep 17 00:00:00 2001 From: Prathmesh Date: Fri, 15 Jun 2018 12:34:53 +0530 Subject: [PATCH 15/16] Implemented getting of start url from resource manager - Change the url load logic from window create to on appcontrol - Pass the AppControl event to Window(On top) - Make start url ready when getpath() is called - Refactor code to move under OS_TIZEN macro Change-Id: I6b739950d16b8391a9af05b0ba63f306b339fcfc Signed-off-by: Prathmesh --- atom/browser/api/atom_api_window.cc | 6 +++++- atom/browser/api/atom_api_window.h | 3 ++- atom/browser/browser.cc | 23 ++++++++++++++++++----- atom/browser/browser.h | 11 +++++++---- atom/browser/browser_observer.h | 2 -- atom/browser/native_window.cc | 20 ++++++++++++++++++++ atom/browser/native_window.h | 5 +++++ atom/browser/native_window_observer.h | 7 +++++++ tizen/common/resource_manager.cc | 6 ++++++ tizen/src/browser/api/wrt_api_core.cc | 12 +++++++++++- wrt/src/web_window.js | 6 +++++- 11 files changed, 86 insertions(+), 15 deletions(-) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index f19fbda..db323ae 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -310,7 +310,7 @@ void Window::OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) { } #endif -#if defined(USE_EFL) +#if defined(OS_TIZEN) void Window::OnSuspend() { Emit("app-on-suspend"); } @@ -318,6 +318,10 @@ void Window::OnSuspend() { void Window::OnResume() { Emit("app-on-resume"); } + +void Window::OnAppControl() { + Emit("app-on-appcontrol"); +} #endif // static diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index 91b5633..b8eff85 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -96,9 +96,10 @@ class Window : public mate::TrackableObject, void OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) override; #endif -#if defined(USE_EFL) +#if defined(OS_TIZEN) void OnSuspend(); void OnResume(); + void OnAppControl(); #endif private: diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index 1110602..aca2f68 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -44,6 +44,7 @@ Browser::~Browser() { WindowList::RemoveObserver(this); } +#if defined(OS_TIZEN) const char* kAppControlMain = "http://tizen.org/appcontrol/operation/main"; const char* kAppControlEventScript = "(function(){" @@ -56,6 +57,7 @@ const char* kAppControlEventScript = "})()"; const char* kDefaultCSPRule = "default-src *; script-src 'self'; style-src 'self'; object-src 'none';"; +#endif // static Browser* Browser::Get() { @@ -260,19 +262,23 @@ void Browser::OnWindowAllClosed() { } } +#if defined(OS_TIZEN) void Browser::Hide() { - for (BrowserObserver& observer : observers_) - observer.OnSuspend(); + NativeWindow *last_window = WindowList::GetLastWindow(); + if (last_window) + last_window->NotifySuspend(); } void Browser::Show() { - for (BrowserObserver& observer : observers_) - observer.OnResume(); + NativeWindow *last_window = WindowList::GetLastWindow(); + if (last_window) + last_window->NotifyResume(); } void Browser::Initialize() { auto appdata = common::ApplicationDataManager::GetCurrentAppData(); resource_manager_.reset(new common::ResourceManager(appdata, locale_manager_.get())); + resource_manager_->set_base_resource_path(appdata->application_path()); } void Browser::AppControl(std::unique_ptr appcontrol) { @@ -312,9 +318,16 @@ void Browser::SendAppControlEvent() { void Browser::Launch(std::unique_ptr appcontrol) { launched_ = true; //To do:Implementation of relaunching of app + std::unique_ptr res = + resource_manager_->GetStartResource(appcontrol.get()); + if (res) + start_url_ = resource_manager_->GetLocalizedPath(res->uri()); + + NativeWindow *last_window = WindowList::GetLastWindow(); + if (last_window) + last_window->NotifyAppControl(); } -#if defined(OS_TIZEN) void Browser::SetSplashScreen() { auto appdata = common::ApplicationDataManager::GetCurrentAppData(); Evas_Object* window_ = elm_win_util_standard_add("", ""); diff --git a/atom/browser/browser.h b/atom/browser/browser.h index 0e759e6..48365b8 100644 --- a/atom/browser/browser.h +++ b/atom/browser/browser.h @@ -16,12 +16,12 @@ #include "base/strings/string16.h" #include "base/values.h" #include "native_mate/arguments.h" +#if defined(OS_TIZEN) +#include "atom/browser/splash_screen.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" -#if defined(OS_TIZEN) -#include "atom/browser/splash_screen.h" #endif // defined(OS_TIZEN) @@ -98,7 +98,7 @@ class Browser : public WindowListObserver { // Set/Get the badge count. bool SetBadgeCount(int count); - bool launched() const { return launched_; } + int GetBadgeCount(); // Set/Get the login item settings of the app @@ -114,14 +114,16 @@ class Browser : public WindowListObserver { void SetLoginItemSettings(LoginItemSettings settings); LoginItemSettings GetLoginItemSettings(const LoginItemSettings& options); +#if defined(OS_TIZEN) void Hide(); void Show(); void AppControl(std::unique_ptr appcontrol); void Launch(std::unique_ptr appcontrol); void SendAppControlEvent(); -#if defined(OS_TIZEN) void SetSplashScreen(); void HideSplashScreen(int reason); + bool launched() const { return launched_; } + std::string StartURL() const { return start_url_;} #endif // defined(OS_TIZEN) #if defined(OS_MACOSX) @@ -263,6 +265,7 @@ class Browser : public WindowListObserver { std::unique_ptr resource_manager_; std::unique_ptr locale_manager_; std::unique_ptr splash_screen_; + std::string start_url_; bool launched_; bool is_electron_launch_; #endif diff --git a/atom/browser/browser_observer.h b/atom/browser/browser_observer.h index b5760ec..88a50a9 100644 --- a/atom/browser/browser_observer.h +++ b/atom/browser/browser_observer.h @@ -55,8 +55,6 @@ class BrowserObserver { // The browser's accessibility suppport has changed. virtual void OnAccessibilitySupportChanged() {} - virtual void OnSuspend() {} - virtual void OnResume() {} #if defined(OS_MACOSX) // The browser wants to resume a user activity via handoff. (macOS only) virtual void OnContinueUserActivity( diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 9e2c11a..4320eb8 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -605,6 +605,26 @@ void NativeWindow::NotifyWindowMessage( } #endif +#if defined(OS_TIZEN) +void NativeWindow::NotifySuspend() +{ + for (NativeWindowObserver& observer : observers_) + observer.OnSuspend(); +} + +void NativeWindow::NotifyResume() +{ + for (NativeWindowObserver& observer : observers_) + observer.OnResume(); +} + +void NativeWindow::NotifyAppControl() +{ + for (NativeWindowObserver& observer : observers_) + observer.OnAppControl(); +} +#endif + std::unique_ptr NativeWindow::DraggableRegionsToSkRegion( const std::vector& regions) { std::unique_ptr sk_region(new SkRegion); diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index 654b68e..0e07787 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -248,6 +248,11 @@ class NativeWindow : public base::SupportsUserData, void NotifyWindowMessage(UINT message, WPARAM w_param, LPARAM l_param); #endif +#if defined(OS_TIZEN) + void NotifySuspend(); + void NotifyResume(); + void NotifyAppControl(); +#endif void AddObserver(NativeWindowObserver* obs) { observers_.AddObserver(obs); } diff --git a/atom/browser/native_window_observer.h b/atom/browser/native_window_observer.h index 8c908dc..96ac375 100644 --- a/atom/browser/native_window_observer.h +++ b/atom/browser/native_window_observer.h @@ -92,6 +92,13 @@ class NativeWindowObserver { // Called on Windows when App Commands arrive (WM_APPCOMMAND) virtual void OnExecuteWindowsCommand(const std::string& command_name) {} + +#if defined(OS_TIZEN) + // Tizen + virtual void OnSuspend() {} + virtual void OnResume() {} + virtual void OnAppControl() {} +#endif }; } // namespace atom diff --git a/tizen/common/resource_manager.cc b/tizen/common/resource_manager.cc index e177ab5..22fa8bf 100644 --- a/tizen/common/resource_manager.cc +++ b/tizen/common/resource_manager.cc @@ -258,6 +258,12 @@ std::unique_ptr ResourceManager::GetMatchedResource( std::unique_ptr ResourceManager::GetStartResource( const AppControl* app_control) { + + if (!app_control) { + LOGGER(ERROR) << "ERROR: No app control"; + return GetDefaultResource(); + } + std::string operation = app_control->operation(); if (operation.empty()) { LOGGER(ERROR) << "operation(mandatory) is NULL"; diff --git a/tizen/src/browser/api/wrt_api_core.cc b/tizen/src/browser/api/wrt_api_core.cc index 51f0f00..b418583 100644 --- a/tizen/src/browser/api/wrt_api_core.cc +++ b/tizen/src/browser/api/wrt_api_core.cc @@ -31,11 +31,20 @@ std::string WebRuntime::GetMessage() const { } std::string WebRuntime::GetPath() const { + atom::Browser* browser_model = atom::Browser::Get(); + if (browser_model) { + std::string res = browser_model->StartURL(); + if (!res.empty()) { + LOG(ERROR) << "PWRT Start URL = " << res; + return res; + } + } + + // Fall back: This code must ideally not execute auto app_data = common::ApplicationDataManager::GetCurrentAppData(); if (!app_data) { return std::string(); } - // TODO: Use resource-manager's GetStartResource() for localized urls base::FilePath path(app_data->application_path()); if (app_data->content_info()) { path = path.Append(app_data->content_info()->src()); @@ -43,6 +52,7 @@ std::string WebRuntime::GetPath() const { path = path.Append("index.html"); } std::string app_path = "file://" + path.value(); + LOG(ERROR) << "PWRT Start Url = " << app_path; return app_path; } diff --git a/wrt/src/web_window.js b/wrt/src/web_window.js index fe6c3b9..039b294 100644 --- a/wrt/src/web_window.js +++ b/wrt/src/web_window.js @@ -24,7 +24,6 @@ class WebWindow { this.handleEvents(winopt); this.appID = options.appID; webwindow_debug('this.appID ' + this.appID); - this.setUrl(options.path); } getBrowserWindowOption() { return { @@ -120,6 +119,10 @@ class WebWindow { webwindow_debug('WebWindow : app-on-resume'); events.emit(WAS_EVENT.WEBAPPLICATION.RESUME, 'web_window', self.mainWindow.id); }); + this.mainWindow.on('app-on-appcontrol', function() { + webwindow_debug('WebWindow : app-on-appcontrol'); + self.setUrl(''); + }); this.mainWindow.webContents.on('crashed', function() { webwindow_debug('WebWindow : webContents crashed'); self.webApplication.exit(100); @@ -219,6 +222,7 @@ class WebWindow { }); } setUrl(path) { + webwindow_debug('WebWindow : Set URL'); if (path && (path.trim() != '')) { this.mainWindow.loadURL(path); } else { -- 2.7.4 From 41bf4458a4ad7ac22f9c6713e4b88c1ab291019f Mon Sep 17 00:00:00 2001 From: Prathmesh Date: Mon, 18 Jun 2018 14:52:27 +0530 Subject: [PATCH 16/16] Block loading of extension in render - Plugins are already loaded in browser - There is no use of loading in renderer as the plugins loaded in browser will be used. Change-Id: I8175667d01f30be7242ff9eb24f7db597533a7c3 Signed-off-by: Prathmesh --- tizen/extensions/renderer/xwalk_extension_client.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tizen/extensions/renderer/xwalk_extension_client.cc b/tizen/extensions/renderer/xwalk_extension_client.cc index d113269..4199fed 100644 --- a/tizen/extensions/renderer/xwalk_extension_client.cc +++ b/tizen/extensions/renderer/xwalk_extension_client.cc @@ -149,8 +149,11 @@ void XWalkExtensionClient::OnReceivedIPCMessage( } void XWalkExtensionClient::LoadUserExtensions(const std::string app_path) { - XWalkExtensionServer* server = XWalkExtensionServer::GetInstance(); - server->LoadUserExtensions(app_path); + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch(switches::kSingleProcess)) { + XWalkExtensionServer* server = XWalkExtensionServer::GetInstance(); + server->LoadUserExtensions(app_path); + } } } // namespace extensions -- 2.7.4