Applying changes requested by @deepak1556 after the review:
- Move RenderFrameHost methods in the UI thread - Check GetAssociatedRenderFrame return value
This commit is contained in:
parent
1ad95eca4a
commit
5030db000a
1 changed files with 17 additions and 9 deletions
|
@ -67,7 +67,8 @@ void HandleExternalProtocolInUI(
|
||||||
|
|
||||||
void OnPdfResourceIntercepted(
|
void OnPdfResourceIntercepted(
|
||||||
const GURL& original_url,
|
const GURL& original_url,
|
||||||
int frame_tree_node_id,
|
int render_process_host_id,
|
||||||
|
int render_frame_id,
|
||||||
const content::ResourceRequestInfo::WebContentsGetter&
|
const content::ResourceRequestInfo::WebContentsGetter&
|
||||||
web_contents_getter) {
|
web_contents_getter) {
|
||||||
content::WebContents* web_contents = web_contents_getter.Run();
|
content::WebContents* web_contents = web_contents_getter.Run();
|
||||||
|
@ -91,7 +92,15 @@ void OnPdfResourceIntercepted(
|
||||||
content::NavigationController::LoadURLParams params(GURL(base::StringPrintf(
|
content::NavigationController::LoadURLParams params(GURL(base::StringPrintf(
|
||||||
"%sindex.html?%s=%s", kPdfViewerUIOrigin, kPdfPluginSrc,
|
"%sindex.html?%s=%s", kPdfViewerUIOrigin, kPdfPluginSrc,
|
||||||
net::EscapeUrlEncodedData(original_url.spec(), false).c_str())));
|
net::EscapeUrlEncodedData(original_url.spec(), false).c_str())));
|
||||||
params.frame_tree_node_id = frame_tree_node_id;
|
|
||||||
|
content::RenderFrameHost* frame_host =
|
||||||
|
content::RenderFrameHost::FromID(render_process_host_id, render_frame_id);
|
||||||
|
if (!frame_host)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
params.frame_tree_node_id = frame_host->GetFrameTreeNodeId();
|
||||||
web_contents->GetController().LoadURLWithParams(params);
|
web_contents->GetController().LoadURLWithParams(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,18 +153,17 @@ bool AtomResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream(
|
||||||
|
|
||||||
int render_process_host_id;
|
int render_process_host_id;
|
||||||
int render_frame_id;
|
int render_frame_id;
|
||||||
info->GetAssociatedRenderFrame(&render_process_host_id, &render_frame_id);
|
if (!info->GetAssociatedRenderFrame(&render_process_host_id, &render_frame_id))
|
||||||
content::RenderFrameHost* rfh =
|
{
|
||||||
content::RenderFrameHost::FromID(render_process_host_id, render_frame_id);
|
return false;
|
||||||
|
}
|
||||||
int frame_tree_node_id = rfh->GetFrameTreeNodeId();
|
|
||||||
|
|
||||||
if (mime_type == "application/pdf") {
|
if (mime_type == "application/pdf") {
|
||||||
*origin = GURL(kPdfViewerUIOrigin);
|
*origin = GURL(kPdfViewerUIOrigin);
|
||||||
content::BrowserThread::PostTask(
|
content::BrowserThread::PostTask(
|
||||||
BrowserThread::UI, FROM_HERE,
|
BrowserThread::UI, FROM_HERE,
|
||||||
base::Bind(&OnPdfResourceIntercepted, request->url(),
|
base::Bind(&OnPdfResourceIntercepted, request->url(),
|
||||||
frame_tree_node_id, info->GetWebContentsGetterForRequest()));
|
render_process_host_id, render_frame_id, info->GetWebContentsGetterForRequest()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue