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

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

Issue 2487403002: Allow navigations to frames that aren't being unloaded in the unload handler. (Closed)
Patch Set: early return on back/forward navigations Created 3 years, 11 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 m_currentItem->setVisualViewportScrollOffset(toScrollOffset( 281 m_currentItem->setVisualViewportScrollOffset(toScrollOffset(
282 m_frame->host()->visualViewport().visibleRect().location())); 282 m_frame->host()->visualViewport().visibleRect().location()));
283 283
284 if (m_frame->isMainFrame()) 284 if (m_frame->isMainFrame())
285 m_currentItem->setPageScaleFactor(m_frame->page()->pageScaleFactor()); 285 m_currentItem->setPageScaleFactor(m_frame->page()->pageScaleFactor());
286 286
287 client()->didUpdateCurrentHistoryItem(); 287 client()->didUpdateCurrentHistoryItem();
288 } 288 }
289 289
290 void FrameLoader::dispatchUnloadEvent() { 290 void FrameLoader::dispatchUnloadEvent() {
291 NavigationDisablerForUnload navigationDisabler; 291 FrameNavigationDisabler navigationDisabler(*m_frame);
292 292
293 // If the frame is unloading, the provisional loader should no longer be 293 // If the frame is unloading, the provisional loader should no longer be
294 // protected. It will be detached soon. 294 // protected. It will be detached soon.
295 m_protectProvisionalLoader = false; 295 m_protectProvisionalLoader = false;
296 saveScrollState(); 296 saveScrollState();
297 297
298 if (m_frame->document() && !SVGImage::isInSVGImage(m_frame->document())) 298 if (m_frame->document() && !SVGImage::isInSVGImage(m_frame->document()))
299 m_frame->document()->dispatchUnloadEvents(); 299 m_frame->document()->dispatchUnloadEvents();
300 } 300 }
301 301
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 } 1086 }
1087 return policy; 1087 return policy;
1088 } 1088 }
1089 1089
1090 void FrameLoader::load(const FrameLoadRequest& passedRequest, 1090 void FrameLoader::load(const FrameLoadRequest& passedRequest,
1091 FrameLoadType frameLoadType, 1091 FrameLoadType frameLoadType,
1092 HistoryItem* historyItem, 1092 HistoryItem* historyItem,
1093 HistoryLoadType historyLoadType) { 1093 HistoryLoadType historyLoadType) {
1094 DCHECK(m_frame->document()); 1094 DCHECK(m_frame->document());
1095 1095
1096 if (!m_frame->isNavigationAllowed()) 1096 if (isBackForwardLoadType(frameLoadType) && !m_frame->isNavigationAllowed())
1097 return; 1097 return;
1098 1098
1099 if (m_inStopAllLoaders) 1099 if (m_inStopAllLoaders)
1100 return; 1100 return;
1101 1101
1102 if (m_frame->page()->suspended() && isBackForwardLoadType(frameLoadType)) { 1102 if (m_frame->page()->suspended() && isBackForwardLoadType(frameLoadType)) {
dcheng 2017/01/04 23:12:02 If we move isNavigationAllowed() to early return i
lfg 2017/01/09 19:04:12 I'm not sure about that. There's also the check fo
dcheng 2017/01/09 19:17:30 I'm OK with this for now, but let's try to clean u
1103 m_deferredHistoryLoad = DeferredHistoryLoad::create( 1103 m_deferredHistoryLoad = DeferredHistoryLoad::create(
1104 passedRequest.resourceRequest(), historyItem, frameLoadType, 1104 passedRequest.resourceRequest(), historyItem, frameLoadType,
1105 historyLoadType); 1105 historyLoadType);
1106 return; 1106 return;
1107 } 1107 }
1108 1108
1109 FrameLoadRequest request(passedRequest); 1109 FrameLoadRequest request(passedRequest);
1110 request.resourceRequest().setHasUserGesture( 1110 request.resourceRequest().setHasUserGesture(
1111 UserGestureIndicator::processingUserGesture()); 1111 UserGestureIndicator::processingUserGesture());
1112 1112
1113 if (!prepareRequestForThisFrame(request)) 1113 if (!prepareRequestForThisFrame(request))
1114 return; 1114 return;
1115 1115
1116 if (isBackForwardLoadType(frameLoadType)) { 1116 if (isBackForwardLoadType(frameLoadType)) {
1117 DCHECK(historyItem); 1117 DCHECK(historyItem);
1118 m_provisionalItem = historyItem; 1118 m_provisionalItem = historyItem;
1119 } 1119 }
1120 1120
1121 // Form submissions appear to need their special-case of finding the target at 1121 // Form submissions appear to need their special-case of finding the target at
1122 // schedule rather than at fire. 1122 // schedule rather than at fire.
1123 Frame* targetFrame = request.form() 1123 Frame* targetFrame = request.form()
1124 ? nullptr 1124 ? nullptr
1125 : m_frame->findFrameForNavigation( 1125 : m_frame->findFrameForNavigation(
1126 AtomicString(request.frameName()), *m_frame); 1126 AtomicString(request.frameName()), *m_frame);
1127
1128 if (targetFrame && targetFrame->isLocalFrame() &&
1129 !toLocalFrame(targetFrame)->isNavigationAllowed()) {
dcheng 2017/01/04 23:12:02 We use targetFrame->navigate(), which (for local f
lfg 2017/01/09 19:04:12 targetFrame->navigate() just calls FrameLoader::lo
dcheng 2017/01/09 19:17:30 OK, this check should be in the block at 1133 - 11
lfg 2017/01/09 21:18:22 Yes, that should be correct. Done.
1130 return;
1131 }
1132
1127 NavigationPolicy policy = navigationPolicyForRequest(request); 1133 NavigationPolicy policy = navigationPolicyForRequest(request);
1128 if (targetFrame && targetFrame != m_frame && 1134 if (targetFrame && targetFrame != m_frame &&
1129 shouldNavigateTargetFrame(policy)) { 1135 shouldNavigateTargetFrame(policy)) {
1130 bool wasInSamePage = targetFrame->page() == m_frame->page(); 1136 bool wasInSamePage = targetFrame->page() == m_frame->page();
1131 1137
1132 request.setFrameName("_self"); 1138 request.setFrameName("_self");
1133 targetFrame->navigate(request); 1139 targetFrame->navigate(request);
1134 Page* page = targetFrame->page(); 1140 Page* page = targetFrame->page();
1135 if (!wasInSamePage && page) 1141 if (!wasInSamePage && page)
1136 page->chromeClient().focus(); 1142 page->chromeClient().focus();
1137 return; 1143 return;
1138 } 1144 }
1139 1145
1140 setReferrerForFrameRequest(request); 1146 setReferrerForFrameRequest(request);
1141 1147
1142 if (!targetFrame && !request.frameName().isEmpty()) { 1148 if (!targetFrame && !request.frameName().isEmpty()) {
1143 if (policy == NavigationPolicyDownload) { 1149 if (policy == NavigationPolicyDownload) {
1144 client()->loadURLExternally(request.resourceRequest(), 1150 client()->loadURLExternally(request.resourceRequest(),
1145 NavigationPolicyDownload, String(), false); 1151 NavigationPolicyDownload, String(), false);
1146 } else { 1152 } else {
1147 request.resourceRequest().setFrameType(WebURLRequest::FrameTypeAuxiliary); 1153 request.resourceRequest().setFrameType(WebURLRequest::FrameTypeAuxiliary);
1148 createWindowForRequest(request, *m_frame, policy); 1154 createWindowForRequest(request, *m_frame, policy);
1149 } 1155 }
1150 return; 1156 return;
1151 } 1157 }
1152 1158
1159 CHECK(m_frame->isNavigationAllowed());
dcheng 2017/01/04 23:12:02 I would be more comfortable with this being an ear
lfg 2017/01/09 19:04:12 I've agree with that, but I still think that going
1160
1153 const KURL& url = request.resourceRequest().url(); 1161 const KURL& url = request.resourceRequest().url();
1154 FrameLoadType newLoadType = (frameLoadType == FrameLoadTypeStandard) 1162 FrameLoadType newLoadType = (frameLoadType == FrameLoadTypeStandard)
1155 ? determineFrameLoadType(request) 1163 ? determineFrameLoadType(request)
1156 : frameLoadType; 1164 : frameLoadType;
1157 bool sameDocumentHistoryNavigation = 1165 bool sameDocumentHistoryNavigation =
1158 isBackForwardLoadType(newLoadType) && 1166 isBackForwardLoadType(newLoadType) &&
1159 historyLoadType == HistorySameDocumentLoad; 1167 historyLoadType == HistorySameDocumentLoad;
1160 bool sameDocumentNavigation = 1168 bool sameDocumentNavigation =
1161 policy == NavigationPolicyCurrentTab && 1169 policy == NavigationPolicyCurrentTab &&
1162 shouldPerformFragmentNavigation(request.form(), 1170 shouldPerformFragmentNavigation(request.form(),
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 for (Frame* child = m_frame->tree().firstChild(); child; 1559 for (Frame* child = m_frame->tree().firstChild(); child;
1552 child = child->tree().traverseNext(m_frame)) { 1560 child = child->tree().traverseNext(m_frame)) {
1553 // FIXME: There is not yet any way to dispatch events to out-of-process 1561 // FIXME: There is not yet any way to dispatch events to out-of-process
1554 // frames. 1562 // frames.
1555 if (child->isLocalFrame()) 1563 if (child->isLocalFrame())
1556 targetFrames.append(toLocalFrame(child)); 1564 targetFrames.append(toLocalFrame(child));
1557 } 1565 }
1558 1566
1559 bool shouldClose = false; 1567 bool shouldClose = false;
1560 { 1568 {
1561 NavigationDisablerForUnload navigationDisabler; 1569 NavigationDisablerForBeforeUnload navigationDisabler;
1562 size_t i; 1570 size_t i;
1563 1571
1564 bool didAllowNavigation = false; 1572 bool didAllowNavigation = false;
1565 for (i = 0; i < targetFrames.size(); i++) { 1573 for (i = 0; i < targetFrames.size(); i++) {
1566 if (!targetFrames[i]->tree().isDescendantOf(m_frame)) 1574 if (!targetFrames[i]->tree().isDescendantOf(m_frame))
1567 continue; 1575 continue;
1568 if (!targetFrames[i]->document()->dispatchBeforeUnloadEvent( 1576 if (!targetFrames[i]->document()->dispatchBeforeUnloadEvent(
1569 page->chromeClient(), isReload, didAllowNavigation)) 1577 page->chromeClient(), isReload, didAllowNavigation))
1570 break; 1578 break;
1571 } 1579 }
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 m_documentLoader ? m_documentLoader->url() : String()); 1900 m_documentLoader ? m_documentLoader->url() : String());
1893 return tracedValue; 1901 return tracedValue;
1894 } 1902 }
1895 1903
1896 inline void FrameLoader::takeObjectSnapshot() const { 1904 inline void FrameLoader::takeObjectSnapshot() const {
1897 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, 1905 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this,
1898 toTracedValue()); 1906 toTracedValue());
1899 } 1907 }
1900 1908
1901 } // namespace blink 1909 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698