| OLD | NEW |
| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 FrameLoader::FrameLoader(LocalFrame* frame) | 177 FrameLoader::FrameLoader(LocalFrame* frame) |
| 178 : m_frame(frame) | 178 : m_frame(frame) |
| 179 , m_progressTracker(ProgressTracker::create(frame)) | 179 , m_progressTracker(ProgressTracker::create(frame)) |
| 180 , m_loadType(FrameLoadTypeStandard) | 180 , m_loadType(FrameLoadTypeStandard) |
| 181 , m_inStopAllLoaders(false) | 181 , m_inStopAllLoaders(false) |
| 182 , m_checkTimer(TaskRunnerHelper::get(TaskType::Networking, frame), this, &Fr
ameLoader::checkTimerFired) | 182 , m_checkTimer(TaskRunnerHelper::get(TaskType::Networking, frame), this, &Fr
ameLoader::checkTimerFired) |
| 183 , m_didAccessInitialDocument(false) | 183 , m_didAccessInitialDocument(false) |
| 184 , m_forcedSandboxFlags(SandboxNone) | 184 , m_forcedSandboxFlags(SandboxNone) |
| 185 , m_dispatchingDidClearWindowObjectInMainWorld(false) | 185 , m_dispatchingDidClearWindowObjectInMainWorld(false) |
| 186 , m_protectProvisionalLoader(false) | 186 , m_protectProvisionalLoader(false) |
| 187 , m_isNavigationHandledByClient(false) |
| 187 { | 188 { |
| 188 TRACE_EVENT_OBJECT_CREATED_WITH_ID("loading", "FrameLoader", this); | 189 TRACE_EVENT_OBJECT_CREATED_WITH_ID("loading", "FrameLoader", this); |
| 189 takeObjectSnapshot(); | 190 takeObjectSnapshot(); |
| 190 } | 191 } |
| 191 | 192 |
| 192 FrameLoader::~FrameLoader() | 193 FrameLoader::~FrameLoader() |
| 193 { | 194 { |
| 194 // Verify that this FrameLoader has been detached. | 195 // Verify that this FrameLoader has been detached. |
| 195 ASSERT(!m_progressTracker); | 196 ASSERT(!m_progressTracker); |
| 196 } | 197 } |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 // We might have declined to run the load event due to an imminent content-i
nitiated navigation. | 613 // We might have declined to run the load event due to an imminent content-i
nitiated navigation. |
| 613 if (!frame->document()->loadEventFinished()) | 614 if (!frame->document()->loadEventFinished()) |
| 614 return false; | 615 return false; |
| 615 | 616 |
| 616 // An event might have restarted a child frame. | 617 // An event might have restarted a child frame. |
| 617 if (!allDescendantsAreComplete(frame)) | 618 if (!allDescendantsAreComplete(frame)) |
| 618 return false; | 619 return false; |
| 619 return true; | 620 return true; |
| 620 } | 621 } |
| 621 | 622 |
| 622 static bool shouldSendCompleteNotification(LocalFrame* frame) | 623 static bool shouldSendCompleteNotification(LocalFrame* frame, bool isNavigationH
andledByClient) |
| 623 { | 624 { |
| 624 // FIXME: We might have already sent stop notifications and be re-completing
. | 625 // FIXME: We might have already sent stop notifications and be re-completing
. |
| 625 if (!frame->isLoading()) | 626 if (!frame->isLoading()) |
| 626 return false; | 627 return false; |
| 627 // Only send didStopLoading() if there are no navigations in progress at all
, | 628 // Only send didStopLoading() if there are no navigations in progress at all
, |
| 628 // whether committed, provisional, or pending. | 629 // whether committed, provisional, or pending. |
| 629 return frame->loader().documentLoader()->sentDidFinishLoad() && !frame->load
er().provisionalDocumentLoader(); | 630 return frame->loader().documentLoader()->sentDidFinishLoad() && !frame->load
er().provisionalDocumentLoader() && !isNavigationHandledByClient; |
| 630 } | 631 } |
| 631 | 632 |
| 632 void FrameLoader::checkCompleted() | 633 void FrameLoader::checkCompleted() |
| 633 { | 634 { |
| 634 if (!shouldComplete(m_frame->document())) | 635 if (!shouldComplete(m_frame->document())) |
| 635 return; | 636 return; |
| 636 | 637 |
| 637 // OK, completed. | 638 // OK, completed. |
| 638 m_frame->document()->setReadyState(Document::Complete); | 639 m_frame->document()->setReadyState(Document::Complete); |
| 639 if (m_frame->document()->loadEventStillNeeded()) | 640 if (m_frame->document()->loadEventStillNeeded()) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 652 // Report mobile vs. desktop page statistics. This will only report on A
ndroid. | 653 // Report mobile vs. desktop page statistics. This will only report on A
ndroid. |
| 653 if (m_frame->isMainFrame()) | 654 if (m_frame->isMainFrame()) |
| 654 m_frame->document()->viewportDescription().reportMobilePageStats(m_f
rame); | 655 m_frame->document()->viewportDescription().reportMobilePageStats(m_f
rame); |
| 655 m_documentLoader->setSentDidFinishLoad(); | 656 m_documentLoader->setSentDidFinishLoad(); |
| 656 client()->dispatchDidFinishLoad(); | 657 client()->dispatchDidFinishLoad(); |
| 657 // Finishing the load can detach the frame when running layout tests. | 658 // Finishing the load can detach the frame when running layout tests. |
| 658 if (!m_frame->client()) | 659 if (!m_frame->client()) |
| 659 return; | 660 return; |
| 660 } | 661 } |
| 661 | 662 |
| 662 if (shouldSendCompleteNotification(m_frame)) { | 663 if (shouldSendCompleteNotification(m_frame, m_isNavigationHandledByClient))
{ |
| 663 m_progressTracker->progressCompleted(); | 664 m_progressTracker->progressCompleted(); |
| 664 // Retry restoring scroll offset since finishing loading disables conten
t | 665 // Retry restoring scroll offset since finishing loading disables conten
t |
| 665 // size clamping. | 666 // size clamping. |
| 666 restoreScrollPositionAndViewState(); | 667 restoreScrollPositionAndViewState(); |
| 667 | 668 |
| 668 m_loadType = FrameLoadTypeStandard; | 669 m_loadType = FrameLoadTypeStandard; |
| 669 m_frame->localDOMWindow()->finishedLoading(); | 670 m_frame->localDOMWindow()->finishedLoading(); |
| 670 } | 671 } |
| 671 | 672 |
| 672 Frame* parent = m_frame->tree().parent(); | 673 Frame* parent = m_frame->tree().parent(); |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 { | 1043 { |
| 1043 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No
Dismissal) | 1044 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No
Dismissal) |
| 1044 return; | 1045 return; |
| 1045 | 1046 |
| 1046 // If this method is called from within this method, infinite recursion can
occur (3442218). Avoid this. | 1047 // If this method is called from within this method, infinite recursion can
occur (3442218). Avoid this. |
| 1047 if (m_inStopAllLoaders) | 1048 if (m_inStopAllLoaders) |
| 1048 return; | 1049 return; |
| 1049 | 1050 |
| 1050 m_inStopAllLoaders = true; | 1051 m_inStopAllLoaders = true; |
| 1051 | 1052 |
| 1053 m_isNavigationHandledByClient = false; |
| 1054 |
| 1052 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree
().nextSibling()) { | 1055 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree
().nextSibling()) { |
| 1053 if (child->isLocalFrame()) | 1056 if (child->isLocalFrame()) |
| 1054 toLocalFrame(child)->loader().stopAllLoaders(); | 1057 toLocalFrame(child)->loader().stopAllLoaders(); |
| 1055 } | 1058 } |
| 1056 | 1059 |
| 1057 m_frame->document()->suppressLoadEvent(); | 1060 m_frame->document()->suppressLoadEvent(); |
| 1058 if (m_documentLoader) | 1061 if (m_documentLoader) |
| 1059 m_documentLoader->fetcher()->stopFetching(); | 1062 m_documentLoader->fetcher()->stopFetching(); |
| 1060 m_frame->document()->cancelParsing(); | 1063 m_frame->document()->cancelParsing(); |
| 1061 if (!m_protectProvisionalLoader) | 1064 if (!m_protectProvisionalLoader) |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1369 shouldClose = true; | 1372 shouldClose = true; |
| 1370 } | 1373 } |
| 1371 | 1374 |
| 1372 return shouldClose; | 1375 return shouldClose; |
| 1373 } | 1376 } |
| 1374 | 1377 |
| 1375 bool FrameLoader::shouldContinueForNavigationPolicy(const ResourceRequest& reque
st, const SubstituteData& substituteData, | 1378 bool FrameLoader::shouldContinueForNavigationPolicy(const ResourceRequest& reque
st, const SubstituteData& substituteData, |
| 1376 DocumentLoader* loader, ContentSecurityPolicyDisposition shouldCheckMainWorl
dContentSecurityPolicy, | 1379 DocumentLoader* loader, ContentSecurityPolicyDisposition shouldCheckMainWorl
dContentSecurityPolicy, |
| 1377 NavigationType type, NavigationPolicy policy, bool replacesCurrentHistoryIte
m, bool isClientRedirect) | 1380 NavigationType type, NavigationPolicy policy, bool replacesCurrentHistoryIte
m, bool isClientRedirect) |
| 1378 { | 1381 { |
| 1382 m_isNavigationHandledByClient = false; |
| 1383 |
| 1379 // Don't ask if we are loading an empty URL. | 1384 // Don't ask if we are loading an empty URL. |
| 1380 if (request.url().isEmpty() || substituteData.isValid()) | 1385 if (request.url().isEmpty() || substituteData.isValid()) |
| 1381 return true; | 1386 return true; |
| 1382 | 1387 |
| 1383 // If we're loading content into a subframe, check against the parent's Cont
ent Security Policy | 1388 // If we're loading content into a subframe, check against the parent's Cont
ent Security Policy |
| 1384 // and kill the load if that check fails, unless we should bypass the main w
orld's CSP. | 1389 // and kill the load if that check fails, unless we should bypass the main w
orld's CSP. |
| 1385 if (shouldCheckMainWorldContentSecurityPolicy == CheckContentSecurityPolicy)
{ | 1390 if (shouldCheckMainWorldContentSecurityPolicy == CheckContentSecurityPolicy)
{ |
| 1386 Frame* parentFrame = m_frame->tree().parent(); | 1391 Frame* parentFrame = m_frame->tree().parent(); |
| 1387 if (parentFrame) { | 1392 if (parentFrame) { |
| 1388 ContentSecurityPolicy* parentPolicy = parentFrame->securityContext()
->contentSecurityPolicy(); | 1393 ContentSecurityPolicy* parentPolicy = parentFrame->securityContext()
->contentSecurityPolicy(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1400 bool isFormSubmission = type == NavigationTypeFormSubmitted || type == Navig
ationTypeFormResubmitted; | 1405 bool isFormSubmission = type == NavigationTypeFormSubmitted || type == Navig
ationTypeFormResubmitted; |
| 1401 if (isFormSubmission && !m_frame->document()->contentSecurityPolicy()->allow
FormAction(request.url())) | 1406 if (isFormSubmission && !m_frame->document()->contentSecurityPolicy()->allow
FormAction(request.url())) |
| 1402 return false; | 1407 return false; |
| 1403 | 1408 |
| 1404 policy = client()->decidePolicyForNavigation(request, loader, type, policy,
replacesCurrentHistoryItem, isClientRedirect); | 1409 policy = client()->decidePolicyForNavigation(request, loader, type, policy,
replacesCurrentHistoryItem, isClientRedirect); |
| 1405 if (policy == NavigationPolicyCurrentTab) | 1410 if (policy == NavigationPolicyCurrentTab) |
| 1406 return true; | 1411 return true; |
| 1407 if (policy == NavigationPolicyIgnore) | 1412 if (policy == NavigationPolicyIgnore) |
| 1408 return false; | 1413 return false; |
| 1409 if (policy == NavigationPolicyHandledByClient) { | 1414 if (policy == NavigationPolicyHandledByClient) { |
| 1415 m_isNavigationHandledByClient = true; |
| 1410 // Mark the frame as loading since the embedder is handling the navigati
on. | 1416 // Mark the frame as loading since the embedder is handling the navigati
on. |
| 1411 m_progressTracker->progressStarted(); | 1417 m_progressTracker->progressStarted(); |
| 1412 return false; | 1418 return false; |
| 1413 } | 1419 } |
| 1414 if (!LocalDOMWindow::allowPopUp(*m_frame) && !UserGestureIndicator::utilizeU
serGesture()) | 1420 if (!LocalDOMWindow::allowPopUp(*m_frame) && !UserGestureIndicator::utilizeU
serGesture()) |
| 1415 return false; | 1421 return false; |
| 1416 client()->loadURLExternally(request, policy, String(), replacesCurrentHistor
yItem); | 1422 client()->loadURLExternally(request, policy, String(), replacesCurrentHistor
yItem); |
| 1417 return false; | 1423 return false; |
| 1418 } | 1424 } |
| 1419 | 1425 |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1622 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa
der->url() : String()); | 1628 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa
der->url() : String()); |
| 1623 return tracedValue; | 1629 return tracedValue; |
| 1624 } | 1630 } |
| 1625 | 1631 |
| 1626 inline void FrameLoader::takeObjectSnapshot() const | 1632 inline void FrameLoader::takeObjectSnapshot() const |
| 1627 { | 1633 { |
| 1628 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced
Value()); | 1634 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced
Value()); |
| 1629 } | 1635 } |
| 1630 | 1636 |
| 1631 } // namespace blink | 1637 } // namespace blink |
| OLD | NEW |