From c9458d0ddabf6f9c30918d77b8b6ae9904f8d099 Mon Sep 17 00:00:00 2001 From: Seungkeun Lee Date: Tue, 21 Apr 2015 19:51:00 +0900 Subject: [PATCH] Add main loop exit method in WebApplication Change-Id: I7d77f0daa8dfcf326b69d91788181dd2a805fe5f --- src/runtime/runtime.cc | 1 + src/runtime/web_application.cc | 10 +++++++--- src/runtime/web_application.h | 4 ++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/runtime/runtime.cc b/src/runtime/runtime.cc index 72bb987..e17dfa0 100755 --- a/src/runtime/runtime.cc +++ b/src/runtime/runtime.cc @@ -44,6 +44,7 @@ bool Runtime::OnCreate() { LoggerE("WebApplication couldn't be created."); return false; } + application_->set_terminator([](){ ui_app_exit(); }); // Process First Launch native_window_ = CreateNativeWindow(); diff --git a/src/runtime/web_application.cc b/src/runtime/web_application.cc index d224622..cb87a3b 100755 --- a/src/runtime/web_application.cc +++ b/src/runtime/web_application.cc @@ -62,7 +62,8 @@ WebApplication::WebApplication(const std::string& appid) ewk_context_(ewk_context_new()), locale_manager_(new LocaleManager()), app_data_(new ApplicationData(appid)), - debug_mode_(false) { + debug_mode_(false), + terminator_(NULL) { // app_data_path std::unique_ptr path {app_get_data_path(), std::free}; @@ -78,7 +79,8 @@ WebApplication::WebApplication(std::unique_ptr app_data) ewk_context_(ewk_context_new()), locale_manager_(new LocaleManager()), app_data_(std::move(app_data)), - debug_mode_(false) { + debug_mode_(false), + terminator_(NULL) { // app_data_path std::unique_ptr path {app_get_data_path(), std::free}; @@ -267,7 +269,9 @@ void WebApplication::OnClosedWebView(WebView * view) { } if (view_stack_.size() == 0) { - // TODO(sngn.lee): terminate the webapp + if (terminator_ != NULL) { + terminator_(); + } } else if (current != view_stack_.front()) { view_stack_.front()->SetVisibility(true); window_->SetContent(view_stack_.front()->evas_object()); diff --git a/src/runtime/web_application.h b/src/runtime/web_application.h index 2b8873a..a3837eb 100755 --- a/src/runtime/web_application.h +++ b/src/runtime/web_application.h @@ -8,6 +8,7 @@ #include #include #include +#include #include "runtime/web_view.h" #include "extension/extension_server.h" @@ -34,6 +35,8 @@ class WebApplication : public WebView::EventListener { bool Initialize(NativeWindow* window); std::string data_path() const { return app_data_path_; } bool initialized() const { return initialized_; } + void set_terminator(std::function terminator) + { terminator_ = terminator; } virtual void OnCreatedNewWebView(WebView* view, WebView* new_view); virtual void OnClosedWebView(WebView * view); @@ -67,6 +70,7 @@ class WebApplication : public WebView::EventListener { std::unique_ptr locale_manager_; std::unique_ptr app_data_; bool debug_mode_; + std::function terminator_; }; } // namespace wrt -- 2.7.4