Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: Source/core/page/CreateWindow.cpp

Issue 1071893003: WebURLRequest: Track the requesting document's URL through navigations. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Ugh. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/loader/FrameLoadRequest.h ('k') | Source/platform/exported/WebURLRequest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 LocalFrame* createWindow(LocalFrame& openerFrame, LocalFrame& lookupFrame , const FrameLoadRequest& request, const WindowFeatures& features, NavigationPol icy policy, ShouldSendReferrer shouldSendReferrer, bool& created) 50 static LocalFrame* createWindow(LocalFrame& openerFrame, LocalFrame& lookupFrame , const FrameLoadRequest& request, const WindowFeatures& features, NavigationPol icy policy, ShouldSendReferrer shouldSendReferrer, bool& created)
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().frameType() == WebURLRequest::FrameTypeAuxi liary); 54 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeAuxi liary);
54 55
55 if (!request.frameName().isEmpty() && request.frameName() != "_blank" && pol icy == NavigationPolicyIgnore) { 56 if (!request.frameName().isEmpty() && request.frameName() != "_blank" && pol icy == NavigationPolicyIgnore) {
56 if (Frame* frame = lookupFrame.findFrameForNavigation(request.frameName( ), openerFrame)) { 57 if (Frame* frame = lookupFrame.findFrameForNavigation(request.frameName( ), openerFrame)) {
57 if (request.frameName() != "_self") { 58 if (request.frameName() != "_self") {
58 if (FrameHost* host = frame->host()) { 59 if (FrameHost* host = frame->host()) {
59 if (host == openerFrame.host()) 60 if (host == openerFrame.host())
60 frame->page()->focusController().setFocusedFrame(frame); 61 frame->page()->focusController().setFocusedFrame(frame);
61 else 62 else
62 host->chrome().focus(); 63 host->chrome().focus();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 133
133 KURL completedURL = urlString.isEmpty() ? KURL(ParsedURLString, emptyString( )) : firstFrame.document()->completeURL(urlString); 134 KURL completedURL = urlString.isEmpty() ? KURL(ParsedURLString, emptyString( )) : firstFrame.document()->completeURL(urlString);
134 if (!completedURL.isEmpty() && !completedURL.isValid()) { 135 if (!completedURL.isEmpty() && !completedURL.isValid()) {
135 // Don't expose client code to invalid URLs. 136 // Don't expose client code to invalid URLs.
136 callingWindow.printErrorMessage("Unable to open a window with invalid UR L '" + completedURL.string() + "'.\n"); 137 callingWindow.printErrorMessage("Unable to open a window with invalid UR L '" + completedURL.string() + "'.\n");
137 return nullptr; 138 return nullptr;
138 } 139 }
139 140
140 FrameLoadRequest frameRequest(callingWindow.document(), completedURL, frameN ame); 141 FrameLoadRequest frameRequest(callingWindow.document(), completedURL, frameN ame);
141 frameRequest.resourceRequest().setFrameType(WebURLRequest::FrameTypeAuxiliar y); 142 frameRequest.resourceRequest().setFrameType(WebURLRequest::FrameTypeAuxiliar y);
143 frameRequest.resourceRequest().setRequestorOrigin(SecurityOrigin::create(act iveFrame->document()->url()));
142 144
143 // Normally, FrameLoader would take care of setting the referrer for a navig ation that is 145 // Normally, FrameLoader would take care of setting the referrer for a navig ation that is
144 // triggered from javascript. However, creating a window goes through suffic ient processing 146 // triggered from javascript. However, creating a window goes through suffic ient processing
145 // that it eventually enters FrameLoader as an embedder-initiated navigation . FrameLoader 147 // that it eventually enters FrameLoader as an embedder-initiated navigation . FrameLoader
146 // assumes no responsibility for generating an embedder-initiated navigation 's referrer, 148 // assumes no responsibility for generating an embedder-initiated navigation 's referrer,
147 // so we need to ensure the proper referrer is set now. 149 // so we need to ensure the proper referrer is set now.
148 frameRequest.resourceRequest().setHTTPReferrer(SecurityPolicy::generateRefer rer(activeFrame->document()->referrerPolicy(), completedURL, activeFrame->docume nt()->outgoingReferrer())); 150 frameRequest.resourceRequest().setHTTPReferrer(SecurityPolicy::generateRefer rer(activeFrame->document()->referrerPolicy(), completedURL, activeFrame->docume nt()->outgoingReferrer()));
149 151
150 bool hasUserGesture = UserGestureIndicator::processingUserGesture(); 152 bool hasUserGesture = UserGestureIndicator::processingUserGesture();
151 153
(...skipping 14 matching lines...) Expand all
166 request.resourceRequest().setHasUserGesture(hasUserGesture); 168 request.resourceRequest().setHasUserGesture(hasUserGesture);
167 newFrame->loader().load(request); 169 newFrame->loader().load(request);
168 } else if (!urlString.isEmpty()) { 170 } else if (!urlString.isEmpty()) {
169 newFrame->navigate(*callingWindow.document(), completedURL, false); 171 newFrame->navigate(*callingWindow.document(), completedURL, false);
170 } 172 }
171 return newFrame; 173 return newFrame;
172 } 174 }
173 175
174 void createWindowForRequest(const FrameLoadRequest& request, LocalFrame& openerF rame, NavigationPolicy policy, ShouldSendReferrer shouldSendReferrer) 176 void createWindowForRequest(const FrameLoadRequest& request, LocalFrame& openerF rame, NavigationPolicy policy, ShouldSendReferrer shouldSendReferrer)
175 { 177 {
178 ASSERT(request.resourceRequest().requestorOrigin() || (openerFrame.document( ) && openerFrame.document()->url().isEmpty()));
179
176 if (openerFrame.document()->pageDismissalEventBeingDispatched() != Document: :NoDismissal) 180 if (openerFrame.document()->pageDismissalEventBeingDispatched() != Document: :NoDismissal)
177 return; 181 return;
178 182
179 if (openerFrame.document() && openerFrame.document()->isSandboxed(SandboxPop ups)) 183 if (openerFrame.document() && openerFrame.document()->isSandboxed(SandboxPop ups))
180 return; 184 return;
181 185
182 if (!LocalDOMWindow::allowPopUp(openerFrame)) 186 if (!LocalDOMWindow::allowPopUp(openerFrame))
183 return; 187 return;
184 188
185 if (policy == NavigationPolicyCurrentTab) 189 if (policy == NavigationPolicyCurrentTab)
186 policy = NavigationPolicyNewForegroundTab; 190 policy = NavigationPolicyNewForegroundTab;
187 191
188 WindowFeatures features; 192 WindowFeatures features;
189 bool created; 193 bool created;
190 LocalFrame* newFrame = createWindow(openerFrame, openerFrame, request, featu res, policy, shouldSendReferrer, created); 194 LocalFrame* newFrame = createWindow(openerFrame, openerFrame, request, featu res, policy, shouldSendReferrer, created);
191 if (!newFrame) 195 if (!newFrame)
192 return; 196 return;
193 if (shouldSendReferrer == MaybeSendReferrer) { 197 if (shouldSendReferrer == MaybeSendReferrer) {
194 newFrame->loader().setOpener(&openerFrame); 198 newFrame->loader().setOpener(&openerFrame);
195 newFrame->document()->setReferrerPolicy(openerFrame.document()->referrer Policy()); 199 newFrame->document()->setReferrerPolicy(openerFrame.document()->referrer Policy());
196 } 200 }
197 FrameLoadRequest newRequest(0, request.resourceRequest()); 201 FrameLoadRequest newRequest(0, request.resourceRequest());
198 newRequest.setFormState(request.formState()); 202 newRequest.setFormState(request.formState());
199 newFrame->loader().load(newRequest); 203 newFrame->loader().load(newRequest);
200 } 204 }
201 205
202 } // namespace blink 206 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/loader/FrameLoadRequest.h ('k') | Source/platform/exported/WebURLRequest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698