| 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 29 matching lines...) Expand all Loading... |
| 40 #include "core/page/WindowFeatures.h" | 40 #include "core/page/WindowFeatures.h" |
| 41 #include "platform/UserGestureIndicator.h" | 41 #include "platform/UserGestureIndicator.h" |
| 42 #include "platform/network/ResourceRequest.h" | 42 #include "platform/network/ResourceRequest.h" |
| 43 #include "platform/weborigin/KURL.h" | 43 #include "platform/weborigin/KURL.h" |
| 44 #include "platform/weborigin/SecurityOrigin.h" | 44 #include "platform/weborigin/SecurityOrigin.h" |
| 45 #include "platform/weborigin/SecurityPolicy.h" | 45 #include "platform/weborigin/SecurityPolicy.h" |
| 46 #include "public/platform/WebURLRequest.h" | 46 #include "public/platform/WebURLRequest.h" |
| 47 | 47 |
| 48 namespace blink { | 48 namespace blink { |
| 49 | 49 |
| 50 static Frame* reuseExistingWindow(LocalFrame& openerFrame, LocalFrame& lookupFra
me, const AtomicString& frameName, NavigationPolicy policy) | 50 static Frame* reuseExistingWindow(LocalFrame& activeFrame, LocalFrame& lookupFra
me, const AtomicString& frameName, NavigationPolicy policy) |
| 51 { | 51 { |
| 52 if (!frameName.isEmpty() && frameName != "_blank" && policy == NavigationPol
icyIgnore) { | 52 if (!frameName.isEmpty() && frameName != "_blank" && policy == NavigationPol
icyIgnore) { |
| 53 if (Frame* frame = lookupFrame.findFrameForNavigation(frameName, openerF
rame)) { | 53 if (Frame* frame = lookupFrame.findFrameForNavigation(frameName, activeF
rame)) { |
| 54 if (frameName != "_self") { | 54 if (frameName != "_self") { |
| 55 if (FrameHost* host = frame->host()) { | 55 if (FrameHost* host = frame->host()) { |
| 56 if (host == openerFrame.host()) | 56 if (host == activeFrame.host()) |
| 57 frame->page()->focusController().setFocusedFrame(frame); | 57 frame->page()->focusController().setFocusedFrame(frame); |
| 58 else | 58 else |
| 59 host->chromeClient().focus(); | 59 host->chromeClient().focus(); |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 return frame; | 62 return frame; |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 return nullptr; | 65 return nullptr; |
| 66 } | 66 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 105 |
| 106 if (openerFrame.document()->isSandboxed(SandboxPropagatesToAuxiliaryBrowsing
Contexts)) | 106 if (openerFrame.document()->isSandboxed(SandboxPropagatesToAuxiliaryBrowsing
Contexts)) |
| 107 frame.loader().forceSandboxFlags(openerFrame.securityContext()->getSandb
oxFlags()); | 107 frame.loader().forceSandboxFlags(openerFrame.securityContext()->getSandb
oxFlags()); |
| 108 | 108 |
| 109 // This call may suspend the execution by running nested message loop. | 109 // This call may suspend the execution by running nested message loop. |
| 110 InspectorInstrumentation::windowCreated(&openerFrame, &frame); | 110 InspectorInstrumentation::windowCreated(&openerFrame, &frame); |
| 111 created = true; | 111 created = true; |
| 112 return &frame; | 112 return &frame; |
| 113 } | 113 } |
| 114 | 114 |
| 115 static Frame* createWindowHelper(LocalFrame& openerFrame, LocalFrame& lookupFram
e, const FrameLoadRequest& request, const WindowFeatures& features, NavigationPo
licy policy, ShouldSetOpener shouldSetOpener, bool& created) | 115 static Frame* createWindowHelper(LocalFrame& openerFrame, LocalFrame& activeFram
e, LocalFrame& lookupFrame, const FrameLoadRequest& request, const WindowFeature
s& features, NavigationPolicy policy, ShouldSetOpener shouldSetOpener, bool& cre
ated) |
| 116 { | 116 { |
| 117 ASSERT(!features.dialog || request.frameName().isEmpty()); | 117 ASSERT(!features.dialog || request.frameName().isEmpty()); |
| 118 ASSERT(request.resourceRequest().requestorOrigin() || openerFrame.document()
->url().isEmpty()); | 118 ASSERT(request.resourceRequest().requestorOrigin() || openerFrame.document()
->url().isEmpty()); |
| 119 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeAuxi
liary); | 119 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeAuxi
liary); |
| 120 | 120 |
| 121 created = false; | 121 created = false; |
| 122 | 122 |
| 123 Frame* window = reuseExistingWindow(openerFrame, lookupFrame, request.frameN
ame(), policy); | 123 Frame* window = reuseExistingWindow(activeFrame, lookupFrame, request.frameN
ame(), policy); |
| 124 | 124 |
| 125 if (!window) { | 125 if (!window) { |
| 126 // Sandboxed frames cannot open new auxiliary browsing contexts. | 126 // Sandboxed frames cannot open new auxiliary browsing contexts. |
| 127 if (openerFrame.document()->isSandboxed(SandboxPopups)) { | 127 if (openerFrame.document()->isSandboxed(SandboxPopups)) { |
| 128 // FIXME: This message should be moved off the console once a soluti
on to https://bugs.webkit.org/show_bug.cgi?id=103274 exists. | 128 // FIXME: This message should be moved off the console once a soluti
on to https://bugs.webkit.org/show_bug.cgi?id=103274 exists. |
| 129 openerFrame.document()->addConsoleMessage(ConsoleMessage::create(Sec
urityMessageSource, ErrorMessageLevel, "Blocked opening '" + request.resourceReq
uest().url().elidedString() + "' in a new window because the request was made in
a sandboxed frame whose 'allow-popups' permission is not set.")); | 129 openerFrame.document()->addConsoleMessage(ConsoleMessage::create(Sec
urityMessageSource, ErrorMessageLevel, "Blocked opening '" + request.resourceReq
uest().url().elidedString() + "' in a new window because the request was made in
a sandboxed frame whose 'allow-popups' permission is not set.")); |
| 130 return nullptr; | 130 return nullptr; |
| 131 } | 131 } |
| 132 | 132 |
| 133 if (openerFrame.settings() && !openerFrame.settings()->supportsMultipleW
indows()) | 133 if (openerFrame.settings() && !openerFrame.settings()->supportsMultipleW
indows()) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 frameRequest.resourceRequest().setHTTPReferrer(SecurityPolicy::generateRefer
rer(activeFrame->document()->getReferrerPolicy(), completedURL, activeFrame->doc
ument()->outgoingReferrer())); | 168 frameRequest.resourceRequest().setHTTPReferrer(SecurityPolicy::generateRefer
rer(activeFrame->document()->getReferrerPolicy(), completedURL, activeFrame->doc
ument()->outgoingReferrer())); |
| 169 | 169 |
| 170 // Records HasUserGesture before the value is invalidated inside createWindo
w(LocalFrame& openerFrame, ...). | 170 // Records HasUserGesture before the value is invalidated inside createWindo
w(LocalFrame& openerFrame, ...). |
| 171 // This value will be set in ResourceRequest loaded in a new LocalFrame. | 171 // This value will be set in ResourceRequest loaded in a new LocalFrame. |
| 172 bool hasUserGesture = UserGestureIndicator::processingUserGesture(); | 172 bool hasUserGesture = UserGestureIndicator::processingUserGesture(); |
| 173 | 173 |
| 174 // We pass the opener frame for the lookupFrame in case the active frame is
different from | 174 // We pass the opener frame for the lookupFrame in case the active frame is
different from |
| 175 // the opener frame, and the name references a frame relative to the opener
frame. | 175 // the opener frame, and the name references a frame relative to the opener
frame. |
| 176 bool created; | 176 bool created; |
| 177 ShouldSetOpener opener = windowFeatures.noopener ? NeverSetOpener : MaybeSet
Opener; | 177 ShouldSetOpener opener = windowFeatures.noopener ? NeverSetOpener : MaybeSet
Opener; |
| 178 Frame* newFrame = createWindowHelper(*activeFrame, openerFrame, frameRequest
, windowFeatures, NavigationPolicyIgnore, opener, created); | 178 Frame* newFrame = createWindowHelper(openerFrame, *activeFrame, openerFrame,
frameRequest, windowFeatures, NavigationPolicyIgnore, opener, created); |
| 179 if (!newFrame) | 179 if (!newFrame) |
| 180 return nullptr; | 180 return nullptr; |
| 181 | 181 |
| 182 if (!newFrame->domWindow()->isInsecureScriptAccess(callingWindow, completedU
RL)) { | 182 if (!newFrame->domWindow()->isInsecureScriptAccess(callingWindow, completedU
RL)) { |
| 183 if (!urlString.isEmpty() || created) | 183 if (!urlString.isEmpty() || created) |
| 184 newFrame->navigate(*callingWindow.document(), completedURL, false, h
asUserGesture ? UserGestureStatus::Active : UserGestureStatus::None); | 184 newFrame->navigate(*callingWindow.document(), completedURL, false, h
asUserGesture ? UserGestureStatus::Active : UserGestureStatus::None); |
| 185 } | 185 } |
| 186 return newFrame->domWindow(); | 186 return newFrame->domWindow(); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void createWindowForRequest(const FrameLoadRequest& request, LocalFrame& openerF
rame, NavigationPolicy policy, ShouldSendReferrer shouldSendReferrer, ShouldSetO
pener shouldSetOpener) | 189 void createWindowForRequest(const FrameLoadRequest& request, LocalFrame& openerF
rame, NavigationPolicy policy, ShouldSendReferrer shouldSendReferrer, ShouldSetO
pener shouldSetOpener) |
| 190 { | 190 { |
| 191 ASSERT(request.resourceRequest().requestorOrigin() || (openerFrame.document(
) && openerFrame.document()->url().isEmpty())); | 191 ASSERT(request.resourceRequest().requestorOrigin() || (openerFrame.document(
) && openerFrame.document()->url().isEmpty())); |
| 192 | 192 |
| 193 if (openerFrame.document()->pageDismissalEventBeingDispatched() != Document:
:NoDismissal) | 193 if (openerFrame.document()->pageDismissalEventBeingDispatched() != Document:
:NoDismissal) |
| 194 return; | 194 return; |
| 195 | 195 |
| 196 if (openerFrame.document() && openerFrame.document()->isSandboxed(SandboxPop
ups)) | 196 if (openerFrame.document() && openerFrame.document()->isSandboxed(SandboxPop
ups)) |
| 197 return; | 197 return; |
| 198 | 198 |
| 199 if (!LocalDOMWindow::allowPopUp(openerFrame)) | 199 if (!LocalDOMWindow::allowPopUp(openerFrame)) |
| 200 return; | 200 return; |
| 201 | 201 |
| 202 if (policy == NavigationPolicyCurrentTab) | 202 if (policy == NavigationPolicyCurrentTab) |
| 203 policy = NavigationPolicyNewForegroundTab; | 203 policy = NavigationPolicyNewForegroundTab; |
| 204 | 204 |
| 205 WindowFeatures features; | 205 WindowFeatures features; |
| 206 bool created; | 206 bool created; |
| 207 Frame* newFrame = createWindowHelper(openerFrame, openerFrame, request, feat
ures, policy, shouldSetOpener, created); | 207 Frame* newFrame = createWindowHelper(openerFrame, openerFrame, openerFrame,
request, features, policy, shouldSetOpener, created); |
| 208 if (!newFrame) | 208 if (!newFrame) |
| 209 return; | 209 return; |
| 210 if (shouldSendReferrer == MaybeSendReferrer) { | 210 if (shouldSendReferrer == MaybeSendReferrer) { |
| 211 // TODO(japhet): Does ReferrerPolicy need to be proagated for RemoteFram
es? | 211 // TODO(japhet): Does ReferrerPolicy need to be proagated for RemoteFram
es? |
| 212 if (newFrame->isLocalFrame()) | 212 if (newFrame->isLocalFrame()) |
| 213 toLocalFrame(newFrame)->document()->setReferrerPolicy(openerFrame.do
cument()->getReferrerPolicy()); | 213 toLocalFrame(newFrame)->document()->setReferrerPolicy(openerFrame.do
cument()->getReferrerPolicy()); |
| 214 } | 214 } |
| 215 | 215 |
| 216 // TODO(japhet): Form submissions on RemoteFrames don't work yet. | 216 // TODO(japhet): Form submissions on RemoteFrames don't work yet. |
| 217 FrameLoadRequest newRequest(0, request.resourceRequest()); | 217 FrameLoadRequest newRequest(0, request.resourceRequest()); |
| 218 newRequest.setForm(request.form()); | 218 newRequest.setForm(request.form()); |
| 219 if (newFrame->isLocalFrame()) | 219 if (newFrame->isLocalFrame()) |
| 220 toLocalFrame(newFrame)->loader().load(newRequest); | 220 toLocalFrame(newFrame)->loader().load(newRequest); |
| 221 } | 221 } |
| 222 | 222 |
| 223 } // namespace blink | 223 } // namespace blink |
| OLD | NEW |