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

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: Rebase + fixed issue with layout test Created 4 years, 6 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 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 for (i = 0; i < targetFrames.size(); i++) { 1347 for (i = 0; i < targetFrames.size(); i++) {
1348 if (!targetFrames[i]->tree().isDescendantOf(m_frame)) 1348 if (!targetFrames[i]->tree().isDescendantOf(m_frame))
1349 continue; 1349 continue;
1350 if (!targetFrames[i]->document()->dispatchBeforeUnloadEvent(page->ch romeClient(), isReload, didAllowNavigation)) 1350 if (!targetFrames[i]->document()->dispatchBeforeUnloadEvent(page->ch romeClient(), isReload, didAllowNavigation))
1351 break; 1351 break;
1352 } 1352 }
1353 1353
1354 if (i == targetFrames.size()) 1354 if (i == targetFrames.size())
1355 shouldClose = true; 1355 shouldClose = true;
1356 } 1356 }
1357
1357 return shouldClose; 1358 return shouldClose;
1358 } 1359 }
1359 1360
1360 bool FrameLoader::shouldContinueForNavigationPolicy(const ResourceRequest& reque st, const SubstituteData& substituteData, 1361 bool FrameLoader::shouldContinueForNavigationPolicy(const ResourceRequest& reque st, const SubstituteData& substituteData,
1361 DocumentLoader* loader, ContentSecurityPolicyDisposition shouldCheckMainWorl dContentSecurityPolicy, 1362 DocumentLoader* loader, ContentSecurityPolicyDisposition shouldCheckMainWorl dContentSecurityPolicy,
1362 NavigationType type, NavigationPolicy policy, bool replacesCurrentHistoryIte m, bool isClientRedirect) 1363 NavigationType type, NavigationPolicy policy, bool replacesCurrentHistoryIte m, bool isClientRedirect)
1363 { 1364 {
1364 // Don't ask if we are loading an empty URL. 1365 // Don't ask if we are loading an empty URL.
1365 if (request.url().isEmpty() || substituteData.isValid()) 1366 if (request.url().isEmpty() || substituteData.isValid())
1366 return true; 1367 return true;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 ASSERT(client()->hasWebView()); 1411 ASSERT(client()->hasWebView());
1411 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal) 1412 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal)
1412 return; 1413 return;
1413 1414
1414 NavigationType navigationType = determineNavigationType(type, frameLoadReque st.resourceRequest().httpBody() || frameLoadRequest.form(), frameLoadRequest.tri ggeringEvent()); 1415 NavigationType navigationType = determineNavigationType(type, frameLoadReque st.resourceRequest().httpBody() || frameLoadRequest.form(), frameLoadRequest.tri ggeringEvent());
1415 frameLoadRequest.resourceRequest().setRequestContext(determineRequestContext FromNavigationType(navigationType)); 1416 frameLoadRequest.resourceRequest().setRequestContext(determineRequestContext FromNavigationType(navigationType));
1416 frameLoadRequest.resourceRequest().setFrameType(m_frame->isMainFrame() ? Web URLRequest::FrameTypeTopLevel : WebURLRequest::FrameTypeNested); 1417 frameLoadRequest.resourceRequest().setFrameType(m_frame->isMainFrame() ? Web URLRequest::FrameTypeTopLevel : WebURLRequest::FrameTypeNested);
1417 ResourceRequest& request = frameLoadRequest.resourceRequest(); 1418 ResourceRequest& request = frameLoadRequest.resourceRequest();
1418 if (!shouldContinueForNavigationPolicy(request, frameLoadRequest.substituteD ata(), nullptr, frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), na vigationType, navigationPolicy, type == FrameLoadTypeReplaceCurrentItem, frameLo adRequest.clientRedirect() == ClientRedirectPolicy::ClientRedirect)) 1419 if (!shouldContinueForNavigationPolicy(request, frameLoadRequest.substituteD ata(), nullptr, frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), na vigationType, navigationPolicy, type == FrameLoadTypeReplaceCurrentItem, frameLo adRequest.clientRedirect() == ClientRedirectPolicy::ClientRedirect))
1419 return; 1420 return;
1420 if (!shouldClose(navigationType == NavigationTypeReload))
1421 return;
1422 1421
1423 m_frame->document()->cancelParsing(); 1422 m_frame->document()->cancelParsing();
1424 if (m_provisionalDocumentLoader) { 1423 if (m_provisionalDocumentLoader) {
1425 FrameNavigationDisabler navigationDisabler(*m_frame); 1424 FrameNavigationDisabler navigationDisabler(*m_frame);
1426 detachDocumentLoader(m_provisionalDocumentLoader); 1425 detachDocumentLoader(m_provisionalDocumentLoader);
1427 } 1426 }
1428 1427
1429 // beforeunload fired above, and detaching a DocumentLoader can fire 1428 // beforeunload fired above, and detaching a DocumentLoader can fire
1430 // events, which can detach this frame. 1429 // events, which can detach this frame.
1431 if (!m_frame->host()) 1430 if (!m_frame->host())
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa der->url() : String()); 1627 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa der->url() : String());
1629 return tracedValue; 1628 return tracedValue;
1630 } 1629 }
1631 1630
1632 inline void FrameLoader::takeObjectSnapshot() const 1631 inline void FrameLoader::takeObjectSnapshot() const
1633 { 1632 {
1634 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced Value()); 1633 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced Value());
1635 } 1634 }
1636 1635
1637 } // namespace blink 1636 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698