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

Side by Side Diff: third_party/WebKit/Source/core/loader/FrameLoader.cpp

Issue 2417983002: Form submissions opening in a new window don't need special treatment anymore. (Closed)
Patch Set: Using params.source_site_instance for consistency with //chrome layer. Created 4 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
6 * (http://www.torchmobile.com/) 6 * (http://www.torchmobile.com/)
7 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 7 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
8 * Copyright (C) Research In Motion Limited 2009. All rights reserved. 8 * Copyright (C) Research In Motion Limited 2009. All rights reserved.
9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> 9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com>
10 * Copyright (C) 2011 Google Inc. All rights reserved. 10 * Copyright (C) 2011 Google Inc. All rights reserved.
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 if (!request.originDocument()->getSecurityOrigin()->canDisplay(url)) { 951 if (!request.originDocument()->getSecurityOrigin()->canDisplay(url)) {
952 reportLocalLoadFailed(m_frame, url.elidedString()); 952 reportLocalLoadFailed(m_frame, url.elidedString());
953 return false; 953 return false;
954 } 954 }
955 955
956 if (!request.form() && request.frameName().isEmpty()) 956 if (!request.form() && request.frameName().isEmpty())
957 request.setFrameName(m_frame->document()->baseTarget()); 957 request.setFrameName(m_frame->document()->baseTarget());
958 return true; 958 return true;
959 } 959 }
960 960
961 static bool shouldOpenInNewWindow(Frame* targetFrame,
962 const FrameLoadRequest& request,
963 NavigationPolicy policy) {
964 if (!targetFrame && !request.frameName().isEmpty())
965 return true;
966 // FIXME: This case is a workaround for the fact that ctrl+clicking a form
967 // submission incorrectly sends as a GET rather than a POST if it creates a
968 // new window in a different process.
969 return request.form() && policy != NavigationPolicyCurrentTab;
970 }
971
972 static bool shouldNavigateTargetFrame(NavigationPolicy policy) { 961 static bool shouldNavigateTargetFrame(NavigationPolicy policy) {
973 switch (policy) { 962 switch (policy) {
974 case NavigationPolicyCurrentTab: 963 case NavigationPolicyCurrentTab:
975 return true; 964 return true;
976 965
977 // Navigation will target a *new* frame (e.g. because of a ctrl-click), 966 // Navigation will target a *new* frame (e.g. because of a ctrl-click),
978 // so the target frame can be ignored. 967 // so the target frame can be ignored.
979 case NavigationPolicyNewBackgroundTab: 968 case NavigationPolicyNewBackgroundTab:
980 case NavigationPolicyNewForegroundTab: 969 case NavigationPolicyNewForegroundTab:
981 case NavigationPolicyNewWindow: 970 case NavigationPolicyNewWindow:
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 UserGestureIndicator::processingUserGesture()); 1083 UserGestureIndicator::processingUserGesture());
1095 1084
1096 if (!prepareRequestForThisFrame(request)) 1085 if (!prepareRequestForThisFrame(request))
1097 return; 1086 return;
1098 1087
1099 if (isBackForwardLoadType(frameLoadType)) { 1088 if (isBackForwardLoadType(frameLoadType)) {
1100 DCHECK(historyItem); 1089 DCHECK(historyItem);
1101 m_provisionalItem = historyItem; 1090 m_provisionalItem = historyItem;
1102 } 1091 }
1103 1092
1093 // Form submissions appear to need their special-case of finding the target at
1094 // schedule rather than at fire.
1104 Frame* targetFrame = request.form() 1095 Frame* targetFrame = request.form()
1105 ? nullptr 1096 ? nullptr
1106 : m_frame->findFrameForNavigation( 1097 : m_frame->findFrameForNavigation(
1107 AtomicString(request.frameName()), *m_frame); 1098 AtomicString(request.frameName()), *m_frame);
1108 NavigationPolicy policy = navigationPolicyForRequest(request); 1099 NavigationPolicy policy = navigationPolicyForRequest(request);
1109 if (targetFrame && targetFrame != m_frame && 1100 if (targetFrame && targetFrame != m_frame &&
1110 shouldNavigateTargetFrame(policy)) { 1101 shouldNavigateTargetFrame(policy)) {
1111 bool wasInSamePage = targetFrame->page() == m_frame->page(); 1102 bool wasInSamePage = targetFrame->page() == m_frame->page();
1112 1103
1113 request.setFrameName("_self"); 1104 request.setFrameName("_self");
1114 targetFrame->navigate(request); 1105 targetFrame->navigate(request);
1115 Page* page = targetFrame->page(); 1106 Page* page = targetFrame->page();
1116 if (!wasInSamePage && page) 1107 if (!wasInSamePage && page)
1117 page->chromeClient().focus(); 1108 page->chromeClient().focus();
1118 return; 1109 return;
1119 } 1110 }
1120 1111
1121 setReferrerForFrameRequest(request); 1112 setReferrerForFrameRequest(request);
1122 1113
1123 if (shouldOpenInNewWindow(targetFrame, request, policy)) { 1114 if (!targetFrame && !request.frameName().isEmpty()) {
1124 if (policy == NavigationPolicyDownload) { 1115 if (policy == NavigationPolicyDownload) {
1125 client()->loadURLExternally(request.resourceRequest(), 1116 client()->loadURLExternally(request.resourceRequest(),
1126 NavigationPolicyDownload, String(), false); 1117 NavigationPolicyDownload, String(), false);
1127 } else { 1118 } else {
1128 request.resourceRequest().setFrameType(WebURLRequest::FrameTypeAuxiliary); 1119 request.resourceRequest().setFrameType(WebURLRequest::FrameTypeAuxiliary);
1129 createWindowForRequest(request, *m_frame, policy); 1120 createWindowForRequest(request, *m_frame, policy);
1130 } 1121 }
1131 return; 1122 return;
1132 } 1123 }
1133 1124
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
1937 m_documentLoader ? m_documentLoader->url() : String()); 1928 m_documentLoader ? m_documentLoader->url() : String());
1938 return tracedValue; 1929 return tracedValue;
1939 } 1930 }
1940 1931
1941 inline void FrameLoader::takeObjectSnapshot() const { 1932 inline void FrameLoader::takeObjectSnapshot() const {
1942 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, 1933 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this,
1943 toTracedValue()); 1934 toTracedValue());
1944 } 1935 }
1945 1936
1946 } // namespace blink 1937 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698