| 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 24 matching lines...) Expand all Loading... |
| 35 #include "core/loader/FrameLoadRequest.h" | 35 #include "core/loader/FrameLoadRequest.h" |
| 36 #include "core/page/Chrome.h" | 36 #include "core/page/Chrome.h" |
| 37 #include "core/page/ChromeClient.h" | 37 #include "core/page/ChromeClient.h" |
| 38 #include "core/page/FocusController.h" | 38 #include "core/page/FocusController.h" |
| 39 #include "core/page/Page.h" | 39 #include "core/page/Page.h" |
| 40 #include "core/page/WindowFeatures.h" | 40 #include "core/page/WindowFeatures.h" |
| 41 #include "platform/network/ResourceRequest.h" | 41 #include "platform/network/ResourceRequest.h" |
| 42 #include "platform/weborigin/KURL.h" | 42 #include "platform/weborigin/KURL.h" |
| 43 #include "platform/weborigin/SecurityOrigin.h" | 43 #include "platform/weborigin/SecurityOrigin.h" |
| 44 #include "platform/weborigin/SecurityPolicy.h" | 44 #include "platform/weborigin/SecurityPolicy.h" |
| 45 #include "public/platform/WebURLRequest.h" |
| 45 | 46 |
| 46 namespace blink { | 47 namespace blink { |
| 47 | 48 |
| 48 static LocalFrame* createWindow(LocalFrame& openerFrame, LocalFrame& lookupFrame
, const FrameLoadRequest& request, const WindowFeatures& features, NavigationPol
icy policy, ShouldSendReferrer shouldSendReferrer, bool& created) | 49 static LocalFrame* createWindow(LocalFrame& openerFrame, LocalFrame& lookupFrame
, const FrameLoadRequest& request, const WindowFeatures& features, NavigationPol
icy policy, ShouldSendReferrer shouldSendReferrer, bool& created) |
| 49 { | 50 { |
| 50 ASSERT(!features.dialog || request.frameName().isEmpty()); | 51 ASSERT(!features.dialog || request.frameName().isEmpty()); |
| 52 ASSERT(!request.resourceRequest().requestorURL().isEmpty() || openerFrame.do
cument()->url().isEmpty()); |
| 53 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeAuxi
liary); |
| 51 | 54 |
| 52 if (!request.frameName().isEmpty() && request.frameName() != "_blank" && pol
icy == NavigationPolicyIgnore) { | 55 if (!request.frameName().isEmpty() && request.frameName() != "_blank" && pol
icy == NavigationPolicyIgnore) { |
| 53 if (Frame* frame = lookupFrame.findFrameForNavigation(request.frameName(
), openerFrame)) { | 56 if (Frame* frame = lookupFrame.findFrameForNavigation(request.frameName(
), openerFrame)) { |
| 54 if (request.frameName() != "_self") { | 57 if (request.frameName() != "_self") { |
| 55 if (FrameHost* host = frame->host()) { | 58 if (FrameHost* host = frame->host()) { |
| 56 if (host == openerFrame.host()) | 59 if (host == openerFrame.host()) |
| 57 frame->page()->focusController().setFocusedFrame(frame); | 60 frame->page()->focusController().setFocusedFrame(frame); |
| 58 else | 61 else |
| 59 host->chrome().focus(); | 62 host->chrome().focus(); |
| 60 } | 63 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 ASSERT(activeFrame); | 134 ASSERT(activeFrame); |
| 132 | 135 |
| 133 KURL completedURL = urlString.isEmpty() ? KURL(ParsedURLString, emptyString(
)) : firstFrame.document()->completeURL(urlString); | 136 KURL completedURL = urlString.isEmpty() ? KURL(ParsedURLString, emptyString(
)) : firstFrame.document()->completeURL(urlString); |
| 134 if (!completedURL.isEmpty() && !completedURL.isValid()) { | 137 if (!completedURL.isEmpty() && !completedURL.isValid()) { |
| 135 // Don't expose client code to invalid URLs. | 138 // Don't expose client code to invalid URLs. |
| 136 callingWindow.printErrorMessage("Unable to open a window with invalid UR
L '" + completedURL.string() + "'.\n"); | 139 callingWindow.printErrorMessage("Unable to open a window with invalid UR
L '" + completedURL.string() + "'.\n"); |
| 137 return nullptr; | 140 return nullptr; |
| 138 } | 141 } |
| 139 | 142 |
| 140 FrameLoadRequest frameRequest(callingWindow.document(), completedURL, frameN
ame); | 143 FrameLoadRequest frameRequest(callingWindow.document(), completedURL, frameN
ame); |
| 144 frameRequest.resourceRequest().setFrameType(WebURLRequest::FrameTypeAuxiliar
y); |
| 145 frameRequest.resourceRequest().setRequestorURL(activeFrame->document()->url(
)); |
| 141 | 146 |
| 142 // Normally, FrameLoader would take care of setting the referrer for a navig
ation that is | 147 // 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 | 148 // triggered from javascript. However, creating a window goes through suffic
ient processing |
| 144 // that it eventually enters FrameLoader as an embedder-initiated navigation
. FrameLoader | 149 // that it eventually enters FrameLoader as an embedder-initiated navigation
. FrameLoader |
| 145 // assumes no responsibility for generating an embedder-initiated navigation
's referrer, | 150 // assumes no responsibility for generating an embedder-initiated navigation
's referrer, |
| 146 // so we need to ensure the proper referrer is set now. | 151 // 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())); | 152 frameRequest.resourceRequest().setHTTPReferrer(SecurityPolicy::generateRefer
rer(activeFrame->document()->referrerPolicy(), completedURL, activeFrame->docume
nt()->outgoingReferrer())); |
| 148 | 153 |
| 149 // We pass the opener frame for the lookupFrame in case the active frame is
different from | 154 // 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. | 155 // the opener frame, and the name references a frame relative to the opener
frame. |
| 151 bool created; | 156 bool created; |
| 152 LocalFrame* newFrame = createWindow(*activeFrame, openerFrame, frameRequest,
windowFeatures, NavigationPolicyIgnore, MaybeSendReferrer, created); | 157 LocalFrame* newFrame = createWindow(*activeFrame, openerFrame, frameRequest,
windowFeatures, NavigationPolicyIgnore, MaybeSendReferrer, created); |
| 153 if (!newFrame) | 158 if (!newFrame) |
| 154 return nullptr; | 159 return nullptr; |
| 155 | 160 |
| 156 newFrame->loader().setOpener(&openerFrame); | 161 newFrame->loader().setOpener(&openerFrame); |
| 157 | 162 |
| 158 if (newFrame->localDOMWindow()->isInsecureScriptAccess(callingWindow, comple
tedURL)) | 163 if (newFrame->localDOMWindow()->isInsecureScriptAccess(callingWindow, comple
tedURL)) |
| 159 return newFrame; | 164 return newFrame; |
| 160 | 165 |
| 161 if (created) | 166 if (created) |
| 162 newFrame->loader().load(FrameLoadRequest(callingWindow.document(), compl
etedURL)); | 167 newFrame->loader().load(FrameLoadRequest(callingWindow.document(), compl
etedURL)); |
| 163 else if (!urlString.isEmpty()) | 168 else if (!urlString.isEmpty()) |
| 164 newFrame->navigate(*callingWindow.document(), completedURL, false); | 169 newFrame->navigate(*callingWindow.document(), completedURL, false); |
| 165 return newFrame; | 170 return newFrame; |
| 166 } | 171 } |
| 167 | 172 |
| 168 void createWindowForRequest(const FrameLoadRequest& request, LocalFrame& openerF
rame, NavigationPolicy policy, ShouldSendReferrer shouldSendReferrer) | 173 void createWindowForRequest(const FrameLoadRequest& request, LocalFrame& openerF
rame, NavigationPolicy policy, ShouldSendReferrer shouldSendReferrer) |
| 169 { | 174 { |
| 175 ASSERT(!request.resourceRequest().requestorURL().isEmpty() || (openerFrame.d
ocument() && openerFrame.document()->url().isEmpty())); |
| 176 |
| 170 if (openerFrame.document()->pageDismissalEventBeingDispatched() != Document:
:NoDismissal) | 177 if (openerFrame.document()->pageDismissalEventBeingDispatched() != Document:
:NoDismissal) |
| 171 return; | 178 return; |
| 172 | 179 |
| 173 if (openerFrame.document() && openerFrame.document()->isSandboxed(SandboxPop
ups)) | 180 if (openerFrame.document() && openerFrame.document()->isSandboxed(SandboxPop
ups)) |
| 174 return; | 181 return; |
| 175 | 182 |
| 176 if (!LocalDOMWindow::allowPopUp(openerFrame)) | 183 if (!LocalDOMWindow::allowPopUp(openerFrame)) |
| 177 return; | 184 return; |
| 178 | 185 |
| 179 if (policy == NavigationPolicyCurrentTab) | 186 if (policy == NavigationPolicyCurrentTab) |
| 180 policy = NavigationPolicyNewForegroundTab; | 187 policy = NavigationPolicyNewForegroundTab; |
| 181 | 188 |
| 182 WindowFeatures features; | 189 WindowFeatures features; |
| 183 bool created; | 190 bool created; |
| 184 LocalFrame* newFrame = createWindow(openerFrame, openerFrame, request, featu
res, policy, shouldSendReferrer, created); | 191 LocalFrame* newFrame = createWindow(openerFrame, openerFrame, request, featu
res, policy, shouldSendReferrer, created); |
| 185 if (!newFrame) | 192 if (!newFrame) |
| 186 return; | 193 return; |
| 187 if (shouldSendReferrer == MaybeSendReferrer) { | 194 if (shouldSendReferrer == MaybeSendReferrer) { |
| 188 newFrame->loader().setOpener(&openerFrame); | 195 newFrame->loader().setOpener(&openerFrame); |
| 189 newFrame->document()->setReferrerPolicy(openerFrame.document()->referrer
Policy()); | 196 newFrame->document()->setReferrerPolicy(openerFrame.document()->referrer
Policy()); |
| 190 } | 197 } |
| 191 FrameLoadRequest newRequest(0, request.resourceRequest()); | 198 FrameLoadRequest newRequest(0, request.resourceRequest()); |
| 192 newRequest.setFormState(request.formState()); | 199 newRequest.setFormState(request.formState()); |
| 193 newFrame->loader().load(newRequest); | 200 newFrame->loader().load(newRequest); |
| 194 } | 201 } |
| 195 | 202 |
| 196 } // namespace blink | 203 } // namespace blink |
| OLD | NEW |