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

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

Issue 2103703004: Always use FrameNavigationDisabler during DocumentLoader detach. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 client()->dispatchDidReceiveTitle(m_frame->document()->title()); 717 client()->dispatchDidReceiveTitle(m_frame->document()->title());
718 if (m_frame->document()->loadEventFinished()) 718 if (m_frame->document()->loadEventFinished())
719 client()->didStopLoading(); 719 client()->didStopLoading();
720 } 720 }
721 721
722 void FrameLoader::detachDocumentLoader(Member<DocumentLoader>& loader) 722 void FrameLoader::detachDocumentLoader(Member<DocumentLoader>& loader)
723 { 723 {
724 if (!loader) 724 if (!loader)
725 return; 725 return;
726 726
727 FrameNavigationDisabler navigationDisabler(*m_frame);
727 loader->detachFromFrame(); 728 loader->detachFromFrame();
728 loader = nullptr; 729 loader = nullptr;
729 } 730 }
730 731
731 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip tValue> stateObject, FrameLoadType frameLoadType, HistoryLoadType historyLoadTyp e, ClientRedirectPolicy clientRedirect, Document* initiatingDocument) 732 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip tValue> stateObject, FrameLoadType frameLoadType, HistoryLoadType historyLoadTyp e, ClientRedirectPolicy clientRedirect, Document* initiatingDocument)
732 { 733 {
733 // If we have a state object, we cannot also be a new navigation. 734 // If we have a state object, we cannot also be a new navigation.
734 ASSERT(!stateObject || frameLoadType == FrameLoadTypeBackForward); 735 ASSERT(!stateObject || frameLoadType == FrameLoadTypeBackForward);
735 736
736 // If we have a provisional request for a different document, a fragment scr oll should cancel it. 737 // If we have a provisional request for a different document, a fragment scr oll should cancel it.
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 // script intiates a new load or causes the current frame to be detached, 1102 // script intiates a new load or causes the current frame to be detached,
1102 // we need to abandon the current load. 1103 // we need to abandon the current load.
1103 if (pdl != m_provisionalDocumentLoader) 1104 if (pdl != m_provisionalDocumentLoader)
1104 return false; 1105 return false;
1105 // detachFromFrame() will abort XHRs that haven't completed, which can 1106 // detachFromFrame() will abort XHRs that haven't completed, which can
1106 // trigger event listeners for 'abort'. These event listeners might call 1107 // trigger event listeners for 'abort'. These event listeners might call
1107 // window.stop(), which will in turn detach the provisional document loader. 1108 // window.stop(), which will in turn detach the provisional document loader.
1108 // At this point, the provisional document loader should not detach, because 1109 // At this point, the provisional document loader should not detach, because
1109 // then the FrameLoader would not have any attached DocumentLoaders. 1110 // then the FrameLoader would not have any attached DocumentLoaders.
1110 if (m_documentLoader) { 1111 if (m_documentLoader) {
1111 FrameNavigationDisabler navigationDisabler(*m_frame);
1112 TemporaryChange<bool> inDetachDocumentLoader(m_protectProvisionalLoader, true); 1112 TemporaryChange<bool> inDetachDocumentLoader(m_protectProvisionalLoader, true);
1113 detachDocumentLoader(m_documentLoader); 1113 detachDocumentLoader(m_documentLoader);
1114 } 1114 }
1115 // 'abort' listeners can also detach the frame. 1115 // 'abort' listeners can also detach the frame.
1116 if (!m_frame->client()) 1116 if (!m_frame->client())
1117 return false; 1117 return false;
1118 ASSERT(m_provisionalDocumentLoader == pdl); 1118 ASSERT(m_provisionalDocumentLoader == pdl);
1119 // No more events will be dispatched so detach the Document. 1119 // No more events will be dispatched so detach the Document.
1120 // TODO(yoav): Should we also be nullifying domWindow's document (or domWind ow) since the doc is now detached? 1120 // TODO(yoav): Should we also be nullifying domWindow's document (or domWind ow) since the doc is now detached?
1121 if (m_frame->document()) 1121 if (m_frame->document())
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 NavigationType navigationType = determineNavigationType(type, frameLoadReque st.resourceRequest().httpBody() || frameLoadRequest.form(), frameLoadRequest.tri ggeringEvent()); 1412 NavigationType navigationType = determineNavigationType(type, frameLoadReque st.resourceRequest().httpBody() || frameLoadRequest.form(), frameLoadRequest.tri ggeringEvent());
1413 frameLoadRequest.resourceRequest().setRequestContext(determineRequestContext FromNavigationType(navigationType)); 1413 frameLoadRequest.resourceRequest().setRequestContext(determineRequestContext FromNavigationType(navigationType));
1414 frameLoadRequest.resourceRequest().setFrameType(m_frame->isMainFrame() ? Web URLRequest::FrameTypeTopLevel : WebURLRequest::FrameTypeNested); 1414 frameLoadRequest.resourceRequest().setFrameType(m_frame->isMainFrame() ? Web URLRequest::FrameTypeTopLevel : WebURLRequest::FrameTypeNested);
1415 ResourceRequest& request = frameLoadRequest.resourceRequest(); 1415 ResourceRequest& request = frameLoadRequest.resourceRequest();
1416 if (!shouldContinueForNavigationPolicy(request, frameLoadRequest.substituteD ata(), nullptr, frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), na vigationType, navigationPolicy, type == FrameLoadTypeReplaceCurrentItem, frameLo adRequest.clientRedirect() == ClientRedirectPolicy::ClientRedirect)) 1416 if (!shouldContinueForNavigationPolicy(request, frameLoadRequest.substituteD ata(), nullptr, frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), na vigationType, navigationPolicy, type == FrameLoadTypeReplaceCurrentItem, frameLo adRequest.clientRedirect() == ClientRedirectPolicy::ClientRedirect))
1417 return; 1417 return;
1418 if (!shouldClose(navigationType == NavigationTypeReload)) 1418 if (!shouldClose(navigationType == NavigationTypeReload))
1419 return; 1419 return;
1420 1420
1421 m_frame->document()->cancelParsing(); 1421 m_frame->document()->cancelParsing();
1422 if (m_provisionalDocumentLoader) { 1422 detachDocumentLoader(m_provisionalDocumentLoader);
1423 FrameNavigationDisabler navigationDisabler(*m_frame);
1424 detachDocumentLoader(m_provisionalDocumentLoader);
1425 }
1426 1423
1427 // beforeunload fired above, and detaching a DocumentLoader can fire 1424 // beforeunload fired above, and detaching a DocumentLoader can fire
1428 // events, which can detach this frame. 1425 // events, which can detach this frame.
1429 if (!m_frame->host()) 1426 if (!m_frame->host())
1430 return; 1427 return;
1431 1428
1432 m_provisionalDocumentLoader = client()->createDocumentLoader(m_frame, reques t, frameLoadRequest.substituteData().isValid() ? frameLoadRequest.substituteData () : defaultSubstituteDataForURL(request.url())); 1429 m_provisionalDocumentLoader = client()->createDocumentLoader(m_frame, reques t, frameLoadRequest.substituteData().isValid() ? frameLoadRequest.substituteData () : defaultSubstituteDataForURL(request.url()));
1433 m_provisionalDocumentLoader->setNavigationType(navigationType); 1430 m_provisionalDocumentLoader->setNavigationType(navigationType);
1434 m_provisionalDocumentLoader->setReplacesCurrentHistoryItem(type == FrameLoad TypeReplaceCurrentItem); 1431 m_provisionalDocumentLoader->setReplacesCurrentHistoryItem(type == FrameLoad TypeReplaceCurrentItem);
1435 m_provisionalDocumentLoader->setIsClientRedirect(frameLoadRequest.clientRedi rect() == ClientRedirectPolicy::ClientRedirect); 1432 m_provisionalDocumentLoader->setIsClientRedirect(frameLoadRequest.clientRedi rect() == ClientRedirectPolicy::ClientRedirect);
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa der->url() : String()); 1625 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa der->url() : String());
1629 return tracedValue; 1626 return tracedValue;
1630 } 1627 }
1631 1628
1632 inline void FrameLoader::takeObjectSnapshot() const 1629 inline void FrameLoader::takeObjectSnapshot() const
1633 { 1630 {
1634 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced Value()); 1631 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced Value());
1635 } 1632 }
1636 1633
1637 } // namespace blink 1634 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698