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()) | |
Nate Chapin
2017/03/17 23:33:18
This early-exit, and the second half of the functi
| |
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(); | |
Nate Chapin
2017/03/17 23:33:18
Removed. I don't think this snapshot is adding a l
| |
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); | |
Nate Chapin
2017/03/17 23:33:18
All this stuff moved to DocumentLoader::didInstall
| |
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 && |
Nate Chapin
2017/03/17 23:33:18
Like the remainder of receivedFirstData(), I want
| |
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() { | |
Nate Chapin
2017/03/17 23:33:18
Most of this moved to DocumentLoader::didInstallNe
| |
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 m_frame->securityContext()->initializeFeaturePolicy(parsedHeader, | |
621 parentFeaturePolicy); | |
622 for (auto& message : messages) { | |
623 m_frame->document()->addConsoleMessage(ConsoleMessage::create( | |
624 OtherMessageSource, ErrorMessageLevel, | |
625 "Error with Feature-Policy header: " + message)); | |
626 } | |
627 if (!parsedHeader.isEmpty()) | |
628 client()->didSetFeaturePolicyHeader(parsedHeader); | |
629 } | |
630 } | |
631 | |
632 if (m_documentLoader) { | |
633 String referrerPolicyHeader = m_documentLoader->response().httpHeaderField( | |
634 HTTPNames::Referrer_Policy); | |
635 if (!referrerPolicyHeader.isNull()) { | |
636 UseCounter::count(*m_frame->document(), UseCounter::ReferrerPolicyHeader); | |
637 m_frame->document()->parseAndSetReferrerPolicy(referrerPolicyHeader); | |
638 } | |
639 } | |
640 | |
641 client()->didCreateNewDocument(); | |
642 } | |
643 | |
644 void FrameLoader::finishedParsing() { | 507 void FrameLoader::finishedParsing() { |
645 if (m_stateMachine.creatingInitialEmptyDocument()) | 508 if (m_stateMachine.creatingInitialEmptyDocument()) |
646 return; | 509 return; |
647 | 510 |
648 m_progressTracker->finishedParsing(); | 511 m_progressTracker->finishedParsing(); |
649 | 512 |
650 if (client()) { | 513 if (client()) { |
651 ScriptForbiddenScope forbidScripts; | 514 ScriptForbiddenScope forbidScripts; |
652 client()->dispatchDidFinishDocumentLoad(); | 515 client()->dispatchDidFinishDocumentLoad(); |
653 } | 516 } |
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1833 client()->documentElementAvailable(); | 1696 client()->documentElementAvailable(); |
1834 } | 1697 } |
1835 | 1698 |
1836 void FrameLoader::runScriptsAtDocumentElementAvailable() { | 1699 void FrameLoader::runScriptsAtDocumentElementAvailable() { |
1837 client()->runScriptsAtDocumentElementAvailable(); | 1700 client()->runScriptsAtDocumentElementAvailable(); |
1838 // The frame might be detached at this point. | 1701 // The frame might be detached at this point. |
1839 } | 1702 } |
1840 | 1703 |
1841 void FrameLoader::dispatchDidClearDocumentOfWindowObject() { | 1704 void FrameLoader::dispatchDidClearDocumentOfWindowObject() { |
1842 DCHECK(m_frame->document()); | 1705 DCHECK(m_frame->document()); |
1706 if (m_stateMachine.creatingInitialEmptyDocument()) | |
1707 return; | |
1843 if (!m_frame->document()->canExecuteScripts(NotAboutToExecuteScript)) | 1708 if (!m_frame->document()->canExecuteScripts(NotAboutToExecuteScript)) |
1844 return; | 1709 return; |
1845 | 1710 |
1846 Settings* settings = m_frame->settings(); | 1711 Settings* settings = m_frame->settings(); |
1847 if (settings && settings->getForceMainWorldInitialization()) { | 1712 if (settings && settings->getForceMainWorldInitialization()) { |
1848 // Forcibly instantiate WindowProxy. | 1713 // Forcibly instantiate WindowProxy. |
1849 m_frame->script().windowProxy(DOMWrapperWorld::mainWorld()); | 1714 m_frame->script().windowProxy(DOMWrapperWorld::mainWorld()); |
1850 } | 1715 } |
1851 probe::didClearDocumentOfWindowObject(m_frame); | 1716 probe::didClearDocumentOfWindowObject(m_frame); |
1852 | 1717 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2006 frameLoadRequest.clientRedirect()); | 1871 frameLoadRequest.clientRedirect()); |
2007 | 1872 |
2008 loader->setLoadType(loadType); | 1873 loader->setLoadType(loadType); |
2009 loader->setNavigationType(navigationType); | 1874 loader->setNavigationType(navigationType); |
2010 loader->setReplacesCurrentHistoryItem(loadType == | 1875 loader->setReplacesCurrentHistoryItem(loadType == |
2011 FrameLoadTypeReplaceCurrentItem); | 1876 FrameLoadTypeReplaceCurrentItem); |
2012 return loader; | 1877 return loader; |
2013 } | 1878 } |
2014 | 1879 |
2015 } // namespace blink | 1880 } // namespace blink |
OLD | NEW |