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

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

Issue 2269653002: PlzNavigate: Prevent tests to end too early. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 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 | « third_party/WebKit/Source/core/loader/FrameLoader.h ('k') | 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 FrameLoader::FrameLoader(LocalFrame* frame) 175 FrameLoader::FrameLoader(LocalFrame* frame)
176 : m_frame(frame) 176 : m_frame(frame)
177 , m_progressTracker(ProgressTracker::create(frame)) 177 , m_progressTracker(ProgressTracker::create(frame))
178 , m_loadType(FrameLoadTypeStandard) 178 , m_loadType(FrameLoadTypeStandard)
179 , m_inStopAllLoaders(false) 179 , m_inStopAllLoaders(false)
180 , m_checkTimer(TaskRunnerHelper::get(TaskType::Networking, frame), this, &Fr ameLoader::checkTimerFired) 180 , m_checkTimer(TaskRunnerHelper::get(TaskType::Networking, frame), this, &Fr ameLoader::checkTimerFired)
181 , m_forcedSandboxFlags(SandboxNone) 181 , m_forcedSandboxFlags(SandboxNone)
182 , m_dispatchingDidClearWindowObjectInMainWorld(false) 182 , m_dispatchingDidClearWindowObjectInMainWorld(false)
183 , m_protectProvisionalLoader(false) 183 , m_protectProvisionalLoader(false)
184 , m_isNavigationHandledByClient(false)
184 { 185 {
185 TRACE_EVENT_OBJECT_CREATED_WITH_ID("loading", "FrameLoader", this); 186 TRACE_EVENT_OBJECT_CREATED_WITH_ID("loading", "FrameLoader", this);
186 takeObjectSnapshot(); 187 takeObjectSnapshot();
187 } 188 }
188 189
189 FrameLoader::~FrameLoader() 190 FrameLoader::~FrameLoader()
190 { 191 {
191 // Verify that this FrameLoader has been detached. 192 // Verify that this FrameLoader has been detached.
192 DCHECK(!m_progressTracker); 193 DCHECK(!m_progressTracker);
193 } 194 }
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 // We might have declined to run the load event due to an imminent content-i nitiated navigation. 610 // We might have declined to run the load event due to an imminent content-i nitiated navigation.
610 if (!frame->document()->loadEventFinished()) 611 if (!frame->document()->loadEventFinished())
611 return false; 612 return false;
612 613
613 // An event might have restarted a child frame. 614 // An event might have restarted a child frame.
614 if (!allDescendantsAreComplete(frame)) 615 if (!allDescendantsAreComplete(frame))
615 return false; 616 return false;
616 return true; 617 return true;
617 } 618 }
618 619
619 static bool shouldSendCompleteNotification(LocalFrame* frame) 620 static bool shouldSendCompleteNotification(LocalFrame* frame, bool isNavigationH andledByClient)
620 { 621 {
621 // FIXME: We might have already sent stop notifications and be re-completing . 622 // FIXME: We might have already sent stop notifications and be re-completing .
622 if (!frame->isLoading()) 623 if (!frame->isLoading())
623 return false; 624 return false;
624 // Only send didStopLoading() if there are no navigations in progress at all , 625 // Only send didStopLoading() if there are no navigations in progress at all ,
625 // whether committed, provisional, or pending. 626 // whether committed, provisional, or pending.
626 return frame->loader().documentLoader()->sentDidFinishLoad() && !frame->load er().provisionalDocumentLoader(); 627 return frame->loader().documentLoader()->sentDidFinishLoad() && !frame->load er().provisionalDocumentLoader() && !isNavigationHandledByClient;
627 } 628 }
628 629
629 void FrameLoader::checkCompleted() 630 void FrameLoader::checkCompleted()
630 { 631 {
631 if (!shouldComplete(m_frame->document())) 632 if (!shouldComplete(m_frame->document()))
632 return; 633 return;
633 634
634 // OK, completed. 635 // OK, completed.
635 m_frame->document()->setReadyState(Document::Complete); 636 m_frame->document()->setReadyState(Document::Complete);
636 if (m_frame->document()->loadEventStillNeeded()) 637 if (m_frame->document()->loadEventStillNeeded())
(...skipping 12 matching lines...) Expand all
649 // Report mobile vs. desktop page statistics. This will only report on A ndroid. 650 // Report mobile vs. desktop page statistics. This will only report on A ndroid.
650 if (m_frame->isMainFrame()) 651 if (m_frame->isMainFrame())
651 m_frame->document()->viewportDescription().reportMobilePageStats(m_f rame); 652 m_frame->document()->viewportDescription().reportMobilePageStats(m_f rame);
652 m_documentLoader->setSentDidFinishLoad(); 653 m_documentLoader->setSentDidFinishLoad();
653 client()->dispatchDidFinishLoad(); 654 client()->dispatchDidFinishLoad();
654 // Finishing the load can detach the frame when running layout tests. 655 // Finishing the load can detach the frame when running layout tests.
655 if (!m_frame->client()) 656 if (!m_frame->client())
656 return; 657 return;
657 } 658 }
658 659
659 if (shouldSendCompleteNotification(m_frame)) { 660 if (shouldSendCompleteNotification(m_frame, m_isNavigationHandledByClient)) {
660 m_progressTracker->progressCompleted(); 661 m_progressTracker->progressCompleted();
661 // Retry restoring scroll offset since finishing loading disables conten t 662 // Retry restoring scroll offset since finishing loading disables conten t
662 // size clamping. 663 // size clamping.
663 restoreScrollPositionAndViewState(); 664 restoreScrollPositionAndViewState();
664 665
665 m_loadType = FrameLoadTypeStandard; 666 m_loadType = FrameLoadTypeStandard;
666 m_frame->localDOMWindow()->finishedLoading(); 667 m_frame->localDOMWindow()->finishedLoading();
667 } 668 }
668 669
669 Frame* parent = m_frame->tree().parent(); 670 Frame* parent = m_frame->tree().parent();
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 { 1046 {
1046 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal) 1047 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal)
1047 return; 1048 return;
1048 1049
1049 // If this method is called from within this method, infinite recursion can occur (3442218). Avoid this. 1050 // If this method is called from within this method, infinite recursion can occur (3442218). Avoid this.
1050 if (m_inStopAllLoaders) 1051 if (m_inStopAllLoaders)
1051 return; 1052 return;
1052 1053
1053 m_inStopAllLoaders = true; 1054 m_inStopAllLoaders = true;
1054 1055
1056 m_isNavigationHandledByClient = false;
1057
1055 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) { 1058 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) {
1056 if (child->isLocalFrame()) 1059 if (child->isLocalFrame())
1057 toLocalFrame(child)->loader().stopAllLoaders(); 1060 toLocalFrame(child)->loader().stopAllLoaders();
1058 } 1061 }
1059 1062
1060 m_frame->document()->suppressLoadEvent(); 1063 m_frame->document()->suppressLoadEvent();
1061 if (m_documentLoader) 1064 if (m_documentLoader)
1062 m_documentLoader->fetcher()->stopFetching(); 1065 m_documentLoader->fetcher()->stopFetching();
1063 m_frame->document()->cancelParsing(); 1066 m_frame->document()->cancelParsing();
1064 if (!m_protectProvisionalLoader) 1067 if (!m_protectProvisionalLoader)
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 shouldClose = true; 1373 shouldClose = true;
1371 } 1374 }
1372 1375
1373 return shouldClose; 1376 return shouldClose;
1374 } 1377 }
1375 1378
1376 bool FrameLoader::shouldContinueForNavigationPolicy(const ResourceRequest& reque st, const SubstituteData& substituteData, 1379 bool FrameLoader::shouldContinueForNavigationPolicy(const ResourceRequest& reque st, const SubstituteData& substituteData,
1377 DocumentLoader* loader, ContentSecurityPolicyDisposition shouldCheckMainWorl dContentSecurityPolicy, 1380 DocumentLoader* loader, ContentSecurityPolicyDisposition shouldCheckMainWorl dContentSecurityPolicy,
1378 NavigationType type, NavigationPolicy policy, bool replacesCurrentHistoryIte m, bool isClientRedirect) 1381 NavigationType type, NavigationPolicy policy, bool replacesCurrentHistoryIte m, bool isClientRedirect)
1379 { 1382 {
1383 m_isNavigationHandledByClient = false;
1384
1380 // Don't ask if we are loading an empty URL. 1385 // Don't ask if we are loading an empty URL.
1381 if (request.url().isEmpty() || substituteData.isValid()) 1386 if (request.url().isEmpty() || substituteData.isValid())
1382 return true; 1387 return true;
1383 1388
1384 // If we're loading content into a subframe, check against the parent's Cont ent Security Policy 1389 // If we're loading content into a subframe, check against the parent's Cont ent Security Policy
1385 // and kill the load if that check fails, unless we should bypass the main w orld's CSP. 1390 // and kill the load if that check fails, unless we should bypass the main w orld's CSP.
1386 if (shouldCheckMainWorldContentSecurityPolicy == CheckContentSecurityPolicy) { 1391 if (shouldCheckMainWorldContentSecurityPolicy == CheckContentSecurityPolicy) {
1387 Frame* parentFrame = m_frame->tree().parent(); 1392 Frame* parentFrame = m_frame->tree().parent();
1388 if (parentFrame) { 1393 if (parentFrame) {
1389 ContentSecurityPolicy* parentPolicy = parentFrame->securityContext() ->contentSecurityPolicy(); 1394 ContentSecurityPolicy* parentPolicy = parentFrame->securityContext() ->contentSecurityPolicy();
(...skipping 11 matching lines...) Expand all
1401 bool isFormSubmission = type == NavigationTypeFormSubmitted || type == Navig ationTypeFormResubmitted; 1406 bool isFormSubmission = type == NavigationTypeFormSubmitted || type == Navig ationTypeFormResubmitted;
1402 if (isFormSubmission && !m_frame->document()->contentSecurityPolicy()->allow FormAction(request.url())) 1407 if (isFormSubmission && !m_frame->document()->contentSecurityPolicy()->allow FormAction(request.url()))
1403 return false; 1408 return false;
1404 1409
1405 policy = client()->decidePolicyForNavigation(request, loader, type, policy, replacesCurrentHistoryItem, isClientRedirect); 1410 policy = client()->decidePolicyForNavigation(request, loader, type, policy, replacesCurrentHistoryItem, isClientRedirect);
1406 if (policy == NavigationPolicyCurrentTab) 1411 if (policy == NavigationPolicyCurrentTab)
1407 return true; 1412 return true;
1408 if (policy == NavigationPolicyIgnore) 1413 if (policy == NavigationPolicyIgnore)
1409 return false; 1414 return false;
1410 if (policy == NavigationPolicyHandledByClient) { 1415 if (policy == NavigationPolicyHandledByClient) {
1416 m_isNavigationHandledByClient = true;
1411 // Mark the frame as loading since the embedder is handling the navigati on. 1417 // Mark the frame as loading since the embedder is handling the navigati on.
1412 m_progressTracker->progressStarted(); 1418 m_progressTracker->progressStarted();
1413 return false; 1419 return false;
1414 } 1420 }
1415 if (!LocalDOMWindow::allowPopUp(*m_frame) && !UserGestureIndicator::utilizeU serGesture()) 1421 if (!LocalDOMWindow::allowPopUp(*m_frame) && !UserGestureIndicator::utilizeU serGesture())
1416 return false; 1422 return false;
1417 client()->loadURLExternally(request, policy, String(), replacesCurrentHistor yItem); 1423 client()->loadURLExternally(request, policy, String(), replacesCurrentHistor yItem);
1418 return false; 1424 return false;
1419 } 1425 }
1420 1426
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa der->url() : String()); 1668 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa der->url() : String());
1663 return tracedValue; 1669 return tracedValue;
1664 } 1670 }
1665 1671
1666 inline void FrameLoader::takeObjectSnapshot() const 1672 inline void FrameLoader::takeObjectSnapshot() const
1667 { 1673 {
1668 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced Value()); 1674 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced Value());
1669 } 1675 }
1670 1676
1671 } // namespace blink 1677 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/FrameLoader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698