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

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

Issue 1890493002: PlzNavigate: properly execute BeforeUnload on renderer initiated navigations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2009. All rights reserved.
7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> 7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com>
8 * Copyright (C) 2011 Google Inc. All rights reserved. 8 * Copyright (C) 2011 Google Inc. All rights reserved.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 for (i = 0; i < targetFrames.size(); i++) { 1312 for (i = 0; i < targetFrames.size(); i++) {
1313 if (!targetFrames[i]->tree().isDescendantOf(m_frame)) 1313 if (!targetFrames[i]->tree().isDescendantOf(m_frame))
1314 continue; 1314 continue;
1315 if (!targetFrames[i]->document()->dispatchBeforeUnloadEvent(page->ch romeClient(), isReload, didAllowNavigation)) 1315 if (!targetFrames[i]->document()->dispatchBeforeUnloadEvent(page->ch romeClient(), isReload, didAllowNavigation))
1316 break; 1316 break;
1317 } 1317 }
1318 1318
1319 if (i == targetFrames.size()) 1319 if (i == targetFrames.size())
1320 shouldClose = true; 1320 shouldClose = true;
1321 } 1321 }
1322
1323 if (!m_frame->host())
dcheng 2016/04/15 17:21:42 How do we get into a case where we call this on a
clamy 2016/04/25 11:36:55 There's a specific layout test checking for what h
dcheng 2016/04/26 06:32:31 Right, but why didn't we need to previously check
clamy 2016/04/26 10:07:09 I think this i sbecause this function was only cal
1324 return false;
1325
1322 return shouldClose; 1326 return shouldClose;
1323 } 1327 }
1324 1328
1325 bool FrameLoader::shouldContinueForNavigationPolicy(const ResourceRequest& reque st, const SubstituteData& substituteData, 1329 bool FrameLoader::shouldContinueForNavigationPolicy(const ResourceRequest& reque st, const SubstituteData& substituteData,
1326 DocumentLoader* loader, ContentSecurityPolicyDisposition shouldCheckMainWorl dContentSecurityPolicy, 1330 DocumentLoader* loader, ContentSecurityPolicyDisposition shouldCheckMainWorl dContentSecurityPolicy,
1327 NavigationType type, NavigationPolicy policy, bool replacesCurrentHistoryIte m, bool isClientRedirect) 1331 NavigationType type, NavigationPolicy policy, bool replacesCurrentHistoryIte m, bool isClientRedirect)
1328 { 1332 {
1329 // Don't ask if we are loading an empty URL. 1333 // Don't ask if we are loading an empty URL.
1330 if (request.url().isEmpty() || substituteData.isValid()) 1334 if (request.url().isEmpty() || substituteData.isValid())
1331 return true; 1335 return true;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 ASSERT(client()->hasWebView()); 1371 ASSERT(client()->hasWebView());
1368 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal) 1372 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal)
1369 return; 1373 return;
1370 1374
1371 NavigationType navigationType = determineNavigationType(type, frameLoadReque st.resourceRequest().httpBody() || frameLoadRequest.form(), frameLoadRequest.tri ggeringEvent()); 1375 NavigationType navigationType = determineNavigationType(type, frameLoadReque st.resourceRequest().httpBody() || frameLoadRequest.form(), frameLoadRequest.tri ggeringEvent());
1372 frameLoadRequest.resourceRequest().setRequestContext(determineRequestContext FromNavigationType(navigationType)); 1376 frameLoadRequest.resourceRequest().setRequestContext(determineRequestContext FromNavigationType(navigationType));
1373 frameLoadRequest.resourceRequest().setFrameType(m_frame->isMainFrame() ? Web URLRequest::FrameTypeTopLevel : WebURLRequest::FrameTypeNested); 1377 frameLoadRequest.resourceRequest().setFrameType(m_frame->isMainFrame() ? Web URLRequest::FrameTypeTopLevel : WebURLRequest::FrameTypeNested);
1374 ResourceRequest& request = frameLoadRequest.resourceRequest(); 1378 ResourceRequest& request = frameLoadRequest.resourceRequest();
1375 if (!shouldContinueForNavigationPolicy(request, frameLoadRequest.substituteD ata(), nullptr, frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), na vigationType, navigationPolicy, type == FrameLoadTypeReplaceCurrentItem, frameLo adRequest.clientRedirect() == ClientRedirectPolicy::ClientRedirect)) 1379 if (!shouldContinueForNavigationPolicy(request, frameLoadRequest.substituteD ata(), nullptr, frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), na vigationType, navigationPolicy, type == FrameLoadTypeReplaceCurrentItem, frameLo adRequest.clientRedirect() == ClientRedirectPolicy::ClientRedirect))
1376 return; 1380 return;
1377 if (!shouldClose(navigationType == NavigationTypeReload)) 1381
1382 // Execute the BeforeUnload event, which may cancel the navigation.
1383 // PlzNavigate: bypassBeforeUnload can be true when committing a navigation
1384 // that has already made a network request. Do not execute the BeforeUnload
1385 // event in that case, since it has already executed just before the
1386 // navigation was sent to the network.
1387 if (!request.bypassBeforeUnload() && !shouldClose(navigationType == Navigati onTypeReload))
1378 return; 1388 return;
1379 1389
1380 m_frame->document()->cancelParsing(); 1390 m_frame->document()->cancelParsing();
1381 detachDocumentLoader(m_provisionalDocumentLoader); 1391 detachDocumentLoader(m_provisionalDocumentLoader);
1382 1392
1383 // beforeunload fired above, and detaching a DocumentLoader can fire 1393 // beforeunload fired above, and detaching a DocumentLoader can fire
1384 // events, which can detach this frame. 1394 // events, which can detach this frame.
1385 if (!m_frame->host()) 1395 if (!m_frame->host())
1386 return; 1396 return;
1387 1397
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 // FIXME: We need a way to propagate insecure requests policy flags to 1574 // FIXME: We need a way to propagate insecure requests policy flags to
1565 // out-of-process frames. For now, we'll always use default behavior. 1575 // out-of-process frames. For now, we'll always use default behavior.
1566 if (!parentFrame->isLocalFrame()) 1576 if (!parentFrame->isLocalFrame())
1567 return nullptr; 1577 return nullptr;
1568 1578
1569 ASSERT(toLocalFrame(parentFrame)->document()); 1579 ASSERT(toLocalFrame(parentFrame)->document());
1570 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ; 1580 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ;
1571 } 1581 }
1572 1582
1573 } // namespace blink 1583 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698