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

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: Created 4 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, 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 m_currentItem->setVisualViewportScrollOffset(toScrollOffset( 280 m_currentItem->setVisualViewportScrollOffset(toScrollOffset(
281 m_frame->host()->visualViewport().visibleRect().location())); 281 m_frame->host()->visualViewport().visibleRect().location()));
282 282
283 if (m_frame->isMainFrame()) 283 if (m_frame->isMainFrame())
284 m_currentItem->setPageScaleFactor(m_frame->page()->pageScaleFactor()); 284 m_currentItem->setPageScaleFactor(m_frame->page()->pageScaleFactor());
285 285
286 client()->didUpdateCurrentHistoryItem(); 286 client()->didUpdateCurrentHistoryItem();
287 } 287 }
288 288
289 void FrameLoader::dispatchUnloadEvent() { 289 void FrameLoader::dispatchUnloadEvent() {
290 NavigationDisablerForUnload navigationDisabler; 290 FrameNavigationDisabler navigationDisabler(*m_frame);
291 291
292 // If the frame is unloading, the provisional loader should no longer be 292 // If the frame is unloading, the provisional loader should no longer be
293 // protected. It will be detached soon. 293 // protected. It will be detached soon.
294 m_protectProvisionalLoader = false; 294 m_protectProvisionalLoader = false;
295 saveScrollState(); 295 saveScrollState();
296 296
297 if (m_frame->document() && !SVGImage::isInSVGImage(m_frame->document())) 297 if (m_frame->document() && !SVGImage::isInSVGImage(m_frame->document()))
298 m_frame->document()->dispatchUnloadEvents(); 298 m_frame->document()->dispatchUnloadEvents();
299 } 299 }
300 300
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 } 1078 }
1079 return policy; 1079 return policy;
1080 } 1080 }
1081 1081
1082 void FrameLoader::load(const FrameLoadRequest& passedRequest, 1082 void FrameLoader::load(const FrameLoadRequest& passedRequest,
1083 FrameLoadType frameLoadType, 1083 FrameLoadType frameLoadType,
1084 HistoryItem* historyItem, 1084 HistoryItem* historyItem,
1085 HistoryLoadType historyLoadType) { 1085 HistoryLoadType historyLoadType) {
1086 DCHECK(m_frame->document()); 1086 DCHECK(m_frame->document());
1087 1087
1088 if (!m_frame->isNavigationAllowed())
lfg 2016/11/10 00:15:04 This change has a side effect that javascript: nav
1089 return;
1090
1091 if (m_inStopAllLoaders) 1088 if (m_inStopAllLoaders)
1092 return; 1089 return;
1093 1090
1094 if (m_frame->page()->defersLoading() && 1091 if (m_frame->page()->defersLoading() &&
1095 isBackForwardLoadType(frameLoadType)) { 1092 isBackForwardLoadType(frameLoadType)) {
1096 m_deferredHistoryLoad = DeferredHistoryLoad::create( 1093 m_deferredHistoryLoad = DeferredHistoryLoad::create(
1097 passedRequest.resourceRequest(), historyItem, frameLoadType, 1094 passedRequest.resourceRequest(), historyItem, frameLoadType,
1098 historyLoadType); 1095 historyLoadType);
1099 return; 1096 return;
1100 } 1097 }
1101 1098
1102 FrameLoadRequest request(passedRequest); 1099 FrameLoadRequest request(passedRequest);
1103 request.resourceRequest().setHasUserGesture( 1100 request.resourceRequest().setHasUserGesture(
1104 UserGestureIndicator::processingUserGesture()); 1101 UserGestureIndicator::processingUserGesture());
1105 1102
1106 if (!prepareRequestForThisFrame(request)) 1103 if (!prepareRequestForThisFrame(request))
1107 return; 1104 return;
1108 1105
1109 if (isBackForwardLoadType(frameLoadType)) { 1106 if (isBackForwardLoadType(frameLoadType)) {
1110 DCHECK(historyItem); 1107 DCHECK(historyItem);
1111 m_provisionalItem = historyItem; 1108 m_provisionalItem = historyItem;
1112 } 1109 }
1113 1110
1114 // Form submissions appear to need their special-case of finding the target at 1111 // Form submissions appear to need their special-case of finding the target at
1115 // schedule rather than at fire. 1112 // schedule rather than at fire.
1116 Frame* targetFrame = request.form() 1113 Frame* targetFrame = request.form()
1117 ? nullptr 1114 ? nullptr
1118 : m_frame->findFrameForNavigation( 1115 : m_frame->findFrameForNavigation(
1119 AtomicString(request.frameName()), *m_frame); 1116 AtomicString(request.frameName()), *m_frame);
1117
1118 if (targetFrame && targetFrame->isLocalFrame() &&
1119 !toLocalFrame(targetFrame)->isNavigationAllowed()) {
1120 return;
1121 }
1122
1120 NavigationPolicy policy = navigationPolicyForRequest(request); 1123 NavigationPolicy policy = navigationPolicyForRequest(request);
1121 if (targetFrame && targetFrame != m_frame && 1124 if (targetFrame && targetFrame != m_frame &&
1122 shouldNavigateTargetFrame(policy)) { 1125 shouldNavigateTargetFrame(policy)) {
1123 bool wasInSamePage = targetFrame->page() == m_frame->page(); 1126 bool wasInSamePage = targetFrame->page() == m_frame->page();
1124 1127
1125 request.setFrameName("_self"); 1128 request.setFrameName("_self");
1126 targetFrame->navigate(request); 1129 targetFrame->navigate(request);
1127 Page* page = targetFrame->page(); 1130 Page* page = targetFrame->page();
1128 if (!wasInSamePage && page) 1131 if (!wasInSamePage && page)
1129 page->chromeClient().focus(); 1132 page->chromeClient().focus();
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 for (Frame* child = m_frame->tree().firstChild(); child; 1548 for (Frame* child = m_frame->tree().firstChild(); child;
1546 child = child->tree().traverseNext(m_frame)) { 1549 child = child->tree().traverseNext(m_frame)) {
1547 // FIXME: There is not yet any way to dispatch events to out-of-process 1550 // FIXME: There is not yet any way to dispatch events to out-of-process
1548 // frames. 1551 // frames.
1549 if (child->isLocalFrame()) 1552 if (child->isLocalFrame())
1550 targetFrames.append(toLocalFrame(child)); 1553 targetFrames.append(toLocalFrame(child));
1551 } 1554 }
1552 1555
1553 bool shouldClose = false; 1556 bool shouldClose = false;
1554 { 1557 {
1555 NavigationDisablerForUnload navigationDisabler; 1558 FrameNavigationDisabler navigationDisabler(*m_frame);
1556 size_t i; 1559 size_t i;
1557 1560
1558 bool didAllowNavigation = false; 1561 bool didAllowNavigation = false;
1559 for (i = 0; i < targetFrames.size(); i++) { 1562 for (i = 0; i < targetFrames.size(); i++) {
1560 if (!targetFrames[i]->tree().isDescendantOf(m_frame)) 1563 if (!targetFrames[i]->tree().isDescendantOf(m_frame))
1561 continue; 1564 continue;
1562 if (!targetFrames[i]->document()->dispatchBeforeUnloadEvent( 1565 if (!targetFrames[i]->document()->dispatchBeforeUnloadEvent(
1563 page->chromeClient(), isReload, didAllowNavigation)) 1566 page->chromeClient(), isReload, didAllowNavigation))
1564 break; 1567 break;
1565 } 1568 }
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1950 m_documentLoader ? m_documentLoader->url() : String()); 1953 m_documentLoader ? m_documentLoader->url() : String());
1951 return tracedValue; 1954 return tracedValue;
1952 } 1955 }
1953 1956
1954 inline void FrameLoader::takeObjectSnapshot() const { 1957 inline void FrameLoader::takeObjectSnapshot() const {
1955 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, 1958 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this,
1956 toTracedValue()); 1959 toTracedValue());
1957 } 1960 }
1958 1961
1959 } // namespace blink 1962 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698