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

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

Issue 1041473002: Detach old frame on WebFrame::swap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 } 949 }
950 950
951 void FrameLoader::notifyIfInitialDocumentAccessed() 951 void FrameLoader::notifyIfInitialDocumentAccessed()
952 { 952 {
953 if (m_didAccessInitialDocumentTimer.isActive()) { 953 if (m_didAccessInitialDocumentTimer.isActive()) {
954 m_didAccessInitialDocumentTimer.stop(); 954 m_didAccessInitialDocumentTimer.stop();
955 didAccessInitialDocumentTimerFired(0); 955 didAccessInitialDocumentTimerFired(0);
956 } 956 }
957 } 957 }
958 958
959 void FrameLoader::commitProvisionalLoad() 959 bool FrameLoader::prepareForCommit()
960 { 960 {
961 ASSERT(client()->hasWebView());
962 RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader; 961 RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader;
963 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
964
965 // Check if the destination page is allowed to access the previous page's ti ming information.
966 if (m_frame->document()) {
967 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::create(pdl->requ est().url());
968 pdl->timing().setHasSameOriginAsPreviousDocument(securityOrigin->canRequ est(m_frame->document()->url()));
969 }
970 962
971 if (m_documentLoader) { 963 if (m_documentLoader) {
972 client()->dispatchWillClose(); 964 client()->dispatchWillClose();
973 dispatchUnloadEvent(); 965 dispatchUnloadEvent();
974 } 966 }
975 m_frame->detachChildren(); 967 m_frame->detachChildren();
976 // The previous calls to dispatchUnloadEvent() and detachChildren() can 968 // The previous calls to dispatchUnloadEvent() and detachChildren() can
977 // execute arbitrary script via things like unload events. If the executed 969 // execute arbitrary script via things like unload events. If the executed
978 // script intiates a new load or causes the current frame to be detached, 970 // script intiates a new load or causes the current frame to be detached,
979 // we need to abandon the current load. 971 // we need to abandon the current load.
980 if (pdl != m_provisionalDocumentLoader) 972 if (pdl != m_provisionalDocumentLoader)
981 return; 973 return false;
982 if (m_documentLoader) 974 if (m_documentLoader)
983 m_documentLoader->detachFromFrame(); 975 m_documentLoader->detachFromFrame();
984 // detachFromFrame() will abort XHRs that haven't completed, which can 976 // detachFromFrame() will abort XHRs that haven't completed, which can
985 // trigger event listeners for 'abort'. These event listeners might detach 977 // trigger event listeners for 'abort'. These event listeners might detach
986 // the frame. 978 // the frame.
987 // TODO(dcheng): Investigate if this can be moved above the check that 979 // TODO(dcheng): Investigate if this can be moved above the check that
988 // m_provisionalDocumentLoader hasn't changed. 980 // m_provisionalDocumentLoader hasn't changed.
989 if (!m_frame->client()) 981 if (!m_frame->client())
990 return; 982 return false;
991 // No more events will be dispatched so detach the Document. 983 // No more events will be dispatched so detach the Document.
992 if (m_frame->document()) 984 if (m_frame->document())
993 m_frame->document()->detach(); 985 m_frame->document()->detach();
994 m_documentLoader = m_provisionalDocumentLoader.release(); 986 m_documentLoader = m_provisionalDocumentLoader.release();
dcheng 2015/06/08 19:34:42 Is it actually safe to assume that m_provisionalDo
lfg 2015/06/10 18:41:28 It doesn't matter, since the oldFrame is being det
995 987
988 return true;
989 }
990
991 void FrameLoader::commitProvisionalLoad()
992 {
993 ASSERT(client()->hasWebView());
994 RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader;
995 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
996
997 // Check if the destination page is allowed to access the previous page's ti ming information.
998 if (m_frame->document()) {
999 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::create(pdl->requ est().url());
1000 pdl->timing().setHasSameOriginAsPreviousDocument(securityOrigin->canRequ est(m_frame->document()->url()));
1001 }
1002
1003 if (!prepareForCommit())
1004 return;
1005
996 if (isLoadingMainFrame()) 1006 if (isLoadingMainFrame())
997 m_frame->page()->chromeClient().needTouchEvents(false); 1007 m_frame->page()->chromeClient().needTouchEvents(false);
998 1008
999 client()->transitionToCommittedForNewPage(); 1009 client()->transitionToCommittedForNewPage();
1000 m_frame->navigationScheduler().cancel(); 1010 m_frame->navigationScheduler().cancel();
1001 m_frame->editor().clearLastEditCommand(); 1011 m_frame->editor().clearLastEditCommand();
1002 1012
1003 // If we are still in the process of initializing an empty document then 1013 // If we are still in the process of initializing an empty document then
1004 // its frame is not in a consistent state for rendering, so avoid setJSStatu sBarText 1014 // its frame is not in a consistent state for rendering, so avoid setJSStatu sBarText
1005 // since it may cause clients to attempt to render the frame. 1015 // since it may cause clients to attempt to render the frame.
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 // FIXME: We need a way to propagate insecure requests policy flags to 1454 // FIXME: We need a way to propagate insecure requests policy flags to
1445 // out-of-process frames. For now, we'll always use default behavior. 1455 // out-of-process frames. For now, we'll always use default behavior.
1446 if (!parentFrame->isLocalFrame()) 1456 if (!parentFrame->isLocalFrame())
1447 return nullptr; 1457 return nullptr;
1448 1458
1449 ASSERT(toLocalFrame(parentFrame)->document()); 1459 ASSERT(toLocalFrame(parentFrame)->document());
1450 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ; 1460 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ;
1451 } 1461 }
1452 1462
1453 } // namespace blink 1463 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698