| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights |
| 3 * reserved. | 3 * reserved. |
| 4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 6 * (http://www.torchmobile.com/) | 6 * (http://www.torchmobile.com/) |
| 7 * Copyright (C) 2008 Alp Toker <alp@atoker.com> | 7 * Copyright (C) 2008 Alp Toker <alp@atoker.com> |
| 8 * Copyright (C) Research In Motion Limited 2009. All rights reserved. | 8 * Copyright (C) Research In Motion Limited 2009. All rights reserved. |
| 9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> | 9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> |
| 10 * Copyright (C) 2011 Google Inc. All rights reserved. | 10 * Copyright (C) 2011 Google Inc. All rights reserved. |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 HistoryCommitType historyCommitType = loadTypeToCommitType(m_loadType); | 465 HistoryCommitType historyCommitType = loadTypeToCommitType(m_loadType); |
| 466 if (historyCommitType == StandardCommit && | 466 if (historyCommitType == StandardCommit && |
| 467 (m_documentLoader->urlForHistory().isEmpty() || | 467 (m_documentLoader->urlForHistory().isEmpty() || |
| 468 (opener() && !m_currentItem && | 468 (opener() && !m_currentItem && |
| 469 m_documentLoader->originalRequest().url().isEmpty()))) | 469 m_documentLoader->originalRequest().url().isEmpty()))) |
| 470 historyCommitType = HistoryInertCommit; | 470 historyCommitType = HistoryInertCommit; |
| 471 setHistoryItemStateForCommit(m_loadType, historyCommitType, | 471 setHistoryItemStateForCommit(m_loadType, historyCommitType, |
| 472 HistoryNavigationType::DifferentDocument); | 472 HistoryNavigationType::DifferentDocument); |
| 473 | 473 |
| 474 if (!m_stateMachine.committedMultipleRealLoads() && | 474 if (!m_stateMachine.committedMultipleRealLoads() && |
| 475 m_loadType == FrameLoadTypeStandard) | 475 m_loadType == FrameLoadTypeStandard) { |
| 476 m_stateMachine.advanceTo( | 476 m_stateMachine.advanceTo( |
| 477 FrameLoaderStateMachine::CommittedMultipleRealLoads); | 477 FrameLoaderStateMachine::CommittedMultipleRealLoads); |
| 478 } |
| 478 | 479 |
| 479 client()->dispatchDidCommitLoad(m_currentItem.get(), historyCommitType); | 480 client()->dispatchDidCommitLoad(m_currentItem.get(), historyCommitType); |
| 480 | 481 |
| 481 // When the embedder gets notified (above) that the new navigation has | 482 // When the embedder gets notified (above) that the new navigation has |
| 482 // committed, the embedder will drop the old Content Security Policy and | 483 // committed, the embedder will drop the old Content Security Policy and |
| 483 // therefore now is a good time to report to the embedder the Content Security | 484 // therefore now is a good time to report to the embedder the Content Security |
| 484 // Policies that have accumulated so far for the new navigation. | 485 // Policies that have accumulated so far for the new navigation. |
| 485 m_frame->securityContext()->contentSecurityPolicy()->reportAccumulatedHeaders( | 486 m_frame->securityContext()->contentSecurityPolicy()->reportAccumulatedHeaders( |
| 486 client()); | 487 client()); |
| 487 | 488 |
| 488 // didObserveLoadingBehavior() must be called after dispatchDidCommitLoad() is | 489 // didObserveLoadingBehavior() must be called after dispatchDidCommitLoad() is |
| 489 // called for the metrics tracking logic to handle it properly. | 490 // called for the metrics tracking logic to handle it properly. |
| 490 if (client()->isControlledByServiceWorker(*m_documentLoader)) | 491 if (client()->isControlledByServiceWorker(*m_documentLoader)) { |
| 491 client()->didObserveLoadingBehavior( | 492 client()->didObserveLoadingBehavior( |
| 492 WebLoadingBehaviorServiceWorkerControlled); | 493 WebLoadingBehaviorServiceWorkerControlled); |
| 494 } |
| 493 | 495 |
| 494 // Links with media values need more information (like viewport information). | 496 // Links with media values need more information (like viewport information). |
| 495 // This happens after the first chunk is parsed in HTMLDocumentParser. | 497 // This happens after the first chunk is parsed in HTMLDocumentParser. |
| 496 m_documentLoader->dispatchLinkHeaderPreloads(nullptr, | 498 m_documentLoader->dispatchLinkHeaderPreloads(nullptr, |
| 497 LinkLoader::OnlyLoadNonMedia); | 499 LinkLoader::OnlyLoadNonMedia); |
| 498 | 500 |
| 499 TRACE_EVENT1("devtools.timeline", "CommitLoad", "data", | 501 TRACE_EVENT1("devtools.timeline", "CommitLoad", "data", |
| 500 InspectorCommitLoadEvent::data(m_frame)); | 502 InspectorCommitLoadEvent::data(m_frame)); |
| 501 InspectorInstrumentation::didCommitLoad(m_frame, m_documentLoader.get()); | 503 InspectorInstrumentation::didCommitLoad(m_frame, m_documentLoader.get()); |
| 502 m_frame->page()->didCommitLoad(m_frame); | 504 m_frame->page()->didCommitLoad(m_frame); |
| 503 dispatchDidClearDocumentOfWindowObject(); | 505 dispatchDidClearDocumentOfWindowObject(); |
| 504 | 506 |
| 505 takeObjectSnapshot(); | 507 takeObjectSnapshot(); |
| 506 } | 508 } |
| 507 | 509 |
| 508 void FrameLoader::didInstallNewDocument(bool dispatchWindowObjectAvailable) { | 510 void FrameLoader::didInstallNewDocument(bool dispatchWindowObjectAvailable) { |
| 509 DCHECK(m_frame); | 511 DCHECK(m_frame); |
| 510 DCHECK(m_frame->document()); | 512 DCHECK(m_frame->document()); |
| 511 | 513 |
| 512 m_frame->document()->setReadyState(Document::Loading); | 514 m_frame->document()->setReadyState(Document::Loading); |
| 513 | 515 |
| 514 if (dispatchWindowObjectAvailable) | 516 if (dispatchWindowObjectAvailable) |
| 515 dispatchDidClearDocumentOfWindowObject(); | 517 dispatchDidClearDocumentOfWindowObject(); |
| 516 | 518 |
| 517 m_frame->document()->initContentSecurityPolicy( | 519 m_frame->document()->initContentSecurityPolicy( |
| 518 m_documentLoader ? m_documentLoader->releaseContentSecurityPolicy() | 520 m_documentLoader ? m_documentLoader->releaseContentSecurityPolicy() |
| 519 : ContentSecurityPolicy::create()); | 521 : ContentSecurityPolicy::create()); |
| 520 | 522 |
| 521 if (m_provisionalItem && isBackForwardLoadType(m_loadType)) | 523 if (m_provisionalItem && isBackForwardLoadType(m_loadType)) { |
| 522 m_frame->document()->setStateForNewFormElements( | 524 m_frame->document()->setStateForNewFormElements( |
| 523 m_provisionalItem->documentState()); | 525 m_provisionalItem->documentState()); |
| 526 } |
| 524 } | 527 } |
| 525 | 528 |
| 526 void FrameLoader::didBeginDocument() { | 529 void FrameLoader::didBeginDocument() { |
| 527 DCHECK(m_frame); | 530 DCHECK(m_frame); |
| 528 DCHECK(m_frame->document()); | 531 DCHECK(m_frame->document()); |
| 529 DCHECK(m_frame->document()->fetcher()); | 532 DCHECK(m_frame->document()->fetcher()); |
| 530 | 533 |
| 531 if (m_documentLoader) { | 534 if (m_documentLoader) { |
| 532 String suboriginHeader = | 535 String suboriginHeader = |
| 533 m_documentLoader->response().httpHeaderField(HTTPNames::Suborigin); | 536 m_documentLoader->response().httpHeaderField(HTTPNames::Suborigin); |
| 534 if (!suboriginHeader.isNull()) { | 537 if (!suboriginHeader.isNull()) { |
| 535 Vector<String> messages; | 538 Vector<String> messages; |
| 536 Suborigin suborigin; | 539 Suborigin suborigin; |
| 537 if (parseSuboriginHeader(suboriginHeader, &suborigin, messages)) | 540 if (parseSuboriginHeader(suboriginHeader, &suborigin, messages)) |
| 538 m_frame->document()->enforceSuborigin(suborigin); | 541 m_frame->document()->enforceSuborigin(suborigin); |
| 539 | 542 |
| 540 for (auto& message : messages) | 543 for (auto& message : messages) { |
| 541 m_frame->document()->addConsoleMessage( | 544 m_frame->document()->addConsoleMessage( |
| 542 ConsoleMessage::create(SecurityMessageSource, ErrorMessageLevel, | 545 ConsoleMessage::create(SecurityMessageSource, ErrorMessageLevel, |
| 543 "Error with Suborigin header: " + message)); | 546 "Error with Suborigin header: " + message)); |
| 547 } |
| 544 } | 548 } |
| 545 m_frame->document()->clientHintsPreferences().updateFrom( | 549 m_frame->document()->clientHintsPreferences().updateFrom( |
| 546 m_documentLoader->clientHintsPreferences()); | 550 m_documentLoader->clientHintsPreferences()); |
| 547 } | 551 } |
| 548 | 552 |
| 549 Settings* settings = m_frame->document()->settings(); | 553 Settings* settings = m_frame->document()->settings(); |
| 550 if (settings) { | 554 if (settings) { |
| 551 m_frame->document()->fetcher()->setImagesEnabled(settings->imagesEnabled()); | 555 m_frame->document()->fetcher()->setImagesEnabled(settings->imagesEnabled()); |
| 552 m_frame->document()->fetcher()->setAutoLoadImages( | 556 m_frame->document()->fetcher()->setAutoLoadImages( |
| 553 settings->loadsImagesAutomatically()); | 557 settings->loadsImagesAutomatically()); |
| 554 } | 558 } |
| 555 | 559 |
| 556 if (m_documentLoader) { | 560 if (m_documentLoader) { |
| 557 const AtomicString& dnsPrefetchControl = | 561 const AtomicString& dnsPrefetchControl = |
| 558 m_documentLoader->response().httpHeaderField( | 562 m_documentLoader->response().httpHeaderField( |
| 559 HTTPNames::X_DNS_Prefetch_Control); | 563 HTTPNames::X_DNS_Prefetch_Control); |
| 560 if (!dnsPrefetchControl.isEmpty()) | 564 if (!dnsPrefetchControl.isEmpty()) |
| 561 m_frame->document()->parseDNSPrefetchControlHeader(dnsPrefetchControl); | 565 m_frame->document()->parseDNSPrefetchControlHeader(dnsPrefetchControl); |
| 562 | 566 |
| 563 String headerContentLanguage = m_documentLoader->response().httpHeaderField( | 567 String headerContentLanguage = m_documentLoader->response().httpHeaderField( |
| 564 HTTPNames::Content_Language); | 568 HTTPNames::Content_Language); |
| 565 if (!headerContentLanguage.isEmpty()) { | 569 if (!headerContentLanguage.isEmpty()) { |
| 566 size_t commaIndex = headerContentLanguage.find(','); | 570 size_t commaIndex = headerContentLanguage.find(','); |
| 567 headerContentLanguage.truncate( | 571 headerContentLanguage.truncate( |
| 568 commaIndex); // kNotFound == -1 == don't truncate | 572 commaIndex); // kNotFound == -1 == don't truncate |
| 569 headerContentLanguage = | 573 headerContentLanguage = |
| 570 headerContentLanguage.stripWhiteSpace(isHTMLSpace<UChar>); | 574 headerContentLanguage.stripWhiteSpace(isHTMLSpace<UChar>); |
| 571 if (!headerContentLanguage.isEmpty()) | 575 if (!headerContentLanguage.isEmpty()) { |
| 572 m_frame->document()->setContentLanguage( | 576 m_frame->document()->setContentLanguage( |
| 573 AtomicString(headerContentLanguage)); | 577 AtomicString(headerContentLanguage)); |
| 578 } |
| 574 } | 579 } |
| 575 | 580 |
| 576 OriginTrialContext::addTokensFromHeader( | 581 OriginTrialContext::addTokensFromHeader( |
| 577 m_frame->document(), | 582 m_frame->document(), |
| 578 m_documentLoader->response().httpHeaderField(HTTPNames::Origin_Trial)); | 583 m_documentLoader->response().httpHeaderField(HTTPNames::Origin_Trial)); |
| 579 } | 584 } |
| 580 | 585 |
| 581 if (m_documentLoader) { | 586 if (m_documentLoader) { |
| 582 String referrerPolicyHeader = m_documentLoader->response().httpHeaderField( | 587 String referrerPolicyHeader = m_documentLoader->response().httpHeaderField( |
| 583 HTTPNames::Referrer_Policy); | 588 HTTPNames::Referrer_Policy); |
| 584 if (!referrerPolicyHeader.isNull()) { | 589 if (!referrerPolicyHeader.isNull()) { |
| 585 m_frame->document()->parseAndSetReferrerPolicy(referrerPolicyHeader); | 590 m_frame->document()->parseAndSetReferrerPolicy(referrerPolicyHeader); |
| 586 } | 591 } |
| 587 } | 592 } |
| 588 | 593 |
| 589 client()->didCreateNewDocument(); | 594 client()->didCreateNewDocument(); |
| 590 } | 595 } |
| 591 | 596 |
| 592 void FrameLoader::finishedParsing() { | 597 void FrameLoader::finishedParsing() { |
| 593 if (m_stateMachine.creatingInitialEmptyDocument()) | 598 if (m_stateMachine.creatingInitialEmptyDocument()) |
| 594 return; | 599 return; |
| 595 | 600 |
| 596 m_progressTracker->finishedParsing(); | 601 m_progressTracker->finishedParsing(); |
| 597 | 602 |
| 598 if (client()) { | 603 if (client()) { |
| 599 ScriptForbiddenScope forbidScripts; | 604 ScriptForbiddenScope forbidScripts; |
| 600 client()->dispatchDidFinishDocumentLoad(); | 605 client()->dispatchDidFinishDocumentLoad(); |
| 601 } | 606 } |
| 602 | 607 |
| 603 if (client()) | 608 if (client()) { |
| 604 client()->runScriptsAtDocumentReady( | 609 client()->runScriptsAtDocumentReady( |
| 605 m_documentLoader ? m_documentLoader->isCommittedButEmpty() : true); | 610 m_documentLoader ? m_documentLoader->isCommittedButEmpty() : true); |
| 611 } |
| 606 | 612 |
| 607 checkCompleted(); | 613 checkCompleted(); |
| 608 | 614 |
| 609 if (!m_frame->view()) | 615 if (!m_frame->view()) |
| 610 return; // We are being destroyed by something checkCompleted called. | 616 return; // We are being destroyed by something checkCompleted called. |
| 611 | 617 |
| 612 // Check if the scrollbars are really needed for the content. If not, remove | 618 // Check if the scrollbars are really needed for the content. If not, remove |
| 613 // them, relayout, and repaint. | 619 // them, relayout, and repaint. |
| 614 m_frame->view()->restoreScrollbar(); | 620 m_frame->view()->restoreScrollbar(); |
| 615 processFragment(m_frame->document()->url(), NavigationToDifferentDocument); | 621 processFragment(m_frame->document()->url(), NavigationToDifferentDocument); |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 // submission incorrectly sends as a GET rather than a POST if it creates a | 973 // submission incorrectly sends as a GET rather than a POST if it creates a |
| 968 // new window in a different process. | 974 // new window in a different process. |
| 969 return request.form() && policy != NavigationPolicyCurrentTab; | 975 return request.form() && policy != NavigationPolicyCurrentTab; |
| 970 } | 976 } |
| 971 | 977 |
| 972 static NavigationType determineNavigationType(FrameLoadType frameLoadType, | 978 static NavigationType determineNavigationType(FrameLoadType frameLoadType, |
| 973 bool isFormSubmission, | 979 bool isFormSubmission, |
| 974 bool haveEvent) { | 980 bool haveEvent) { |
| 975 bool isReload = isReloadLoadType(frameLoadType); | 981 bool isReload = isReloadLoadType(frameLoadType); |
| 976 bool isBackForward = isBackForwardLoadType(frameLoadType); | 982 bool isBackForward = isBackForwardLoadType(frameLoadType); |
| 977 if (isFormSubmission) | 983 if (isFormSubmission) { |
| 978 return (isReload || isBackForward) ? NavigationTypeFormResubmitted | 984 return (isReload || isBackForward) ? NavigationTypeFormResubmitted |
| 979 : NavigationTypeFormSubmitted; | 985 : NavigationTypeFormSubmitted; |
| 986 } |
| 980 if (haveEvent) | 987 if (haveEvent) |
| 981 return NavigationTypeLinkClicked; | 988 return NavigationTypeLinkClicked; |
| 982 if (isReload) | 989 if (isReload) |
| 983 return NavigationTypeReload; | 990 return NavigationTypeReload; |
| 984 if (isBackForward) | 991 if (isBackForward) |
| 985 return NavigationTypeBackForward; | 992 return NavigationTypeBackForward; |
| 986 return NavigationTypeOther; | 993 return NavigationTypeOther; |
| 987 } | 994 } |
| 988 | 995 |
| 989 static WebURLRequest::RequestContext determineRequestContextFromNavigationType( | 996 static WebURLRequest::RequestContext determineRequestContextFromNavigationType( |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1181 m_frame->document()->cancelParsing(); | 1188 m_frame->document()->cancelParsing(); |
| 1182 if (!m_protectProvisionalLoader) | 1189 if (!m_protectProvisionalLoader) |
| 1183 detachDocumentLoader(m_provisionalDocumentLoader); | 1190 detachDocumentLoader(m_provisionalDocumentLoader); |
| 1184 | 1191 |
| 1185 m_checkTimer.stop(); | 1192 m_checkTimer.stop(); |
| 1186 m_frame->navigationScheduler().cancel(); | 1193 m_frame->navigationScheduler().cancel(); |
| 1187 | 1194 |
| 1188 // It's possible that the above actions won't have stopped loading if load | 1195 // It's possible that the above actions won't have stopped loading if load |
| 1189 // completion had been blocked on parsing or if we were in the middle of | 1196 // completion had been blocked on parsing or if we were in the middle of |
| 1190 // committing an empty document. In that case, emulate a failed navigation. | 1197 // committing an empty document. In that case, emulate a failed navigation. |
| 1191 if (!m_provisionalDocumentLoader && m_documentLoader && m_frame->isLoading()) | 1198 if (!m_provisionalDocumentLoader && m_documentLoader && |
| 1199 m_frame->isLoading()) { |
| 1192 loadFailed(m_documentLoader.get(), | 1200 loadFailed(m_documentLoader.get(), |
| 1193 ResourceError::cancelledError(m_documentLoader->url())); | 1201 ResourceError::cancelledError(m_documentLoader->url())); |
| 1202 } |
| 1194 | 1203 |
| 1195 m_inStopAllLoaders = false; | 1204 m_inStopAllLoaders = false; |
| 1196 takeObjectSnapshot(); | 1205 takeObjectSnapshot(); |
| 1197 } | 1206 } |
| 1198 | 1207 |
| 1199 void FrameLoader::didAccessInitialDocument() { | 1208 void FrameLoader::didAccessInitialDocument() { |
| 1200 // We only need to notify the client for the main frame. | 1209 // We only need to notify the client for the main frame. |
| 1201 if (isLoadingMainFrame()) { | 1210 if (isLoadingMainFrame()) { |
| 1202 // Forbid script execution to prevent re-entering V8, since this is called | 1211 // Forbid script execution to prevent re-entering V8, since this is called |
| 1203 // from a binding security check. | 1212 // from a binding security check. |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1455 return; | 1464 return; |
| 1456 | 1465 |
| 1457 // Leaking scroll position to a cross-origin ancestor would permit the | 1466 // Leaking scroll position to a cross-origin ancestor would permit the |
| 1458 // so-called "framesniffing" attack. | 1467 // so-called "framesniffing" attack. |
| 1459 Frame* boundaryFrame = | 1468 Frame* boundaryFrame = |
| 1460 url.hasFragmentIdentifier() | 1469 url.hasFragmentIdentifier() |
| 1461 ? m_frame->findUnsafeParentScrollPropagationBoundary() | 1470 ? m_frame->findUnsafeParentScrollPropagationBoundary() |
| 1462 : 0; | 1471 : 0; |
| 1463 | 1472 |
| 1464 // FIXME: Handle RemoteFrames | 1473 // FIXME: Handle RemoteFrames |
| 1465 if (boundaryFrame && boundaryFrame->isLocalFrame()) | 1474 if (boundaryFrame && boundaryFrame->isLocalFrame()) { |
| 1466 toLocalFrame(boundaryFrame) | 1475 toLocalFrame(boundaryFrame) |
| 1467 ->view() | 1476 ->view() |
| 1468 ->setSafeToPropagateScrollToParent(false); | 1477 ->setSafeToPropagateScrollToParent(false); |
| 1478 } |
| 1469 | 1479 |
| 1470 // If scroll position is restored from history fragment then we should not | 1480 // If scroll position is restored from history fragment then we should not |
| 1471 // override it unless this is a same document reload. | 1481 // override it unless this is a same document reload. |
| 1472 bool shouldScrollToFragment = | 1482 bool shouldScrollToFragment = |
| 1473 (loadStartType == NavigationWithinSameDocument && | 1483 (loadStartType == NavigationWithinSameDocument && |
| 1474 !isBackForwardLoadType(m_loadType)) || | 1484 !isBackForwardLoadType(m_loadType)) || |
| 1475 (documentLoader() && | 1485 (documentLoader() && |
| 1476 !documentLoader()->initialScrollState().didRestoreFromHistory); | 1486 !documentLoader()->initialScrollState().didRestoreFromHistory); |
| 1477 | 1487 |
| 1478 view->processUrlFragment(url, shouldScrollToFragment | 1488 view->processUrlFragment(url, shouldScrollToFragment |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1906 m_documentLoader ? m_documentLoader->url() : String()); | 1916 m_documentLoader ? m_documentLoader->url() : String()); |
| 1907 return tracedValue; | 1917 return tracedValue; |
| 1908 } | 1918 } |
| 1909 | 1919 |
| 1910 inline void FrameLoader::takeObjectSnapshot() const { | 1920 inline void FrameLoader::takeObjectSnapshot() const { |
| 1911 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, | 1921 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, |
| 1912 toTracedValue()); | 1922 toTracedValue()); |
| 1913 } | 1923 } |
| 1914 | 1924 |
| 1915 } // namespace blink | 1925 } // namespace blink |
| OLD | NEW |