From d6da556b700f674ab3504bcdd1261cc5ae9e6922 Mon Sep 17 00:00:00 2001 From: Tomasz Czekala Date: Fri, 6 Feb 2015 13:25:13 +0100 Subject: [PATCH] Fix crash in HandlePolicyResponseOnUIThread when WebContents is NULL In some situtations it was possible that HandlePolicyResponseOnUIThread was called after related WebContents was already gone or when there was no WebContents assigned to the Response Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=9527 Reviewed by: Jaesik Chang, Janusz Majnert, Kamil Klimek, Piotr Grad, Piotr Tworek Change-Id: Idb65a2684373a6a21543591f857a53d544090ac7 Signed-off-by: Tomasz Czekala --- .../browser/policy_response_delegate_efl.cc | 38 ++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/tizen_src/impl/browser/policy_response_delegate_efl.cc b/tizen_src/impl/browser/policy_response_delegate_efl.cc index fdec7f990ed0..7157aabda60b 100644 --- a/tizen_src/impl/browser/policy_response_delegate_efl.cc +++ b/tizen_src/impl/browser/policy_response_delegate_efl.cc @@ -26,6 +26,7 @@ using content::WebContents; using content::ResourceController; using web_contents_utils::WebContentsFromFrameID; +using web_contents_utils::WebContentsFromViewID; using web_contents_utils::WebViewFromWebContents; @@ -53,23 +54,42 @@ PolicyResponseDelegateEfl::PolicyResponseDelegateEfl( ResourceRequestInfo::GetRenderFrameForRequest(request, &render_process_id_, &render_frame_id_); } - /* - * In some situations there is no render_process and render_frame associated with - * request. Such situation happens in TC utc_blink_ewk_geolocation_permission_request_suspend_func - */ - //DCHECK(render_process_id_ > 0); - //DCHECK(render_frame_id_ > 0 || render_view_id_ > 0); - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, + // Chromium internal downloads are not associated with any frame or view, we should + // accept them without EWK-specific logic. For example notification icon is internal + // chromium download + if (render_process_id_ > 0 && (render_frame_id_ > 0 || render_view_id_ > 0)) { + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(&PolicyResponseDelegateEfl::HandlePolicyResponseOnUIThread, this)); + } else { + // Async call required! + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, + base::Bind(&PolicyResponseDelegateEfl::UseResponseOnIOThread, this)); + } } void PolicyResponseDelegateEfl::HandlePolicyResponseOnUIThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(policy_decision_.get()); - WebContents* web_contents = WebContentsFromFrameID( + WebContents* web_contents = NULL; + + DCHECK(render_process_id_ > 0); + DCHECK(render_frame_id_ > 0 || render_view_id_ > 0); + + if (render_frame_id_ > 0) { + web_contents = WebContentsFromFrameID( render_process_id_, render_frame_id_); - DCHECK(web_contents); + } else { + web_contents = WebContentsFromViewID(render_process_id_, render_view_id_); + } + + if (!web_contents) { + // this is a situation where we had frame/view info on IO thread but it + // does not exist now in UI. We'll ignore such responses + IgnoreResponse(); + return; + } + content::BrowserContextEfl* browser_context = static_cast( web_contents->GetBrowserContext()); -- 2.34.1