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

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

Issue 1459603002: Implement the 'noopener' window feature. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nasko Created 5 years, 1 month 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
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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // so we need to ensure the proper referrer is set now. 148 // so we need to ensure the proper referrer is set now.
149 frameRequest.resourceRequest().setHTTPReferrer(SecurityPolicy::generateRefer rer(activeFrame->document()->referrerPolicy(), completedURL, activeFrame->docume nt()->outgoingReferrer())); 149 frameRequest.resourceRequest().setHTTPReferrer(SecurityPolicy::generateRefer rer(activeFrame->document()->referrerPolicy(), completedURL, activeFrame->docume nt()->outgoingReferrer()));
150 150
151 // Records HasUserGesture before the value is invalidated inside createWindo w(LocalFrame& openerFrame, ...). 151 // Records HasUserGesture before the value is invalidated inside createWindo w(LocalFrame& openerFrame, ...).
152 // This value will be set in ResourceRequest loaded in a new LocalFrame. 152 // This value will be set in ResourceRequest loaded in a new LocalFrame.
153 bool hasUserGesture = UserGestureIndicator::processingUserGesture(); 153 bool hasUserGesture = UserGestureIndicator::processingUserGesture();
154 154
155 // We pass the opener frame for the lookupFrame in case the active frame is different from 155 // We pass the opener frame for the lookupFrame in case the active frame is different from
156 // the opener frame, and the name references a frame relative to the opener frame. 156 // the opener frame, and the name references a frame relative to the opener frame.
157 bool created; 157 bool created;
158 Frame* newFrame = createWindow(*activeFrame, openerFrame, frameRequest, wind owFeatures, NavigationPolicyIgnore, MaybeSetOpener, created); 158 ShouldSetOpener opener = windowFeatures.noopener ? NeverSetOpener : MaybeSet Opener;
159 Frame* newFrame = createWindow(*activeFrame, openerFrame, frameRequest, wind owFeatures, NavigationPolicyIgnore, opener, created);
159 if (!newFrame) 160 if (!newFrame)
160 return nullptr; 161 return nullptr;
161 162
162 newFrame->client()->setOpener(&openerFrame); 163 if (!windowFeatures.noopener)
164 newFrame->client()->setOpener(&openerFrame);
163 165
164 if (!newFrame->domWindow()->isInsecureScriptAccess(callingWindow, completedU RL)) { 166 if (!newFrame->domWindow()->isInsecureScriptAccess(callingWindow, completedU RL)) {
165 if (!urlString.isEmpty() || created) 167 if (!urlString.isEmpty() || created)
166 newFrame->navigate(*callingWindow.document(), completedURL, false, h asUserGesture ? UserGestureStatus::Active : UserGestureStatus::None); 168 newFrame->navigate(*callingWindow.document(), completedURL, false, h asUserGesture ? UserGestureStatus::Active : UserGestureStatus::None);
167 } 169 }
168 return newFrame->domWindow(); 170 return newFrame->domWindow();
169 } 171 }
170 172
171 void createWindowForRequest(const FrameLoadRequest& request, LocalFrame& openerF rame, NavigationPolicy policy, ShouldSendReferrer shouldSendReferrer, ShouldSetO pener shouldSetOpener) 173 void createWindowForRequest(const FrameLoadRequest& request, LocalFrame& openerF rame, NavigationPolicy policy, ShouldSendReferrer shouldSendReferrer, ShouldSetO pener shouldSetOpener)
172 { 174 {
(...skipping 25 matching lines...) Expand all
198 } 200 }
199 201
200 // TODO(japhet): Form submissions on RemoteFrames don't work yet. 202 // TODO(japhet): Form submissions on RemoteFrames don't work yet.
201 FrameLoadRequest newRequest(0, request.resourceRequest()); 203 FrameLoadRequest newRequest(0, request.resourceRequest());
202 newRequest.setForm(request.form()); 204 newRequest.setForm(request.form());
203 if (newFrame->isLocalFrame()) 205 if (newFrame->isLocalFrame())
204 toLocalFrame(newFrame)->loader().load(newRequest); 206 toLocalFrame(newFrame)->loader().load(newRequest);
205 } 207 }
206 208
207 } // namespace blink 209 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/Window.idl ('k') | third_party/WebKit/Source/core/page/WindowFeatures.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698