Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
Merge pull request #408 from brave/browser-laptop-issue-12327
Browse files Browse the repository at this point in the history
Fix basic auth crash by content::WebContents::FromFrameTreeNodeId
  • Loading branch information
bridiver authored Dec 19, 2017
2 parents 24b0666 + 468c387 commit da53f1a
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions atom/browser/login_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,23 @@ LoginHandler::~LoginHandler() {
content::WebContents* LoginHandler::GetWebContents() const {
DCHECK_CURRENTLY_ON(BrowserThread::UI);

content::RenderFrameHost* rfh = content::RenderFrameHost::FromID(
render_process_host_id_, render_frame_id_);
return content::WebContents::FromRenderFrameHost(rfh);
int frame_tree_node_id = -1;
auto* request_info = content::ResourceRequestInfo::ForRequest(request_);
if (request_info) {
frame_tree_node_id = request_info->GetFrameTreeNodeId();
}

content::WebContents* web_contents =
content::WebContents::FromFrameTreeNodeId(frame_tree_node_id);

if (!web_contents) {
content::RenderFrameHost* rfh =
content::RenderFrameHost::FromID(render_process_host_id_,
render_frame_id_);
web_contents = content::WebContents::FromRenderFrameHost(rfh);
}

return web_contents;
}

void LoginHandler::Login(const base::string16& username,
Expand Down

0 comments on commit da53f1a

Please sign in to comment.