| File: | Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp |
| Warning: | line 297, column 224 Captured raw-pointer 'resource' to uncounted type is unsafe |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* |
| 2 | * Copyright (C) 2012-2025 Apple Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
| 14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
| 17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 | * THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
| 26 | #include "config.h" |
| 27 | #include "WebLoaderStrategy.h" |
| 28 | |
| 29 | #include "HangDetectionDisabler.h" |
| 30 | #include "Logging.h" |
| 31 | #include "NetworkConnectionToWebProcessMessages.h" |
| 32 | #include "NetworkProcessConnection.h" |
| 33 | #include "NetworkResourceLoadParameters.h" |
| 34 | #include "RemoteWorkerFrameLoaderClient.h" |
| 35 | #include "WebCompiledContentRuleList.h" |
| 36 | #include "WebErrors.h" |
| 37 | #include "WebFrame.h" |
| 38 | #include "WebLocalFrameLoaderClient.h" |
| 39 | #include "WebPage.h" |
| 40 | #include "WebPageInlines.h" |
| 41 | #include "WebPageProxyMessages.h" |
| 42 | #include "WebProcess.h" |
| 43 | #include "WebProcessPoolMessages.h" |
| 44 | #include "WebResourceLoader.h" |
| 45 | #include "WebSWContextManagerConnection.h" |
| 46 | #include "WebServiceWorkerProvider.h" |
| 47 | #include "WebURLSchemeHandlerProxy.h" |
| 48 | #include "WebURLSchemeTaskProxy.h" |
| 49 | #include <WebCore/CachedResource.h> |
| 50 | #include <WebCore/ContentSecurityPolicy.h> |
| 51 | #include <WebCore/DataURLDecoder.h> |
| 52 | #include <WebCore/DiagnosticLoggingClient.h> |
| 53 | #include <WebCore/DiagnosticLoggingKeys.h> |
| 54 | #include <WebCore/DocumentLoader.h> |
| 55 | #include <WebCore/DocumentPage.h> |
| 56 | #include <WebCore/FetchOptions.h> |
| 57 | #include <WebCore/FrameDestructionObserverInlines.h> |
| 58 | #include <WebCore/FrameInlines.h> |
| 59 | #include <WebCore/FrameLoader.h> |
| 60 | #include <WebCore/HTMLFrameOwnerElement.h> |
| 61 | #include <WebCore/HitTestResult.h> |
| 62 | #include <WebCore/InspectorInstrumentationWebKit.h> |
| 63 | #include <WebCore/LocalFrame.h> |
| 64 | #include <WebCore/LocalFrameInlines.h> |
| 65 | #include <WebCore/NetscapePlugInStreamLoader.h> |
| 66 | #include <WebCore/NetworkLoadInformation.h> |
| 67 | #include <WebCore/NodeDocument.h> |
| 68 | #include <WebCore/PlatformStrategies.h> |
| 69 | #include <WebCore/ReferrerPolicy.h> |
| 70 | #include <WebCore/ResourceLoader.h> |
| 71 | #include <WebCore/SecurityOrigin.h> |
| 72 | #include <WebCore/Settings.h> |
| 73 | #include <WebCore/SubresourceLoader.h> |
| 74 | #include <WebCore/UserContentProvider.h> |
| 75 | #include <pal/SessionID.h> |
| 76 | #include <wtf/CompletionHandler.h> |
| 77 | #include <wtf/RuntimeApplicationChecks.h> |
| 78 | #include <wtf/TZoneMallocInlines.h> |
| 79 | #include <wtf/text/CString.h> |
| 80 | |
| 81 | #if USE(QUICK_LOOK)(defined USE_QUICK_LOOK && USE_QUICK_LOOK) |
| 82 | #include <WebCore/QuickLook.h> |
| 83 | #endif |
| 84 | |
| 85 | #if ENABLE(WK_WEB_EXTENSIONS)(defined 1 && 1) && PLATFORM(COCOA)(defined 1 && 1) |
| 86 | #include "WebExtensionControllerProxy.h" |
| 87 | #endif |
| 88 | |
| 89 | #define WEBLOADERSTRATEGY_RELEASE_LOG_BASIC(fmt, ...) RELEASE_LOG(Network, "%p - WebLoaderStrategy::" fmt, this, ##__VA_ARGS__)clang diagnostic push
clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = (OS_LOG_TYPE_DEFAULT ); if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__ ({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("%p - WebLoaderStrategy::" fmt), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG43" ) = "%p - WebLoaderStrategy::" fmt; uint8_t _Alignas(16) __attribute__ ((uninitialized)) _os_fmt_buf[__builtin_os_log_format_buffer_size ("%p - WebLoaderStrategy::" fmt, this, ##__VA_ARGS__)]; _os_log_impl (&__dso_handle, _log_tmp, _type_tmp, _os_fmt_str, (uint8_t *)__builtin_os_log_format(_os_fmt_buf, "%p - WebLoaderStrategy::" fmt, this, ##__VA_ARGS__), (uint32_t)sizeof(_os_fmt_buf)) clang diagnostic pop ; }); } }) clang diagnostic pop |
| 90 | #define WEBLOADERSTRATEGY_RELEASE_LOG_ERROR_BASIC(fmt, ...) RELEASE_LOG_ERROR(Network, "%p - WebLoaderStrategy::" fmt, this, ##__VA_ARGS__)clang diagnostic push
clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = OS_LOG_TYPE_ERROR; if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("%p - WebLoaderStrategy::" fmt), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG44" ) = "%p - WebLoaderStrategy::" fmt; uint8_t _Alignas(16) __attribute__ ((uninitialized)) _os_fmt_buf[__builtin_os_log_format_buffer_size ("%p - WebLoaderStrategy::" fmt, this, ##__VA_ARGS__)]; _os_log_error_impl (&__dso_handle, _log_tmp, _type_tmp, _os_fmt_str, (uint8_t *)__builtin_os_log_format(_os_fmt_buf, "%p - WebLoaderStrategy::" fmt, this, ##__VA_ARGS__), (uint32_t)sizeof(_os_fmt_buf)) clang diagnostic pop ; }); } }) clang diagnostic pop |
| 91 | |
| 92 | #define WEBLOADERSTRATEGY_RELEASE_LOG_STANDARD_TEMPLATE"%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" PRIu64"ll" "u" ", frameID=%" PRIu64"ll" "u" ", resourceID=%" PRIu64"ll" "u" "] WebLoaderStrategy::" |
| 93 | #define WEBLOADERSTRATEGY_RELEASE_LOG_STANDARD_PARAMETERSthis, &resourceLoader, resourceLoader.frameLoader(), resourceLoader .frame(), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters) this, &resourceLoader, resourceLoader.frameLoader(), resourceLoader.frame(), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters), resourceIDForLog(trackingParameters) |
| 94 | #define WEBLOADERSTRATEGY_WITH_FRAMELOADER_RELEASE_LOG_STANDARD_PARAMETERSthis, nullptr, &frameLoader, &frameLoader.frame(), pageIDForLog (trackingParameters), frameIDForLog(trackingParameters), resourceIDForLog (trackingParameters) this, nullptr, &frameLoader, &frameLoader.frame(), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters), resourceIDForLog(trackingParameters) |
| 95 | |
| 96 | #define WEBLOADERSTRATEGY_RELEASE_LOG(fmt, ...)clang diagnostic push
clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = (OS_LOG_TYPE_DEFAULT ); if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__ ({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG45" ) = "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt; uint8_t _Alignas(16) __attribute__((uninitialized)) _os_fmt_buf [__builtin_os_log_format_buffer_size("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt, this, &resourceLoader, resourceLoader.frameLoader() , resourceLoader.frame(), pageIDForLog(trackingParameters), frameIDForLog (trackingParameters), resourceIDForLog(trackingParameters), ... )]; _os_log_impl(&__dso_handle, _log_tmp, _type_tmp, _os_fmt_str , (uint8_t *)__builtin_os_log_format(_os_fmt_buf, "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt, this, &resourceLoader, resourceLoader.frameLoader() , resourceLoader.frame(), pageIDForLog(trackingParameters), frameIDForLog (trackingParameters), resourceIDForLog(trackingParameters), ... ), (uint32_t)sizeof(_os_fmt_buf)) clang diagnostic pop ; }); } }) clang diagnostic pop RELEASE_LOG(Network, WEBLOADERSTRATEGY_RELEASE_LOG_STANDARD_TEMPLATE fmt, WEBLOADERSTRATEGY_RELEASE_LOG_STANDARD_PARAMETERS, ##__VA_ARGS__)clang diagnostic push clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = (OS_LOG_TYPE_DEFAULT ); if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__ ({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG46" ) = "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt; uint8_t _Alignas(16) __attribute__((uninitialized)) _os_fmt_buf [__builtin_os_log_format_buffer_size("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt, this, &resourceLoader, resourceLoader.frameLoader() , resourceLoader.frame(), pageIDForLog(trackingParameters), frameIDForLog (trackingParameters), resourceIDForLog(trackingParameters), ## __VA_ARGS__)]; _os_log_impl(&__dso_handle, _log_tmp, _type_tmp , _os_fmt_str, (uint8_t *)__builtin_os_log_format(_os_fmt_buf , "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt, this, &resourceLoader, resourceLoader.frameLoader() , resourceLoader.frame(), pageIDForLog(trackingParameters), frameIDForLog (trackingParameters), resourceIDForLog(trackingParameters), ## __VA_ARGS__), (uint32_t)sizeof(_os_fmt_buf)) clang diagnostic pop ; }); } }) clang diagnostic pop |
| 97 | #define WEBLOADERSTRATEGY_RELEASE_LOG_FORWARDABLE(fmt, ...)clang diagnostic push
clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = (OS_LOG_TYPE_DEFAULT ); if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__ ({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p (MESSAGE_fmt), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG47" ) = MESSAGE_fmt; uint8_t _Alignas(16) __attribute__((uninitialized )) _os_fmt_buf[__builtin_os_log_format_buffer_size(MESSAGE_fmt , pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters), ...)]; _os_log_impl( &__dso_handle, _log_tmp, _type_tmp, _os_fmt_str, (uint8_t *)__builtin_os_log_format(_os_fmt_buf, MESSAGE_fmt, pageIDForLog (trackingParameters), frameIDForLog(trackingParameters), resourceIDForLog (trackingParameters), ...), (uint32_t)sizeof(_os_fmt_buf)) clang diagnostic pop ; }); } }) clang diagnostic pop RELEASE_LOG_FORWARDABLE(Network, fmt, pageIDForLog(trackingParameters), frameIDForLog(trackingParameters), resourceIDForLog(trackingParameters), ##__VA_ARGS__)clang diagnostic push clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = (OS_LOG_TYPE_DEFAULT ); if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__ ({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p (MESSAGE_fmt), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG48" ) = MESSAGE_fmt; uint8_t _Alignas(16) __attribute__((uninitialized )) _os_fmt_buf[__builtin_os_log_format_buffer_size(MESSAGE_fmt , pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters), ##__VA_ARGS__)]; _os_log_impl (&__dso_handle, _log_tmp, _type_tmp, _os_fmt_str, (uint8_t *)__builtin_os_log_format(_os_fmt_buf, MESSAGE_fmt, pageIDForLog (trackingParameters), frameIDForLog(trackingParameters), resourceIDForLog (trackingParameters), ##__VA_ARGS__), (uint32_t)sizeof(_os_fmt_buf )) clang diagnostic pop ; }); } }) clang diagnostic pop |
| 98 | #define WEBLOADERSTRATEGY_RELEASE_LOG_ERROR(fmt, ...)clang diagnostic push
clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = OS_LOG_TYPE_ERROR; if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG49" ) = "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt; uint8_t _Alignas(16) __attribute__((uninitialized)) _os_fmt_buf [__builtin_os_log_format_buffer_size("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt, this, &resourceLoader, resourceLoader.frameLoader() , resourceLoader.frame(), pageIDForLog(trackingParameters), frameIDForLog (trackingParameters), resourceIDForLog(trackingParameters), ... )]; _os_log_error_impl(&__dso_handle, _log_tmp, _type_tmp , _os_fmt_str, (uint8_t *)__builtin_os_log_format(_os_fmt_buf , "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt, this, &resourceLoader, resourceLoader.frameLoader() , resourceLoader.frame(), pageIDForLog(trackingParameters), frameIDForLog (trackingParameters), resourceIDForLog(trackingParameters), ... ), (uint32_t)sizeof(_os_fmt_buf)) clang diagnostic pop ; }); } }) clang diagnostic pop RELEASE_LOG_ERROR(Network, WEBLOADERSTRATEGY_RELEASE_LOG_STANDARD_TEMPLATE fmt, WEBLOADERSTRATEGY_RELEASE_LOG_STANDARD_PARAMETERS, ##__VA_ARGS__)clang diagnostic push clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = OS_LOG_TYPE_ERROR; if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG50" ) = "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt; uint8_t _Alignas(16) __attribute__((uninitialized)) _os_fmt_buf [__builtin_os_log_format_buffer_size("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt, this, &resourceLoader, resourceLoader.frameLoader() , resourceLoader.frame(), pageIDForLog(trackingParameters), frameIDForLog (trackingParameters), resourceIDForLog(trackingParameters), ## __VA_ARGS__)]; _os_log_error_impl(&__dso_handle, _log_tmp , _type_tmp, _os_fmt_str, (uint8_t *)__builtin_os_log_format( _os_fmt_buf, "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt, this, &resourceLoader, resourceLoader.frameLoader() , resourceLoader.frame(), pageIDForLog(trackingParameters), frameIDForLog (trackingParameters), resourceIDForLog(trackingParameters), ## __VA_ARGS__), (uint32_t)sizeof(_os_fmt_buf)) clang diagnostic pop ; }); } }) clang diagnostic pop |
| 99 | |
| 100 | #define WEBLOADERSTRATEGY_WITH_FRAMELOADER_RELEASE_LOG(fmt, ...)clang diagnostic push
clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = (OS_LOG_TYPE_DEFAULT ); if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__ ({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG51" ) = "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt; uint8_t _Alignas(16) __attribute__((uninitialized)) _os_fmt_buf [__builtin_os_log_format_buffer_size("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt, this, nullptr, &frameLoader, &frameLoader.frame (), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters), ...)]; _os_log_impl( &__dso_handle, _log_tmp, _type_tmp, _os_fmt_str, (uint8_t *)__builtin_os_log_format(_os_fmt_buf, "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt, this, nullptr, &frameLoader, &frameLoader.frame (), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters), ...), (uint32_t)sizeof (_os_fmt_buf)) clang diagnostic pop ; }); } }) clang diagnostic pop RELEASE_LOG(Network, WEBLOADERSTRATEGY_RELEASE_LOG_STANDARD_TEMPLATE fmt, WEBLOADERSTRATEGY_WITH_FRAMELOADER_RELEASE_LOG_STANDARD_PARAMETERS, ##__VA_ARGS__)clang diagnostic push clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = (OS_LOG_TYPE_DEFAULT ); if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__ ({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG52" ) = "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt; uint8_t _Alignas(16) __attribute__((uninitialized)) _os_fmt_buf [__builtin_os_log_format_buffer_size("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt, this, nullptr, &frameLoader, &frameLoader.frame (), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters), ##__VA_ARGS__)]; _os_log_impl (&__dso_handle, _log_tmp, _type_tmp, _os_fmt_str, (uint8_t *)__builtin_os_log_format(_os_fmt_buf, "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt, this, nullptr, &frameLoader, &frameLoader.frame (), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters), ##__VA_ARGS__), (uint32_t )sizeof(_os_fmt_buf)) clang diagnostic pop ; }); } }) clang diagnostic pop |
| 101 | #define WEBLOADERSTRATEGY_WITH_FRAMELOADER_RELEASE_LOG_ERROR(fmt, ...)clang diagnostic push
clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = OS_LOG_TYPE_ERROR; if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG53" ) = "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt; uint8_t _Alignas(16) __attribute__((uninitialized)) _os_fmt_buf [__builtin_os_log_format_buffer_size("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt, this, nullptr, &frameLoader, &frameLoader.frame (), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters), ...)]; _os_log_error_impl (&__dso_handle, _log_tmp, _type_tmp, _os_fmt_str, (uint8_t *)__builtin_os_log_format(_os_fmt_buf, "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt, this, nullptr, &frameLoader, &frameLoader.frame (), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters), ...), (uint32_t)sizeof (_os_fmt_buf)) clang diagnostic pop ; }); } }) clang diagnostic pop RELEASE_LOG_ERROR(Network, WEBLOADERSTRATEGY_RELEASE_LOG_STANDARD_TEMPLATE fmt, WEBLOADERSTRATEGY_WITH_FRAMELOADER_RELEASE_LOG_STANDARD_PARAMETERS, ##__VA_ARGS__)clang diagnostic push clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = OS_LOG_TYPE_ERROR; if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG54" ) = "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt; uint8_t _Alignas(16) __attribute__((uninitialized)) _os_fmt_buf [__builtin_os_log_format_buffer_size("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt, this, nullptr, &frameLoader, &frameLoader.frame (), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters), ##__VA_ARGS__)]; _os_log_error_impl (&__dso_handle, _log_tmp, _type_tmp, _os_fmt_str, (uint8_t *)__builtin_os_log_format(_os_fmt_buf, "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" fmt, this, nullptr, &frameLoader, &frameLoader.frame (), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters), ##__VA_ARGS__), (uint32_t )sizeof(_os_fmt_buf)) clang diagnostic pop ; }); } }) clang diagnostic pop |
| 102 | |
| 103 | namespace WebKit { |
| 104 | using namespace WebCore; |
| 105 | |
| 106 | WTF_MAKE_TZONE_ALLOCATED_IMPL(WebLoaderStrategy)::bmalloc::api::HeapRef WebLoaderStrategy::s_heapRef; const TZoneSpecification WebLoaderStrategy::s_heapSpec = { &WebLoaderStrategy::s_heapRef , TZoneSpecification::encodeSize<WebLoaderStrategy>(), TZoneSpecification ::encodeAlignment<WebLoaderStrategy>(), TZoneSpecification ::encodeCategory<WebLoaderStrategy>(), ::bmalloc::api:: compactAllocationMode<WebLoaderStrategy>(), TZoneSpecification ::encodeDescriptor<WebLoaderStrategy>(), }; void* WebLoaderStrategy ::operatorNewSlow(size_t size) { if constexpr (::bmalloc::api ::compactAllocationMode<WebLoaderStrategy>() == CompactAllocationMode ::Compact) return ::bmalloc::api::tzoneAllocateCompactSlow(size , s_heapSpec); return ::bmalloc::api::tzoneAllocateNonCompactSlow (size, s_heapSpec); } using __makeBtzoneMallocedInlineMacroSemicolonifier __attribute__((unused)) = int; |
| 107 | |
| 108 | [[maybe_unused]] static uint64_t NODELETE[[clang::annotate_type("webkit.nodelete")]] pageIDForLog(const std::optional<WebResourceLoader::TrackingParameters>& parameters) |
| 109 | { |
| 110 | return parameters ? parameters->pageID.toUInt64() : 0; |
| 111 | } |
| 112 | |
| 113 | [[maybe_unused]] static uint64_t NODELETE[[clang::annotate_type("webkit.nodelete")]] frameIDForLog(const std::optional<WebResourceLoader::TrackingParameters>& parameters) |
| 114 | { |
| 115 | return parameters ? parameters->frameID.toUInt64() : 0; |
| 116 | } |
| 117 | |
| 118 | [[maybe_unused]] static uint64_t NODELETE[[clang::annotate_type("webkit.nodelete")]] resourceIDForLog(const std::optional<WebResourceLoader::TrackingParameters>& parameters) |
| 119 | { |
| 120 | return parameters ? parameters->resourceID.toUInt64() : 0; |
| 121 | } |
| 122 | |
| 123 | WebLoaderStrategy::WebLoaderStrategy(WebProcess& webProcess) |
| 124 | : m_webProcess(webProcess) |
| 125 | , m_internallyFailedLoadTimer(RunLoop::mainSingleton(), "WebLoaderStrategy::InternallyFailedLoadTimer"_s, this, &WebLoaderStrategy::internallyFailedLoadTimerFired) |
| 126 | { |
| 127 | } |
| 128 | |
| 129 | WebLoaderStrategy::~WebLoaderStrategy() = default; |
| 130 | |
| 131 | void WebLoaderStrategy::ref() const |
| 132 | { |
| 133 | m_webProcess->ref(); |
| 134 | } |
| 135 | |
| 136 | void WebLoaderStrategy::deref() const |
| 137 | { |
| 138 | m_webProcess->deref(); |
| 139 | } |
| 140 | |
| 141 | void WebLoaderStrategy::loadResource(LocalFrame& frame, CachedResource& resource, ResourceRequest&& request, const ResourceLoaderOptions& options, CompletionHandler<void(RefPtr<SubresourceLoader>&&)>&& completionHandler) |
| 142 | { |
| 143 | if (resource.type() != CachedResource::Type::MainResource || !frame.isMainFrame()) { |
| 144 | if (RefPtr localMainFrame = frame.localMainFrame()) { |
| 145 | if (RefPtr document = localMainFrame->document()) { |
| 146 | if (document && document->loader()) |
| 147 | request.setIsAppInitiated(document->loader()->lastNavigationWasAppInitiated()); |
| 148 | } |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | SubresourceLoader::create(frame, resource, WTF::move(request), options, [this, protectedThis = Ref { *this }, referrerPolicy = options.referrerPolicy, completionHandler = WTF::move(completionHandler), resource = CachedResourceHandle<CachedResource>(&resource), frame = Ref { frame }] (RefPtr<SubresourceLoader>&& loader) mutable { |
| 153 | if (loader) |
| 154 | scheduleLoad(*loader, resource.get(), referrerPolicy == ReferrerPolicy::NoReferrerWhenDowngrade); |
| 155 | else |
| 156 | RELEASE_LOG(Network, "%p - [webPageID=%" PRIu64 ", frameID=%" PRIu64 "] WebLoaderStrategy::loadResource: Unable to create SubresourceLoader", this, frame->pageID() ? frame->pageID()->toUInt64() : 0, frame->frameID().toUInt64())clang diagnostic push
clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = (OS_LOG_TYPE_DEFAULT ); if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__ ({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("%p - [webPageID=%" "ll" "u" ", frameID=%" "ll" "u" "] WebLoaderStrategy::loadResource: Unable to create SubresourceLoader" ), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG55" ) = "%p - [webPageID=%" "ll" "u" ", frameID=%" "ll" "u" "] WebLoaderStrategy::loadResource: Unable to create SubresourceLoader" ; uint8_t _Alignas(16) __attribute__((uninitialized)) _os_fmt_buf [__builtin_os_log_format_buffer_size("%p - [webPageID=%" "ll" "u" ", frameID=%" "ll" "u" "] WebLoaderStrategy::loadResource: Unable to create SubresourceLoader" , this, frame->pageID() ? frame->pageID()->toUInt64( ) : 0, frame->frameID().toUInt64())]; _os_log_impl(&__dso_handle , _log_tmp, _type_tmp, _os_fmt_str, (uint8_t *)__builtin_os_log_format (_os_fmt_buf, "%p - [webPageID=%" "ll" "u" ", frameID=%" "ll" "u" "] WebLoaderStrategy::loadResource: Unable to create SubresourceLoader" , this, frame->pageID() ? frame->pageID()->toUInt64( ) : 0, frame->frameID().toUInt64()), (uint32_t)sizeof(_os_fmt_buf )) clang diagnostic pop ; }); } }) clang diagnostic pop ; |
| 157 | completionHandler(WTF::move(loader)); |
| 158 | }); |
| 159 | } |
| 160 | |
| 161 | void WebLoaderStrategy::schedulePluginStreamLoad(LocalFrame& frame, NetscapePlugInStreamLoaderClient& client, ResourceRequest&& request, CompletionHandler<void(RefPtr<NetscapePlugInStreamLoader>&&)>&& completionHandler) |
| 162 | { |
| 163 | NetscapePlugInStreamLoader::create(frame, client, WTF::move(request), [this, protectedThis = Ref { *this }, completionHandler = WTF::move(completionHandler), frame = Ref { frame }] (RefPtr<NetscapePlugInStreamLoader>&& loader) mutable { |
| 164 | if (loader) |
| 165 | scheduleLoad(*loader, 0, frame->document()->referrerPolicy() == ReferrerPolicy::NoReferrerWhenDowngrade); |
| 166 | completionHandler(WTF::move(loader)); |
| 167 | }); |
| 168 | } |
| 169 | |
| 170 | static Seconds maximumBufferingTime(CachedResource* resource) |
| 171 | { |
| 172 | if (!resource) |
| 173 | return 0_s; |
| 174 | |
| 175 | switch (resource->type()) { |
| 176 | case CachedResource::Type::Beacon: |
| 177 | case CachedResource::Type::Ping: |
| 178 | case CachedResource::Type::CSSStyleSheet: |
| 179 | case CachedResource::Type::JSON: |
| 180 | case CachedResource::Type::Script: |
| 181 | case CachedResource::Type::SVGFontResource: |
| 182 | case CachedResource::Type::FontResource: |
| 183 | #if ENABLE(APPLICATION_MANIFEST)(defined 1 && 1) |
| 184 | case CachedResource::Type::ApplicationManifest: |
| 185 | #endif |
| 186 | #if ENABLE(MODEL_ELEMENT)(defined 1 && 1) |
| 187 | case CachedResource::Type::EnvironmentMapResource: |
| 188 | case CachedResource::Type::ModelResource: |
| 189 | #endif |
| 190 | return Seconds::infinity(); |
| 191 | case CachedResource::Type::ImageResource: |
| 192 | return 500_ms; |
| 193 | case CachedResource::Type::MediaResource: |
| 194 | return WebLoaderStrategy::mediaMaximumBufferingTime; |
| 195 | case CachedResource::Type::MainResource: |
| 196 | case CachedResource::Type::Icon: |
| 197 | case CachedResource::Type::RawResource: |
| 198 | case CachedResource::Type::SVGDocumentResource: |
| 199 | case CachedResource::Type::LinkPrefetch: |
| 200 | #if ENABLE(VIDEO)(defined 1 && 1) |
| 201 | case CachedResource::Type::TextTrackResource: |
| 202 | #endif |
| 203 | #if ENABLE(XSLT)(defined 1 && 1) |
| 204 | case CachedResource::Type::XSLStyleSheet: |
| 205 | #endif |
| 206 | return 0_s; |
| 207 | } |
| 208 | |
| 209 | ASSERT_NOT_REACHED()((void)0); |
| 210 | return 0_s; |
| 211 | } |
| 212 | |
| 213 | void WebLoaderStrategy::scheduleLoad(ResourceLoader& resourceLoader, CachedResource* resource, bool shouldClearReferrerOnHTTPSToHTTPRedirect) |
| 214 | { |
| 215 | auto identifier = *resourceLoader.identifier(); |
| 216 | |
| 217 | RefPtr frameLoader = resourceLoader.frameLoader(); |
| 218 | if (!frameLoader) { |
| 219 | ASSERT_NOT_REACHED()((void)0); |
| 220 | return; |
| 221 | } |
| 222 | auto& frameLoaderClient = frameLoader->client(); |
| 223 | auto pageID = frameLoader->frame().pageID(); |
| 224 | |
| 225 | std::optional<WebPageProxyIdentifier> webPageProxyID; |
| 226 | if (RefPtr webFrameLoaderClient = dynamicDowncast<WebLocalFrameLoaderClient>(frameLoaderClient)) |
| 227 | webPageProxyID = webFrameLoaderClient->webPageProxyID(); |
| 228 | else if (RefPtr workerFrameLoaderClient = dynamicDowncast<RemoteWorkerFrameLoaderClient>(frameLoaderClient)) |
| 229 | webPageProxyID = workerFrameLoaderClient->webPageProxyID(); |
| 230 | |
| 231 | auto trackingParameters = webPageProxyID && pageID ? std::optional(WebResourceLoader::TrackingParameters { |
| 232 | *webPageProxyID, |
| 233 | *pageID, |
| 234 | frameLoader->frameID(), |
| 235 | identifier |
| 236 | }) : std::nullopt; |
| 237 | |
| 238 | #if ENABLE(WEB_ARCHIVE)(defined 1 && 1) || ENABLE(MHTML)(defined 0 && 0) |
| 239 | // If the DocumentLoader schedules this as an archive resource load, |
| 240 | // then we should remember the ResourceLoader in our records but not schedule it in the NetworkProcess. |
| 241 | if (protect(resourceLoader.documentLoader())->scheduleArchiveLoad(resourceLoader, resourceLoader.request())) { |
| 242 | LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::scheduleLoad, url '%s' will be handled as an archive resource.", resourceLoader.url().string().utf8().data())((void)0); |
| 243 | WEBLOADERSTRATEGY_RELEASE_LOG("scheduleLoad: URL will be handled as an archive resource")clang diagnostic push
clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = (OS_LOG_TYPE_DEFAULT ); if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__ ({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: URL will be handled as an archive resource"), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG56" ) = "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: URL will be handled as an archive resource"; uint8_t _Alignas(16) __attribute__((uninitialized)) _os_fmt_buf[__builtin_os_log_format_buffer_size ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: URL will be handled as an archive resource", this , &resourceLoader, resourceLoader.frameLoader(), resourceLoader .frame(), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters))]; _os_log_impl(& __dso_handle, _log_tmp, _type_tmp, _os_fmt_str, (uint8_t *)__builtin_os_log_format (_os_fmt_buf, "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: URL will be handled as an archive resource", this , &resourceLoader, resourceLoader.frameLoader(), resourceLoader .frame(), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters)), (uint32_t)sizeof(_os_fmt_buf )) clang diagnostic pop ; }); } }) clang diagnostic pop ; |
| 244 | m_webResourceLoaders.set(identifier, WebResourceLoader::create(resourceLoader, trackingParameters)); |
| 245 | return; |
| 246 | } |
| 247 | #endif |
| 248 | |
| 249 | if (resourceLoader.request().url().protocolIsData()) { |
| 250 | LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::scheduleLoad, url '%s' will be loaded as data.", resourceLoader.url().string().utf8().data())((void)0); |
| 251 | WEBLOADERSTRATEGY_RELEASE_LOG_FORWARDABLE(WEBLOADERSTRATEGY_SCHEDULELOAD_URL_LOADED_AS_DATA)clang diagnostic push
clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = (OS_LOG_TYPE_DEFAULT ); if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__ ({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("[webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::scheduleLoad: URL will be loaded as data" ), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG57" ) = "[webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::scheduleLoad: URL will be loaded as data" ; uint8_t _Alignas(16) __attribute__((uninitialized)) _os_fmt_buf [__builtin_os_log_format_buffer_size("[webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::scheduleLoad: URL will be loaded as data" , pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters))]; _os_log_impl(& __dso_handle, _log_tmp, _type_tmp, _os_fmt_str, (uint8_t *)__builtin_os_log_format (_os_fmt_buf, "[webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::scheduleLoad: URL will be loaded as data" , pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters)), (uint32_t)sizeof(_os_fmt_buf )) clang diagnostic pop ; }); } }) clang diagnostic pop ; |
| 252 | startLocalLoad(resourceLoader); |
| 253 | return; |
| 254 | } |
| 255 | |
| 256 | #if USE(QUICK_LOOK)(defined USE_QUICK_LOOK && USE_QUICK_LOOK) |
| 257 | if (isQuickLookPreviewURL(resourceLoader.request().url())) { |
| 258 | LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::scheduleLoad, url '%s' will be handled as a QuickLook resource.", resourceLoader.url().string().utf8().data())((void)0); |
| 259 | WEBLOADERSTRATEGY_RELEASE_LOG("scheduleLoad: URL will be handled as a QuickLook resource")clang diagnostic push
clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = (OS_LOG_TYPE_DEFAULT ); if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__ ({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: URL will be handled as a QuickLook resource") , "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG58" ) = "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: URL will be handled as a QuickLook resource"; uint8_t _Alignas(16) __attribute__((uninitialized)) _os_fmt_buf [__builtin_os_log_format_buffer_size("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: URL will be handled as a QuickLook resource", this, &resourceLoader, resourceLoader.frameLoader(), resourceLoader .frame(), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters))]; _os_log_impl(& __dso_handle, _log_tmp, _type_tmp, _os_fmt_str, (uint8_t *)__builtin_os_log_format (_os_fmt_buf, "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: URL will be handled as a QuickLook resource", this, &resourceLoader, resourceLoader.frameLoader(), resourceLoader .frame(), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters)), (uint32_t)sizeof(_os_fmt_buf )) clang diagnostic pop ; }); } }) clang diagnostic pop ; |
| 260 | startLocalLoad(resourceLoader); |
| 261 | return; |
| 262 | } |
| 263 | #endif |
| 264 | |
| 265 | #if USE(SOUP)(defined USE_SOUP && USE_SOUP) |
| 266 | // For apps that call g_resource_load in a web extension. |
| 267 | // https://blogs.gnome.org/alexl/2012/01/26/resources-in-glib/ |
| 268 | if (resourceLoader.request().url().protocolIs("resource"_s)) { |
| 269 | LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::scheduleLoad, url '%s' will be handled as a GResource.", resourceLoader.url().string().utf8().data())((void)0); |
| 270 | WEBLOADERSTRATEGY_RELEASE_LOG("scheduleLoad: URL will be handled as a GResource")clang diagnostic push
clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = (OS_LOG_TYPE_DEFAULT ); if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__ ({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: URL will be handled as a GResource"), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG59" ) = "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: URL will be handled as a GResource"; uint8_t _Alignas (16) __attribute__((uninitialized)) _os_fmt_buf[__builtin_os_log_format_buffer_size ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: URL will be handled as a GResource", this, & resourceLoader, resourceLoader.frameLoader(), resourceLoader. frame(), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters))]; _os_log_impl(& __dso_handle, _log_tmp, _type_tmp, _os_fmt_str, (uint8_t *)__builtin_os_log_format (_os_fmt_buf, "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: URL will be handled as a GResource", this, & resourceLoader, resourceLoader.frameLoader(), resourceLoader. frame(), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters)), (uint32_t)sizeof(_os_fmt_buf )) clang diagnostic pop ; }); } }) clang diagnostic pop ; |
| 271 | startLocalLoad(resourceLoader); |
| 272 | return; |
| 273 | } |
| 274 | #endif |
| 275 | |
| 276 | #if ENABLE(PDFJS)(defined 0 && 0) |
| 277 | if (tryLoadingUsingPDFJSHandler(resourceLoader, trackingParameters)) |
| 278 | return; |
| 279 | #endif |
| 280 | |
| 281 | if (tryLoadingUsingURLSchemeHandler(resourceLoader, trackingParameters)) |
| 282 | return; |
| 283 | |
| 284 | #if ENABLE(SWIFT_DEMO_URI_SCHEME)(defined ENABLE_SWIFT_DEMO_URI_SCHEME && ENABLE_SWIFT_DEMO_URI_SCHEME ) |
| 285 | if (resourceLoader.request().url().protocolIs("x-swift-demo"_s)) { |
| 286 | // We don't load this at all - higher layers of webkit code will call loadData later. |
| 287 | return; |
| 288 | } |
| 289 | #endif |
| 290 | |
| 291 | if (!trackingParameters) { |
| 292 | ASSERT_NOT_REACHED()((void)0); |
| 293 | return; |
| 294 | } |
| 295 | |
| 296 | if (InspectorInstrumentationWebKit::shouldInterceptRequest(resourceLoader)) { |
| 297 | InspectorInstrumentationWebKit::interceptRequest(resourceLoader, [this, protectedThis = Ref { *this }, protectedResourceLoader = Ref { resourceLoader }, trackingParameters, shouldClearReferrerOnHTTPSToHTTPRedirect, resource](const ResourceRequest& request) { |
Captured raw-pointer 'resource' to uncounted type is unsafe | |
| 298 | auto& resourceLoader = protectedResourceLoader.get(); |
| 299 | WEBLOADERSTRATEGY_RELEASE_LOG("scheduleLoad: intercepted URL will be scheduled with the NetworkProcess")clang diagnostic push
clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = (OS_LOG_TYPE_DEFAULT ); if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__ ({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: intercepted URL will be scheduled with the NetworkProcess" ), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG60" ) = "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: intercepted URL will be scheduled with the NetworkProcess" ; uint8_t _Alignas(16) __attribute__((uninitialized)) _os_fmt_buf [__builtin_os_log_format_buffer_size("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: intercepted URL will be scheduled with the NetworkProcess" , this, &resourceLoader, resourceLoader.frameLoader(), resourceLoader .frame(), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters))]; _os_log_impl(& __dso_handle, _log_tmp, _type_tmp, _os_fmt_str, (uint8_t *)__builtin_os_log_format (_os_fmt_buf, "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: intercepted URL will be scheduled with the NetworkProcess" , this, &resourceLoader, resourceLoader.frameLoader(), resourceLoader .frame(), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters)), (uint32_t)sizeof(_os_fmt_buf )) clang diagnostic pop ; }); } }) clang diagnostic pop ; |
| 300 | scheduleLoadFromNetworkProcess(resourceLoader, request, *trackingParameters, shouldClearReferrerOnHTTPSToHTTPRedirect, maximumBufferingTime(resource)); |
| 301 | }); |
| 302 | return; |
| 303 | } |
| 304 | |
| 305 | WEBLOADERSTRATEGY_RELEASE_LOG_FORWARDABLE(WEBLOADERSTRATEGY_SCHEDULELOAD)clang diagnostic push
clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = (OS_LOG_TYPE_DEFAULT ); if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__ ({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("[webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::scheduleLoad: URL will be scheduled with the NetworkProcess" ), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG61" ) = "[webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::scheduleLoad: URL will be scheduled with the NetworkProcess" ; uint8_t _Alignas(16) __attribute__((uninitialized)) _os_fmt_buf [__builtin_os_log_format_buffer_size("[webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::scheduleLoad: URL will be scheduled with the NetworkProcess" , pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters))]; _os_log_impl(& __dso_handle, _log_tmp, _type_tmp, _os_fmt_str, (uint8_t *)__builtin_os_log_format (_os_fmt_buf, "[webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::scheduleLoad: URL will be scheduled with the NetworkProcess" , pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters)), (uint32_t)sizeof(_os_fmt_buf )) clang diagnostic pop ; }); } }) clang diagnostic pop ; |
| 306 | scheduleLoadFromNetworkProcess(resourceLoader, resourceLoader.request(), *trackingParameters, shouldClearReferrerOnHTTPSToHTTPRedirect, maximumBufferingTime(resource)); |
| 307 | } |
| 308 | |
| 309 | bool WebLoaderStrategy::tryLoadingUsingURLSchemeHandler(ResourceLoader& resourceLoader, const std::optional<WebResourceLoader::TrackingParameters>& trackingParameters) |
| 310 | { |
| 311 | RefPtr<WebPage> webPage; |
| 312 | RefPtr<WebFrame> webFrame; |
| 313 | |
| 314 | if (!resourceLoader.frameLoader()) |
| 315 | return false; |
| 316 | |
| 317 | if (auto* webFrameLoaderClient = dynamicDowncast<WebLocalFrameLoaderClient>(resourceLoader.frameLoader()->client())) { |
| 318 | webFrame = webFrameLoaderClient->webFrame(); |
| 319 | webPage = webFrame->page(); |
| 320 | } else if (auto* workerFrameLoaderClient = dynamicDowncast<RemoteWorkerFrameLoaderClient>(resourceLoader.frameLoader()->client())) { |
| 321 | if (auto serviceWorkerPageIdentifier = workerFrameLoaderClient->serviceWorkerPageIdentifier()) { |
| 322 | if (RefPtr page = Page::serviceWorkerPage(*serviceWorkerPageIdentifier)) { |
| 323 | webPage = WebPage::fromCorePage(*page); |
| 324 | RefPtr frame = webPage ? webPage->mainFrame() : nullptr; |
| 325 | webFrame = frame ? WebFrame::fromCoreFrame(*frame) : nullptr; |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | if (!webPage || !webFrame) |
| 331 | return false; |
| 332 | |
| 333 | if (resourceLoader.request().url().protocolIsAbout() && !resourceLoader.documentLoader()->isLoadingMainResource()) |
| 334 | return false; |
| 335 | |
| 336 | RefPtr handler = webPage->urlSchemeHandlerForScheme(resourceLoader.request().url().protocol()); |
| 337 | if (!handler) |
| 338 | return false; |
| 339 | |
| 340 | LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::scheduleLoad, URL '%s' will be handled by a UIProcess URL scheme handler.", resourceLoader.url().string().utf8().data())((void)0); |
| 341 | WEBLOADERSTRATEGY_RELEASE_LOG("tryLoadingUsingURLSchemeHandler: URL will be handled by a UIProcess URL scheme handler")clang diagnostic push
clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = (OS_LOG_TYPE_DEFAULT ); if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__ ({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "tryLoadingUsingURLSchemeHandler: URL will be handled by a UIProcess URL scheme handler" ), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG62" ) = "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "tryLoadingUsingURLSchemeHandler: URL will be handled by a UIProcess URL scheme handler" ; uint8_t _Alignas(16) __attribute__((uninitialized)) _os_fmt_buf [__builtin_os_log_format_buffer_size("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "tryLoadingUsingURLSchemeHandler: URL will be handled by a UIProcess URL scheme handler" , this, &resourceLoader, resourceLoader.frameLoader(), resourceLoader .frame(), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters))]; _os_log_impl(& __dso_handle, _log_tmp, _type_tmp, _os_fmt_str, (uint8_t *)__builtin_os_log_format (_os_fmt_buf, "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "tryLoadingUsingURLSchemeHandler: URL will be handled by a UIProcess URL scheme handler" , this, &resourceLoader, resourceLoader.frameLoader(), resourceLoader .frame(), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters)), (uint32_t)sizeof(_os_fmt_buf )) clang diagnostic pop ; }); } }) clang diagnostic pop ; |
| 342 | |
| 343 | handler->startNewTask(resourceLoader, *webFrame); |
| 344 | return true; |
| 345 | } |
| 346 | |
| 347 | #if ENABLE(PDFJS)(defined 0 && 0) |
| 348 | bool WebLoaderStrategy::tryLoadingUsingPDFJSHandler(ResourceLoader& resourceLoader, const std::optional<WebResourceLoader::TrackingParameters>& trackingParameters) |
| 349 | { |
| 350 | if (!resourceLoader.request().url().protocolIs("webkit-pdfjs-viewer"_s)) |
| 351 | return false; |
| 352 | |
| 353 | LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::scheduleLoad, url '%s' will be handled as a PDFJS resource.", resourceLoader.url().string().utf8().data())((void)0); |
| 354 | WEBLOADERSTRATEGY_RELEASE_LOG("tryLoadingUsingPDFJSHandler: URL will be scheduled with the PDFJS url scheme handler")clang diagnostic push
clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = (OS_LOG_TYPE_DEFAULT ); if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__ ({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "tryLoadingUsingPDFJSHandler: URL will be scheduled with the PDFJS url scheme handler" ), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG63" ) = "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "tryLoadingUsingPDFJSHandler: URL will be scheduled with the PDFJS url scheme handler" ; uint8_t _Alignas(16) __attribute__((uninitialized)) _os_fmt_buf [__builtin_os_log_format_buffer_size("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "tryLoadingUsingPDFJSHandler: URL will be scheduled with the PDFJS url scheme handler" , this, &resourceLoader, resourceLoader.frameLoader(), resourceLoader .frame(), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters))]; _os_log_impl(& __dso_handle, _log_tmp, _type_tmp, _os_fmt_str, (uint8_t *)__builtin_os_log_format (_os_fmt_buf, "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "tryLoadingUsingPDFJSHandler: URL will be scheduled with the PDFJS url scheme handler" , this, &resourceLoader, resourceLoader.frameLoader(), resourceLoader .frame(), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters)), (uint32_t)sizeof(_os_fmt_buf )) clang diagnostic pop ; }); } }) clang diagnostic pop ; |
| 355 | |
| 356 | startLocalLoad(resourceLoader); |
| 357 | return true; |
| 358 | } |
| 359 | #endif |
| 360 | |
| 361 | static RefPtr<DocumentLoader> policySourceDocumentLoaderForFrame(const LocalFrame& frame, bool isMainFrameNavigation = false) |
| 362 | { |
| 363 | RefPtr mainFrame = frame.localMainFrame(); |
| 364 | if (!mainFrame) |
| 365 | return { }; |
| 366 | |
| 367 | auto canIncludeCurrentDocumentLoader = isMainFrameNavigation ? FrameLoader::CanIncludeCurrentDocumentLoader::No : FrameLoader::CanIncludeCurrentDocumentLoader::Yes; |
| 368 | auto mainFrameDocumentLoader = mainFrame->loader().loaderForWebsitePolicies(canIncludeCurrentDocumentLoader); |
| 369 | |
| 370 | auto policySourceDocumentLoader = mainFrameDocumentLoader; |
| 371 | if (policySourceDocumentLoader && !policySourceDocumentLoader->request().url().hasSpecialScheme() && protect(frame.document())->url().protocolIsInHTTPFamily()) |
| 372 | policySourceDocumentLoader = frame.loader().documentLoader(); |
| 373 | |
| 374 | return policySourceDocumentLoader; |
| 375 | } |
| 376 | |
| 377 | static void addParametersShared(const LocalFrame* frame, NetworkResourceLoadParameters& parameters, bool isMainFrameNavigation = false) |
| 378 | { |
| 379 | parameters.crossOriginAccessControlCheckEnabled = CrossOriginAccessControlCheckDisabler::singleton().crossOriginAccessControlCheckEnabled(); |
| 380 | parameters.hadMainFrameMainResourcePrivateRelayed = WebProcess::singleton().hadMainFrameMainResourcePrivateRelayed(); |
| 381 | |
| 382 | if (!frame) |
| 383 | return; |
| 384 | |
| 385 | // When loading the main frame, we need to get allowPrivacyProxy from the same DocumentLoader that |
| 386 | // WebLocalFrameLoaderClient::applyToDocumentLoader stored the value on. Otherwise, we need to get the |
| 387 | // value from the main frame's current DocumentLoader. |
| 388 | |
| 389 | Ref mainFrame = frame->mainFrame(); |
| 390 | RefPtr policySourceDocumentLoader = policySourceDocumentLoaderForFrame(*frame, isMainFrameNavigation); |
| 391 | |
| 392 | parameters.allowPrivacyProxy = !policySourceDocumentLoader || policySourceDocumentLoader->allowPrivacyProxy(); |
| 393 | |
| 394 | if (RefPtr framePolicySourceDocumentLoader = frame->loader().loaderForWebsitePolicies(isMainFrameNavigation ? FrameLoader::CanIncludeCurrentDocumentLoader::No : FrameLoader::CanIncludeCurrentDocumentLoader::Yes)) { |
| 395 | if (String referrer = framePolicySourceDocumentLoader->preferences().overrideReferrerForAllRequests; !referrer.isNull()) |
| 396 | parameters.request.setHTTPHeaderField(HTTPHeaderName::Referer, referrer); |
| 397 | } |
| 398 | |
| 399 | if (RefPtr document = frame->document()) { |
| 400 | parameters.crossOriginEmbedderPolicy = document->crossOriginEmbedderPolicy(); |
| 401 | parameters.isClearSiteDataHeaderEnabled = document->settings().clearSiteDataHTTPHeaderEnabled(); |
| 402 | parameters.isClearSiteDataExecutionContextEnabled = document->settings().clearSiteDataExecutionContextsSupportEnabled(); |
| 403 | parameters.mayBlockNetworkRequest = document->settings().scriptTrackingPrivacyNetworkRequestBlockingLatchEnabled() ? |
| 404 | std::optional { WebProcess::singleton().shouldBlockRequest(parameters.request.url(), protect(document->topOrigin())) } : std::nullopt; |
| 405 | } |
| 406 | |
| 407 | if (RefPtr page = frame->page()) { |
| 408 | parameters.pageHasResourceLoadClient = page->hasResourceLoadClient(); |
| 409 | page->logMediaDiagnosticMessage(parameters.request.httpBody()); |
| 410 | |
| 411 | if (RefPtr webPage = WebPage::fromCorePage(*page)) { |
| 412 | #if ENABLE(WK_WEB_EXTENSIONS)(defined 1 && 1) && PLATFORM(COCOA)(defined 1 && 1) |
| 413 | if (RefPtr extensionControllerProxy = webPage->webExtensionControllerProxy()) |
| 414 | parameters.pageHasLoadedWebExtensions = extensionControllerProxy->hasLoadedContexts(); |
| 415 | #endif |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | if (RefPtr ownerElement = frame->ownerElement()) { |
| 420 | if (RefPtr parentFrame = ownerElement->document().frame()) { |
| 421 | parameters.parentFrameID = parentFrame->loader().frameID(); |
| 422 | parameters.parentCrossOriginEmbedderPolicy = ownerElement->document().crossOriginEmbedderPolicy(); |
| 423 | parameters.parentFrameURL = protect(ownerElement->document())->url(); |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | auto advancedPrivacyProtections = policySourceDocumentLoader ? policySourceDocumentLoader->advancedPrivacyProtections() : OptionSet<AdvancedPrivacyProtections> { }; |
| 428 | parameters.advancedPrivacyProtections = advancedPrivacyProtections; |
| 429 | |
| 430 | if (isMainFrameNavigation) |
| 431 | parameters.linkPreconnectEarlyHintsEnabled = mainFrame->settings().linkPreconnectEarlyHintsEnabled(); |
| 432 | } |
| 433 | |
| 434 | void WebLoaderStrategy::scheduleLoadFromNetworkProcess(ResourceLoader& resourceLoader, const ResourceRequest& request, const WebResourceLoader::TrackingParameters& trackingParameters, bool shouldClearReferrerOnHTTPSToHTTPRedirect, Seconds maximumBufferingTime) |
| 435 | { |
| 436 | auto identifier = *resourceLoader.identifier(); |
| 437 | |
| 438 | RefPtr frame = resourceLoader.frame(); |
| 439 | |
| 440 | if (RefPtr page = frame ? frame->page() : nullptr) { |
| 441 | auto mainFrameMainResource = frame->isMainFrame() |
| 442 | && resourceLoader.frameLoader() |
| 443 | && resourceLoader.frameLoader()->notifier().isInitialRequestIdentifier(identifier) |
| 444 | ? MainFrameMainResource::Yes : MainFrameMainResource::No; |
| 445 | if (!page->allowsLoadFromURL(request.url(), mainFrameMainResource)) { |
| 446 | RunLoop::mainSingleton().dispatch([resourceLoader = Ref { resourceLoader }, error = blockedError(request)] { |
| 447 | resourceLoader->didFail(error); |
| 448 | }); |
| 449 | return; |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | ContentSniffingPolicy contentSniffingPolicy = resourceLoader.shouldSniffContent() ? ContentSniffingPolicy::SniffContent : ContentSniffingPolicy::DoNotSniffContent; |
| 454 | auto contentEncodingSniffingPolicy = resourceLoader.contentEncodingSniffingPolicy(); |
| 455 | StoredCredentialsPolicy storedCredentialsPolicy = resourceLoader.shouldUseCredentialStorage() ? StoredCredentialsPolicy::Use : StoredCredentialsPolicy::DoNotUse; |
| 456 | |
| 457 | LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::scheduleLoad, url '%s' will be scheduled with the NetworkProcess with priority %d, storedCredentialsPolicy %i", resourceLoader.url().string().latin1().data(), static_cast<int>(resourceLoader.request().priority()), (int)storedCredentialsPolicy)((void)0); |
| 458 | |
| 459 | NetworkResourceLoadParameters loadParameters { |
| 460 | trackingParameters.webPageProxyID, |
| 461 | trackingParameters.pageID, |
| 462 | trackingParameters.frameID, |
| 463 | request |
| 464 | }; |
| 465 | loadParameters.createSandboxExtensionHandlesIfNecessary(); |
| 466 | |
| 467 | loadParameters.identifier = identifier; |
| 468 | loadParameters.parentPID = legacyPresentingApplicationPID(); |
| 469 | loadParameters.contentSniffingPolicy = contentSniffingPolicy; |
| 470 | loadParameters.contentEncodingSniffingPolicy = contentEncodingSniffingPolicy; |
| 471 | loadParameters.storedCredentialsPolicy = storedCredentialsPolicy; |
| 472 | // If there is no WebFrame then this resource cannot be authenticated with the client. |
| 473 | loadParameters.clientCredentialPolicy = resourceLoader.isAllowedToAskUserForCredentials() ? ClientCredentialPolicy::MayAskClientForCredentials : ClientCredentialPolicy::CannotAskClientForCredentials; |
| 474 | loadParameters.shouldClearReferrerOnHTTPSToHTTPRedirect = shouldClearReferrerOnHTTPSToHTTPRedirect; |
| 475 | loadParameters.needsCertificateInfo = resourceLoader.shouldIncludeCertificateInfo(); |
| 476 | loadParameters.maximumBufferingTime = maximumBufferingTime; |
| 477 | loadParameters.options = resourceLoader.options(); |
| 478 | loadParameters.preflightPolicy = resourceLoader.options().preflightPolicy; |
| 479 | bool isMainFrameNavigation = resourceLoader.frame() && resourceLoader.frame()->isMainFrame() && resourceLoader.options().mode == FetchOptions::Mode::Navigate; |
| 480 | addParametersShared(frame.get(), loadParameters, isMainFrameNavigation); |
| 481 | |
| 482 | loadParameters.serviceWorkersMode = resourceLoader.options().loadedFromOpaqueSource == LoadedFromOpaqueSource::No ? resourceLoader.options().serviceWorkersMode : ServiceWorkersMode::None; |
| 483 | loadParameters.serviceWorkerRegistrationIdentifier = resourceLoader.options().serviceWorkerRegistrationIdentifier; |
| 484 | loadParameters.workerIdentifier = resourceLoader.options().workerIdentifier; |
| 485 | loadParameters.httpHeadersToKeep = resourceLoader.options().httpHeadersToKeep; |
| 486 | if (resourceLoader.options().navigationPreloadIdentifier) |
| 487 | loadParameters.navigationPreloadIdentifier = resourceLoader.options().navigationPreloadIdentifier; |
| 488 | if (frame && !frame->isMainFrame()) |
| 489 | loadParameters.shouldRecordFrameLoadForStorageAccess = frame->settings().requestStorageAccessThrowsExceptionUntilReload(); |
| 490 | |
| 491 | RefPtr document = frame ? frame->document() : nullptr; |
| 492 | if (resourceLoader.options().cspResponseHeaders) |
| 493 | loadParameters.cspResponseHeaders = resourceLoader.options().cspResponseHeaders; |
| 494 | else if (document && !document->shouldBypassMainWorldContentSecurityPolicy() && resourceLoader.options().contentSecurityPolicyImposition == ContentSecurityPolicyImposition::DoPolicyCheck) { |
| 495 | if (CheckedPtr contentSecurityPolicy = document->contentSecurityPolicy()) |
| 496 | loadParameters.cspResponseHeaders = contentSecurityPolicy->responseHeaders(); |
| 497 | } |
| 498 | |
| 499 | if (resourceLoader.options().crossOriginEmbedderPolicy) |
| 500 | loadParameters.crossOriginEmbedderPolicy = *resourceLoader.options().crossOriginEmbedderPolicy; |
| 501 | |
| 502 | auto* webFrameLoaderClient = frame ? dynamicDowncast<WebLocalFrameLoaderClient>(frame->loader().client()) : nullptr; |
| 503 | RefPtr webFrame = webFrameLoaderClient ? &webFrameLoaderClient->webFrame() : nullptr; |
| 504 | |
| 505 | #if ENABLE(APP_BOUND_DOMAINS)(defined ENABLE_APP_BOUND_DOMAINS && ENABLE_APP_BOUND_DOMAINS ) |
| 506 | if (webFrame) |
| 507 | loadParameters.isNavigatingToAppBoundDomain = webFrame->isTopFrameNavigatingToAppBoundDomain(); |
| 508 | #endif |
| 509 | |
| 510 | if (document) { |
| 511 | loadParameters.frameURL = document->url(); |
| 512 | #if ENABLE(CONTENT_EXTENSIONS)(defined 1 && 1) || (ENABLE(CONTENT_FILTERING)(defined 1 && 1) && HAVE(WEBCONTENTRESTRICTIONS)(defined HAVE_WEBCONTENTRESTRICTIONS && HAVE_WEBCONTENTRESTRICTIONS )) |
| 513 | if (RefPtr page = document->page()) |
| 514 | loadParameters.mainDocumentURL = page->mainFrameURL(); |
| 515 | #endif |
| 516 | #if ENABLE(CONTENT_EXTENSIONS)(defined 1 && 1) |
| 517 | // FIXME: Instead of passing userContentControllerIdentifier, the NetworkProcess should be able to get it using webPageId. |
| 518 | if (RefPtr webPage = webFrame ? webFrame->page() : nullptr) |
| 519 | loadParameters.userContentControllerIdentifier = webPage->userContentControllerIdentifier(); |
| 520 | #endif |
| 521 | } |
| 522 | |
| 523 | // FIXME: All loaders should provide their origin if navigation mode is cors/no-cors/same-origin. |
| 524 | // As a temporary approach, we use the document origin if available or the HTTP Origin header otherwise. |
| 525 | if (auto* loader = dynamicDowncast<SubresourceLoader>(resourceLoader)) { |
| 526 | loadParameters.sourceOrigin = loader->origin(); |
| 527 | |
| 528 | if (auto* headers = loader->originalHeaders()) |
| 529 | loadParameters.originalRequestHeaders = *headers; |
| 530 | } |
| 531 | |
| 532 | if (!loadParameters.sourceOrigin && document) |
| 533 | loadParameters.sourceOrigin = document->securityOrigin(); |
| 534 | if (!loadParameters.sourceOrigin) { |
| 535 | auto origin = request.httpOrigin(); |
| 536 | if (!origin.isNull()) |
| 537 | loadParameters.sourceOrigin = SecurityOrigin::createFromString(origin); |
| 538 | } |
| 539 | if (isMainFrameNavigation) { |
| 540 | if (request.url().protocolIsBlob() && resourceLoader.documentLoader() && !resourceLoader.documentLoader()->triggeringAction().isEmpty() && resourceLoader.documentLoader()->triggeringAction().requester()) |
| 541 | loadParameters.topOrigin = resourceLoader.documentLoader()->triggeringAction().requester()->topOrigin.ptr(); |
| 542 | else |
| 543 | loadParameters.topOrigin = SecurityOrigin::create(request.url()); |
| 544 | } else if (document) |
| 545 | loadParameters.topOrigin = document->topOrigin(); |
| 546 | |
| 547 | if (document) |
| 548 | loadParameters.documentURL = document->url(); |
| 549 | |
| 550 | if (loadParameters.options.mode != FetchOptions::Mode::Navigate) { |
| 551 | ASSERT(loadParameters.sourceOrigin)((void)0); |
| 552 | if (!loadParameters.sourceOrigin) { |
| 553 | WEBLOADERSTRATEGY_RELEASE_LOG_ERROR("scheduleLoad: no sourceOrigin (priority=%d)", static_cast<int>(resourceLoader.request().priority()))clang diagnostic push
clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = OS_LOG_TYPE_ERROR; if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: no sourceOrigin (priority=%d)"), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG64" ) = "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: no sourceOrigin (priority=%d)"; uint8_t _Alignas (16) __attribute__((uninitialized)) _os_fmt_buf[__builtin_os_log_format_buffer_size ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: no sourceOrigin (priority=%d)", this, &resourceLoader , resourceLoader.frameLoader(), resourceLoader.frame(), pageIDForLog (trackingParameters), frameIDForLog(trackingParameters), resourceIDForLog (trackingParameters), static_cast<int>(resourceLoader.request ().priority()))]; _os_log_error_impl(&__dso_handle, _log_tmp , _type_tmp, _os_fmt_str, (uint8_t *)__builtin_os_log_format( _os_fmt_buf, "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: no sourceOrigin (priority=%d)", this, &resourceLoader , resourceLoader.frameLoader(), resourceLoader.frame(), pageIDForLog (trackingParameters), frameIDForLog(trackingParameters), resourceIDForLog (trackingParameters), static_cast<int>(resourceLoader.request ().priority())), (uint32_t)sizeof(_os_fmt_buf)) clang diagnostic pop ; }); } }) clang diagnostic pop ; |
| 554 | scheduleInternallyFailedLoad(resourceLoader); |
| 555 | return; |
| 556 | } |
| 557 | } |
| 558 | |
| 559 | loadParameters.shouldRestrictHTTPResponseAccess = shouldPerformSecurityChecks(); |
| 560 | |
| 561 | loadParameters.isMainFrameNavigation = isMainFrameNavigation; |
| 562 | if (loadParameters.isMainFrameNavigation && document) { |
| 563 | // Fall back to use opener's cross-origin opener policy like in Document::initSecurityContext. |
| 564 | RefPtr webFrame = WebFrame::webFrame(frame->frameID()); |
| 565 | RefPtr coreFrame = webFrame ? webFrame->coreFrame() : nullptr; |
| 566 | RefPtr openerFrame = coreFrame ? coreFrame->opener() : nullptr; |
| 567 | RefPtr openerDocumentSecurityOrigin = openerFrame ? openerFrame->frameDocumentSecurityOrigin() : nullptr; |
| 568 | bool openerDocumentIsSameOriginAsTopDocument = openerDocumentSecurityOrigin && openerDocumentSecurityOrigin->isSameOriginAs(protect(openerFrame->topOrigin())); |
| 569 | auto openerDocumentSecurityPolicy = openerFrame ? openerFrame->frameDocumentSecurityPolicy() : std::nullopt; |
| 570 | if (!document->haveInitializedSecurityOrigin() && openerDocumentSecurityPolicy && openerDocumentIsSameOriginAsTopDocument) |
| 571 | loadParameters.sourceCrossOriginOpenerPolicy = openerDocumentSecurityPolicy->crossOriginOpenerPolicy; |
| 572 | else |
| 573 | loadParameters.sourceCrossOriginOpenerPolicy = document->crossOriginOpenerPolicy(); |
| 574 | } |
| 575 | |
| 576 | if (resourceLoader.frame() |
| 577 | && resourceLoader.options().mode == FetchOptions::Mode::Navigate |
| 578 | && webFrame |
| 579 | && webFrame->frameLoaderClient()) { |
| 580 | auto navigationUpgradeToHTTPSBehavior = frame ? frame->loader().navigationUpgradeToHTTPSBehavior() : NavigationUpgradeToHTTPSBehavior::BasedOnPolicy; |
| 581 | // FIXME: Gather more parameters here like we have in WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction. |
| 582 | loadParameters.mainResourceNavigationDataForAnyFrame = webFrame->frameLoaderClient()->navigationActionData(resourceLoader.documentLoader()->triggeringAction(), request, { }, { }, { }, { }, { }, navigationUpgradeToHTTPSBehavior, { }); |
| 583 | } |
| 584 | if (loadParameters.mainResourceNavigationDataForAnyFrame) { |
| 585 | if (RefPtr documentLoader = resourceLoader.documentLoader()) { |
| 586 | loadParameters.navigationID = documentLoader->navigationID(); |
| 587 | loadParameters.navigationRequester = documentLoader->triggeringAction().requester(); |
| 588 | } |
| 589 | } |
| 590 | loadParameters.isCrossOriginOpenerPolicyEnabled = document && document->settings().crossOriginOpenerPolicyEnabled(); |
| 591 | loadParameters.isDisplayingInitialEmptyDocument = frame && frame->loader().stateMachine().isDisplayingInitialEmptyDocument(); |
| 592 | if (frame) |
| 593 | loadParameters.effectiveSandboxFlags = frame->sandboxFlagsFromSandboxAttributeNotCSP(); |
| 594 | if (RefPtr openerFrame = frame ? dynamicDowncast<LocalFrame>(frame->opener()) : nullptr) { |
| 595 | if (RefPtr openerDocument = openerFrame->document()) |
| 596 | loadParameters.openerURL = openerDocument->url(); |
| 597 | } |
| 598 | |
| 599 | loadParameters.shouldEnableCrossOriginResourcePolicy = !loadParameters.isMainFrameNavigation; |
| 600 | |
| 601 | if (resourceLoader.options().mode == FetchOptions::Mode::Navigate) { |
| 602 | Vector<Ref<SecurityOrigin>> frameAncestorOrigins; |
| 603 | |
| 604 | // Use the WebFrame to get the parent because this may be a provisional frame not hooked up to its parent yet. |
| 605 | RefPtr thisWebFrame = WebFrame::webFrame(frame ? std::optional(frame->frameID()) : std::nullopt); |
| 606 | RefPtr parentWebFrame = thisWebFrame ? thisWebFrame->parentFrame() : nullptr; |
| 607 | for (RefPtr frame = parentWebFrame ? parentWebFrame->coreFrame() : nullptr; frame; frame = frame->tree().parent()) { |
| 608 | RefPtr<WebCore::SecurityOrigin> frameOrigin = frame->frameDocumentSecurityOrigin(); |
| 609 | if (!frameOrigin) { |
| 610 | WEBLOADERSTRATEGY_RELEASE_LOG_ERROR("scheduleLoad: Unable to get document origin of frame (frameID=%" PRIu64 ")", frame->frameID().toUInt64())clang diagnostic push
clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = OS_LOG_TYPE_ERROR; if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: Unable to get document origin of frame (frameID=%" "ll" "u" ")"), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG65" ) = "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: Unable to get document origin of frame (frameID=%" "ll" "u" ")"; uint8_t _Alignas(16) __attribute__((uninitialized )) _os_fmt_buf[__builtin_os_log_format_buffer_size("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: Unable to get document origin of frame (frameID=%" "ll" "u" ")", this, &resourceLoader, resourceLoader.frameLoader (), resourceLoader.frame(), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters), resourceIDForLog(trackingParameters ), frame->frameID().toUInt64())]; _os_log_error_impl(& __dso_handle, _log_tmp, _type_tmp, _os_fmt_str, (uint8_t *)__builtin_os_log_format (_os_fmt_buf, "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: Unable to get document origin of frame (frameID=%" "ll" "u" ")", this, &resourceLoader, resourceLoader.frameLoader (), resourceLoader.frame(), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters), resourceIDForLog(trackingParameters ), frame->frameID().toUInt64()), (uint32_t)sizeof(_os_fmt_buf )) clang diagnostic pop ; }); } }) clang diagnostic pop ; |
| 611 | frameOrigin = SecurityOrigin::opaqueOrigin(); |
| 612 | } |
| 613 | frameAncestorOrigins.append(*frameOrigin); |
| 614 | } |
| 615 | loadParameters.frameAncestorOrigins = WTF::move(frameAncestorOrigins); |
| 616 | } |
| 617 | |
| 618 | if (RefPtr frameLoader = resourceLoader.frameLoader()) |
| 619 | loadParameters.requiredCookiesVersion = frameLoader->requiredCookiesVersion(); |
| 620 | |
| 621 | if (RefPtr handle = resourceLoader.cachedResource()) |
| 622 | loadParameters.isInitiatorPrefetch = handle->type() == CachedResource::Type::LinkPrefetch; |
| 623 | |
| 624 | std::optional<NetworkResourceLoadIdentifier> existingNetworkResourceLoadIdentifierToResume; |
| 625 | if (loadParameters.isMainFrameNavigation) |
| 626 | existingNetworkResourceLoadIdentifierToResume = std::exchange(m_existingNetworkResourceLoadIdentifierToResume, std::nullopt); |
| 627 | WEBLOADERSTRATEGY_RELEASE_LOG_FORWARDABLE(WEBLOADERSTRATEGY_SCHEDULELOAD_RESOURCE_SCHEDULED_WITH_NETWORKPROCESS, static_cast<int>(resourceLoader.request().priority()), existingNetworkResourceLoadIdentifierToResume ? existingNetworkResourceLoadIdentifierToResume->toUInt64() : 0)clang diagnostic push
clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = (OS_LOG_TYPE_DEFAULT ); if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__ ({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("[webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::scheduleLoad: Resource is being scheduled with the NetworkProcess (priority=%d, existingNetworkResourceLoadIdentifierToResume=%" "ll" "u" ")"), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG66" ) = "[webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::scheduleLoad: Resource is being scheduled with the NetworkProcess (priority=%d, existingNetworkResourceLoadIdentifierToResume=%" "ll" "u" ")"; uint8_t _Alignas(16) __attribute__((uninitialized )) _os_fmt_buf[__builtin_os_log_format_buffer_size("[webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::scheduleLoad: Resource is being scheduled with the NetworkProcess (priority=%d, existingNetworkResourceLoadIdentifierToResume=%" "ll" "u" ")", pageIDForLog(trackingParameters), frameIDForLog (trackingParameters), resourceIDForLog(trackingParameters), static_cast <int>(resourceLoader.request().priority()), existingNetworkResourceLoadIdentifierToResume ? existingNetworkResourceLoadIdentifierToResume->toUInt64 () : 0)]; _os_log_impl(&__dso_handle, _log_tmp, _type_tmp , _os_fmt_str, (uint8_t *)__builtin_os_log_format(_os_fmt_buf , "[webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::scheduleLoad: Resource is being scheduled with the NetworkProcess (priority=%d, existingNetworkResourceLoadIdentifierToResume=%" "ll" "u" ")", pageIDForLog(trackingParameters), frameIDForLog (trackingParameters), resourceIDForLog(trackingParameters), static_cast <int>(resourceLoader.request().priority()), existingNetworkResourceLoadIdentifierToResume ? existingNetworkResourceLoadIdentifierToResume->toUInt64 () : 0), (uint32_t)sizeof(_os_fmt_buf)) clang diagnostic pop ; }); } }) clang diagnostic pop ; |
| 628 | |
| 629 | loadParameters.isInitiatedByDedicatedWorker = resourceLoader.options().initiatorContext == InitiatorContext::Worker && std::holds_alternative<std::monostate>(resourceLoader.options().workerIdentifier); |
| 630 | if (WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::ScheduleResourceLoad(WTF::move(loadParameters), existingNetworkResourceLoadIdentifierToResume), 0) != IPC::Error::NoError) { |
| 631 | WEBLOADERSTRATEGY_RELEASE_LOG_ERROR("scheduleLoad: Unable to schedule resource with the NetworkProcess (priority=%d)", static_cast<int>(resourceLoader.request().priority()))clang diagnostic push
clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = OS_LOG_TYPE_ERROR; if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: Unable to schedule resource with the NetworkProcess (priority=%d)" ), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG67" ) = "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: Unable to schedule resource with the NetworkProcess (priority=%d)" ; uint8_t _Alignas(16) __attribute__((uninitialized)) _os_fmt_buf [__builtin_os_log_format_buffer_size("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: Unable to schedule resource with the NetworkProcess (priority=%d)" , this, &resourceLoader, resourceLoader.frameLoader(), resourceLoader .frame(), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters), static_cast<int> (resourceLoader.request().priority()))]; _os_log_error_impl(& __dso_handle, _log_tmp, _type_tmp, _os_fmt_str, (uint8_t *)__builtin_os_log_format (_os_fmt_buf, "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "scheduleLoad: Unable to schedule resource with the NetworkProcess (priority=%d)" , this, &resourceLoader, resourceLoader.frameLoader(), resourceLoader .frame(), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters), static_cast<int> (resourceLoader.request().priority())), (uint32_t)sizeof(_os_fmt_buf )) clang diagnostic pop ; }); } }) clang diagnostic pop ; |
| 632 | // We probably failed to schedule this load with the NetworkProcess because it had crashed. |
| 633 | // This load will never succeed so we will schedule it to fail asynchronously. |
| 634 | scheduleInternallyFailedLoad(resourceLoader); |
| 635 | return; |
| 636 | } |
| 637 | |
| 638 | auto loader = WebResourceLoader::create(resourceLoader, trackingParameters); |
| 639 | m_webResourceLoaders.set(identifier, WTF::move(loader)); |
| 640 | } |
| 641 | |
| 642 | void WebLoaderStrategy::scheduleInternallyFailedLoad(WebCore::ResourceLoader& resourceLoader) |
| 643 | { |
| 644 | m_internallyFailedResourceLoaders.add(resourceLoader); |
| 645 | m_internallyFailedLoadTimer.startOneShot(0_s); |
| 646 | } |
| 647 | |
| 648 | void WebLoaderStrategy::internallyFailedLoadTimerFired() |
| 649 | { |
| 650 | for (auto& resourceLoader : copyToVector(m_internallyFailedResourceLoaders)) |
| 651 | resourceLoader->didFail(internalError(resourceLoader->url())); |
| 652 | } |
| 653 | |
| 654 | void WebLoaderStrategy::startLocalLoad(WebCore::ResourceLoader& resourceLoader) |
| 655 | { |
| 656 | resourceLoader.start(); |
| 657 | m_webResourceLoaders.set(*resourceLoader.identifier(), WebResourceLoader::create(resourceLoader, { })); |
| 658 | } |
| 659 | |
| 660 | void WebLoaderStrategy::addURLSchemeTaskProxy(WebURLSchemeTaskProxy& task) |
| 661 | { |
| 662 | auto result = m_urlSchemeTasks.add(task.identifier(), task); |
| 663 | ASSERT_UNUSED(result, result.isNewEntry)((void)result); |
| 664 | } |
| 665 | |
| 666 | void WebLoaderStrategy::removeURLSchemeTaskProxy(WebURLSchemeTaskProxy& task) |
| 667 | { |
| 668 | m_urlSchemeTasks.remove(task.identifier()); |
| 669 | } |
| 670 | |
| 671 | void WebLoaderStrategy::remove(ResourceLoader* resourceLoader) |
| 672 | { |
| 673 | ASSERT(resourceLoader)((void)0); |
| 674 | LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::remove, url '%s'", resourceLoader->url().string().utf8().data())((void)0); |
| 675 | |
| 676 | auto identifier = resourceLoader->identifier(); |
| 677 | if (!identifier) { |
| 678 | LOG_ERROR("WebLoaderStrategy removing a ResourceLoader that has no identifier.")((void)0); |
| 679 | return; |
| 680 | } |
| 681 | |
| 682 | if (RefPtr task = m_urlSchemeTasks.take(*identifier).get()) { |
| 683 | ASSERT(!m_internallyFailedResourceLoaders.contains(resourceLoader))((void)0); |
| 684 | task->stopLoading(); |
| 685 | return; |
| 686 | } |
| 687 | |
| 688 | if (m_internallyFailedResourceLoaders.contains(resourceLoader)) { |
| 689 | m_internallyFailedResourceLoaders.remove(resourceLoader); |
| 690 | return; |
| 691 | } |
| 692 | |
| 693 | RefPtr<WebResourceLoader> loader = m_webResourceLoaders.take(*identifier); |
| 694 | // Loader may not be registered if we created it, but haven't scheduled yet (a bundle client can decide to cancel such request via willSendRequest). |
| 695 | if (!loader) |
| 696 | return; |
| 697 | |
| 698 | if (RefPtr networkProcessConnection = WebProcess::singleton().existingNetworkProcessConnection()) |
| 699 | networkProcessConnection->connection().send(Messages::NetworkConnectionToWebProcess::RemoveLoadIdentifier(*identifier), 0); |
| 700 | |
| 701 | // It's possible that this WebResourceLoader might be just about to message back to the NetworkProcess (e.g. ContinueWillSendRequest) |
| 702 | // but there's no point in doing so anymore. |
| 703 | loader->detachFromCoreLoader(); |
| 704 | } |
| 705 | |
| 706 | void WebLoaderStrategy::setDefersLoading(ResourceLoader&, bool) |
| 707 | { |
| 708 | } |
| 709 | |
| 710 | void WebLoaderStrategy::crossOriginRedirectReceived(ResourceLoader*, const URL&) |
| 711 | { |
| 712 | // We handle cross origin redirects entirely within the NetworkProcess. |
| 713 | // We override this call in the WebProcess to make it a no-op. |
| 714 | } |
| 715 | |
| 716 | void WebLoaderStrategy::servePendingRequests(ResourceLoadPriority) |
| 717 | { |
| 718 | // This overrides the base class version. |
| 719 | // We don't need to do anything as this is handled by the network process. |
| 720 | } |
| 721 | |
| 722 | void WebLoaderStrategy::suspendPendingRequests() |
| 723 | { |
| 724 | // Network process does keep requests in pending state. |
| 725 | } |
| 726 | |
| 727 | void WebLoaderStrategy::resumePendingRequests() |
| 728 | { |
| 729 | // Network process does keep requests in pending state. |
| 730 | } |
| 731 | |
| 732 | void WebLoaderStrategy::networkProcessCrashed() |
| 733 | { |
| 734 | WEBLOADERSTRATEGY_RELEASE_LOG_ERROR_BASIC("networkProcessCrashed: failing all pending resource loaders"); |
| 735 | |
| 736 | for (auto& loader : m_webResourceLoaders.values()) { |
| 737 | scheduleInternallyFailedLoad(*protect(loader->resourceLoader())); |
| 738 | loader->detachFromCoreLoader(); |
| 739 | } |
| 740 | |
| 741 | m_webResourceLoaders.clear(); |
| 742 | |
| 743 | auto pingLoadCompletionHandlers = WTF::move(m_pingLoadCompletionHandlers); |
| 744 | for (auto& pingLoadCompletionHandler : pingLoadCompletionHandlers.values()) |
| 745 | pingLoadCompletionHandler(internalError(URL()), { }); |
| 746 | |
| 747 | auto preconnectCompletionHandlers = WTF::move(m_preconnectCompletionHandlers); |
| 748 | for (auto& preconnectCompletionHandler : preconnectCompletionHandlers.values()) |
| 749 | preconnectCompletionHandler(internalError(URL())); |
| 750 | } |
| 751 | |
| 752 | static bool shouldClearReferrerOnHTTPSToHTTPRedirect(LocalFrame* frame) |
| 753 | { |
| 754 | if (frame) { |
| 755 | if (RefPtr document = frame->document()) |
| 756 | return document->referrerPolicy() == ReferrerPolicy::NoReferrerWhenDowngrade; |
| 757 | } |
| 758 | return true; |
| 759 | } |
| 760 | |
| 761 | WebLoaderStrategy::SyncLoadResult WebLoaderStrategy::loadDataURLSynchronously(const ResourceRequest& request) |
| 762 | { |
| 763 | SyncLoadResult result; |
| 764 | auto decodeResult = DataURLDecoder::decode(request.url()); |
| 765 | if (!decodeResult) { |
| 766 | WEBLOADERSTRATEGY_RELEASE_LOG_BASIC("loadDataURLSynchronously: decoding of data failed"); |
| 767 | result.error = internalError(request.url()); |
| 768 | return result; |
| 769 | } |
| 770 | |
| 771 | result.response = ResourceResponse::dataURLResponse(request.url(), decodeResult.value()); |
| 772 | result.data = WTF::move(decodeResult->data); |
| 773 | |
| 774 | return result; |
| 775 | } |
| 776 | |
| 777 | std::optional<WebLoaderStrategy::SyncLoadResult> WebLoaderStrategy::tryLoadingSynchronouslyUsingURLSchemeHandler(FrameLoader& frameLoader, WebCore::ResourceLoaderIdentifier identifier, const ResourceRequest& request) |
| 778 | { |
| 779 | auto* webFrameLoaderClient = dynamicDowncast<WebLocalFrameLoaderClient>(frameLoader.client()); |
| 780 | auto* webFrame = webFrameLoaderClient ? &webFrameLoaderClient->webFrame() : nullptr; |
| 781 | RefPtr webPage = webFrame ? webFrame->page() : nullptr; |
| 782 | if (!webPage) |
| 783 | return std::nullopt; |
| 784 | |
| 785 | RefPtr handler = webPage->urlSchemeHandlerForScheme(request.url().protocol()); |
| 786 | if (!handler) |
| 787 | return std::nullopt; |
| 788 | |
| 789 | LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::scheduleLoad, sync load to URL '%s' will be handled by a UIProcess URL scheme handler.", request.url().string().utf8().data())((void)0); |
| 790 | |
| 791 | SyncLoadResult result; |
| 792 | handler->loadSynchronously(identifier, *webFrame, request, result.response, result.error, result.data); |
| 793 | |
| 794 | return result; |
| 795 | } |
| 796 | |
| 797 | void WebLoaderStrategy::loadResourceSynchronously(FrameLoader& frameLoader, WebCore::ResourceLoaderIdentifier resourceLoadIdentifier, const ResourceRequest& request, ClientCredentialPolicy clientCredentialPolicy, const FetchOptions& options, const HTTPHeaderMap& originalRequestHeaders, ResourceError& error, ResourceResponse& response, Vector<uint8_t>& data) |
| 798 | { |
| 799 | RefPtr webFrameLoaderClient = dynamicDowncast<WebLocalFrameLoaderClient>(frameLoader.client()); |
| 800 | RefPtr webFrame = webFrameLoaderClient ? &webFrameLoaderClient->webFrame() : nullptr; |
| 801 | if (!webFrame) { |
| 802 | ASSERT_NOT_REACHED()((void)0); |
| 803 | return; |
| 804 | } |
| 805 | RefPtr webPage = webFrame ? webFrame->page() : nullptr; |
| 806 | if (!webPage) { |
| 807 | ASSERT_NOT_REACHED()((void)0); |
| 808 | return; |
| 809 | } |
| 810 | RefPtr page = webPage ? webPage->corePage() : nullptr; |
| 811 | if (!page) { |
| 812 | ASSERT_NOT_REACHED()((void)0); |
| 813 | return; |
| 814 | } |
| 815 | |
| 816 | auto webPageProxyID = webPage->webPageProxyIdentifier(); |
| 817 | auto pageID = webPage->identifier(); |
| 818 | auto frameID = webFrame->frameID(); |
| 819 | |
| 820 | [[maybe_unused]] WebResourceLoader::TrackingParameters trackingParameters { |
| 821 | webPageProxyID, |
| 822 | pageID, |
| 823 | frameID, |
| 824 | resourceLoadIdentifier |
| 825 | }; |
| 826 | |
| 827 | RefPtr document = frameLoader.frame().document(); |
| 828 | if (!document) { |
| 829 | WEBLOADERSTRATEGY_WITH_FRAMELOADER_RELEASE_LOG_ERROR("loadResourceSynchronously: no document")clang diagnostic push
clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = OS_LOG_TYPE_ERROR; if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "loadResourceSynchronously: no document"), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG68" ) = "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "loadResourceSynchronously: no document"; uint8_t _Alignas(16 ) __attribute__((uninitialized)) _os_fmt_buf[__builtin_os_log_format_buffer_size ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "loadResourceSynchronously: no document", this, nullptr, & frameLoader, &frameLoader.frame(), pageIDForLog(trackingParameters ), frameIDForLog(trackingParameters), resourceIDForLog(trackingParameters ))]; _os_log_error_impl(&__dso_handle, _log_tmp, _type_tmp , _os_fmt_str, (uint8_t *)__builtin_os_log_format(_os_fmt_buf , "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "loadResourceSynchronously: no document", this, nullptr, & frameLoader, &frameLoader.frame(), pageIDForLog(trackingParameters ), frameIDForLog(trackingParameters), resourceIDForLog(trackingParameters )), (uint32_t)sizeof(_os_fmt_buf)) clang diagnostic pop ; }); } }) clang diagnostic pop ; |
| 830 | error = internalError(request.url()); |
| 831 | return; |
| 832 | } |
| 833 | |
| 834 | if (request.url().protocolIsData()) { |
| 835 | WEBLOADERSTRATEGY_WITH_FRAMELOADER_RELEASE_LOG_ERROR("loadResourceSynchronously: URL will be loaded as data")clang diagnostic push
clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = OS_LOG_TYPE_ERROR; if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "loadResourceSynchronously: URL will be loaded as data"), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG69" ) = "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "loadResourceSynchronously: URL will be loaded as data"; uint8_t _Alignas(16) __attribute__((uninitialized)) _os_fmt_buf[__builtin_os_log_format_buffer_size ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "loadResourceSynchronously: URL will be loaded as data", this , nullptr, &frameLoader, &frameLoader.frame(), pageIDForLog (trackingParameters), frameIDForLog(trackingParameters), resourceIDForLog (trackingParameters))]; _os_log_error_impl(&__dso_handle, _log_tmp, _type_tmp, _os_fmt_str, (uint8_t *)__builtin_os_log_format (_os_fmt_buf, "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "loadResourceSynchronously: URL will be loaded as data", this , nullptr, &frameLoader, &frameLoader.frame(), pageIDForLog (trackingParameters), frameIDForLog(trackingParameters), resourceIDForLog (trackingParameters)), (uint32_t)sizeof(_os_fmt_buf)) clang diagnostic pop ; }); } }) clang diagnostic pop ; |
| 836 | auto syncLoadResult = loadDataURLSynchronously(request); |
| 837 | error = WTF::move(syncLoadResult.error); |
| 838 | response = WTF::move(syncLoadResult.response); |
| 839 | data = WTF::move(syncLoadResult.data); |
| 840 | return; |
| 841 | } |
| 842 | |
| 843 | if (auto syncLoadResult = tryLoadingSynchronouslyUsingURLSchemeHandler(frameLoader, resourceLoadIdentifier, request)) { |
| 844 | WEBLOADERSTRATEGY_WITH_FRAMELOADER_RELEASE_LOG_ERROR("loadResourceSynchronously: failed calling tryLoadingSynchronouslyUsingURLSchemeHandler (error=%d)", syncLoadResult->error.errorCode())clang diagnostic push
clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = OS_LOG_TYPE_ERROR; if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "loadResourceSynchronously: failed calling tryLoadingSynchronouslyUsingURLSchemeHandler (error=%d)" ), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG70" ) = "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "loadResourceSynchronously: failed calling tryLoadingSynchronouslyUsingURLSchemeHandler (error=%d)" ; uint8_t _Alignas(16) __attribute__((uninitialized)) _os_fmt_buf [__builtin_os_log_format_buffer_size("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "loadResourceSynchronously: failed calling tryLoadingSynchronouslyUsingURLSchemeHandler (error=%d)" , this, nullptr, &frameLoader, &frameLoader.frame(), pageIDForLog (trackingParameters), frameIDForLog(trackingParameters), resourceIDForLog (trackingParameters), syncLoadResult->error.errorCode())]; _os_log_error_impl(&__dso_handle, _log_tmp, _type_tmp, _os_fmt_str , (uint8_t *)__builtin_os_log_format(_os_fmt_buf, "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "loadResourceSynchronously: failed calling tryLoadingSynchronouslyUsingURLSchemeHandler (error=%d)" , this, nullptr, &frameLoader, &frameLoader.frame(), pageIDForLog (trackingParameters), frameIDForLog(trackingParameters), resourceIDForLog (trackingParameters), syncLoadResult->error.errorCode()), ( uint32_t)sizeof(_os_fmt_buf)) clang diagnostic pop ; }); } }) clang diagnostic pop ; |
| 845 | error = WTF::move(syncLoadResult->error); |
| 846 | response = WTF::move(syncLoadResult->response); |
| 847 | data = WTF::move(syncLoadResult->data); |
| 848 | return; |
| 849 | } |
| 850 | |
| 851 | NetworkResourceLoadParameters loadParameters { |
| 852 | webPageProxyID, |
| 853 | pageID, |
| 854 | frameID, |
| 855 | request |
| 856 | }; |
| 857 | loadParameters.createSandboxExtensionHandlesIfNecessary(); |
| 858 | |
| 859 | loadParameters.identifier = resourceLoadIdentifier; |
| 860 | loadParameters.parentPID = legacyPresentingApplicationPID(); |
| 861 | loadParameters.contentSniffingPolicy = ContentSniffingPolicy::SniffContent; |
| 862 | loadParameters.contentEncodingSniffingPolicy = ContentEncodingSniffingPolicy::Default; |
| 863 | loadParameters.storedCredentialsPolicy = options.credentials == FetchOptions::Credentials::Omit ? StoredCredentialsPolicy::DoNotUse : StoredCredentialsPolicy::Use; |
| 864 | loadParameters.clientCredentialPolicy = clientCredentialPolicy; |
| 865 | loadParameters.shouldClearReferrerOnHTTPSToHTTPRedirect = shouldClearReferrerOnHTTPSToHTTPRedirect(webFrame ? protect(webFrame->coreLocalFrame()).get() : nullptr); |
| 866 | loadParameters.shouldRestrictHTTPResponseAccess = shouldPerformSecurityChecks(); |
| 867 | |
| 868 | loadParameters.options = options; |
| 869 | loadParameters.sourceOrigin = document->securityOrigin(); |
| 870 | loadParameters.topOrigin = document->topOrigin(); |
| 871 | if (!document->shouldBypassMainWorldContentSecurityPolicy()) { |
| 872 | if (CheckedPtr contentSecurityPolicy = document->contentSecurityPolicy()) |
| 873 | loadParameters.cspResponseHeaders = contentSecurityPolicy->responseHeaders(); |
| 874 | } |
| 875 | loadParameters.originalRequestHeaders = originalRequestHeaders; |
| 876 | #if ENABLE(APP_BOUND_DOMAINS)(defined ENABLE_APP_BOUND_DOMAINS && ENABLE_APP_BOUND_DOMAINS ) |
| 877 | if (webFrame) |
| 878 | loadParameters.isNavigatingToAppBoundDomain = webFrame->isTopFrameNavigatingToAppBoundDomain(); |
| 879 | #endif |
| 880 | addParametersShared(protect(webFrame->coreLocalFrame()).get(), loadParameters); |
| 881 | |
| 882 | data.shrink(0); |
| 883 | |
| 884 | HangDetectionDisabler hangDetectionDisabler; |
| 885 | IPC::UnboundedSynchronousIPCScope unboundedSynchronousIPCScope; |
| 886 | |
| 887 | auto sendResult = WebProcess::singleton().ensureNetworkProcessConnection().connection().sendSync(Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad(WTF::move(loadParameters)), 0); |
| 888 | if (!sendResult.succeeded()) { |
| 889 | WEBLOADERSTRATEGY_WITH_FRAMELOADER_RELEASE_LOG_ERROR("loadResourceSynchronously: failed sending synchronous network process message %" PUBLIC_LOG_STRING, IPC::errorAsString(sendResult.error()).characters())clang diagnostic push
clang diagnostic ignored "-Wunknown-warning-option" clang diagnostic ignored "-Wunsafe-buffer-usage" clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call" clang diagnostic ignored "-Wunsafe-buffer-usage-in-format-attr-call" [[clang ::suppress]] __extension__({ os_log_t _log_tmp = (WebKit2LogNetwork .osLogChannel); os_log_type_t _type_tmp = OS_LOG_TYPE_ERROR; if (os_log_type_enabled(_log_tmp, _type_tmp)) { __extension__({ clang diagnostic push clang diagnostic ignored "-Wvla" clang diagnostic error "-Wformat" _Static_assert(__builtin_constant_p ("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "loadResourceSynchronously: failed sending synchronous network process message %" "{public}s"), "format/label/description argument must be a string constant" ); __attribute__((section("__TEXT,__oslogstring,cstring_literals" ),internal_linkage)) static const char _os_fmt_str[] __asm("LOS_LOG71" ) = "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "loadResourceSynchronously: failed sending synchronous network process message %" "{public}s"; uint8_t _Alignas(16) __attribute__((uninitialized )) _os_fmt_buf[__builtin_os_log_format_buffer_size("%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "loadResourceSynchronously: failed sending synchronous network process message %" "{public}s", this, nullptr, &frameLoader, &frameLoader .frame(), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters), IPC::errorAsString(sendResult .error()).characters())]; _os_log_error_impl(&__dso_handle , _log_tmp, _type_tmp, _os_fmt_str, (uint8_t *)__builtin_os_log_format (_os_fmt_buf, "%p - [resourceLoader=%p, frameLoader=%p, frame=%p, webPageID=%" "ll" "u" ", frameID=%" "ll" "u" ", resourceID=%" "ll" "u" "] WebLoaderStrategy::" "loadResourceSynchronously: failed sending synchronous network process message %" "{public}s", this, nullptr, &frameLoader, &frameLoader .frame(), pageIDForLog(trackingParameters), frameIDForLog(trackingParameters ), resourceIDForLog(trackingParameters), IPC::errorAsString(sendResult .error()).characters()), (uint32_t)sizeof(_os_fmt_buf)) clang diagnostic pop ; }); } }) clang diagnostic pop ; |
| 890 | if (page) |
| 891 | protect(page->diagnosticLoggingClient())->logDiagnosticMessage(WebCore::DiagnosticLoggingKeys::internalErrorKey(), WebCore::DiagnosticLoggingKeys::synchronousMessageFailedKey(), WebCore::ShouldSample::No); |
| 892 | response = ResourceResponse(); |
| 893 | error = internalError(request.url()); |
| 894 | } else |
| 895 | std::tie(error, response, data) = sendResult.takeReply(); |
| 896 | } |
| 897 | |
| 898 | void WebLoaderStrategy::pageLoadCompleted(Page& page) |
| 899 | { |
| 900 | if (RefPtr networkProcessConnection = WebProcess::singleton().existingNetworkProcessConnection()) |
| 901 | networkProcessConnection->connection().send(Messages::NetworkConnectionToWebProcess::PageLoadCompleted(WebPage::fromCorePage(page)->identifier()), 0); |
| 902 | } |
| 903 | |
| 904 | void WebLoaderStrategy::browsingContextRemoved(LocalFrame& frame) |
| 905 | { |
| 906 | ASSERT(frame.page())((void)0); |
| 907 | RefPtr networkProcessConnection = WebProcess::singleton().existingNetworkProcessConnection(); |
| 908 | if (!networkProcessConnection) |
| 909 | return; |
| 910 | |
| 911 | Ref page = *WebPage::fromCorePage(*protect(frame.page())); |
| 912 | networkProcessConnection->connection().send(Messages::NetworkConnectionToWebProcess::BrowsingContextRemoved(page->webPageProxyIdentifier(), page->identifier(), WebFrame::fromCoreFrame(frame)->frameID()), 0); |
| 913 | } |
| 914 | |
| 915 | void WebLoaderStrategy::startPingLoad(LocalFrame& frame, ResourceRequest& request, const HTTPHeaderMap& originalRequestHeaders, const FetchOptions& options, ContentSecurityPolicyImposition policyCheck, PingLoadCompletionHandler&& completionHandler) |
| 916 | { |
| 917 | RefPtr webFrame = WebFrame::fromCoreFrame(frame); |
| 918 | RefPtr document = frame.document(); |
| 919 | if (!document || !webFrame) { |
| 920 | if (completionHandler) |
| 921 | completionHandler(internalError(request.url()), { }); |
| 922 | return; |
| 923 | } |
| 924 | |
| 925 | RefPtr webPage = webFrame->page(); |
| 926 | if (!webPage) { |
| 927 | if (completionHandler) |
| 928 | completionHandler(internalError(request.url()), { }); |
| 929 | return; |
| 930 | } |
| 931 | |
| 932 | NetworkResourceLoadParameters loadParameters { |
| 933 | webPage->webPageProxyIdentifier(), |
| 934 | webPage->identifier(), |
| 935 | webFrame->frameID(), |
| 936 | request |
| 937 | }; |
| 938 | loadParameters.createSandboxExtensionHandlesIfNecessary(); |
| 939 | |
| 940 | loadParameters.identifier = WebCore::ResourceLoaderIdentifier::generate(); |
| 941 | loadParameters.sourceOrigin = document->securityOrigin(); |
| 942 | loadParameters.topOrigin = document->topOrigin(); |
| 943 | loadParameters.parentPID = legacyPresentingApplicationPID(); |
| 944 | loadParameters.storedCredentialsPolicy = options.credentials == FetchOptions::Credentials::Omit ? StoredCredentialsPolicy::DoNotUse : StoredCredentialsPolicy::Use; |
| 945 | loadParameters.options = options; |
| 946 | loadParameters.originalRequestHeaders = originalRequestHeaders; |
| 947 | loadParameters.shouldClearReferrerOnHTTPSToHTTPRedirect = shouldClearReferrerOnHTTPSToHTTPRedirect(&frame); |
| 948 | loadParameters.shouldRestrictHTTPResponseAccess = shouldPerformSecurityChecks(); |
| 949 | if (policyCheck == ContentSecurityPolicyImposition::DoPolicyCheck && !document->shouldBypassMainWorldContentSecurityPolicy()) { |
| 950 | if (CheckedPtr contentSecurityPolicy = document->contentSecurityPolicy()) |
| 951 | loadParameters.cspResponseHeaders = contentSecurityPolicy->responseHeaders(); |
| 952 | } |
| 953 | addParametersShared(&frame, loadParameters); |
| 954 | #if ENABLE(APP_BOUND_DOMAINS)(defined ENABLE_APP_BOUND_DOMAINS && ENABLE_APP_BOUND_DOMAINS ) |
| 955 | loadParameters.isNavigatingToAppBoundDomain = webFrame->isTopFrameNavigatingToAppBoundDomain(); |
| 956 | #endif |
| 957 | |
| 958 | loadParameters.frameURL = document->url(); |
| 959 | #if ENABLE(CONTENT_EXTENSIONS)(defined 1 && 1) || (ENABLE(CONTENT_FILTERING)(defined 1 && 1) && HAVE(WEBCONTENTRESTRICTIONS)(defined HAVE_WEBCONTENTRESTRICTIONS && HAVE_WEBCONTENTRESTRICTIONS )) |
| 960 | if (RefPtr page = document->page()) |
| 961 | loadParameters.mainDocumentURL = page->mainFrameURL(); |
| 962 | #endif |
| 963 | #if ENABLE(CONTENT_EXTENSIONS)(defined 1 && 1) |
| 964 | // FIXME: Instead of passing userContentControllerIdentifier, we should just pass webPageId to NetworkProcess. |
| 965 | loadParameters.userContentControllerIdentifier = webPage->userContentControllerIdentifier(); |
| 966 | #endif |
| 967 | |
| 968 | if (completionHandler) |
| 969 | m_pingLoadCompletionHandlers.add(*loadParameters.identifier, WTF::move(completionHandler)); |
| 970 | |
| 971 | WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::LoadPing { WTF::move(loadParameters) }, 0); |
| 972 | } |
| 973 | |
| 974 | void WebLoaderStrategy::didFinishPingLoad(WebCore::ResourceLoaderIdentifier pingLoadIdentifier, ResourceError&& error, ResourceResponse&& response) |
| 975 | { |
| 976 | if (auto completionHandler = m_pingLoadCompletionHandlers.take(pingLoadIdentifier)) |
| 977 | completionHandler(WTF::move(error), WTF::move(response)); |
| 978 | } |
| 979 | |
| 980 | void WebLoaderStrategy::preconnectTo(FrameLoader& frameLoader, ResourceRequest&& request, StoredCredentialsPolicy storedCredentialsPolicy, ShouldPreconnectAsFirstParty shouldPreconnectAsFirstParty, PreconnectCompletionHandler&& completionHandler) |
| 981 | { |
| 982 | RefPtr webFrame = WebProcess::singleton().webFrame(frameLoader.frameID()); |
| 983 | if (!webFrame) |
| 984 | return completionHandler(internalError(request.url())); |
| 985 | |
| 986 | RefPtr webPage = webFrame->page(); |
| 987 | if (!webPage) |
| 988 | return completionHandler(internalError(request.url())); |
| 989 | |
| 990 | preconnectTo(WTF::move(request), *webPage, *webFrame, storedCredentialsPolicy, shouldPreconnectAsFirstParty, WTF::move(completionHandler)); |
| 991 | } |
| 992 | |
| 993 | void WebLoaderStrategy::preconnectTo(WebCore::ResourceRequest&& request, WebPage& webPage, WebFrame& webFrame, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, ShouldPreconnectAsFirstParty shouldPreconnectAsFirstParty, PreconnectCompletionHandler&& completionHandler) |
| 994 | { |
| 995 | if (RefPtr corePage = webPage.corePage(); corePage && !corePage->allowsLoadFromURL(request.url(), MainFrameMainResource::No)) { |
| 996 | if (completionHandler) |
| 997 | completionHandler({ }); |
| 998 | return; |
| 999 | } |
| 1000 | |
| 1001 | RefPtr mainFrame = dynamicDowncast<WebCore::LocalFrame>(webPage.mainFrame()); |
| 1002 | if (RefPtr document = mainFrame ? mainFrame->document() : nullptr) { |
| 1003 | if (shouldPreconnectAsFirstParty == ShouldPreconnectAsFirstParty::Yes) |
| 1004 | request.setFirstPartyForCookies(request.url()); |
| 1005 | else |
| 1006 | request.setFirstPartyForCookies(document->firstPartyForCookies()); |
| 1007 | if (RefPtr loader = document->loader()) |
| 1008 | request.setIsAppInitiated(loader->lastNavigationWasAppInitiated()); |
| 1009 | } |
| 1010 | |
| 1011 | NetworkResourceLoadParameters parameters { |
| 1012 | webPage.webPageProxyIdentifier(), |
| 1013 | webPage.identifier(), |
| 1014 | webFrame.frameID(), |
| 1015 | WTF::move(request) |
| 1016 | }; |
| 1017 | parameters.createSandboxExtensionHandlesIfNecessary(); |
| 1018 | |
| 1019 | if (parameters.request.httpUserAgent().isEmpty()) { |
| 1020 | // FIXME: we add user-agent to the preconnect request because otherwise the preconnect |
| 1021 | // gets thrown away by CFNetwork when using an HTTPS proxy (<rdar://problem/59434166>). |
| 1022 | String webPageUserAgent = webPage.userAgent(parameters.request.url()); |
| 1023 | if (!webPageUserAgent.isEmpty()) |
| 1024 | parameters.request.setHTTPUserAgent(webPageUserAgent); |
| 1025 | } |
| 1026 | parameters.identifier = WebCore::ResourceLoaderIdentifier::generate(); |
| 1027 | parameters.parentPID = legacyPresentingApplicationPID(); |
| 1028 | parameters.storedCredentialsPolicy = storedCredentialsPolicy; |
| 1029 | parameters.shouldPreconnectOnly = PreconnectOnly::Yes; |
| 1030 | parameters.shouldRestrictHTTPResponseAccess = shouldPerformSecurityChecks(); |
| 1031 | // FIXME: Use the proper destination once all fetch options are passed. |
| 1032 | parameters.options.destination = FetchOptions::Destination::EmptyString; |
| 1033 | #if ENABLE(APP_BOUND_DOMAINS)(defined ENABLE_APP_BOUND_DOMAINS && ENABLE_APP_BOUND_DOMAINS ) |
| 1034 | parameters.isNavigatingToAppBoundDomain = webFrame.isTopFrameNavigatingToAppBoundDomain(); |
| 1035 | #endif |
| 1036 | if (RefPtr loader = policySourceDocumentLoaderForFrame(*protect(webFrame.coreLocalFrame()))) |
| 1037 | parameters.advancedPrivacyProtections = loader->advancedPrivacyProtections(); |
| 1038 | |
| 1039 | std::optional<WebCore::ResourceLoaderIdentifier> preconnectionIdentifier; |
| 1040 | if (completionHandler) { |
| 1041 | preconnectionIdentifier = parameters.identifier; |
| 1042 | auto addResult = m_preconnectCompletionHandlers.add(*preconnectionIdentifier, WTF::move(completionHandler)); |
| 1043 | ASSERT_UNUSED(addResult, addResult.isNewEntry)((void)addResult); |
| 1044 | } |
| 1045 | |
| 1046 | // FIXME: Use sendWithAsyncReply instead of preconnectionIdentifier |
| 1047 | // FIXME: don't use WebCore::ResourceLoaderIdentifier for a preconnection identifier, too. It should have its own type. |
| 1048 | WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::PreconnectTo(preconnectionIdentifier, WTF::move(parameters)), 0); |
| 1049 | } |
| 1050 | |
| 1051 | void WebLoaderStrategy::didFinishPreconnection(WebCore::ResourceLoaderIdentifier preconnectionIdentifier, ResourceError&& error) |
| 1052 | { |
| 1053 | if (auto completionHandler = m_preconnectCompletionHandlers.take(preconnectionIdentifier)) |
| 1054 | completionHandler(WTF::move(error)); |
| 1055 | } |
| 1056 | |
| 1057 | bool WebLoaderStrategy::isOnLine() const |
| 1058 | { |
| 1059 | return m_isOnLine; |
| 1060 | } |
| 1061 | |
| 1062 | void WebLoaderStrategy::addOnlineStateChangeListener(Function<void(bool)>&& listener) |
| 1063 | { |
| 1064 | WebProcess::singleton().ensureNetworkProcessConnection(); |
| 1065 | m_onlineStateChangeListeners.append(WTF::move(listener)); |
| 1066 | } |
| 1067 | |
| 1068 | void WebLoaderStrategy::isResourceLoadFinished(CachedResource& resource, CompletionHandler<void(bool)>&& callback) |
| 1069 | { |
| 1070 | if (!resource.loader()) { |
| 1071 | callback(true); |
| 1072 | return; |
| 1073 | } |
| 1074 | |
| 1075 | if (!WebProcess::singleton().existingNetworkProcessConnection()) { |
| 1076 | callback(true); |
| 1077 | return; |
| 1078 | } |
| 1079 | |
| 1080 | WebProcess::singleton().ensureNetworkProcessConnection().connection().sendWithAsyncReply(Messages::NetworkConnectionToWebProcess::IsResourceLoadFinished(*resource.loader()->identifier()), WTF::move(callback), 0); |
| 1081 | } |
| 1082 | |
| 1083 | void WebLoaderStrategy::setOnLineState(bool isOnLine) |
| 1084 | { |
| 1085 | if (m_isOnLine == isOnLine) |
| 1086 | return; |
| 1087 | |
| 1088 | m_isOnLine = isOnLine; |
| 1089 | for (auto& listener : m_onlineStateChangeListeners) |
| 1090 | listener(isOnLine); |
| 1091 | } |
| 1092 | |
| 1093 | void WebLoaderStrategy::setCaptureExtraNetworkLoadMetricsEnabled(bool enabled) |
| 1094 | { |
| 1095 | WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::SetCaptureExtraNetworkLoadMetricsEnabled(enabled), 0); |
| 1096 | } |
| 1097 | |
| 1098 | ResourceResponse WebLoaderStrategy::responseFromResourceLoadIdentifier(ResourceLoaderIdentifier resourceLoadIdentifier) |
| 1099 | { |
| 1100 | auto sendResult = WebProcess::singleton().ensureNetworkProcessConnection().connection().sendSync(Messages::NetworkConnectionToWebProcess::GetNetworkLoadInformationResponse { resourceLoadIdentifier }, 0); |
| 1101 | auto [response] = sendResult.takeReplyOr(ResourceResponse { }); |
| 1102 | return response; |
| 1103 | } |
| 1104 | |
| 1105 | Vector<NetworkTransactionInformation> WebLoaderStrategy::intermediateLoadInformationFromResourceLoadIdentifier(WebCore::ResourceLoaderIdentifier resourceLoadIdentifier) |
| 1106 | { |
| 1107 | auto sendResult = WebProcess::singleton().ensureNetworkProcessConnection().connection().sendSync(Messages::NetworkConnectionToWebProcess::GetNetworkLoadIntermediateInformation { resourceLoadIdentifier }, 0); |
| 1108 | auto [information] = sendResult.takeReplyOr(Vector<NetworkTransactionInformation> { }); |
| 1109 | return information; |
| 1110 | } |
| 1111 | |
| 1112 | NetworkLoadMetrics WebLoaderStrategy::networkMetricsFromResourceLoadIdentifier(WebCore::ResourceLoaderIdentifier resourceLoadIdentifier) |
| 1113 | { |
| 1114 | auto sendResult = WebProcess::singleton().ensureNetworkProcessConnection().connection().sendSync(Messages::NetworkConnectionToWebProcess::TakeNetworkLoadInformationMetrics { resourceLoadIdentifier }, 0); |
| 1115 | auto [networkMetrics] = sendResult.takeReplyOr(NetworkLoadMetrics { }); |
| 1116 | return networkMetrics; |
| 1117 | } |
| 1118 | |
| 1119 | bool WebLoaderStrategy::shouldPerformSecurityChecks() const |
| 1120 | { |
| 1121 | return true; |
| 1122 | } |
| 1123 | |
| 1124 | bool WebLoaderStrategy::havePerformedSecurityChecks(const ResourceResponse& response) const |
| 1125 | { |
| 1126 | if (!shouldPerformSecurityChecks()) |
| 1127 | return false; |
| 1128 | switch (response.source()) { |
| 1129 | case ResourceResponse::Source::DOMCache: |
| 1130 | case ResourceResponse::Source::LegacyApplicationCachePlaceholder: |
| 1131 | case ResourceResponse::Source::MemoryCache: |
| 1132 | case ResourceResponse::Source::MemoryCacheAfterValidation: |
| 1133 | case ResourceResponse::Source::ServiceWorker: |
| 1134 | case ResourceResponse::Source::InspectorOverride: |
| 1135 | return false; |
| 1136 | case ResourceResponse::Source::DiskCache: |
| 1137 | case ResourceResponse::Source::DiskCacheAfterValidation: |
| 1138 | case ResourceResponse::Source::Network: |
| 1139 | case ResourceResponse::Source::Unknown: |
| 1140 | return true; |
| 1141 | } |
| 1142 | ASSERT_NOT_REACHED()((void)0); |
| 1143 | return false; |
| 1144 | } |
| 1145 | |
| 1146 | void WebLoaderStrategy::setResourceLoadSchedulingMode(WebCore::Page& page, WebCore::LoadSchedulingMode mode) |
| 1147 | { |
| 1148 | auto& connection = WebProcess::singleton().ensureNetworkProcessConnection().connection(); |
| 1149 | connection.send(Messages::NetworkConnectionToWebProcess::SetResourceLoadSchedulingMode(WebPage::fromCorePage(page)->identifier(), mode), 0); |
| 1150 | } |
| 1151 | |
| 1152 | void WebLoaderStrategy::prioritizeResourceLoads(const Vector<Ref<WebCore::SubresourceLoader>>& resources) |
| 1153 | { |
| 1154 | auto identifiers = resources.map([](auto& loader) { |
| 1155 | return *loader->identifier(); |
| 1156 | }); |
| 1157 | |
| 1158 | auto& connection = WebProcess::singleton().ensureNetworkProcessConnection().connection(); |
| 1159 | connection.send(Messages::NetworkConnectionToWebProcess::PrioritizeResourceLoads(identifiers), 0); |
| 1160 | } |
| 1161 | |
| 1162 | ResourceError WebLoaderStrategy::cancelledError(const ResourceRequest& request) const |
| 1163 | { |
| 1164 | return WebKit::cancelledError(request); |
| 1165 | } |
| 1166 | |
| 1167 | ResourceError WebLoaderStrategy::blockedError(const ResourceRequest& request) const |
| 1168 | { |
| 1169 | return WebKit::blockedError(request); |
| 1170 | } |
| 1171 | |
| 1172 | ResourceError WebLoaderStrategy::blockedByContentBlockerError(const ResourceRequest& request) const |
| 1173 | { |
| 1174 | return WebKit::blockedByContentBlockerError(request); |
| 1175 | } |
| 1176 | |
| 1177 | ResourceError WebLoaderStrategy::cannotShowURLError(const ResourceRequest& request) const |
| 1178 | { |
| 1179 | return WebKit::cannotShowURLError(request); |
| 1180 | } |
| 1181 | |
| 1182 | ResourceError WebLoaderStrategy::interruptedForPolicyChangeError(const ResourceRequest& request) const |
| 1183 | { |
| 1184 | return WebKit::interruptedForPolicyChangeError(request); |
| 1185 | } |
| 1186 | |
| 1187 | #if ENABLE(CONTENT_FILTERING)(defined 1 && 1) |
| 1188 | ResourceError WebLoaderStrategy::blockedByContentFilterError(const ResourceRequest& request) const |
| 1189 | { |
| 1190 | return WebKit::blockedByContentFilterError(request); |
| 1191 | } |
| 1192 | #endif |
| 1193 | |
| 1194 | ResourceError WebLoaderStrategy::cannotShowMIMETypeError(const ResourceResponse& response) const |
| 1195 | { |
| 1196 | return WebKit::cannotShowMIMETypeError(response); |
| 1197 | } |
| 1198 | |
| 1199 | ResourceError WebLoaderStrategy::fileDoesNotExistError(const ResourceResponse& response) const |
| 1200 | { |
| 1201 | return WebKit::fileDoesNotExistError(response); |
| 1202 | } |
| 1203 | |
| 1204 | ResourceError WebLoaderStrategy::httpsUpgradeRedirectLoopError(const ResourceRequest& request) const |
| 1205 | { |
| 1206 | return WebKit::httpsUpgradeRedirectLoopError(request); |
| 1207 | } |
| 1208 | |
| 1209 | ResourceError WebLoaderStrategy::httpNavigationWithHTTPSOnlyError(const ResourceRequest& request) const |
| 1210 | { |
| 1211 | return WebKit::httpNavigationWithHTTPSOnlyError(request); |
| 1212 | } |
| 1213 | |
| 1214 | ResourceError WebLoaderStrategy::pluginWillHandleLoadError(const ResourceResponse& response) const |
| 1215 | { |
| 1216 | return WebKit::pluginWillHandleLoadError(response); |
| 1217 | } |
| 1218 | |
| 1219 | } // namespace WebKit |
| 1220 | |
| 1221 | #undef WEBLOADERSTRATEGY_RELEASE_LOG_BASIC |
| 1222 | #undef WEBLOADERSTRATEGY_RELEASE_LOG_ERROR_BASIC |