Chromium Code Reviews| Index: extensions/renderer/script_context.cc |
| diff --git a/extensions/renderer/script_context.cc b/extensions/renderer/script_context.cc |
| index 197e6c0c764c6ee96c514d876b832a2dea46894d..5e41ec4e57868419253c5c2551aca06313fde3e8 100644 |
| --- a/extensions/renderer/script_context.cc |
| +++ b/extensions/renderer/script_context.cc |
| @@ -300,7 +300,7 @@ GURL ScriptContext::GetAccessCheckedFrameURL( |
| } |
| // static |
| -GURL ScriptContext::GetEffectiveDocumentURL(const blink::WebLocalFrame* frame, |
| +GURL ScriptContext::GetEffectiveDocumentURL(blink::WebLocalFrame* frame, |
| const GURL& document_url, |
| bool match_about_blank) { |
| // Common scenario. If |match_about_blank| is false (as is the case in most |
| @@ -312,7 +312,8 @@ GURL ScriptContext::GetEffectiveDocumentURL(const blink::WebLocalFrame* frame, |
| // Non-sandboxed about:blank and about:srcdoc pages inherit their security |
| // origin from their parent frame/window. So, traverse the frame/window |
| // hierarchy to find the closest non-about:-page and return its URL. |
| - const blink::WebFrame* parent = frame; |
| + blink::WebFrame* parent = frame; |
|
Łukasz Anforowicz
2017/06/15 20:15:59
The is no const-aware version of ToWebLocalFrame m
|
| + blink::WebDocument parent_document; |
| do { |
| if (parent->Parent()) |
| parent = parent->Parent(); |
| @@ -320,12 +321,15 @@ GURL ScriptContext::GetEffectiveDocumentURL(const blink::WebLocalFrame* frame, |
| parent = parent->Opener(); |
| else |
| parent = nullptr; |
| - } while (parent && !parent->GetDocument().IsNull() && |
| - GURL(parent->GetDocument().Url()).SchemeIs(url::kAboutScheme)); |
| - if (parent && !parent->GetDocument().IsNull()) { |
| + parent_document = blink::WebDocument(); |
|
dcheng
2017/06/15 23:17:00
Nit: no need to set parent_document here, it's alr
Łukasz Anforowicz
2017/06/16 19:39:24
We might need to reset |parent_document| on subseq
|
| + if (parent && parent->IsWebLocalFrame()) |
| + parent_document = parent->ToWebLocalFrame()->GetDocument(); |
| + } while (!parent_document.IsNull() && |
| + GURL(parent_document.Url()).SchemeIs(url::kAboutScheme)); |
| + |
| + if (!parent_document.IsNull()) { |
| // Only return the parent URL if the frame can access it. |
| - const blink::WebDocument& parent_document = parent->GetDocument(); |
| if (frame->GetDocument().GetSecurityOrigin().CanAccess( |
| parent_document.GetSecurityOrigin())) { |
| return parent_document.Url(); |