Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 #include "core/page/WindowFeatures.h" | 41 #include "core/page/WindowFeatures.h" |
| 42 #include "platform/UserGestureIndicator.h" | 42 #include "platform/UserGestureIndicator.h" |
| 43 #include "platform/network/ResourceRequest.h" | 43 #include "platform/network/ResourceRequest.h" |
| 44 #include "platform/weborigin/KURL.h" | 44 #include "platform/weborigin/KURL.h" |
| 45 #include "platform/weborigin/SecurityOrigin.h" | 45 #include "platform/weborigin/SecurityOrigin.h" |
| 46 #include "platform/weborigin/SecurityPolicy.h" | 46 #include "platform/weborigin/SecurityPolicy.h" |
| 47 #include "public/platform/WebURLRequest.h" | 47 #include "public/platform/WebURLRequest.h" |
| 48 | 48 |
| 49 namespace blink { | 49 namespace blink { |
| 50 | 50 |
| 51 static Frame* createWindow(LocalFrame& openerFrame, LocalFrame& lookupFrame, con st FrameLoadRequest& request, const WindowFeatures& features, NavigationPolicy p olicy, ShouldSendReferrer shouldSendReferrer) | 51 static Frame* createWindow(LocalFrame& openerFrame, LocalFrame& lookupFrame, con st FrameLoadRequest& request, const WindowFeatures& features, NavigationPolicy p olicy, ReferrerPolicy referrerPolicy) |
| 52 { | 52 { |
| 53 ASSERT(!features.dialog || request.frameName().isEmpty()); | 53 ASSERT(!features.dialog || request.frameName().isEmpty()); |
| 54 ASSERT(request.resourceRequest().requestorOrigin() || openerFrame.document() ->url().isEmpty()); | 54 ASSERT(request.resourceRequest().requestorOrigin() || openerFrame.document() ->url().isEmpty()); |
| 55 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeAuxi liary); | 55 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeAuxi liary); |
| 56 | 56 |
| 57 if (!request.frameName().isEmpty() && request.frameName() != "_blank" && pol icy == NavigationPolicyIgnore) { | 57 if (!request.frameName().isEmpty() && request.frameName() != "_blank" && pol icy == NavigationPolicyIgnore) { |
| 58 if (Frame* frame = lookupFrame.findFrameForNavigation(request.frameName( ), openerFrame)) { | 58 if (Frame* frame = lookupFrame.findFrameForNavigation(request.frameName( ), openerFrame)) { |
| 59 if (request.frameName() != "_self") { | 59 if (request.frameName() != "_self") { |
| 60 if (FrameHost* host = frame->host()) { | 60 if (FrameHost* host = frame->host()) { |
| 61 if (host == openerFrame.host()) | 61 if (host == openerFrame.host()) |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 75 return nullptr; | 75 return nullptr; |
| 76 } | 76 } |
| 77 | 77 |
| 78 if (openerFrame.settings() && !openerFrame.settings()->supportsMultipleWindo ws()) | 78 if (openerFrame.settings() && !openerFrame.settings()->supportsMultipleWindo ws()) |
| 79 return openerFrame.tree().top(); | 79 return openerFrame.tree().top(); |
| 80 | 80 |
| 81 FrameHost* oldHost = openerFrame.host(); | 81 FrameHost* oldHost = openerFrame.host(); |
| 82 if (!oldHost) | 82 if (!oldHost) |
| 83 return nullptr; | 83 return nullptr; |
| 84 | 84 |
| 85 Page* page = oldHost->chrome().client().createWindow(&openerFrame, request, features, policy, shouldSendReferrer); | 85 Page* page = oldHost->chrome().client().createWindow(&openerFrame, request, features, policy, referrerPolicy); |
| 86 if (!page) | 86 if (!page) |
| 87 return nullptr; | 87 return nullptr; |
| 88 FrameHost* host = &page->frameHost(); | 88 FrameHost* host = &page->frameHost(); |
| 89 | 89 |
| 90 ASSERT(page->mainFrame()); | 90 ASSERT(page->mainFrame()); |
| 91 Frame& frame = *page->mainFrame(); | 91 Frame& frame = *page->mainFrame(); |
| 92 | 92 |
| 93 if (request.frameName() != "_blank") | 93 if (request.frameName() != "_blank") |
| 94 frame.tree().setName(request.frameName()); | 94 frame.tree().setName(request.frameName()); |
| 95 | 95 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 | 141 |
| 142 // Normally, FrameLoader would take care of setting the referrer for a navig ation that is | 142 // Normally, FrameLoader would take care of setting the referrer for a navig ation that is |
| 143 // triggered from javascript. However, creating a window goes through suffic ient processing | 143 // triggered from javascript. However, creating a window goes through suffic ient processing |
| 144 // that it eventually enters FrameLoader as an embedder-initiated navigation . FrameLoader | 144 // that it eventually enters FrameLoader as an embedder-initiated navigation . FrameLoader |
| 145 // assumes no responsibility for generating an embedder-initiated navigation 's referrer, | 145 // assumes no responsibility for generating an embedder-initiated navigation 's referrer, |
| 146 // so we need to ensure the proper referrer is set now. | 146 // so we need to ensure the proper referrer is set now. |
| 147 frameRequest.resourceRequest().setHTTPReferrer(SecurityPolicy::generateRefer rer(activeFrame->document()->referrerPolicy(), completedURL, activeFrame->docume nt()->outgoingReferrer())); | 147 frameRequest.resourceRequest().setHTTPReferrer(SecurityPolicy::generateRefer rer(activeFrame->document()->referrerPolicy(), completedURL, activeFrame->docume nt()->outgoingReferrer())); |
| 148 | 148 |
| 149 // We pass the opener frame for the lookupFrame in case the active frame is different from | 149 // We pass the opener frame for the lookupFrame in case the active frame is different from |
| 150 // the opener frame, and the name references a frame relative to the opener frame. | 150 // the opener frame, and the name references a frame relative to the opener frame. |
| 151 Frame* newFrame = createWindow(*activeFrame, openerFrame, frameRequest, wind owFeatures, NavigationPolicyIgnore, MaybeSendReferrer); | 151 Frame* newFrame = createWindow(*activeFrame, openerFrame, frameRequest, wind owFeatures, NavigationPolicyIgnore, ReferrerPolicyDefault); |
|
Mike West
2015/05/20 07:56:42
This would previously have read the referrer polic
burnik
2015/05/20 08:27:56
Not quite sure at this point. I just followed this
| |
| 152 if (!newFrame) | 152 if (!newFrame) |
| 153 return nullptr; | 153 return nullptr; |
| 154 | 154 |
| 155 newFrame->client()->setOpener(&openerFrame); | 155 newFrame->client()->setOpener(&openerFrame); |
| 156 | 156 |
| 157 if (!newFrame->domWindow()->isInsecureScriptAccess(callingWindow, completedU RL)) | 157 if (!newFrame->domWindow()->isInsecureScriptAccess(callingWindow, completedU RL)) |
| 158 newFrame->navigate(*callingWindow.document(), completedURL, false); | 158 newFrame->navigate(*callingWindow.document(), completedURL, false); |
| 159 return newFrame->domWindow(); | 159 return newFrame->domWindow(); |
| 160 } | 160 } |
| 161 | 161 |
| 162 void createWindowForRequest(const FrameLoadRequest& request, LocalFrame& openerF rame, NavigationPolicy policy, ShouldSendReferrer shouldSendReferrer) | 162 void createWindowForRequest(const FrameLoadRequest& request, LocalFrame& openerF rame, NavigationPolicy policy, ReferrerPolicy referrerPolicy) |
| 163 { | 163 { |
| 164 ASSERT(request.resourceRequest().requestorOrigin() || (openerFrame.document( ) && openerFrame.document()->url().isEmpty())); | 164 ASSERT(request.resourceRequest().requestorOrigin() || (openerFrame.document( ) && openerFrame.document()->url().isEmpty())); |
| 165 | 165 |
| 166 if (openerFrame.document()->pageDismissalEventBeingDispatched() != Document: :NoDismissal) | 166 if (openerFrame.document()->pageDismissalEventBeingDispatched() != Document: :NoDismissal) |
| 167 return; | 167 return; |
| 168 | 168 |
| 169 if (openerFrame.document() && openerFrame.document()->isSandboxed(SandboxPop ups)) | 169 if (openerFrame.document() && openerFrame.document()->isSandboxed(SandboxPop ups)) |
| 170 return; | 170 return; |
| 171 | 171 |
| 172 if (!LocalDOMWindow::allowPopUp(openerFrame)) | 172 if (!LocalDOMWindow::allowPopUp(openerFrame)) |
| 173 return; | 173 return; |
| 174 | 174 |
| 175 if (policy == NavigationPolicyCurrentTab) | 175 if (policy == NavigationPolicyCurrentTab) |
| 176 policy = NavigationPolicyNewForegroundTab; | 176 policy = NavigationPolicyNewForegroundTab; |
| 177 | 177 |
| 178 WindowFeatures features; | 178 WindowFeatures features; |
| 179 Frame* newFrame = createWindow(openerFrame, openerFrame, request, features, policy, shouldSendReferrer); | 179 Frame* newFrame = createWindow(openerFrame, openerFrame, request, features, policy, referrerPolicy); |
| 180 if (!newFrame) | 180 if (!newFrame) |
| 181 return; | 181 return; |
| 182 if (shouldSendReferrer == MaybeSendReferrer) { | 182 if (referrerPolicy != ReferrerPolicyNever) { |
| 183 newFrame->client()->setOpener(&openerFrame); | 183 newFrame->client()->setOpener(&openerFrame); |
| 184 // TODO(japhet): Does ReferrerPolicy need to be proagated for RemoteFram es? | 184 // TODO(japhet): Does ReferrerPolicy need to be proagated for RemoteFram es? |
| 185 if (newFrame->isLocalFrame()) | 185 if (newFrame->isLocalFrame()) |
| 186 toLocalFrame(newFrame)->document()->setReferrerPolicy(openerFrame.do cument()->referrerPolicy()); | 186 toLocalFrame(newFrame)->document()->setReferrerPolicy(openerFrame.do cument()->referrerPolicy()); |
|
Mike West
2015/05/20 07:56:42
Hrm. What is this code doing? Why are we pushing t
burnik
2015/05/20 08:27:56
This was a bit confusing to me too. I'll ponder on
| |
| 187 } | 187 } |
| 188 | 188 |
| 189 // TODO(japhet): Form submissions on RemoteFrames don't work yet. | 189 // TODO(japhet): Form submissions on RemoteFrames don't work yet. |
| 190 FrameLoadRequest newRequest(0, request.resourceRequest()); | 190 FrameLoadRequest newRequest(0, request.resourceRequest()); |
| 191 newRequest.setForm(request.form()); | 191 newRequest.setForm(request.form()); |
| 192 if (newFrame->isLocalFrame()) | 192 if (newFrame->isLocalFrame()) |
| 193 toLocalFrame(newFrame)->loader().load(newRequest); | 193 toLocalFrame(newFrame)->loader().load(newRequest); |
| 194 } | 194 } |
| 195 | 195 |
| 196 } // namespace blink | 196 } // namespace blink |
| OLD | NEW |