Commit 31beb806 authored by Lukasz Anforowicz's avatar Lukasz Anforowicz Committed by Commit Bot

GuestViewBase::GetOwnerSiteURL needs to work before the owner commits.

Before this CL, GuestViewBase::GetOwnerSiteURL would return:
    owner_web_contents()->GetLastCommittedURL()

The code above is incorrect for two reasons:
1. It doesn't account for about:blank URLs
2. It doesn't work before |owner_web_contents()| commit their first
   navigation.

Problem #2 is what happens when a new, blank popup is opened and then
written to via document.write.  In such scenario, GetOwnerSiteURL would
return an invalid URL which incorrectly caused PDF rendering pipeline to
fail by rejecting invalid URLs in URLPattern::MatchesURL:
  URLPattern::MatchesURL()
  extensions::URLPatternSet::MatchesURL()
  extensions::SimpleFeature::GetContextAvailability()
  extensions::SimpleFeature::IsAvailableToContext()
  extensions::ExtensionsGuestViewManagerDelegate::IsGuestAvailableToContext()
     ^- IsGuestAvailableToContext passes result of
        GetOwnerSiteURL to IsAvailableToContext above
  guest_view::GuestViewBase::Init()
  guest_view::GuestViewManager::CreateGuest()
  extensions::MimeHandlerViewEmbedder::CreateMimeHandlerViewGuest()

Bug: 1041880
Change-Id: I252a15e464d70a7131c101b4f4889fa9fa968a66
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2023047Reviewed-by: default avatarCharlie Reis <creis@chromium.org>
Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737817}
parent d8266b32
......@@ -445,7 +445,7 @@ WebContents* GuestViewBase::GetOwnerWebContents() {
}
const GURL& GuestViewBase::GetOwnerSiteURL() const {
return owner_web_contents()->GetLastCommittedURL();
return owner_web_contents()->GetMainFrame()->GetSiteInstance()->GetSiteURL();
}
bool GuestViewBase::ShouldDestroyOnDetach() const {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment