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* createWindow(LocalFrame& openerFrame, LocalFrame& lookupFrame, con
st FrameLoadRequest& request, const WindowFeatures& features, NavigationPolicy p
olicy, ShouldSendReferrer shouldSendReferrer) | 50 static Frame* createWindow(LocalFrame& openerFrame, LocalFrame& lookupFrame, con
st FrameLoadRequest& request, const WindowFeatures& features, NavigationPolicy p
olicy, ShouldSendReferrer shouldSendReferrer, CreateWindowReason createWindowRea
son) |
51 { | 51 { |
52 ASSERT(!features.dialog || request.frameName().isEmpty()); | 52 ASSERT(!features.dialog || request.frameName().isEmpty()); |
53 ASSERT(request.resourceRequest().requestorOrigin() || openerFrame.document()
->url().isEmpty()); | 53 ASSERT(request.resourceRequest().requestorOrigin() || openerFrame.document()
->url().isEmpty()); |
54 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeAuxi
liary); | 54 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeAuxi
liary); |
55 | 55 |
56 if (!request.frameName().isEmpty() && request.frameName() != "_blank" && pol
icy == NavigationPolicyIgnore) { | 56 if (!request.frameName().isEmpty() && request.frameName() != "_blank" && pol
icy == NavigationPolicyIgnore) { |
57 if (Frame* frame = lookupFrame.findFrameForNavigation(request.frameName(
), openerFrame)) { | 57 if (Frame* frame = lookupFrame.findFrameForNavigation(request.frameName(
), openerFrame)) { |
58 if (request.frameName() != "_self") { | 58 if (request.frameName() != "_self") { |
59 if (FrameHost* host = frame->host()) { | 59 if (FrameHost* host = frame->host()) { |
60 if (host == openerFrame.host()) | 60 if (host == openerFrame.host()) |
(...skipping 13 matching lines...) Expand all Loading... |
74 return nullptr; | 74 return nullptr; |
75 } | 75 } |
76 | 76 |
77 if (openerFrame.settings() && !openerFrame.settings()->supportsMultipleWindo
ws()) | 77 if (openerFrame.settings() && !openerFrame.settings()->supportsMultipleWindo
ws()) |
78 return openerFrame.tree().top(); | 78 return openerFrame.tree().top(); |
79 | 79 |
80 FrameHost* oldHost = openerFrame.host(); | 80 FrameHost* oldHost = openerFrame.host(); |
81 if (!oldHost) | 81 if (!oldHost) |
82 return nullptr; | 82 return nullptr; |
83 | 83 |
84 Page* page = oldHost->chromeClient().createWindow(&openerFrame, request, fea
tures, policy, shouldSendReferrer); | 84 Page* page = oldHost->chromeClient().createWindow(&openerFrame, request, fea
tures, policy, shouldSendReferrer, createWindowReason); |
85 if (!page) | 85 if (!page) |
86 return nullptr; | 86 return nullptr; |
87 FrameHost* host = &page->frameHost(); | 87 FrameHost* host = &page->frameHost(); |
88 | 88 |
89 ASSERT(page->mainFrame()); | 89 ASSERT(page->mainFrame()); |
90 Frame& frame = *page->mainFrame(); | 90 Frame& frame = *page->mainFrame(); |
91 | 91 |
92 if (request.frameName() != "_blank") | 92 if (request.frameName() != "_blank") |
93 frame.tree().setName(request.frameName()); | 93 frame.tree().setName(request.frameName()); |
94 | 94 |
95 host->chromeClient().setWindowFeatures(features); | 95 host->chromeClient().setWindowFeatures(features); |
96 | 96 |
97 // 'x' and 'y' specify the location of the window, while 'width' and 'height
' | 97 // 'x' and 'y' specify the location of the window, while 'width' and 'height
' |
98 // specify the size of the viewport. We can only resize the window, so adjus
t | 98 // specify the size of the viewport. We can only resize the window, so adjus
t |
99 // for the difference between the window size and the viewport size. | 99 // for the difference between the window size and the viewport size. |
100 | 100 |
101 IntRect windowRect = host->chromeClient().windowRect(); | 101 IntRect windowRect = host->chromeClient().windowRect(); |
102 IntSize viewportSize = host->chromeClient().pageRect().size(); | 102 IntSize viewportSize = host->chromeClient().pageRect().size(); |
103 | 103 |
104 if (features.xSet) | 104 if (features.xSet) |
105 windowRect.setX(features.x); | 105 windowRect.setX(features.x); |
106 if (features.ySet) | 106 if (features.ySet) |
107 windowRect.setY(features.y); | 107 windowRect.setY(features.y); |
108 if (features.widthSet) | 108 if (features.widthSet) |
109 windowRect.setWidth(features.width + (windowRect.width() - viewportSize.
width())); | 109 windowRect.setWidth(features.width + (windowRect.width() - viewportSize.
width())); |
110 if (features.heightSet) | 110 if (features.heightSet) |
111 windowRect.setHeight(features.height + (windowRect.height() - viewportSi
ze.height())); | 111 windowRect.setHeight(features.height + (windowRect.height() - viewportSi
ze.height())); |
112 | 112 |
113 host->chromeClient().setWindowRectWithAdjustment(windowRect); | 113 host->chromeClient().setWindowRectWithAdjustment(windowRect); |
114 host->chromeClient().show(policy); | 114 host->chromeClient().show(policy, createWindowReason); |
115 | 115 |
116 // TODO(japhet): There's currently no way to set sandbox flags on a RemoteFr
ame and have it propagate | 116 // TODO(japhet): There's currently no way to set sandbox flags on a RemoteFr
ame and have it propagate |
117 // to the real frame in a different process. See crbug.com/483584. | 117 // to the real frame in a different process. See crbug.com/483584. |
118 if (frame.isLocalFrame() && openerFrame.document()->isSandboxed(SandboxPropa
gatesToAuxiliaryBrowsingContexts)) | 118 if (frame.isLocalFrame() && openerFrame.document()->isSandboxed(SandboxPropa
gatesToAuxiliaryBrowsingContexts)) |
119 toLocalFrame(&frame)->loader().forceSandboxFlags(openerFrame.document()-
>sandboxFlags()); | 119 toLocalFrame(&frame)->loader().forceSandboxFlags(openerFrame.document()-
>sandboxFlags()); |
120 | 120 |
121 return &frame; | 121 return &frame; |
122 } | 122 } |
123 | 123 |
124 DOMWindow* createWindow(const String& urlString, const AtomicString& frameName,
const WindowFeatures& windowFeatures, | 124 DOMWindow* createWindow(const String& urlString, const AtomicString& frameName,
const WindowFeatures& windowFeatures, |
(...skipping 19 matching lines...) Expand all Loading... |
144 // assumes no responsibility for generating an embedder-initiated navigation
's referrer, | 144 // assumes no responsibility for generating an embedder-initiated navigation
's referrer, |
145 // so we need to ensure the proper referrer is set now. | 145 // so we need to ensure the proper referrer is set now. |
146 frameRequest.resourceRequest().setHTTPReferrer(SecurityPolicy::generateRefer
rer(activeFrame->document()->referrerPolicy(), completedURL, activeFrame->docume
nt()->outgoingReferrer())); | 146 frameRequest.resourceRequest().setHTTPReferrer(SecurityPolicy::generateRefer
rer(activeFrame->document()->referrerPolicy(), completedURL, activeFrame->docume
nt()->outgoingReferrer())); |
147 | 147 |
148 // Records HasUserGesture before the value is invalidated inside createWindo
w(LocalFrame& openerFrame, ...). | 148 // Records HasUserGesture before the value is invalidated inside createWindo
w(LocalFrame& openerFrame, ...). |
149 // This value will be set in ResourceRequest loaded in a new LocalFrame. | 149 // This value will be set in ResourceRequest loaded in a new LocalFrame. |
150 bool hasUserGesture = UserGestureIndicator::processingUserGesture(); | 150 bool hasUserGesture = UserGestureIndicator::processingUserGesture(); |
151 | 151 |
152 // We pass the opener frame for the lookupFrame in case the active frame is
different from | 152 // We pass the opener frame for the lookupFrame in case the active frame is
different from |
153 // the opener frame, and the name references a frame relative to the opener
frame. | 153 // the opener frame, and the name references a frame relative to the opener
frame. |
154 Frame* newFrame = createWindow(*activeFrame, openerFrame, frameRequest, wind
owFeatures, NavigationPolicyIgnore, MaybeSendReferrer); | 154 Frame* newFrame = createWindow(*activeFrame, openerFrame, frameRequest, wind
owFeatures, NavigationPolicyIgnore, MaybeSendReferrer, CreatedFromWindowOpen); |
155 if (!newFrame) | 155 if (!newFrame) |
156 return nullptr; | 156 return nullptr; |
157 | 157 |
158 newFrame->client()->setOpener(&openerFrame); | 158 newFrame->client()->setOpener(&openerFrame); |
159 | 159 |
160 if (!newFrame->domWindow()->isInsecureScriptAccess(callingWindow, completedU
RL)) | 160 if (!newFrame->domWindow()->isInsecureScriptAccess(callingWindow, completedU
RL)) |
161 newFrame->navigate(*callingWindow.document(), completedURL, false, hasUs
erGesture ? UserGestureStatus::Active : UserGestureStatus::None); | 161 newFrame->navigate(*callingWindow.document(), completedURL, false, hasUs
erGesture ? UserGestureStatus::Active : UserGestureStatus::None); |
162 return newFrame->domWindow(); | 162 return newFrame->domWindow(); |
163 } | 163 } |
164 | 164 |
165 void createWindowForRequest(const FrameLoadRequest& request, LocalFrame& openerF
rame, NavigationPolicy policy, ShouldSendReferrer shouldSendReferrer) | 165 void createWindowForRequest(const FrameLoadRequest& request, LocalFrame& openerF
rame, NavigationPolicy policy, ShouldSendReferrer shouldSendReferrer) |
166 { | 166 { |
167 ASSERT(request.resourceRequest().requestorOrigin() || (openerFrame.document(
) && openerFrame.document()->url().isEmpty())); | 167 ASSERT(request.resourceRequest().requestorOrigin() || (openerFrame.document(
) && openerFrame.document()->url().isEmpty())); |
168 | 168 |
169 if (openerFrame.document()->pageDismissalEventBeingDispatched() != Document:
:NoDismissal) | 169 if (openerFrame.document()->pageDismissalEventBeingDispatched() != Document:
:NoDismissal) |
170 return; | 170 return; |
171 | 171 |
172 if (openerFrame.document() && openerFrame.document()->isSandboxed(SandboxPop
ups)) | 172 if (openerFrame.document() && openerFrame.document()->isSandboxed(SandboxPop
ups)) |
173 return; | 173 return; |
174 | 174 |
175 if (!LocalDOMWindow::allowPopUp(openerFrame)) | 175 if (!LocalDOMWindow::allowPopUp(openerFrame)) |
176 return; | 176 return; |
177 | 177 |
178 if (policy == NavigationPolicyCurrentTab) | 178 if (policy == NavigationPolicyCurrentTab) |
179 policy = NavigationPolicyNewForegroundTab; | 179 policy = NavigationPolicyNewForegroundTab; |
180 | 180 |
181 WindowFeatures features; | 181 WindowFeatures features; |
182 Frame* newFrame = createWindow(openerFrame, openerFrame, request, features,
policy, shouldSendReferrer); | 182 Frame* newFrame = createWindow(openerFrame, openerFrame, request, features,
policy, shouldSendReferrer, CreatedFromLoadRequest); |
183 if (!newFrame) | 183 if (!newFrame) |
184 return; | 184 return; |
185 if (shouldSendReferrer == MaybeSendReferrer) { | 185 if (shouldSendReferrer == MaybeSendReferrer) { |
186 newFrame->client()->setOpener(&openerFrame); | 186 newFrame->client()->setOpener(&openerFrame); |
187 // TODO(japhet): Does ReferrerPolicy need to be proagated for RemoteFram
es? | 187 // TODO(japhet): Does ReferrerPolicy need to be proagated for RemoteFram
es? |
188 if (newFrame->isLocalFrame()) | 188 if (newFrame->isLocalFrame()) |
189 toLocalFrame(newFrame)->document()->setReferrerPolicy(openerFrame.do
cument()->referrerPolicy()); | 189 toLocalFrame(newFrame)->document()->setReferrerPolicy(openerFrame.do
cument()->referrerPolicy()); |
190 } | 190 } |
191 | 191 |
192 // TODO(japhet): Form submissions on RemoteFrames don't work yet. | 192 // TODO(japhet): Form submissions on RemoteFrames don't work yet. |
193 FrameLoadRequest newRequest(0, request.resourceRequest()); | 193 FrameLoadRequest newRequest(0, request.resourceRequest()); |
194 newRequest.setForm(request.form()); | 194 newRequest.setForm(request.form()); |
195 if (newFrame->isLocalFrame()) | 195 if (newFrame->isLocalFrame()) |
196 toLocalFrame(newFrame)->loader().load(newRequest); | 196 toLocalFrame(newFrame)->loader().load(newRequest); |
197 } | 197 } |
198 | 198 |
199 } // namespace blink | 199 } // namespace blink |
OLD | NEW |