Fix WebEngine opened Popup related crash issue with workaround code
authorSeungkeun Lee <sngn.lee@samsung.com>
Fri, 28 Aug 2015 07:37:54 +0000 (16:37 +0900)
committerSeungkeun Lee <sngn.lee@samsung.com>
Mon, 31 Aug 2015 03:33:24 +0000 (20:33 -0700)
 - If popup(opened by webengein) was not closed when WebView was deleted, it will cause crash
 - When WebView was deleted, request closing popup to the webengine
 - popup close request API should be provided by webengine, currently use workaround API

Change-Id: I3ac2647e09c8d434b6398dbc3143a8e5bf77af20

src/runtime/web_view_impl.cc
src/runtime/web_view_impl.h

index 16fea01..628a88e 100755 (executable)
@@ -78,11 +78,15 @@ WebViewImpl::WebViewImpl(WebView* view,
       listener_(NULL),
       view_(view),
       fullscreen_(false),
-      evas_smart_class_(NULL) {
+      evas_smart_class_(NULL),
+      internal_popup_opened_(false) {
   Initialize();
 }
 
 WebViewImpl::~WebViewImpl() {
+  if (internal_popup_opened_) {
+    ewk_view_javascript_alert_reply(ewk_view_);
+  }
   Deinitialize();
   evas_object_del(ewk_view_);
   if (evas_smart_class_ != NULL)
@@ -187,6 +191,7 @@ void WebViewImpl::Initialize() {
   InitGeolocationPermissionCallback();
   InitAuthenticationCallback();
   InitCertificateAllowCallback();
+  InitPopupWaitCallback();
 
   Ewk_Settings* settings = ewk_view_settings_get(ewk_view_);
   ewk_settings_scripts_can_open_windows_set(settings, EINA_TRUE);
@@ -763,6 +768,22 @@ void WebViewImpl::InitCertificateAllowCallback() {
   smart_callbacks_["request,certificate,confirm"] = certi_callback;
 }
 
+void WebViewImpl::InitPopupWaitCallback() {
+  evas_object_smart_callback_add(ewk_view_,
+      "popup,reply,wait,start",
+      [](void* user_data, Evas_Object* /*obj*/, void*) {
+        WebViewImpl* self = static_cast<WebViewImpl*>(user_data);
+        self->internal_popup_opened_ = true;
+      }, this);
+  evas_object_smart_callback_add(ewk_view_,
+      "popup,reply,wait,finish",
+      [](void* user_data, Evas_Object* /*obj*/, void*) {
+        WebViewImpl* self = static_cast<WebViewImpl*>(user_data);
+        self->internal_popup_opened_ = false;
+      }, this);
+}
+
+
 
 std::string WebViewImpl::GetUrl() {
   return std::string(ewk_view_url_get(ewk_view_));
index dad7126..3631346 100755 (executable)
@@ -71,6 +71,7 @@ class WebViewImpl {
   void InitGeolocationPermissionCallback();
   void InitAuthenticationCallback();
   void InitCertificateAllowCallback();
+  void InitPopupWaitCallback();
 
   NativeWindow* window_;
   Ewk_Context* context_;
@@ -83,6 +84,7 @@ class WebViewImpl {
   std::string mime_;
   Evas_Smart* evas_smart_class_;
   Ewk_View_Smart_Class ewk_smart_class_;
+  bool internal_popup_opened_;
 };
 }  // namespace wrt