From acbd308b2b8a199b98a9da4d6e0cda2bf7f6d6ae Mon Sep 17 00:00:00 2001 From: Youngcheol Kang Date: Mon, 19 Dec 2016 18:46:49 +0900 Subject: [PATCH 01/16] Handle back-key behavior when viewmode is 'windowed' The Webview should be navigated back in history if the viewmode is 'windowed' in config.xml. This patch adds the codes for handling the back-key behavior when viewmode is 'windowed' for backward compatibility with Tizen 2.x. Bug: P161214-06597 Change-Id: I83dff6c297cbc2baa82fdd19a49b1f89a433710e Signed-off-by: Youngcheol Kang --- runtime/browser/web_application.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index 47da126..91614ee 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -725,8 +725,10 @@ void WebApplication::OnHardwareKey(WebView* view, const std::string& keyname) { view->EvalJavascript(kBackKeyEventScript); // NOTE: This code is added for backward compatibility. // If the 'backbutton_presence' is true, WebView should be navigated back. - if (app_data_->setting_info() && - app_data_->setting_info()->backbutton_presence()) { + if ((app_data_->setting_info() != NULL && + app_data_->setting_info()->backbutton_presence()) || + (app_data_->widget_info() != NULL && + app_data_->widget_info()->view_modes() == "windowed")) { if (!view->Backward()) { RemoveWebViewFromStack(view_stack_.front()); } -- 2.7.4 From 7b666c7222ef32130f1a887092bbaafc8628663b Mon Sep 17 00:00:00 2001 From: "jaekuk, lee" Date: Tue, 20 Dec 2016 11:05:33 +0900 Subject: [PATCH 02/16] Add ewk_settings_tizen_compatibility_mode_set API Change-Id: I23b837c6ecb49c5033e8945f8d92991a37b7eaf0 Signed-off-by: jaekuk, lee --- runtime/browser/web_application.cc | 25 +++++++++++++++++++++++++ runtime/browser/web_application.h | 1 + 2 files changed, 26 insertions(+) diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index 91614ee..50526f4 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -214,6 +214,20 @@ static bool ProcessWellKnownScheme(const std::string& url) { } // namespace +std::vector ParseTizenVersion(const std::string& tizen_string) { + std::vector version(3, 0); + for (unsigned i = 0, index = 0; i < tizen_string.size(); i++) { + if ((i % 2) == 0) { + if (isdigit(tizen_string[i]) && index < version.size()) + version[index++] = atoi(&tizen_string[i]); + else + return std::vector(3, 0); + } else if (tizen_string[i] != '.') + return std::vector(3, 0); + } + return version; +} + WebApplication::WebApplication( NativeWindow* window, common::ApplicationData* app_data) @@ -403,6 +417,7 @@ void WebApplication::Launch(std::unique_ptr appcontrol) { // Setup View WebView* view = new WebView(window_, ewk_context_); SetupWebView(view); + SetupWebViewTizenApplicationInfo(view); std::unique_ptr res = resource_manager_->GetStartResource(appcontrol.get()); @@ -935,6 +950,16 @@ 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()) { + 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]); + } +} + bool WebApplication::OnDidNavigation(WebView* /*view*/, const std::string& url) { // scheme handling diff --git a/runtime/browser/web_application.h b/runtime/browser/web_application.h index 75b934e..915287d 100755 --- a/runtime/browser/web_application.h +++ b/runtime/browser/web_application.h @@ -112,6 +112,7 @@ class WebApplication : public WebView::EventListener { void SendAppControlEvent(); void LaunchInspector(common::AppControl* appcontrol); void SetupWebView(WebView* view); + void SetupWebViewTizenApplicationInfo(WebView* view); void RemoveWebViewFromStack(WebView* view); bool launched_; -- 2.7.4 From c0a5770c5843a0a7671c103bf971dcafc3ee2ca2 Mon Sep 17 00:00:00 2001 From: "jaekuk, lee" Date: Tue, 20 Dec 2016 15:38:10 +0900 Subject: [PATCH 03/16] Change the location of BackKeyEvent Change-Id: I4b49a1f991527f2ebf314fbef36c80d4665bb6fb Signed-off-by: jaekuk, lee --- runtime/browser/web_application.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index 50526f4..fabbd02 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -727,9 +727,9 @@ void WebApplication::OnHardwareKey(WebView* view, const std::string& keyname) { if (!common::utils::StartsWith(view->GetUrl(), kFileScheme)) { if (kKeyNameBack == keyname) { LOGGER(DEBUG) << "Back to previous page for remote URL"; + if(enabled) + view->EvalJavascript(kBackKeyEventScript); if (!view->Backward()) { - if(enabled) - view->EvalJavascript(kBackKeyEventScript); RemoveWebViewFromStack(view_stack_.front()); } } -- 2.7.4 From fcf578a4aa5f6359ad8834a11ccc72725b7fb1f2 Mon Sep 17 00:00:00 2001 From: Youngcheol Kang Date: Fri, 23 Dec 2016 01:12:55 +0900 Subject: [PATCH 04/16] Fix the terminate routine to avoid deadlock in ewk_shutdown If ewk_shutdown is called when renderer thread works, the deadlock happens while exiting the web application. In order to prevent this deadlock problem, crosswalk don't terminate the web application directly, it terminate the web application using ewk_view_page_close API. By using ewk_view_page_close API, crosswalk can receive the callback that renderer thread was terminated. After then crosswalk call the ewk_shutdown. Bug: http://suprem.sec.samsung.net/jira/browse/TSAM-11982 Change-Id: I0d6279be0a03835ab58e2bf21443dcbba286f823 Signed-off-by: Youngcheol Kang --- runtime/browser/runtime_process.cc | 1 + runtime/browser/web_application.cc | 44 +++++++++++++++++++++++++++----------- runtime/browser/web_application.h | 2 ++ 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/runtime/browser/runtime_process.cc b/runtime/browser/runtime_process.cc index b115546..0f015fe 100755 --- a/runtime/browser/runtime_process.cc +++ b/runtime/browser/runtime_process.cc @@ -154,6 +154,7 @@ int real_main(int argc, char* argv[]) { } #endif ewk_shutdown(); + elm_shutdown(); elm_exit(); return EXIT_SUCCESS; diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index fabbd02..bdb6d76 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -173,8 +173,17 @@ static void InitializeNotificationCallback(Ewk_Context* ewk_context, static Eina_Bool ExitAppIdlerCallback(void* data) { WebApplication* app = static_cast(data); - if (app) - app->Terminate(); + + if (app) { + std::list vstack = app->view_stack(); + auto it = vstack.begin(); + + for (; it != vstack.end(); ++it) { + vstack.front()->SetVisibility(false); + ewk_view_page_close((*it)->evas_object()); + } + } + return ECORE_CALLBACK_CANCEL; } @@ -238,6 +247,7 @@ WebApplication::WebApplication( ewk_context_( ewk_context_new_with_injected_bundle_path(INJECTED_BUNDLE_PATH)), has_ownership_of_ewk_context_(true), + is_terminated_by_callback_(false), window_(window), appid_(app_data->app_id()), app_data_(app_data), @@ -255,6 +265,7 @@ WebApplication::WebApplication( verbose_mode_(false), ewk_context_(context), has_ownership_of_ewk_context_(false), + is_terminated_by_callback_(false), window_(window), appid_(app_data->app_id()), app_data_(app_data), @@ -567,6 +578,7 @@ void WebApplication::Suspend() { } void WebApplication::Terminate() { + is_terminated_by_callback_ = false; if (terminator_) { terminator_(); } else { @@ -586,28 +598,35 @@ void WebApplication::OnCreatedNewWebView(WebView* /*view*/, WebView* new_view) { } void WebApplication::RemoveWebViewFromStack(WebView* view) { - if (view_stack_.size() == 0) return; + if (view_stack_.size() == 0) { + if (is_terminated_by_callback_) { + Terminate(); + } else { + return; + } + } WebView* current = view_stack_.front(); if (current == view) { - // In order to prevent the crash issue due to the callback - // which occur after destroying WebApplication class, - // we have to set the 'SetEventListener' to NULL. - view->SetEventListener(NULL); view_stack_.pop_front(); } else { auto found = std::find(view_stack_.begin(), view_stack_.end(), view); if (found != view_stack_.end()) { - // In order to prevent the crash issue due to the callback - // which occur after destroying WebApplication class, - // we have to set the 'SetEventListener' to NULL. - view->SetEventListener(NULL); view_stack_.erase(found); } } if (view_stack_.size() == 0) { - Terminate(); + if (is_terminated_by_callback_) { + // In order to prevent the crash issue due to the callback + // which occur after destroying WebApplication class, + // we have to set the 'SetEventListener' to NULL. + view->SetEventListener(NULL); + Terminate(); + } else { + ewk_view_page_close(view->evas_object()); + return; + } } else if (current != view_stack_.front()) { view_stack_.front()->SetVisibility(true); window_->SetContent(view_stack_.front()->evas_object()); @@ -623,6 +642,7 @@ void WebApplication::RemoveWebViewFromStack(WebView* view) { } void WebApplication::OnClosedWebView(WebView* view) { + is_terminated_by_callback_ = true; RemoveWebViewFromStack(view); } diff --git a/runtime/browser/web_application.h b/runtime/browser/web_application.h index 915287d..89ffdaa 100755 --- a/runtime/browser/web_application.h +++ b/runtime/browser/web_application.h @@ -57,6 +57,7 @@ class WebApplication : public WebView::EventListener { terminator_ = terminator; } bool launched() const { return launched_; } + std::list view_stack() const { return view_stack_; } virtual void OnCreatedNewWebView(WebView* view, WebView* new_view); virtual void OnClosedWebView(WebView* view); @@ -121,6 +122,7 @@ class WebApplication : public WebView::EventListener { bool lang_changed_mode_; Ewk_Context* ewk_context_; bool has_ownership_of_ewk_context_; + bool is_terminated_by_callback_; NativeWindow* window_; std::string appid_; std::string app_data_path_; -- 2.7.4 From ad19b93ec04c84565c4dcbf2a77c17c970068cb7 Mon Sep 17 00:00:00 2001 From: Youngcheol Kang Date: Wed, 21 Dec 2016 20:31:11 +0900 Subject: [PATCH 05/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 06/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 07/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 08/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 09/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 10/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 11/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 12/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 13/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 a554a6ba46892023faf3a4aef4cc6bb9a7ae9fa6 Mon Sep 17 00:00:00 2001 From: Youngsoo Choi Date: Mon, 2 Jan 2017 22:33:48 +0900 Subject: [PATCH 14/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 15/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 cdda603905ece7c48b08917f083e5f83dc10bb16 Mon Sep 17 00:00:00 2001 From: Youngmin Yoo Date: Thu, 5 Jan 2017 12:58:18 +0900 Subject: [PATCH 16/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