12021-09-27 Chris Dumez <cdumez@apple.com>
2
3 Move Cross-Origin-Opener-Policy handling to the NetworkProcess
4 https://bugs.webkit.org/show_bug.cgi?id=230812
5 <rdar://83504842>
6
7 Reviewed by NOBODY (OOPS!).
8
9 Previous, COOP handling was fully implemented in the WebContent process. This meant that a
10 WebProcess for origin A could get a network response with COOP header from origin B, decide
11 that cross-origin isolation is needed and ask the UIProcess to process-swap. This was not a
12 good design given that the WebContent process is not a trusted process. We should not trust
13 the WebProcess for origin A to make the swap on behavior of origin B. Also, the network
14 response from origin B may contain sensitive headers that we don't want origin A's WebProcess
15 to see.
16
17 To address these issues, I have moved COOP handling from the WebContent process to the
18 NetworkProcess. As soon as the NetworkProcess gets the network response, it makes the decision
19 whether or not cross-origin isolation is needed. If isolation is needed, the network process
20 asks the UIProcess directly to continue the load in a new WebProcess instead of sending the
21 network response to the currently associated WebProcess. When the new WebProcess resumes the
22 load, the network process sends it the network response it already has.
23
24 I moved most of the COOP specification implementation from DocumentLoader.cpp/h to
25 CrossOriginOpenerPolicy.cpp/h so that we can leverage it from the NetworkResourceLoader in
26 the network process. We still have to do *some* COOP handling at DocumentLoader level
27 currently for non-initial navigations to about:blank given that those can trigger a browsing
28 context group switch but currently do not involved the network process. I also had to add
29 more information to NetworkResourceLoadParameters so that we are able to make appropriate
30 COOP decisions in the NetworkProcess.
31
32 No new tests, covered by existing COOP tests that are still passing.
33
34 * Headers.cmake:
35 * Sources.txt:
36 * WebCore.xcodeproj/project.pbxproj:
37 * dom/Document.h:
38
39 * loader/CrossOriginOpenerPolicy.cpp:
40 (WebCore::checkIfCOOPValuesRequireBrowsingContextGroupSwitch):
41 (WebCore::checkIfEnforcingReportOnlyCOOPWouldRequireBrowsingContextGroupSwitch):
42 (WebCore::computeResponseOriginAndCOOP):
43 (WebCore::enforceResponseCrossOriginOpenerPolicy):
44 (WebCore::obtainCrossOriginOpenerPolicy):
45 (WebCore::sendViolationReportWhenNavigatingToCOOPResponse):
46 (WebCore::sendViolationReportWhenNavigatingAwayFromCOOPResponse):
47 (WebCore::doCrossOriginOpenerHandlingOfResponse):
48 (WebCore::CrossOriginOpenerPolicyEnforcementResult::from):
49 * loader/CrossOriginOpenerPolicy.h:
50 (WebCore::CrossOriginOpenerPolicy::reportingEndpointForDisposition const):
51 (WebCore::CrossOriginOpenerPolicy::hasReportingEndpoint const):
52 * loader/DocumentLoader.cpp:
53 (WebCore::DocumentLoader::willSendRequest):
54 (WebCore::DocumentLoader::doCrossOriginOpenerHandlingOfResponse):
55 (WebCore::DocumentLoader::responseReceived):
56 (WebCore::DocumentLoader::maybeLoadEmpty):
57 (WebCore::DocumentLoader::clearMainResource):
58 * loader/DocumentLoader.h:
59 (WebCore::DocumentLoader::crossOriginOpenerPolicy const):
60 (WebCore::DocumentLoader::isContinuingLoadAfterProvisionalLoadStarted const):
61 (WebCore::DocumentLoader::setIsContinuingLoadAfterProvisionalLoadStarted):
62 Move most of the COOP logic from DocumentLoader.cpp to CrossOriginOpenerPolicy.cpp, so that
63 it can be reused by NetworkResourceLoader in the network process.
64
65 * loader/EmptyClients.cpp:
66 (WebCore::EmptyFrameLoaderClient::dispatchDecidePolicyForResponse):
67 * loader/EmptyFrameLoaderClient.h:
68 * loader/FrameLoader.cpp:
69 (WebCore::FrameLoader::checkContentPolicy):
70 (WebCore::FrameLoader::load):
71 * loader/FrameLoader.h:
72 * loader/FrameLoaderClient.h:
73
74 * loader/NavigationAction.cpp:
75 (WebCore::NavigationAction::NavigationAction):
76 * loader/NavigationAction.h:
77 (WebCore::NavigationAction::requester const):
78 (WebCore::NavigationAction::isEmpty const):
79 * loader/NavigationRequester.cpp: Added.
80 * loader/NavigationRequester.h: Added.
81 Extracted NavigationAction::Requester to its own header and rename it to NavigationRequester,
82 so that its implementation can be shared between NavigationAction, NetworkResourceLoadParameters
83 and COOP.
84
85 * loader/ReportingEndpointsCache.cpp:
86 (WebCore::ReportingEndpointsCache::addEndPointsFromResponse):
87 (WebCore::ReportingEndpointsCache::addEndPointsFromReportToHeader):
88 * loader/ReportingEndpointsCache.h:
89 * loader/ShouldTreatAsContinuingLoad.h:
90 * page/Page.h:
91