Fix the Download crash issue 67/126067/3 accepted/tizen/unified/20170420.155911 submit/tizen/20170420.102547
authorHyeKyoung Hwang <cookie@samsung.com>
Thu, 20 Apr 2017 04:47:37 +0000 (13:47 +0900)
committerHyeKyoung Hwang <cookie@samsung.com>
Thu, 20 Apr 2017 10:08:39 +0000 (19:08 +0900)
[ Problem] When download https://tizenpackage.blob.core.windows.net/tizenpackage/119/XamarinApplication.TizenMobile-1.0.0.tpk, browse have the crash
[ Cause ] Before the download, browser close the window by evas_object_smart_callback_call(wv->m_ewkView, "close,window", nullptr);

Change-Id: I5e8e126236165e20ba183f93a38226b4ba27ff98
Signed-off-by: HyeKyoung Hwang <cookie@samsung.com>
services/WebEngineService/WebView.cpp

index f2c45f8..a29e4ac 100755 (executable)
@@ -336,7 +336,7 @@ void WebView::unregisterCallbacks()
     evas_object_smart_callback_del_full(m_ewkView, "load,provisional,started", __load_provisional_started, this);
     evas_object_smart_callback_del_full(m_ewkView, "load,provisional,redirect", __load_provisional_redirect, this);
 
-    evas_object_smart_callback_del_full(m_ewkView, "contextmenu,customize", __contextmenu_customize_cb,this);
+    evas_object_smart_callback_del_full(m_ewkView, "contextmenu,customize", __contextmenu_customize_cb, this);
     evas_object_smart_callback_del_full(m_ewkView, "contextmenu,selected", __contextmenu_selected_cb, this);
     evas_object_smart_callback_del_full(m_ewkView, "fullscreen,enterfullscreen", __fullscreen_enter_cb, this);
     evas_object_smart_callback_del_full(m_ewkView, "fullscreen,exitfullscreen", __fullscreen_exit_cb, this);
@@ -441,7 +441,7 @@ void WebView::setPWAData()
         + "&icon=" + std::string(text = curl_easy_escape(curl, s_icon.c_str(), s_icon.length()));
     curl_free(text);
     retVal += "&name=" + s_name
-        + "&uri=" + std::string(text = curl_easy_escape(curl,m_manifestData.start_url.c_str(),
+        + "&uri=" + std::string(text = curl_easy_escape(curl, m_manifestData.start_url.c_str(),
             m_manifestData.start_url.length()));
     curl_free(text);
     retVal += "&pwa_shortName=" + m_manifestData.short_name
@@ -587,8 +587,9 @@ void WebView::reload(void)
     if (m_loadError) {
         m_loadError = false;
         ewk_view_url_set(m_ewkView, ewk_view_url_get(m_ewkView));
-    } else
+    } else {
         ewk_view_reload(m_ewkView);
+    }
 }
 
 void WebView::back(void)
@@ -636,10 +637,12 @@ void WebView::confirmationResult(WebConfirmationPtr confirmation)
         Ewk_Certificate_Policy_Decision *request = m_confirmationCertificatenMap[cert];
         Eina_Bool result;
 
-        if (cert->getResult() == WebConfirmation::ConfirmationResult::Confirmed)
+        if (cert->getResult() == WebConfirmation::ConfirmationResult::Confirmed) {
             result = EINA_TRUE;
-        else if (cert->getResult() == WebConfirmation::ConfirmationResult::Rejected)
+        }
+        else if (cert->getResult() == WebConfirmation::ConfirmationResult::Rejected) {
             result = EINA_FALSE;
+        }
         else {
             BROWSER_LOGE("Wrong ConfirmationResult");
             return;
@@ -706,7 +709,7 @@ tools::BrowserImagePtr WebView::captureSnapshot(int targetWidth, int targetHeigh
             BROWSER_LOGD("[%s:%d] ewk_view_screenshot_contents_get_async API failed", __func__, __LINE__);
     } else {
         Evas_Object *snapshot = ewk_view_screenshot_contents_get(m_ewkView, area, scale, evas_object_evas_get(m_ewkView));
-        BROWSER_LOGD("[%s:%d] Snapshot (screenshot) catched, evas pointer: %p",__func__, __LINE__, snapshot);
+        BROWSER_LOGD("[%s:%d] Snapshot (screenshot) catched, evas pointer: %p", __func__, __LINE__, snapshot);
         if (snapshot)
             return std::make_shared<tools::BrowserImage>(snapshot);
     }
@@ -819,8 +822,8 @@ void WebView::__setManifestData(Evas_Object *view, Ewk_View_Request_Manifest *ma
 
         } else {
             BROWSER_LOGW("No manifest for webview!");
-            std::string uri=self->getURI();
-             shortcut_add_to_home(self->m_title.c_str(), LAUNCH_BY_URI, uri.c_str(),nullptr, 0, result_cb, nullptr);
+            std::string uri = self->getURI();
+             shortcut_add_to_home(self->m_title.c_str(), LAUNCH_BY_URI, uri.c_str(), nullptr, 0, result_cb, nullptr);
         }
     } else {
         BROWSER_LOGW("No View or data!");
@@ -885,16 +888,14 @@ void WebView::__loadError(void* data, Evas_Object * obj, void* ewkError)
 
     BROWSER_LOGD("[%s:%d] emiting signal ", __PRETTY_FUNCTION__, __LINE__);
     int errorCode = ewk_error_code_get(error);
-    if(errorCode == EWK_ERROR_NETWORK_STATUS_CANCELLED)
-    {
+    if (errorCode == EWK_ERROR_NETWORK_STATUS_CANCELLED) {
         BROWSER_LOGD("Stop signal emitted");
         BROWSER_LOGD("Error description: %s", ewk_error_description_get(error));
         evas_object_smart_callback_call(obj, "load,stop", nullptr);
     }
-    else
-    {
+    else {
         self->loadError();
-        self->m_loadError=true;
+        self->m_loadError = true;
     }
 }
 
@@ -906,8 +907,9 @@ void WebView::__focusWebView(void *data, Evas_Object * /* obj */, void * /*event
     if (data) {
         auto *self = static_cast<WebView *>(data);
         self->focusWebView();
-    } else
+    } else {
         BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__);
+    }
 }
 #endif
 
@@ -943,7 +945,7 @@ void WebView::__faviconChanged(void* data, Evas_Object*, void*)
     if(data)
     {
         WebView * self = static_cast<WebView *>(data);
-        Evas_Object * favicon = ewk_context_icon_database_icon_object_add(self->m_ewkContext, ewk_view_url_get(self->m_ewkView),evas_object_evas_get(self->m_ewkView));
+        Evas_Object * favicon = ewk_context_icon_database_icon_object_add(self->m_ewkContext, ewk_view_url_get(self->m_ewkView), evas_object_evas_get(self->m_ewkView));
         if (favicon) {
             BROWSER_LOGD("[%s:%d] Favicon received", __PRETTY_FUNCTION__, __LINE__);
             self->m_faviconImage = std::make_shared<tools::BrowserImage>(favicon);
@@ -1670,18 +1672,19 @@ void WebView::__policy_response_decide_cb(void *data, Evas_Object * /* obj */, v
 
     case EWK_POLICY_DECISION_DOWNLOAD: {
         BROWSER_LOGD("[%s:%d] policy_download", __PRETTY_FUNCTION__, __LINE__);
-        evas_object_smart_callback_call(wv->m_ewkView, "close,window", nullptr);
         const char *uri = ewk_policy_decision_url_get(policy_decision);
         const char *content_type = ewk_policy_decision_response_mime_get(policy_decision);
         const Eina_Hash *headers = ewk_policy_decision_response_headers_get(policy_decision);
         app_control_h app_control = nullptr;
         if (app_control_create(&app_control) < 0) {
             BROWSER_LOGE("[%s:%d] Fail to app_control_create", __PRETTY_FUNCTION__, __LINE__);
+            //evas_object_smart_callback_call(wv->m_ewkView, "close,window", nullptr);
             return;
          }
 
         if (app_control_set_operation(app_control, APP_CONTROL_OPERATION_VIEW) < 0) {
             BROWSER_LOGE("[%s:%d] Fail to app_control_set_operation", __PRETTY_FUNCTION__, __LINE__);
+            //evas_object_smart_callback_call(wv->m_ewkView, "close,window", nullptr);
             app_control_destroy(app_control);
             return;
          }
@@ -1689,6 +1692,7 @@ void WebView::__policy_response_decide_cb(void *data, Evas_Object * /* obj */, v
         BROWSER_LOGD("[%s:%d] uri: %s", __PRETTY_FUNCTION__, __LINE__, uri);
         if (app_control_set_uri(app_control, uri) < 0) {
             BROWSER_LOGE("[%s:%d] Fail to app_control_set_uri", __PRETTY_FUNCTION__, __LINE__);
+            //evas_object_smart_callback_call(wv->m_ewkView, "close,window", nullptr);
             app_control_destroy(app_control);
             return;
          }
@@ -1696,7 +1700,8 @@ void WebView::__policy_response_decide_cb(void *data, Evas_Object * /* obj */, v
         BROWSER_LOGD("[%s:%d] content_type: %s", __PRETTY_FUNCTION__, __LINE__, content_type);
         if (app_control_set_mime(app_control, content_type) < 0) {
             BROWSER_LOGE("[%s:%d] Fail to app_control_set_mime", __PRETTY_FUNCTION__, __LINE__);
-            app_control_destroy(app_control);
+          //evas_object_smart_callback_call(wv->m_ewkView, "close,window", nullptr);
+          app_control_destroy(app_control);
             return;
          }
 
@@ -1706,6 +1711,7 @@ void WebView::__policy_response_decide_cb(void *data, Evas_Object * /* obj */, v
             wv->m_downloadControl->handle_download_request(uri, content_type);
             app_control_destroy(app_control);
             ewk_policy_decision_ignore(policy_decision);
+          //evas_object_smart_callback_call(wv->m_ewkView, "close,window", nullptr);
             break;
          }
 
@@ -1715,6 +1721,7 @@ void WebView::__policy_response_decide_cb(void *data, Evas_Object * /* obj */, v
          }
         app_control_destroy(app_control);
         ewk_policy_decision_ignore(policy_decision);
+        //evas_object_smart_callback_call(wv->m_ewkView, "close,window", nullptr);
         break;
     }
     case EWK_POLICY_DECISION_IGNORE: