| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 #include "core/frame/FrameHost.h" | 53 #include "core/frame/FrameHost.h" |
| 54 #include "core/frame/FrameView.h" | 54 #include "core/frame/FrameView.h" |
| 55 #include "core/frame/LocalDOMWindow.h" | 55 #include "core/frame/LocalDOMWindow.h" |
| 56 #include "core/frame/LocalFrame.h" | 56 #include "core/frame/LocalFrame.h" |
| 57 #include "core/frame/LocalFrameClient.h" | 57 #include "core/frame/LocalFrameClient.h" |
| 58 #include "core/frame/Settings.h" | 58 #include "core/frame/Settings.h" |
| 59 #include "core/frame/VisualViewport.h" | 59 #include "core/frame/VisualViewport.h" |
| 60 #include "core/frame/csp/ContentSecurityPolicy.h" | 60 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 61 #include "core/html/HTMLFormElement.h" | 61 #include "core/html/HTMLFormElement.h" |
| 62 #include "core/html/HTMLFrameOwnerElement.h" | 62 #include "core/html/HTMLFrameOwnerElement.h" |
| 63 #include "core/html/parser/HTMLParserIdioms.h" | |
| 64 #include "core/input/EventHandler.h" | 63 #include "core/input/EventHandler.h" |
| 65 #include "core/inspector/ConsoleMessage.h" | 64 #include "core/inspector/ConsoleMessage.h" |
| 66 #include "core/inspector/InspectorInstrumentation.h" | 65 #include "core/inspector/InspectorInstrumentation.h" |
| 67 #include "core/inspector/InspectorTraceEvents.h" | |
| 68 #include "core/loader/DocumentLoadTiming.h" | 66 #include "core/loader/DocumentLoadTiming.h" |
| 69 #include "core/loader/DocumentLoader.h" | 67 #include "core/loader/DocumentLoader.h" |
| 70 #include "core/loader/FormSubmission.h" | 68 #include "core/loader/FormSubmission.h" |
| 71 #include "core/loader/FrameLoadRequest.h" | 69 #include "core/loader/FrameLoadRequest.h" |
| 72 #include "core/loader/LinkLoader.h" | 70 #include "core/loader/LinkLoader.h" |
| 73 #include "core/loader/MixedContentChecker.h" | 71 #include "core/loader/MixedContentChecker.h" |
| 74 #include "core/loader/NavigationScheduler.h" | 72 #include "core/loader/NavigationScheduler.h" |
| 75 #include "core/loader/NetworkHintsInterface.h" | 73 #include "core/loader/NetworkHintsInterface.h" |
| 76 #include "core/loader/ProgressTracker.h" | 74 #include "core/loader/ProgressTracker.h" |
| 77 #include "core/loader/appcache/ApplicationCacheHost.h" | 75 #include "core/loader/appcache/ApplicationCacheHost.h" |
| 78 #include "core/origin_trials/OriginTrialContext.h" | |
| 79 #include "core/page/ChromeClient.h" | 76 #include "core/page/ChromeClient.h" |
| 80 #include "core/page/CreateWindow.h" | 77 #include "core/page/CreateWindow.h" |
| 81 #include "core/page/FrameTree.h" | 78 #include "core/page/FrameTree.h" |
| 82 #include "core/page/Page.h" | 79 #include "core/page/Page.h" |
| 83 #include "core/page/WindowFeatures.h" | 80 #include "core/page/WindowFeatures.h" |
| 84 #include "core/page/scrolling/ScrollingCoordinator.h" | 81 #include "core/page/scrolling/ScrollingCoordinator.h" |
| 85 #include "core/svg/graphics/SVGImage.h" | 82 #include "core/svg/graphics/SVGImage.h" |
| 86 #include "core/xml/parser/XMLDocumentParser.h" | 83 #include "core/xml/parser/XMLDocumentParser.h" |
| 87 #include "platform/InstanceCounters.h" | 84 #include "platform/InstanceCounters.h" |
| 88 #include "platform/PluginScriptForbiddenScope.h" | 85 #include "platform/PluginScriptForbiddenScope.h" |
| 89 #include "platform/ScriptForbiddenScope.h" | 86 #include "platform/ScriptForbiddenScope.h" |
| 90 #include "platform/UserGestureIndicator.h" | 87 #include "platform/UserGestureIndicator.h" |
| 91 #include "platform/feature_policy/FeaturePolicy.h" | |
| 92 #include "platform/instrumentation/tracing/TraceEvent.h" | 88 #include "platform/instrumentation/tracing/TraceEvent.h" |
| 93 #include "platform/loader/fetch/ResourceFetcher.h" | 89 #include "platform/loader/fetch/ResourceFetcher.h" |
| 94 #include "platform/loader/fetch/ResourceRequest.h" | 90 #include "platform/loader/fetch/ResourceRequest.h" |
| 95 #include "platform/network/HTTPParsers.h" | 91 #include "platform/network/HTTPParsers.h" |
| 96 #include "platform/scroll/ScrollAnimatorBase.h" | 92 #include "platform/scroll/ScrollAnimatorBase.h" |
| 97 #include "platform/weborigin/SchemeRegistry.h" | 93 #include "platform/weborigin/SchemeRegistry.h" |
| 98 #include "platform/weborigin/SecurityOrigin.h" | 94 #include "platform/weborigin/SecurityOrigin.h" |
| 99 #include "platform/weborigin/SecurityPolicy.h" | 95 #include "platform/weborigin/SecurityPolicy.h" |
| 100 #include "platform/weborigin/Suborigin.h" | 96 #include "platform/weborigin/Suborigin.h" |
| 101 #include "public/platform/WebCachePolicy.h" | 97 #include "public/platform/WebCachePolicy.h" |
| 102 #include "public/platform/WebFeaturePolicy.h" | |
| 103 #include "public/platform/WebURLRequest.h" | 98 #include "public/platform/WebURLRequest.h" |
| 104 #include "public/platform/modules/serviceworker/WebServiceWorkerNetworkProvider.
h" | 99 #include "public/platform/modules/serviceworker/WebServiceWorkerNetworkProvider.
h" |
| 105 #include "wtf/AutoReset.h" | 100 #include "wtf/AutoReset.h" |
| 106 #include "wtf/text/CString.h" | 101 #include "wtf/text/CString.h" |
| 107 #include "wtf/text/WTFString.h" | 102 #include "wtf/text/WTFString.h" |
| 108 | 103 |
| 109 using blink::WebURLRequest; | 104 using blink::WebURLRequest; |
| 110 | 105 |
| 111 namespace blink { | 106 namespace blink { |
| 112 | 107 |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 return InitialCommitInChildFrame; | 463 return InitialCommitInChildFrame; |
| 469 case FrameLoadTypeBackForward: | 464 case FrameLoadTypeBackForward: |
| 470 return BackForwardCommit; | 465 return BackForwardCommit; |
| 471 default: | 466 default: |
| 472 break; | 467 break; |
| 473 } | 468 } |
| 474 return HistoryInertCommit; | 469 return HistoryInertCommit; |
| 475 } | 470 } |
| 476 | 471 |
| 477 void FrameLoader::receivedFirstData() { | 472 void FrameLoader::receivedFirstData() { |
| 478 if (m_stateMachine.creatingInitialEmptyDocument()) | |
| 479 return; | |
| 480 | |
| 481 FrameLoadType loadType = m_documentLoader->loadType(); | 473 FrameLoadType loadType = m_documentLoader->loadType(); |
| 482 HistoryCommitType historyCommitType = loadTypeToCommitType(loadType); | 474 HistoryCommitType historyCommitType = loadTypeToCommitType(loadType); |
| 483 if (historyCommitType == StandardCommit && | 475 if (historyCommitType == StandardCommit && |
| 484 (m_documentLoader->urlForHistory().isEmpty() || | 476 (m_documentLoader->urlForHistory().isEmpty() || |
| 485 (opener() && !m_currentItem && | 477 (opener() && !m_currentItem && |
| 486 m_documentLoader->originalRequest().url().isEmpty()))) | 478 m_documentLoader->originalRequest().url().isEmpty()))) |
| 487 historyCommitType = HistoryInertCommit; | 479 historyCommitType = HistoryInertCommit; |
| 488 setHistoryItemStateForCommit(loadType, historyCommitType, | 480 setHistoryItemStateForCommit(loadType, historyCommitType, |
| 489 HistoryNavigationType::DifferentDocument); | 481 HistoryNavigationType::DifferentDocument); |
| 490 | 482 |
| 491 if (!m_stateMachine.committedMultipleRealLoads() && | 483 if (!m_stateMachine.committedMultipleRealLoads() && |
| 492 loadType == FrameLoadTypeStandard) { | 484 loadType == FrameLoadTypeStandard) { |
| 493 m_stateMachine.advanceTo( | 485 m_stateMachine.advanceTo( |
| 494 FrameLoaderStateMachine::CommittedMultipleRealLoads); | 486 FrameLoaderStateMachine::CommittedMultipleRealLoads); |
| 495 } | 487 } |
| 496 | 488 |
| 497 client()->dispatchDidCommitLoad(m_currentItem.get(), historyCommitType); | 489 client()->dispatchDidCommitLoad(m_currentItem.get(), historyCommitType); |
| 498 | 490 |
| 499 // When the embedder gets notified (above) that the new navigation has | 491 // When the embedder gets notified (above) that the new navigation has |
| 500 // committed, the embedder will drop the old Content Security Policy and | 492 // committed, the embedder will drop the old Content Security Policy and |
| 501 // therefore now is a good time to report to the embedder the Content Security | 493 // therefore now is a good time to report to the embedder the Content Security |
| 502 // Policies that have accumulated so far for the new navigation. | 494 // Policies that have accumulated so far for the new navigation. |
| 503 m_frame->securityContext()->contentSecurityPolicy()->reportAccumulatedHeaders( | 495 m_frame->securityContext()->contentSecurityPolicy()->reportAccumulatedHeaders( |
| 504 client()); | 496 client()); |
| 505 | |
| 506 // didObserveLoadingBehavior() must be called after dispatchDidCommitLoad() is | |
| 507 // called for the metrics tracking logic to handle it properly. | |
| 508 if (m_documentLoader->getServiceWorkerNetworkProvider() && | |
| 509 m_documentLoader->getServiceWorkerNetworkProvider() | |
| 510 ->isControlledByServiceWorker()) { | |
| 511 client()->didObserveLoadingBehavior( | |
| 512 WebLoadingBehaviorServiceWorkerControlled); | |
| 513 } | |
| 514 | |
| 515 // Links with media values need more information (like viewport information). | |
| 516 // This happens after the first chunk is parsed in HTMLDocumentParser. | |
| 517 m_documentLoader->dispatchLinkHeaderPreloads(nullptr, | |
| 518 LinkLoader::OnlyLoadNonMedia); | |
| 519 | |
| 520 TRACE_EVENT1("devtools.timeline", "CommitLoad", "data", | |
| 521 InspectorCommitLoadEvent::data(m_frame)); | |
| 522 probe::didCommitLoad(m_frame, m_documentLoader.get()); | |
| 523 m_frame->page()->didCommitLoad(m_frame); | |
| 524 dispatchDidClearDocumentOfWindowObject(); | |
| 525 | |
| 526 takeObjectSnapshot(); | |
| 527 } | 497 } |
| 528 | 498 |
| 529 void FrameLoader::didInstallNewDocument(bool dispatchWindowObjectAvailable) { | 499 void FrameLoader::didInstallNewDocument() { |
| 530 DCHECK(m_frame); | |
| 531 DCHECK(m_frame->document()); | |
| 532 | |
| 533 m_frame->document()->setReadyState(Document::Loading); | |
| 534 | |
| 535 if (dispatchWindowObjectAvailable) | |
| 536 dispatchDidClearDocumentOfWindowObject(); | |
| 537 | |
| 538 m_frame->document()->initContentSecurityPolicy( | |
| 539 m_documentLoader ? m_documentLoader->releaseContentSecurityPolicy() | |
| 540 : ContentSecurityPolicy::create()); | |
| 541 | |
| 542 if (m_provisionalItem && | 500 if (m_provisionalItem && |
| 543 isBackForwardLoadType(m_documentLoader->loadType())) { | 501 isBackForwardLoadType(m_documentLoader->loadType())) { |
| 544 m_frame->document()->setStateForNewFormElements( | 502 m_frame->document()->setStateForNewFormElements( |
| 545 m_provisionalItem->getDocumentState()); | 503 m_provisionalItem->getDocumentState()); |
| 546 } | 504 } |
| 547 } | 505 } |
| 548 | 506 |
| 549 void FrameLoader::didBeginDocument() { | |
| 550 DCHECK(m_frame); | |
| 551 DCHECK(m_frame->client()); | |
| 552 DCHECK(m_frame->document()); | |
| 553 DCHECK(m_frame->document()->fetcher()); | |
| 554 | |
| 555 if (m_documentLoader) { | |
| 556 String suboriginHeader = | |
| 557 m_documentLoader->response().httpHeaderField(HTTPNames::Suborigin); | |
| 558 if (!suboriginHeader.isNull()) { | |
| 559 Vector<String> messages; | |
| 560 Suborigin suborigin; | |
| 561 if (parseSuboriginHeader(suboriginHeader, &suborigin, messages)) | |
| 562 m_frame->document()->enforceSuborigin(suborigin); | |
| 563 | |
| 564 for (auto& message : messages) { | |
| 565 m_frame->document()->addConsoleMessage( | |
| 566 ConsoleMessage::create(SecurityMessageSource, ErrorMessageLevel, | |
| 567 "Error with Suborigin header: " + message)); | |
| 568 } | |
| 569 } | |
| 570 m_frame->document()->clientHintsPreferences().updateFrom( | |
| 571 m_documentLoader->clientHintsPreferences()); | |
| 572 } | |
| 573 | |
| 574 Settings* settings = m_frame->document()->settings(); | |
| 575 if (settings) { | |
| 576 m_frame->document()->fetcher()->setImagesEnabled( | |
| 577 settings->getImagesEnabled()); | |
| 578 m_frame->document()->fetcher()->setAutoLoadImages( | |
| 579 settings->getLoadsImagesAutomatically()); | |
| 580 } | |
| 581 | |
| 582 if (m_documentLoader) { | |
| 583 const AtomicString& dnsPrefetchControl = | |
| 584 m_documentLoader->response().httpHeaderField( | |
| 585 HTTPNames::X_DNS_Prefetch_Control); | |
| 586 if (!dnsPrefetchControl.isEmpty()) | |
| 587 m_frame->document()->parseDNSPrefetchControlHeader(dnsPrefetchControl); | |
| 588 | |
| 589 String headerContentLanguage = m_documentLoader->response().httpHeaderField( | |
| 590 HTTPNames::Content_Language); | |
| 591 if (!headerContentLanguage.isEmpty()) { | |
| 592 size_t commaIndex = headerContentLanguage.find(','); | |
| 593 headerContentLanguage.truncate( | |
| 594 commaIndex); // kNotFound == -1 == don't truncate | |
| 595 headerContentLanguage = | |
| 596 headerContentLanguage.stripWhiteSpace(isHTMLSpace<UChar>); | |
| 597 if (!headerContentLanguage.isEmpty()) { | |
| 598 m_frame->document()->setContentLanguage( | |
| 599 AtomicString(headerContentLanguage)); | |
| 600 } | |
| 601 } | |
| 602 | |
| 603 OriginTrialContext::addTokensFromHeader( | |
| 604 m_frame->document(), | |
| 605 m_documentLoader->response().httpHeaderField(HTTPNames::Origin_Trial)); | |
| 606 if (RuntimeEnabledFeatures::featurePolicyEnabled()) { | |
| 607 WebFeaturePolicy* parentFeaturePolicy = | |
| 608 (isLoadingMainFrame() ? nullptr | |
| 609 : m_frame->client() | |
| 610 ->parent() | |
| 611 ->securityContext() | |
| 612 ->getFeaturePolicy()); | |
| 613 const String& featurePolicyHeader = | |
| 614 m_documentLoader->response().httpHeaderField( | |
| 615 HTTPNames::Feature_Policy); | |
| 616 Vector<String> messages; | |
| 617 const WebParsedFeaturePolicy& parsedHeader = parseFeaturePolicy( | |
| 618 featurePolicyHeader, m_frame->securityContext()->getSecurityOrigin(), | |
| 619 &messages); | |
| 620 WebParsedFeaturePolicy containerPolicy; | |
| 621 if (m_frame->owner()) { | |
| 622 containerPolicy = getContainerPolicyFromAllowedFeatures( | |
| 623 m_frame->owner()->allowedFeatures(), | |
| 624 m_frame->securityContext()->getSecurityOrigin()); | |
| 625 } | |
| 626 m_frame->securityContext()->initializeFeaturePolicy( | |
| 627 parsedHeader, containerPolicy, parentFeaturePolicy); | |
| 628 for (auto& message : messages) { | |
| 629 m_frame->document()->addConsoleMessage(ConsoleMessage::create( | |
| 630 OtherMessageSource, ErrorMessageLevel, | |
| 631 "Error with Feature-Policy header: " + message)); | |
| 632 } | |
| 633 if (!parsedHeader.isEmpty()) | |
| 634 client()->didSetFeaturePolicyHeader(parsedHeader); | |
| 635 } | |
| 636 } | |
| 637 | |
| 638 if (m_documentLoader) { | |
| 639 String referrerPolicyHeader = m_documentLoader->response().httpHeaderField( | |
| 640 HTTPNames::Referrer_Policy); | |
| 641 if (!referrerPolicyHeader.isNull()) { | |
| 642 UseCounter::count(*m_frame->document(), UseCounter::ReferrerPolicyHeader); | |
| 643 m_frame->document()->parseAndSetReferrerPolicy(referrerPolicyHeader); | |
| 644 } | |
| 645 } | |
| 646 | |
| 647 client()->didCreateNewDocument(); | |
| 648 } | |
| 649 | |
| 650 void FrameLoader::finishedParsing() { | 507 void FrameLoader::finishedParsing() { |
| 651 if (m_stateMachine.creatingInitialEmptyDocument()) | 508 if (m_stateMachine.creatingInitialEmptyDocument()) |
| 652 return; | 509 return; |
| 653 | 510 |
| 654 m_progressTracker->finishedParsing(); | 511 m_progressTracker->finishedParsing(); |
| 655 | 512 |
| 656 if (client()) { | 513 if (client()) { |
| 657 ScriptForbiddenScope forbidScripts; | 514 ScriptForbiddenScope forbidScripts; |
| 658 client()->dispatchDidFinishDocumentLoad(); | 515 client()->dispatchDidFinishDocumentLoad(); |
| 659 } | 516 } |
| (...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1871 client()->documentElementAvailable(); | 1728 client()->documentElementAvailable(); |
| 1872 } | 1729 } |
| 1873 | 1730 |
| 1874 void FrameLoader::runScriptsAtDocumentElementAvailable() { | 1731 void FrameLoader::runScriptsAtDocumentElementAvailable() { |
| 1875 client()->runScriptsAtDocumentElementAvailable(); | 1732 client()->runScriptsAtDocumentElementAvailable(); |
| 1876 // The frame might be detached at this point. | 1733 // The frame might be detached at this point. |
| 1877 } | 1734 } |
| 1878 | 1735 |
| 1879 void FrameLoader::dispatchDidClearDocumentOfWindowObject() { | 1736 void FrameLoader::dispatchDidClearDocumentOfWindowObject() { |
| 1880 DCHECK(m_frame->document()); | 1737 DCHECK(m_frame->document()); |
| 1738 if (m_stateMachine.creatingInitialEmptyDocument()) |
| 1739 return; |
| 1881 if (!m_frame->document()->canExecuteScripts(NotAboutToExecuteScript)) | 1740 if (!m_frame->document()->canExecuteScripts(NotAboutToExecuteScript)) |
| 1882 return; | 1741 return; |
| 1883 | 1742 |
| 1884 Settings* settings = m_frame->settings(); | 1743 Settings* settings = m_frame->settings(); |
| 1885 if (settings && settings->getForceMainWorldInitialization()) { | 1744 if (settings && settings->getForceMainWorldInitialization()) { |
| 1886 // Forcibly instantiate WindowProxy. | 1745 // Forcibly instantiate WindowProxy. |
| 1887 m_frame->script().windowProxy(DOMWrapperWorld::mainWorld()); | 1746 m_frame->script().windowProxy(DOMWrapperWorld::mainWorld()); |
| 1888 } | 1747 } |
| 1889 probe::didClearDocumentOfWindowObject(m_frame); | 1748 probe::didClearDocumentOfWindowObject(m_frame); |
| 1890 | 1749 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2044 frameLoadRequest.clientRedirect()); | 1903 frameLoadRequest.clientRedirect()); |
| 2045 | 1904 |
| 2046 loader->setLoadType(loadType); | 1905 loader->setLoadType(loadType); |
| 2047 loader->setNavigationType(navigationType); | 1906 loader->setNavigationType(navigationType); |
| 2048 loader->setReplacesCurrentHistoryItem(loadType == | 1907 loader->setReplacesCurrentHistoryItem(loadType == |
| 2049 FrameLoadTypeReplaceCurrentItem); | 1908 FrameLoadTypeReplaceCurrentItem); |
| 2050 return loader; | 1909 return loader; |
| 2051 } | 1910 } |
| 2052 | 1911 |
| 2053 } // namespace blink | 1912 } // namespace blink |
| OLD | NEW |