From ad19b93ec04c84565c4dcbf2a77c17c970068cb7 Mon Sep 17 00:00:00 2001 From: Youngcheol Kang Date: Wed, 21 Dec 2016 20:31:11 +0900 Subject: [PATCH 01/16] fixup! Apply mime_override_callback for specific mimetype When the mime is empty, the callback should be released to prevent the crash issue. Bug: http://suprem.sec.samsung.net/jira/browse/TSAM-11333 Change-Id: Iaec07731e0c4a092cce161f3d39dc4bac18c2d22 Signed-off-by: Youngcheol Kang --- runtime/browser/web_view_impl.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/runtime/browser/web_view_impl.cc b/runtime/browser/web_view_impl.cc index b7d36eb..ddc4816 100644 --- a/runtime/browser/web_view_impl.cc +++ b/runtime/browser/web_view_impl.cc @@ -117,6 +117,10 @@ void WebViewImpl::LoadUrl(const std::string& url, const std::string& mime) { return view->mime_set_cb_(url, mime, new_mime, data); }; ewk_context_mime_override_callback_set(context_, mime_override_cb, this); + } else { + // In order to prevent crash issue, the callback should be released + // when the mime is empty. + ewk_context_mime_override_callback_set(context_, nullptr, nullptr); } ewk_view_url_set(ewk_view_, url.c_str()); } -- 2.7.4 From f8f6fb79ebb54b0c1719e1359529be2849cec901 Mon Sep 17 00:00:00 2001 From: "jaekuk, lee" Date: Fri, 23 Dec 2016 11:38:02 +0900 Subject: [PATCH 02/16] Modify not to do symlink when upgrading wrt Change-Id: I65bd183b3dff314b2fa5212fd2a166c7ebbeca6f Signed-off-by: jaekuk, lee --- packaging/crosswalk-tizen.spec | 2 ++ wrt-upgrade/wrt-upgrade.cc | 7 ------- 2 files changed, 2 insertions(+), 7 deletions(-) mode change 100644 => 100755 wrt-upgrade/wrt-upgrade.cc diff --git a/packaging/crosswalk-tizen.spec b/packaging/crosswalk-tizen.spec index 51e0d20..1b9c54b 100755 --- a/packaging/crosswalk-tizen.spec +++ b/packaging/crosswalk-tizen.spec @@ -155,6 +155,7 @@ install -p -m 644 out/Default/gen/splash_screen.json %{buildroot}%{extension_pat # xwalk_runtime install -p -m 755 out/Default/xwalk_runtime %{buildroot}%{_bindir} ln -s %{_bindir}/xwalk_runtime %{buildroot}%{_bindir}/wrt +ln -s %{_bindir}/xwalk_runtime %{buildroot}%{_bindir}/wrt-client # xwalk extension shared install -p -m 644 out/Default/lib/libxwalk_extension_shared.so %{buildroot}%{_libdir} @@ -193,6 +194,7 @@ rm -fr %{buildroot} %attr(644,root,root) %{extension_path}/splash_screen.json %attr(755,root,root) %{_bindir}/xwalk_runtime %attr(755,root,root) %{_bindir}/wrt +%attr(755,root,root) %{_bindir}/wrt-client %attr(755,root,root) %{_bindir}/wrt-loader %attr(644,root,root) %{_datadir}/aul/wrt.loader %attr(755,root,root) %{_bindir}/wrt-upgrade diff --git a/wrt-upgrade/wrt-upgrade.cc b/wrt-upgrade/wrt-upgrade.cc old mode 100644 new mode 100755 index 6376f54..43e7ea4 --- a/wrt-upgrade/wrt-upgrade.cc +++ b/wrt-upgrade/wrt-upgrade.cc @@ -34,7 +34,6 @@ void WrtUpgrade::Run() { ParseCertificatenDatabase(); CreateMigrationFile(); RemoveDatabases(); - RedirectSymlink(); } void WrtUpgrade::ParseWrtDatabse() { std::cout << "parseWrtDatabse" << std::endl; @@ -286,12 +285,6 @@ bool WrtUpgrade::RemoveFile(const std::string& path) { } return (remove(path.c_str()) == 0); } -void WrtUpgrade::RedirectSymlink() { - std::string xwalk_runtime = "/usr/bin/xwalk_runtime"; - std::string wrt_client = "/usr/bin/wrt-client"; - - symlink(xwalk_runtime.c_str(), wrt_client.c_str()); -} } // namespace upgrade int main() { std::cout << "Tizen database migration tool for Webruntime" << std::endl; -- 2.7.4 From d16f61aa1e06fb819e5a27f1534a646783883df2 Mon Sep 17 00:00:00 2001 From: Youngcheol Kang Date: Fri, 23 Dec 2016 16:53:05 +0900 Subject: [PATCH 03/16] fixup! Code refactoring about checking the EventListener of WebView class This patch fixes the -fpermissive error about return-statement. Change-Id: Id845258c1ee328f2d98cce50e1cfc21aeb9ec2a5 Signed-off-by: Youngcheol Kang --- runtime/browser/web_view_impl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/browser/web_view_impl.cc b/runtime/browser/web_view_impl.cc index ddc4816..25b2dc3 100644 --- a/runtime/browser/web_view_impl.cc +++ b/runtime/browser/web_view_impl.cc @@ -936,7 +936,7 @@ void WebViewImpl::InitRotaryEventCallback() { Eext_Rotary_Event_Info* event_info) -> Eina_Bool { WebViewImpl* self = static_cast(user_data); if (!self->listener_) - return; + return EINA_FALSE; Eext_Rotary_Event_Info* rotary = event_info; -- 2.7.4 From cb897ea9e7955483620f8b7787644d07ce26a267 Mon Sep 17 00:00:00 2001 From: Youngmin Yoo Date: Thu, 22 Dec 2016 13:29:37 +0900 Subject: [PATCH 04/16] Support the orientation lock for Tizen 2.4 compatibility. In Tizen 2.4 WebKit locking screen orientation was possible with WebAPI screen.lockOrientation(). This WebAPI was deprecated and replaced with screen.orientation.lock(). But for compatibility case Web Engine needs to support old API. So WRT also need to support the orientation lock for backward compatibility. Releted web engine patch: https://review.tizen.org/gerrit/#/c/106159/ https://review.tizen.org/gerrit/#/c/105156/ Bug : http://suprem.sec.samsung.net/jira/browse/TWF-2640 Bug : http://suprem.sec.samsung.net/jira/browse/TWF-2698 Change-Id: I4542929c731a4c5218cfccba3592562720d21e89 Signed-off-by: Youngmin Yoo --- runtime/browser/web_application.cc | 50 ++++++++++++++++++++++++++++---------- runtime/browser/web_application.h | 9 +++++++ 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index fabbd02..17f08aa 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -410,10 +410,27 @@ bool WebApplication::Initialize() { return true; } +void WebApplication::SetupTizenVersion() { + if (app_data_->tizen_application_info() != NULL && + !app_data_->tizen_application_info()->required_version().empty()) { + std::string tizen_version = app_data_->tizen_application_info()->required_version(); + std::vector parsed_tizen_version = ParseTizenVersion(tizen_version); + m_tizenCompatibilitySettings.m_major = parsed_tizen_version[0]; + m_tizenCompatibilitySettings.m_minor = parsed_tizen_version[1]; + m_tizenCompatibilitySettings.m_release = parsed_tizen_version[0]; + } +} + +bool WebApplication::tizenWebKitCompatibilityEnabled() const { + return m_tizenCompatibilitySettings.tizenWebKitCompatibilityEnabled(); +} + void WebApplication::Launch(std::unique_ptr appcontrol) { // send widget info to injected bundle ewk_context_tizen_app_id_set(ewk_context_, appid_.c_str()); + SetupTizenVersion(); + // Setup View WebView* view = new WebView(window_, ewk_context_); SetupWebView(view); @@ -702,13 +719,20 @@ void WebApplication::OnOrientationLock( // Only top-most view can set the orientation relate operation if (view_stack_.front() != view) return; - auto orientaion_setting = - app_data_->setting_info() != NULL - ? app_data_->setting_info()->screen_orientation() - : - wgt::parse::SettingInfo::ScreenOrientation::AUTO; - if (orientaion_setting != wgt::parse::SettingInfo::ScreenOrientation::AUTO) { - return; + // This is for 2.4 compatibility. Requested by Webengine Team. + // + // In Tizen 2.4 WebKit locking screen orientation was possible with Web API + // screen.lockOrientation(). This API was deprecated and replaced with + // screen.orientation.lock(). But for compatibility case we need to support + // old API. + if(!tizenWebKitCompatibilityEnabled()) { + auto orientaion_setting = app_data_->setting_info() != NULL + ? app_data_->setting_info()->screen_orientation() + : wgt::parse::SettingInfo::ScreenOrientation::AUTO; + if (wgt::parse::SettingInfo::ScreenOrientation::AUTO != orientaion_setting) { + // If Tizen version is 3.0, it return. + return; + } } if (lock) { @@ -951,13 +975,13 @@ void WebApplication::SetupWebView(WebView* view) { } void WebApplication::SetupWebViewTizenApplicationInfo(WebView* view) { - if (app_data_->tizen_application_info() != NULL && - !app_data_->tizen_application_info()->required_version().empty()) { + if (tizenWebKitCompatibilityEnabled()) { Ewk_Settings* settings = ewk_view_settings_get(view->evas_object()); - std::string tizen_version = app_data_->tizen_application_info()->required_version(); - std::vector parsed_tizen_version = ParseTizenVersion(tizen_version); - ewk_settings_tizen_compatibility_mode_set(settings, parsed_tizen_version[0], parsed_tizen_version[1], parsed_tizen_version[2]); - } + ewk_settings_tizen_compatibility_mode_set(settings, + m_tizenCompatibilitySettings.m_major, + m_tizenCompatibilitySettings.m_minor, + m_tizenCompatibilitySettings.m_release); + } } bool WebApplication::OnDidNavigation(WebView* /*view*/, diff --git a/runtime/browser/web_application.h b/runtime/browser/web_application.h index 915287d..fe5d594 100755 --- a/runtime/browser/web_application.h +++ b/runtime/browser/web_application.h @@ -115,6 +115,15 @@ class WebApplication : public WebView::EventListener { void SetupWebViewTizenApplicationInfo(WebView* view); void RemoveWebViewFromStack(WebView* view); + void SetupTizenVersion(); + bool tizenWebKitCompatibilityEnabled() const; + struct { + unsigned m_major; + unsigned m_minor; + unsigned m_release; + bool tizenWebKitCompatibilityEnabled() const { return (m_major && m_major < 3); } + } m_tizenCompatibilitySettings; + bool launched_; bool debug_mode_; bool verbose_mode_; -- 2.7.4 From 12d7e69351097af2a99a59abef0879b156eae5e3 Mon Sep 17 00:00:00 2001 From: Youngmin Yoo Date: Mon, 26 Dec 2016 17:30:48 +0900 Subject: [PATCH 05/16] fixup! Support the orientation lock for Tizen 2.4 compatibility. This patch fixes parsed tizen verion. Change-Id: If1b2ba0b78a76f0eee0b6e896c1e705e26f5cf68 Signed-off-by: Youngmin Yoo --- runtime/browser/web_application.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index ca662af..49c4478 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -428,7 +428,7 @@ void WebApplication::SetupTizenVersion() { std::vector parsed_tizen_version = ParseTizenVersion(tizen_version); m_tizenCompatibilitySettings.m_major = parsed_tizen_version[0]; m_tizenCompatibilitySettings.m_minor = parsed_tizen_version[1]; - m_tizenCompatibilitySettings.m_release = parsed_tizen_version[0]; + m_tizenCompatibilitySettings.m_release = parsed_tizen_version[2]; } } -- 2.7.4 From a23e752ec1e31c10dffbaca1d95a2c1f2941b64d Mon Sep 17 00:00:00 2001 From: Youngcheol Kang Date: Tue, 27 Dec 2016 15:15:41 +0900 Subject: [PATCH 06/16] Apply the suspend before closing webview In order to prevent crash/freeze issue, the webview should be suspended before closing. Bug: http://suprem.sec.samsung.net/jira/browse/TWF-2711 Change-Id: I0e69d0ccc12c41eae58b5989aeca317babcee780 Signed-off-by: Youngcheol Kang --- runtime/browser/web_application.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index 49c4478..27195f3 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -180,6 +180,7 @@ static Eina_Bool ExitAppIdlerCallback(void* data) { for (; it != vstack.end(); ++it) { vstack.front()->SetVisibility(false); + (*it)->Suspend(); ewk_view_page_close((*it)->evas_object()); } } @@ -278,6 +279,7 @@ WebApplication::~WebApplication() { window_->SetContent(NULL); auto it = view_stack_.begin(); for (; it != view_stack_.end(); ++it) { + (*it)->Suspend(); delete *it; } view_stack_.clear(); @@ -641,6 +643,7 @@ void WebApplication::RemoveWebViewFromStack(WebView* view) { view->SetEventListener(NULL); Terminate(); } else { + view->Suspend(); ewk_view_page_close(view->evas_object()); return; } -- 2.7.4 From a405e58397ecd67886c49f08a6d0d38028f56622 Mon Sep 17 00:00:00 2001 From: Youngmin Yoo Date: Thu, 22 Dec 2016 14:15:49 +0900 Subject: [PATCH 07/16] Improve privilege checker. Privilege check: - given default privilege when application installed. - added privilege in config.xml by Application developer. Bug: P161214-04760 Bug: http://suprem.sec.samsung.net/jira/browse/TWF-2681 Change-Id: Ic21058964aa98ca26460b6717dca063aaf406043 Signed-off-by: Youngmin Yoo --- build/common.gypi | 1 + build/cynara-client.gypi | 16 ++++++++++ common/common.gyp | 1 + packaging/crosswalk-tizen.spec | 1 + runtime/browser/web_application.cc | 63 +++++++++++++++++++++++++++++++++----- 5 files changed, 75 insertions(+), 7 deletions(-) create mode 100644 build/cynara-client.gypi diff --git a/build/common.gypi b/build/common.gypi index 876c0fe..ec6b82a 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -28,6 +28,7 @@ }], ], 'includes': [ + 'cynara-client.gypi', 'pkg-config.gypi', 'xwalk_js2c.gypi', ], diff --git a/build/cynara-client.gypi b/build/cynara-client.gypi new file mode 100644 index 0000000..b0fac97 --- /dev/null +++ b/build/cynara-client.gypi @@ -0,0 +1,16 @@ +{ + 'variables': { + 'pkg-config': 'pkg-config', + }, + 'cflags': [ + ' -#include #include +#include +#include #include #include #include +#include #include #include @@ -98,10 +100,12 @@ const char* kAmbientTickEventScript = "for (var i=0; i < window.frames.length; i++)\n" "{ window.frames[i].document.dispatchEvent(__event); }" "})()"; +const char* kCameraPrivilege = "http://tizen.org/privilege/camera"; const char* kFullscreenPrivilege = "http://tizen.org/privilege/fullscreen"; const char* kFullscreenFeature = "fullscreen"; const char* kNotificationPrivilege = "http://tizen.org/privilege/notification"; const char* kLocationPrivilege = "http://tizen.org/privilege/location"; +const char* kRecordPrivilege = "http://tizen.org/privilege/recorder"; const char* kStoragePrivilege = "http://tizen.org/privilege/unlimitedstorage"; const char* kUsermediaPrivilege = "http://tizen.org/privilege/mediacapture"; const char* kNotiIconFile = "noti_icon.png"; @@ -128,9 +132,11 @@ const char* kDefaultCSPRule = const char* kResWgtPath = "res/wgt/"; const char* kAppControlMain = "http://tizen.org/appcontrol/operation/main"; -bool FindPrivilege(common::ApplicationData* app_data, +// Looking for added privilege by Application developer in config.xml. +bool FindPrivilegeFromConfig(common::ApplicationData* app_data, const std::string& privilege) { if (app_data->permissions_info().get() == NULL) return false; + LOGGER(INFO) << "Finding privilege from config.xml"; auto it = app_data->permissions_info()->GetAPIPermissions().begin(); auto end = app_data->permissions_info()->GetAPIPermissions().end(); for (; it != end; ++it) { @@ -139,6 +145,47 @@ bool FindPrivilege(common::ApplicationData* app_data, return false; } +// Looking for given default privilege when application installed. +bool FindPrivilegeFromCynara(const std::string& privilege_name) { + LOGGER(INFO) << "Finding privilege from cynara db"; + static constexpr char kSmackLabelFilePath[] = "/proc/self/attr/current"; + std::ifstream file(kSmackLabelFilePath); + if (!file.is_open()) { + LOGGER(ERROR) << "Failed to open " << kSmackLabelFilePath; + return false; + } + + int ret; + cynara* p_cynara = NULL; + ret = cynara_initialize(&p_cynara, 0); + if (CYNARA_API_SUCCESS != ret) { + LOGGER(ERROR) << "Failed. The result of cynara_initialize() : " << ret; + return false; + } + + std::string uid = std::to_string(getuid()); + std::string smack_label{std::istreambuf_iterator(file), + std::istreambuf_iterator()}; + + bool result = false; + ret = cynara_check(p_cynara, smack_label.c_str(), "", uid.c_str(), privilege_name.c_str()); + if (CYNARA_API_ACCESS_ALLOWED != ret) { + LOGGER(ERROR) << "Access denied. The result of cynara_check() : " << ret; + } else { + LOGGER(INFO) << "Access allowed! The result of cynara_check() : " << ret; + result = true; + } + + if (p_cynara) { + ret = cynara_finish(p_cynara); + if (CYNARA_API_SUCCESS != ret) { + LOGGER(ERROR) << "Failed. The result of cynara_finish() : " << ret; + } + } + + return result; +} + static void SendDownloadRequest(const std::string& url) { common::AppControl request; request.set_operation(APP_CONTROL_OPERATION_DOWNLOAD); @@ -348,7 +395,7 @@ bool WebApplication::Initialize() { this); InitializeNotificationCallback(ewk_context_, this); - if (FindPrivilege(app_data_, kFullscreenPrivilege)) { + if (FindPrivilegeFromConfig(app_data_, kFullscreenPrivilege)) { ewk_context_tizen_extensible_api_string_set(ewk_context_, kFullscreenFeature, true); } @@ -1043,7 +1090,7 @@ void WebApplication::OnNotificationPermissionRequest( // Local Domain: Grant permission if defined, otherwise Popup user prompt. // Remote Domain: Popup user prompt. if (common::utils::StartsWith(url, "file://") && - FindPrivilege(app_data_, kNotificationPrivilege)) { + FindPrivilegeFromConfig(app_data_, kNotificationPrivilege)) { result_handler(true); return; } @@ -1083,7 +1130,8 @@ void WebApplication::OnGeolocationPermissionRequest( // Local Domain: Grant permission if defined, otherwise block execution. // Remote Domain: Popup user prompt if defined, otherwise block execution. - if (!FindPrivilege(app_data_, kLocationPrivilege)) { + if (!FindPrivilegeFromConfig(app_data_, kLocationPrivilege) && + !FindPrivilegeFromCynara(kLocationPrivilege)) { result_handler(false); return; } @@ -1128,7 +1176,7 @@ void WebApplication::OnQuotaExceed(WebView*, const std::string& url, // Local Domain: Grant permission if defined, otherwise Popup user prompt. // Remote Domain: Popup user prompt. if (common::utils::StartsWith(url, "file://") && - FindPrivilege(app_data_, kStoragePrivilege)) { + FindPrivilegeFromConfig(app_data_, kStoragePrivilege)) { result_handler(true); return; } @@ -1224,7 +1272,8 @@ void WebApplication::OnUsermediaPermissionRequest( // Local Domain: Grant permission if defined, otherwise block execution. // Remote Domain: Popup user prompt if defined, otherwise block execution. - if (!FindPrivilege(app_data_, kUsermediaPrivilege)) { + if (!FindPrivilegeFromConfig(app_data_, kUsermediaPrivilege) && + !(FindPrivilegeFromCynara(kCameraPrivilege) && FindPrivilegeFromCynara(kRecordPrivilege))) { result_handler(false); return; } -- 2.7.4 From 38e9ba832327c75448136718b1240b23f8af07b4 Mon Sep 17 00:00:00 2001 From: Youngsoo Choi Date: Tue, 27 Dec 2016 00:23:50 +0900 Subject: [PATCH 08/16] Defer main loop until window is completely closed When uninstalling a webapp is performed while running the webapp, there's no enough time for termination of render thread by |OnTerminate|. In that case, the life-cycle of main loop needs to be guaranteed until closing window callback is called. So, this CL defers main loop until window is completely closed and removes previously implemented timer for the termination. Bug: TSAM-12072 Url: http://suprem.sec.samsung.net/jira/browse/TSAM-12072 Change-Id: I095d522f70d1c1759d07f697a179986fea7ebab5 Signed-off-by: Youngsoo Choi --- runtime/browser/ime_runtime.cc | 1 + runtime/browser/runtime.cc | 15 +++++++++++++++ runtime/browser/runtime.h | 5 +++++ runtime/browser/runtime_process.cc | 26 +++++--------------------- runtime/browser/ui_runtime.cc | 3 +-- runtime/browser/watch_runtime.cc | 9 +-------- runtime/browser/watch_runtime.h | 1 - runtime/browser/web_application.cc | 9 +++++++-- 8 files changed, 35 insertions(+), 34 deletions(-) mode change 100755 => 100644 runtime/browser/runtime.cc mode change 100644 => 100755 runtime/browser/runtime.h diff --git a/runtime/browser/ime_runtime.cc b/runtime/browser/ime_runtime.cc index 9cdc3db..0527c83 100644 --- a/runtime/browser/ime_runtime.cc +++ b/runtime/browser/ime_runtime.cc @@ -164,6 +164,7 @@ void ImeRuntime::OnCreate() { void ImeRuntime::OnTerminate() { LOGGER(DEBUG) << "ime_app_terminate"; + ClosePageFromOnTerminate(application_); } void ImeRuntime::OnShow(int context_id, ime_context_h context) { diff --git a/runtime/browser/runtime.cc b/runtime/browser/runtime.cc old mode 100755 new mode 100644 index 051ffe0..a2e0c03 --- a/runtime/browser/runtime.cc +++ b/runtime/browser/runtime.cc @@ -32,6 +32,8 @@ namespace runtime { +bool Runtime::is_on_terminate_called = false; + Runtime::~Runtime() { } @@ -55,5 +57,18 @@ std::unique_ptr Runtime::MakeRuntime( } } +void Runtime::ClosePageFromOnTerminate(WebApplication* app) { + if (app) { + std::list vstack = app->view_stack(); + auto it = vstack.begin(); + if (it != vstack.end()) { + Runtime::is_on_terminate_called = true; + for (; it != vstack.end(); ++it) { + vstack.front()->SetVisibility(false); + ewk_view_page_close((*it)->evas_object()); + } + } + } +} } // namespace runtime diff --git a/runtime/browser/runtime.h b/runtime/browser/runtime.h old mode 100644 new mode 100755 index db4ef00..b4f1029 --- a/runtime/browser/runtime.h +++ b/runtime/browser/runtime.h @@ -22,6 +22,7 @@ #include #include "common/application_data.h" +#include "runtime/browser/web_application.h" namespace runtime { @@ -31,8 +32,12 @@ class Runtime { virtual int Exec(int argc, char* argv[]) = 0; + static bool is_on_terminate_called; static std::unique_ptr MakeRuntime( common::ApplicationData* app_data); + + protected: + void ClosePageFromOnTerminate(WebApplication* app); }; } // namespace runtime diff --git a/runtime/browser/runtime_process.cc b/runtime/browser/runtime_process.cc index 0f015fe..1d01b99 100755 --- a/runtime/browser/runtime_process.cc +++ b/runtime/browser/runtime_process.cc @@ -33,17 +33,10 @@ #include "runtime/browser/prelauncher.h" #include "runtime/browser/preload_manager.h" -bool g_prelaunch = false; +#include "runtime/browser/ui_runtime.h" -#ifdef IME_FEATURE_SUPPORT -static Ecore_Timer* timeout = NULL; +bool g_prelaunch = false; -static Eina_Bool terminateDelayCallback(void* data) { - timeout = NULL; - ecore_main_loop_quit(); - return ECORE_CALLBACK_CANCEL; -} -#endif #ifdef WATCH_FACE_FEATURE_SUPPORT static int setWatchEnv(int argc, char **argv) { bundle *kb = NULL; @@ -139,20 +132,11 @@ int real_main(int argc, char* argv[]) { std::unique_ptr runtime = runtime::Runtime::MakeRuntime(appdata); ret = runtime->Exec(argc, argv); + if (runtime->is_on_terminate_called) { + ecore_main_loop_begin(); + } runtime.reset(); } -#ifdef IME_FEATURE_SUPPORT - if (appdata->app_type() == common::ApplicationData::IME) { - timeout = ecore_timer_add(0.5, terminateDelayCallback, NULL); - // This timer is added because of deadlock issue. - // If default keyboard is switched from webapp keyboard to tizen keyboard - // before webapp keyboard is completely loaded, main loop waits - // until webview is closed where webview is waiting to finish load. - // This timer delays main loop shutdown until webview load is finished. - // FIXME: http://suprem.sec.samsung.net/jira/browse/TSAM-11361 - ecore_main_loop_begin(); - } -#endif ewk_shutdown(); elm_shutdown(); elm_exit(); diff --git a/runtime/browser/ui_runtime.cc b/runtime/browser/ui_runtime.cc index 20dddc6..4e20943 100755 --- a/runtime/browser/ui_runtime.cc +++ b/runtime/browser/ui_runtime.cc @@ -142,8 +142,7 @@ bool UiRuntime::OnCreate() { } void UiRuntime::OnTerminate() { - application_.reset(); - native_window_.reset(); + ClosePageFromOnTerminate(application_.get()); } void UiRuntime::OnPause() { diff --git a/runtime/browser/watch_runtime.cc b/runtime/browser/watch_runtime.cc index afc3dbd..657a7f1 100644 --- a/runtime/browser/watch_runtime.cc +++ b/runtime/browser/watch_runtime.cc @@ -99,14 +99,7 @@ bool WatchRuntime::OnCreate() { } void WatchRuntime::OnTerminate() { - if (application_) { - delete application_; - application_ = nullptr; - } - if (native_window_) { - delete native_window_; - native_window_ = nullptr; - } + ClosePageFromOnTerminate(application_); } void WatchRuntime::OnPause() { diff --git a/runtime/browser/watch_runtime.h b/runtime/browser/watch_runtime.h index 8838c0d..94c23d2 100644 --- a/runtime/browser/watch_runtime.h +++ b/runtime/browser/watch_runtime.h @@ -24,7 +24,6 @@ #include "common/application_data.h" #include "runtime/browser/runtime.h" #include "runtime/browser/native_window.h" -#include "runtime/browser/web_application.h" namespace runtime { diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index d146265..30be530 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -44,6 +44,7 @@ #include "runtime/browser/vibration_manager.h" #include "runtime/browser/web_view.h" #include "runtime/browser/splash_screen.h" +#include "runtime/browser/ui_runtime.h" #include "extensions/common/xwalk_extension_server.h" #ifndef INJECTED_BUNDLE_PATH @@ -709,8 +710,12 @@ void WebApplication::RemoveWebViewFromStack(WebView* view) { } void WebApplication::OnClosedWebView(WebView* view) { - is_terminated_by_callback_ = true; - RemoveWebViewFromStack(view); + is_terminated_by_callback_ = true; + RemoveWebViewFromStack(view); + + if (runtime::Runtime::is_on_terminate_called) { + ecore_main_loop_quit(); + } } void WebApplication::OnReceivedWrtMessage(WebView* /*view*/, -- 2.7.4 From 8c28224dffb6361852e26af2153433e3fadc9df8 Mon Sep 17 00:00:00 2001 From: Youngcheol Kang Date: Tue, 27 Dec 2016 16:09:11 +0900 Subject: [PATCH 09/16] Reply to javascript dialog before closing webview In order to prevent crash/fress issue, this patch adds the codes which call the ewk_view_javascript_alert_reply() when internal popup was opened. Bug: http://suprem.sec.samsung.net/jira/browse/TWF-2715 Change-Id: I029f0cbc4ffc5b8bb9cdf2dc35d40e0f69c9338f Signed-off-by: Youngcheol Kang --- runtime/browser/web_application.cc | 6 +++++- runtime/browser/web_view.cc | 4 ++++ runtime/browser/web_view.h | 1 + runtime/browser/web_view_impl.cc | 8 ++++++++ runtime/browser/web_view_impl.h | 1 + 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index 30be530..f5f16ba 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -711,6 +711,8 @@ void WebApplication::RemoveWebViewFromStack(WebView* view) { void WebApplication::OnClosedWebView(WebView* view) { is_terminated_by_callback_ = true; + // Reply to javascript dialog for preventing freeze issue. + view->ReplyToJavascriptDialog(); RemoveWebViewFromStack(view); if (runtime::Runtime::is_on_terminate_called) { @@ -718,7 +720,7 @@ void WebApplication::OnClosedWebView(WebView* view) { } } -void WebApplication::OnReceivedWrtMessage(WebView* /*view*/, +void WebApplication::OnReceivedWrtMessage(WebView* view, Ewk_IPC_Wrt_Message_Data* msg) { Eina_Stringshare* msg_type = ewk_ipc_wrt_message_data_type_get(msg); @@ -739,6 +741,8 @@ void WebApplication::OnReceivedWrtMessage(WebView* /*view*/, window_->InActive(); } else if (TYPE_IS("tizen://exit")) { // One Way Message + // Reply to javascript dialog for preventing freeze issue. + view->ReplyToJavascriptDialog(); ecore_idler_add(ExitAppIdlerCallback, this); } else if (TYPE_IS("tizen://changeUA")) { // Async Message diff --git a/runtime/browser/web_view.cc b/runtime/browser/web_view.cc index c96a28f..7f2b4fe 100644 --- a/runtime/browser/web_view.cc +++ b/runtime/browser/web_view.cc @@ -32,6 +32,10 @@ WebView::~WebView() { delete impl_; } +void WebView::ReplyToJavascriptDialog() { + impl_->ReplyToJavascriptDialog(); +} + void WebView::LoadUrl(const std::string& url, const std::string& mime) { impl_->LoadUrl(url, mime); } diff --git a/runtime/browser/web_view.h b/runtime/browser/web_view.h index 29a6fad..9441db2 100644 --- a/runtime/browser/web_view.h +++ b/runtime/browser/web_view.h @@ -116,6 +116,7 @@ class WebView { WebView(NativeWindow* window, Ewk_Context* context); virtual ~WebView(); + void ReplyToJavascriptDialog(); void LoadUrl(const std::string& url, const std::string& mime = std::string()); std::string GetUrl(); diff --git a/runtime/browser/web_view_impl.cc b/runtime/browser/web_view_impl.cc index 25b2dc3..ca2a92c 100644 --- a/runtime/browser/web_view_impl.cc +++ b/runtime/browser/web_view_impl.cc @@ -87,6 +87,7 @@ WebViewImpl::WebViewImpl(WebView* view, WebViewImpl::~WebViewImpl() { if (internal_popup_opened_) { + internal_popup_opened_ = false; ewk_view_javascript_alert_reply(ewk_view_); } Deinitialize(); @@ -95,6 +96,13 @@ WebViewImpl::~WebViewImpl() { evas_smart_free(evas_smart_class_); } +void WebViewImpl::ReplyToJavascriptDialog() { + if (internal_popup_opened_) { + internal_popup_opened_ = false; + ewk_view_javascript_alert_reply(ewk_view_); + } +} + void WebViewImpl::LoadUrl(const std::string& url, const std::string& mime) { SCOPE_PROFILE(); if (!mime.empty()) { diff --git a/runtime/browser/web_view_impl.h b/runtime/browser/web_view_impl.h index eba7748..b97fb79 100644 --- a/runtime/browser/web_view_impl.h +++ b/runtime/browser/web_view_impl.h @@ -36,6 +36,7 @@ class WebViewImpl { WebViewImpl(WebView* view, NativeWindow* window, Ewk_Context* context); virtual ~WebViewImpl(); + void ReplyToJavascriptDialog(); void LoadUrl(const std::string& url, const std::string& mime = std::string()); std::string GetUrl(); -- 2.7.4 From 6fc53455d5b8b4d0693cced38e70e5ebfd7f2bb1 Mon Sep 17 00:00:00 2001 From: Youngmin Yoo Date: Thu, 29 Dec 2016 11:01:33 +0900 Subject: [PATCH 10/16] Change UserMedia popup message 3.0 UserMedia popup message has wrong mapping. BUG : http://suprem.sec.samsung.net/jira/browse/TWF-2729 Change-Id: Id74ea20f780f00ac35123975f661715653c2fae3 Signed-off-by: Youngmin Yoo --- runtime/browser/popup_string.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/browser/popup_string.cc b/runtime/browser/popup_string.cc index 8bf48be..d6172d6e 100755 --- a/runtime/browser/popup_string.cc +++ b/runtime/browser/popup_string.cc @@ -40,7 +40,7 @@ const char kPopupBodyCert[] = const char kPopupBodyGeoLocation[] = "IDS_WRT_BODY_ALLOWS_THIS_SITE_TO_ACCESS_YOUR_LOCATION_INFORMATION"; const char kPopupBodyUserMedia[] = - "IDS_WRT_BODY_ALLOWS_THIS_SITE_TO_USE_THE_MEDIA_FILES_STORED_ON_YOUR_DEVICE"; + "IDS_BR_POP_P1SS_HP2SS_IS_REQUESTING_PERMISSION_TO_USE_YOUR_CAMERA"; const char kPopupBodyWebNotification[] = "IDS_WRT_BODY_ALLOWS_THIS_SITE_TO_DISPLAY_NOTIFICATIONS"; const char kPopupBodyWebStorage[] = -- 2.7.4 From a554a6ba46892023faf3a4aef4cc6bb9a7ae9fa6 Mon Sep 17 00:00:00 2001 From: Youngsoo Choi Date: Mon, 2 Jan 2017 22:33:48 +0900 Subject: [PATCH 11/16] Refactor ClosePageFromOnTerminate The view stack needs to be handled in class WebApplication. Bug: http://suprem.sec.samsung.net/jira/browse/TWF-2743 Change-Id: Ide43a3d254da9d1746b5235a97ed401aa24ea7b8 Signed-off-by: Youngsoo Choi --- runtime/browser/runtime.cc | 13 ++----------- runtime/browser/web_application.cc | 11 +++++++++++ runtime/browser/web_application.h | 1 + 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/runtime/browser/runtime.cc b/runtime/browser/runtime.cc index a2e0c03..bba1168 100644 --- a/runtime/browser/runtime.cc +++ b/runtime/browser/runtime.cc @@ -58,17 +58,8 @@ std::unique_ptr Runtime::MakeRuntime( } void Runtime::ClosePageFromOnTerminate(WebApplication* app) { - if (app) { - std::list vstack = app->view_stack(); - auto it = vstack.begin(); - if (it != vstack.end()) { - Runtime::is_on_terminate_called = true; - for (; it != vstack.end(); ++it) { - vstack.front()->SetVisibility(false); - ewk_view_page_close((*it)->evas_object()); - } - } - } + if (app) + app->ClosePageFromOnTerminate(); } } // namespace runtime diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index f5f16ba..753711a 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -655,6 +655,17 @@ void WebApplication::Terminate() { extension_server->Shutdown(); } +void WebApplication::ClosePageFromOnTerminate() { + auto it = view_stack_.begin(); + if (it != view_stack_.end()) { + runtime::Runtime::is_on_terminate_called = true; + for (; it != view_stack_.end(); ++it) { + view_stack_.front()->SetVisibility(false); + ewk_view_page_close((*it)->evas_object()); + } + } +} + void WebApplication::OnCreatedNewWebView(WebView* /*view*/, WebView* new_view) { if (view_stack_.size() > 0 && view_stack_.front() != NULL) view_stack_.front()->SetVisibility(false); diff --git a/runtime/browser/web_application.h b/runtime/browser/web_application.h index f219a37..1c31d21 100755 --- a/runtime/browser/web_application.h +++ b/runtime/browser/web_application.h @@ -52,6 +52,7 @@ class WebApplication : public WebView::EventListener { void Suspend(); void Terminate(); + void ClosePageFromOnTerminate(); std::string data_path() const { return app_data_path_; } void set_terminator(std::function terminator) { terminator_ = terminator; -- 2.7.4 From 8b10d34491ddfcc7cf5fd3d75aa873e070c2ea7e Mon Sep 17 00:00:00 2001 From: Youngsoo Choi Date: Tue, 3 Jan 2017 13:10:51 +0900 Subject: [PATCH 12/16] Reply to javascript dialog when exiting by command |pkgcmd| There's an issue not to kill web app when javascript dialog is opened even if the command |pkgcmd -k -n | is executed to kill the web app. To prevent the issue, this CL replies to the dialog to close it right before the termination. Bug: TSAM-11809, TSAM-11813 Url: http://suprem.sec.samsung.net/jira/browse/TSAM-11809 Url: http://suprem.sec.samsung.net/jira/browse/TSAM-11813 Change-Id: I4757f45b3731d25cb57876f12c7b2e52b9f62af7 Signed-off-by: Youngsoo Choi --- runtime/browser/web_application.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index 753711a..856c8ab 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -660,6 +660,7 @@ void WebApplication::ClosePageFromOnTerminate() { if (it != view_stack_.end()) { runtime::Runtime::is_on_terminate_called = true; for (; it != view_stack_.end(); ++it) { + (*it)->ReplyToJavascriptDialog(); view_stack_.front()->SetVisibility(false); ewk_view_page_close((*it)->evas_object()); } -- 2.7.4 From 345ed487fb09774323ab7d23fbbf6a5bb1eec7f8 Mon Sep 17 00:00:00 2001 From: "jaekuk, lee" Date: Wed, 4 Jan 2017 11:13:00 +0900 Subject: [PATCH 13/16] Add a api of tizen version when creating new web view and when receiving a event of appcontrol. Change-Id: Ica6df4f23e4a6637ae448e95080fcfb882add280 Signed-off-by: jaekuk, lee --- runtime/browser/web_application.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index 856c8ab..4d8fe2c 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -579,6 +579,7 @@ void WebApplication::AppControl( ClearViewStack(); WebView* view = view_stack_.front(); SetupWebView(view); + SetupWebViewTizenApplicationInfo(view); view->SetDefaultEncoding(res->encoding()); view->LoadUrl(res->uri(), res->mime()); window_->SetContent(view->evas_object()); @@ -672,6 +673,7 @@ void WebApplication::OnCreatedNewWebView(WebView* /*view*/, WebView* new_view) { view_stack_.front()->SetVisibility(false); SetupWebView(new_view); + SetupWebViewTizenApplicationInfo(new_view); view_stack_.push_front(new_view); window_->SetContent(new_view->evas_object()); } -- 2.7.4 From cdda603905ece7c48b08917f083e5f83dc10bb16 Mon Sep 17 00:00:00 2001 From: Youngmin Yoo Date: Thu, 5 Jan 2017 12:58:18 +0900 Subject: [PATCH 14/16] Fix URI scheme parsing IP/Host on the internet ex) http://user:password@www.tizen.org:8080/market/Item?12345 url_ = http://user:password@www.tizen.org:8080/market/Item?12345 scheme_ = http domain_ = www.tizen.org user_ = user password_ = password Link : https://www.w3.org/Addressing/rfc1738.txt Bug : P161229-04063 Bug : http://suprem.sec.samsung.net/jira/browse/TWF-2753 Change-Id: I71fbc95c5b71cd36c370c3ed34fe6d8176cb21a7 Signed-off-by: Youngmin Yoo --- common/url.cc | 5 +++++ common/url.h | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/common/url.cc b/common/url.cc index adfbff1..898190c 100644 --- a/common/url.cc +++ b/common/url.cc @@ -109,9 +109,14 @@ void URLImpl::ExtractDomain() { size_t start_of_domain = scheme_.empty() ? 0 : scheme_.length() + kSchemeIdLen; size_t end_of_domain = url_.find_first_of('/', start_of_domain); + size_t at = url_.find_first_of('@', start_of_domain); + if (at < end_of_domain) { + start_of_domain = at + 1; + } domain_ = url_.substr(start_of_domain, end_of_domain == std::string::npos ? std::string::npos : end_of_domain - start_of_domain); + LOGGER(INFO) << "Extract Domain is " << domain_; } void URLImpl::ExtractDomainPort() { diff --git a/common/url.h b/common/url.h index 89ef348..222e738 100644 --- a/common/url.h +++ b/common/url.h @@ -38,12 +38,14 @@ class URLImpl; * => domain_, path_ * * If the url does not have specific data, an empty string will be stored - * in the corresponding variables. + * in the corresponding variables.(RFC 1738) * - * ex) http://user:password@www.google.co.kr:8080/market/Item?12345 - * url_ = http://user:password@www.google.co.kr:8080/market/Item?12345 + * ex) http://user:password@www.tizen.org:8080/market/Item?12345 + * url_ = http://user:password@www.tizen.org:8080/market/Item?12345 * scheme_ = http - * domain_ = user:password@www.google.co.kr + * user_ = user + * password_ = password + * domain_ = www.tizen.org * port_ = 8080 * path_ = /market/Item?12345 */ -- 2.7.4 From 7ba3ec0f4e4b83abf21ad2b9bf8fd46a65427383 Mon Sep 17 00:00:00 2001 From: "ws29.jung" Date: Thu, 5 Jan 2017 13:22:04 +0900 Subject: [PATCH 15/16] Fix Hardware Key action when popup is on This patch fix hardware key handling when popup is shown. Before this patch, hardware key handled in wrt before popup action is done when key is repidly tabbed. Now when popup is on, wrt will not trigger event. Bug: http://suprem.sec.samsung.net/jira/browse/TSAM-12331 Change-Id: I7b620e4f4349e8c54849ee9d24a66c0ccbe062f7 Signed-off-by: ws29.jung --- runtime/browser/web_view_impl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/browser/web_view_impl.cc b/runtime/browser/web_view_impl.cc index ca2a92c..cc52275 100644 --- a/runtime/browser/web_view_impl.cc +++ b/runtime/browser/web_view_impl.cc @@ -993,7 +993,7 @@ void WebViewImpl::OnKeyEvent(Eext_Callback_Type key_type) { return; } - if (listener_) { + if (listener_ && !internal_popup_opened_) { listener_->OnHardwareKey(view_, keyname); } } -- 2.7.4 From a3b39d11bcfdb312ccbfde756457a9b1de87c946 Mon Sep 17 00:00:00 2001 From: "jaekuk, lee" Date: Thu, 5 Jan 2017 12:32:33 +0900 Subject: [PATCH 16/16] Modify prefix and suffix checking the allowed domain [P161229-05961]login page runs in browser Change-Id: I960af6fd8254fcf071516f43f53f9650f0c357b2 Signed-off-by: jaekuk, lee --- common/resource_manager.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 common/resource_manager.cc diff --git a/common/resource_manager.cc b/common/resource_manager.cc old mode 100644 new mode 100755 index 203f454..8881428 --- a/common/resource_manager.cc +++ b/common/resource_manager.cc @@ -519,12 +519,12 @@ bool ResourceManager::CheckAllowNavigation(const std::string& url) { bool prefix_wild = false; bool suffix_wild = false; std::string a_domain = a_domain_info.domain(); - if (utils::StartsWith(a_domain, "*.")) { + if (utils::StartsWith(a_domain, "*")) { prefix_wild = true; // *.domain.com -> .domain.com a_domain = a_domain.substr(1); } - if (utils::EndsWith(a_domain, ".*")) { + if (utils::EndsWith(a_domain, "*")) { suffix_wild = true; // domain.* -> domain. a_domain = a_domain.substr(0, a_domain.length() - 1); -- 2.7.4