Diff
Modified: trunk/Source/WebCore/ChangeLog (251487 => 251488)
--- trunk/Source/WebCore/ChangeLog 2019-10-23 19:25:01 UTC (rev 251487)
+++ trunk/Source/WebCore/ChangeLog 2019-10-23 19:34:32 UTC (rev 251488)
@@ -1,3 +1,38 @@
+2019-10-23 Andy Estes <[email protected]>
+
+ [Quick Look] Rename PreviewLoader{,Client} to LegacyPreviewLoader{,Client}
+ https://bugs.webkit.org/show_bug.cgi?id=203306
+
+ Reviewed by Tim Horton.
+
+ * SourcesCocoa.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * loader/EmptyClients.cpp:
+ * loader/EmptyFrameLoaderClient.h:
+ * loader/FrameLoaderClient.h:
+ * loader/ResourceLoader.cpp:
+ * loader/ResourceLoader.h:
+ * loader/SubresourceLoader.cpp:
+ (WebCore::SubresourceLoader::didReceiveResponse):
+ * loader/ios/LegacyPreviewLoader.h: Renamed from Source/WebCore/loader/ios/PreviewLoader.h.
+ * loader/ios/LegacyPreviewLoader.mm: Renamed from Source/WebCore/loader/ios/PreviewLoader.mm.
+ (testingClient):
+ (emptyClient):
+ (WebCore::LegacyPreviewLoader::LegacyPreviewLoader):
+ (WebCore::LegacyPreviewLoader::~LegacyPreviewLoader):
+ (WebCore::LegacyPreviewLoader::create):
+ (WebCore::LegacyPreviewLoader::didReceiveResponse):
+ (WebCore::LegacyPreviewLoader::didReceiveData):
+ (WebCore::LegacyPreviewLoader::didReceiveBuffer):
+ (WebCore::LegacyPreviewLoader::didFinishLoading):
+ (WebCore::LegacyPreviewLoader::didFail):
+ (WebCore::LegacyPreviewLoader::setClientForTesting):
+ * platform/network/ios/LegacyPreviewLoaderClient.h: Renamed from Source/WebCore/platform/network/ios/PreviewLoaderClient.h.
+ * testing/Internals.cpp:
+ (WebCore::Internals::resetToConsistentState):
+ (WebCore::Internals::setQuickLookPassword):
+ * testing/MockPreviewLoaderClient.h:
+
2019-10-23 Antti Koivisto <[email protected]>
[LFC] LayoutState should have out-of-line destructor
Modified: trunk/Source/WebCore/SourcesCocoa.txt (251487 => 251488)
--- trunk/Source/WebCore/SourcesCocoa.txt 2019-10-23 19:25:01 UTC (rev 251487)
+++ trunk/Source/WebCore/SourcesCocoa.txt 2019-10-23 19:34:32 UTC (rev 251488)
@@ -116,7 +116,7 @@
loader/cocoa/DiskCacheMonitorCocoa.mm
loader/cocoa/SubresourceLoaderCocoa.mm
-loader/ios/PreviewLoader.mm
+loader/ios/LegacyPreviewLoader.mm
loader/mac/DocumentLoaderMac.cpp
loader/mac/LoaderNSURLExtras.mm
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (251487 => 251488)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2019-10-23 19:25:01 UTC (rev 251487)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2019-10-23 19:34:32 UTC (rev 251488)
@@ -2893,7 +2893,7 @@
A104F24414C71F7A009E2C23 /* CachedSVGDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = A104F24214C71F7A009E2C23 /* CachedSVGDocument.h */; settings = {ATTRIBUTES = (Private, ); }; };
A10BB5851484E3A700B2E87A /* RenderSVGRect.h in Headers */ = {isa = PBXBuildFile; fileRef = A10BB5831484E3A700B2E87A /* RenderSVGRect.h */; };
A10BB58B1484E3B300B2E87A /* RenderSVGShape.h in Headers */ = {isa = PBXBuildFile; fileRef = A10BB5891484E3B300B2E87A /* RenderSVGShape.h */; };
- A10DBF4718F92317000D70C6 /* PreviewLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A10DBF4618F92317000D70C6 /* PreviewLoaderClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ A10DBF4718F92317000D70C6 /* LegacyPreviewLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A10DBF4618F92317000D70C6 /* LegacyPreviewLoaderClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
A10DC76B14747BAB005E2471 /* StyleGridData.h in Headers */ = {isa = PBXBuildFile; fileRef = A10DC76914747BAB005E2471 /* StyleGridData.h */; settings = {ATTRIBUTES = (Private, ); }; };
A110DB9B14F5DF7700A03B93 /* StyleGridItemData.h in Headers */ = {isa = PBXBuildFile; fileRef = A110DB9A14F5DF7700A03B93 /* StyleGridItemData.h */; settings = {ATTRIBUTES = (Private, ); }; };
A113E02823318293009C33A0 /* PaymentSessionError.h in Headers */ = {isa = PBXBuildFile; fileRef = A113E02723318293009C33A0 /* PaymentSessionError.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -2973,7 +2973,7 @@
A17D275E1EAC579800BF01E7 /* MediaSelectionOption.h in Headers */ = {isa = PBXBuildFile; fileRef = A17D275D1EAC579800BF01E7 /* MediaSelectionOption.h */; settings = {ATTRIBUTES = (Private, ); }; };
A17FEE641F8893220021E811 /* PaymentSessionBase.h in Headers */ = {isa = PBXBuildFile; fileRef = A17FEE631F8893220021E811 /* PaymentSessionBase.h */; };
A180AD5B219F81B000DC039A /* WebCoreAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = A17E4F26219BC01600E1C7EE /* WebCoreAdditions.mm */; };
- A185B42A1E8211A100DC9118 /* PreviewLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = A185B4281E8211A100DC9118 /* PreviewLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ A185B42A1E8211A100DC9118 /* LegacyPreviewLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = A185B4281E8211A100DC9118 /* LegacyPreviewLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
A18890AF1AA13F250026C301 /* ParentalControlsContentFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = A18890AD1AA13F250026C301 /* ParentalControlsContentFilter.h */; };
A1956F1C2331A6770057E9D2 /* JSApplePayCancelEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A1956F1B2331A6460057E9D2 /* JSApplePayCancelEvent.h */; };
A1956F202331A8C70057E9D2 /* ApplePaySessionError.h in Headers */ = {isa = PBXBuildFile; fileRef = A1956F1D2331A8C70057E9D2 /* ApplePaySessionError.h */; };
@@ -11187,7 +11187,7 @@
A10BB5881484E3B300B2E87A /* RenderSVGShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGShape.cpp; sourceTree = "<group>"; };
A10BB5891484E3B300B2E87A /* RenderSVGShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGShape.h; sourceTree = "<group>"; };
A10D6E942144C99800FDD14D /* JSPaymentResponseCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSPaymentResponseCustom.cpp; sourceTree = "<group>"; };
- A10DBF4618F92317000D70C6 /* PreviewLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PreviewLoaderClient.h; sourceTree = "<group>"; };
+ A10DBF4618F92317000D70C6 /* LegacyPreviewLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LegacyPreviewLoaderClient.h; sourceTree = "<group>"; };
A10DC76814747BAB005E2471 /* StyleGridData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleGridData.cpp; sourceTree = "<group>"; };
A10DC76914747BAB005E2471 /* StyleGridData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleGridData.h; sourceTree = "<group>"; };
A110DB9A14F5DF7700A03B93 /* StyleGridItemData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleGridItemData.h; sourceTree = "<group>"; };
@@ -11293,8 +11293,8 @@
A17E4F26219BC01600E1C7EE /* WebCoreAdditions.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreAdditions.mm; sourceTree = "<group>"; };
A17FEE631F8893220021E811 /* PaymentSessionBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PaymentSessionBase.h; sourceTree = "<group>"; };
A182D5B61BE722620087A7CC /* SettingsBaseCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SettingsBaseCocoa.mm; sourceTree = "<group>"; };
- A185B4271E8211A100DC9118 /* PreviewLoader.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PreviewLoader.mm; sourceTree = "<group>"; };
- A185B4281E8211A100DC9118 /* PreviewLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PreviewLoader.h; sourceTree = "<group>"; };
+ A185B4271E8211A100DC9118 /* LegacyPreviewLoader.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LegacyPreviewLoader.mm; sourceTree = "<group>"; };
+ A185B4281E8211A100DC9118 /* LegacyPreviewLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LegacyPreviewLoader.h; sourceTree = "<group>"; };
A18890AC1AA13F250026C301 /* ParentalControlsContentFilter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ParentalControlsContentFilter.mm; sourceTree = "<group>"; };
A18890AD1AA13F250026C301 /* ParentalControlsContentFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParentalControlsContentFilter.h; sourceTree = "<group>"; };
A18F7A351ECA73640059E1E1 /* RuntimeApplicationChecks.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RuntimeApplicationChecks.cpp; sourceTree = "<group>"; };
@@ -18263,10 +18263,10 @@
4497D58C0EBA854F00A10552 /* ios */ = {
isa = PBXGroup;
children = (
+ A10DBF4618F92317000D70C6 /* LegacyPreviewLoaderClient.h */,
443F04260E75C8FB007E5407 /* NetworkStateNotifierIOS.mm */,
A1C150781E3F2B3E0032C98C /* PreviewConverter.h */,
A1C150771E3F2B3E0032C98C /* PreviewConverter.mm */,
- A10DBF4618F92317000D70C6 /* PreviewLoaderClient.h */,
44A20DB80F84166C00B3E1FE /* WebCoreURLResponseIOS.h */,
444D4E210F708B2E003158E0 /* WebCoreURLResponseIOS.mm */,
);
@@ -22488,8 +22488,8 @@
A15E31F01E0CB075004B371C /* ios */ = {
isa = PBXGroup;
children = (
- A185B4281E8211A100DC9118 /* PreviewLoader.h */,
- A185B4271E8211A100DC9118 /* PreviewLoader.mm */,
+ A185B4281E8211A100DC9118 /* LegacyPreviewLoader.h */,
+ A185B4271E8211A100DC9118 /* LegacyPreviewLoader.mm */,
);
path = ios;
sourceTree = "<group>";
@@ -30982,6 +30982,8 @@
CDF4B7121E0087AE00E235A2 /* LegacyCDMSession.h in Headers */,
CDE8B5F11A69778B00B4B66A /* LegacyCDMSessionClearKey.h in Headers */,
F44A5F591FED38F2007F5944 /* LegacyNSPasteboardTypes.h in Headers */,
+ A185B42A1E8211A100DC9118 /* LegacyPreviewLoader.h in Headers */,
+ A10DBF4718F92317000D70C6 /* LegacyPreviewLoaderClient.h in Headers */,
5162C7F511F77EFB00612EFE /* LegacySchemeRegistry.h in Headers */,
E4C3B1FA0F0E4161009693F6 /* LegacyTileCache.h in Headers */,
E4B65A58132FA8E70070E7BE /* LegacyTileGrid.h in Headers */,
@@ -31471,8 +31473,6 @@
46DBB6501AB8C96F00D9A813 /* PowerObserverMac.h in Headers */,
C0F2A44113869AAB0066C534 /* preprocessor.pm in Headers */,
A1C1507A1E3F2B3E0032C98C /* PreviewConverter.h in Headers */,
- A185B42A1E8211A100DC9118 /* PreviewLoader.h in Headers */,
- A10DBF4718F92317000D70C6 /* PreviewLoaderClient.h in Headers */,
E4605FEC2166480900E53046 /* PrewarmInformation.h in Headers */,
B71FE6DF11091CB300DAEF77 /* PrintContext.h in Headers */,
51F645D51FECDBCE00B54DED /* ProcessIdentifier.h in Headers */,
Modified: trunk/Source/WebCore/loader/EmptyClients.cpp (251487 => 251488)
--- trunk/Source/WebCore/loader/EmptyClients.cpp 2019-10-23 19:25:01 UTC (rev 251487)
+++ trunk/Source/WebCore/loader/EmptyClients.cpp 2019-10-23 19:34:32 UTC (rev 251488)
@@ -78,7 +78,7 @@
#endif
#if USE(QUICK_LOOK)
-#include "PreviewLoaderClient.h"
+#include "LegacyPreviewLoaderClient.h"
#endif
namespace WebCore {
Modified: trunk/Source/WebCore/loader/EmptyFrameLoaderClient.h (251487 => 251488)
--- trunk/Source/WebCore/loader/EmptyFrameLoaderClient.h 2019-10-23 19:25:01 UTC (rev 251487)
+++ trunk/Source/WebCore/loader/EmptyFrameLoaderClient.h 2019-10-23 19:34:32 UTC (rev 251488)
@@ -29,7 +29,7 @@
#include "ResourceError.h"
#if USE(QUICK_LOOK)
-#include "PreviewLoaderClient.h"
+#include "LegacyPreviewLoaderClient.h"
#endif
namespace WebCore {
@@ -201,7 +201,7 @@
void prefetchDNS(const String&) final { }
#if USE(QUICK_LOOK)
- RefPtr<PreviewLoaderClient> createPreviewLoaderClient(const String&, const String&) final { return nullptr; }
+ RefPtr<LegacyPreviewLoaderClient> createPreviewLoaderClient(const String&, const String&) final { return nullptr; }
#endif
#if ENABLE(RESOURCE_LOAD_STATISTICS)
bool hasFrameSpecificStorageAccess() final { return false; }
Modified: trunk/Source/WebCore/loader/FrameLoaderClient.h (251487 => 251488)
--- trunk/Source/WebCore/loader/FrameLoaderClient.h 2019-10-23 19:25:01 UTC (rev 251487)
+++ trunk/Source/WebCore/loader/FrameLoaderClient.h 2019-10-23 19:34:32 UTC (rev 251488)
@@ -84,11 +84,11 @@
class HTMLPlugInElement;
class HistoryItem;
class IntSize;
+class LegacyPreviewLoaderClient;
class MessageEvent;
class NavigationAction;
class Page;
class PluginViewBase;
-class PreviewLoaderClient;
class ProtectionSpace;
class RTCPeerConnectionHandler;
class ResourceError;
@@ -351,7 +351,7 @@
virtual bool isServiceWorkerFrameLoaderClient() const { return false; }
#if USE(QUICK_LOOK)
- virtual RefPtr<PreviewLoaderClient> createPreviewLoaderClient(const String&, const String&) = 0;
+ virtual RefPtr<LegacyPreviewLoaderClient> createPreviewLoaderClient(const String&, const String&) = 0;
#endif
#if ENABLE(CONTENT_FILTERING)
Modified: trunk/Source/WebCore/loader/ResourceLoader.cpp (251487 => 251488)
--- trunk/Source/WebCore/loader/ResourceLoader.cpp 2019-10-23 19:25:01 UTC (rev 251487)
+++ trunk/Source/WebCore/loader/ResourceLoader.cpp 2019-10-23 19:34:32 UTC (rev 251488)
@@ -59,8 +59,8 @@
#endif
#if USE(QUICK_LOOK)
+#include "LegacyPreviewLoader.h"
#include "PreviewConverter.h"
-#include "PreviewLoader.h"
#endif
#undef RELEASE_LOG_IF_ALLOWED
Modified: trunk/Source/WebCore/loader/ResourceLoader.h (251487 => 251488)
--- trunk/Source/WebCore/loader/ResourceLoader.h 2019-10-23 19:25:01 UTC (rev 251487)
+++ trunk/Source/WebCore/loader/ResourceLoader.h 2019-10-23 19:34:32 UTC (rev 251488)
@@ -51,8 +51,8 @@
class DocumentLoader;
class Frame;
class FrameLoader;
+class LegacyPreviewLoader;
class NetworkLoadMetrics;
-class PreviewLoader;
class ResourceLoader : public CanMakeWeakPtr<ResourceLoader>, public RefCounted<ResourceLoader>, protected ResourceHandleClient {
public:
@@ -178,7 +178,7 @@
ResourceResponse m_response;
LoadTiming m_loadTiming;
#if USE(QUICK_LOOK)
- std::unique_ptr<PreviewLoader> m_previewLoader;
+ std::unique_ptr<LegacyPreviewLoader> m_previewLoader;
#endif
bool m_canCrossOriginRequestsAskUserForCredentials { true };
Modified: trunk/Source/WebCore/loader/SubresourceLoader.cpp (251487 => 251488)
--- trunk/Source/WebCore/loader/SubresourceLoader.cpp 2019-10-23 19:25:01 UTC (rev 251487)
+++ trunk/Source/WebCore/loader/SubresourceLoader.cpp 2019-10-23 19:34:32 UTC (rev 251488)
@@ -64,8 +64,8 @@
#endif
#if USE(QUICK_LOOK)
+#include "LegacyPreviewLoader.h"
#include "PreviewConverter.h"
-#include "PreviewLoader.h"
#endif
#undef RELEASE_LOG_IF_ALLOWED
@@ -334,7 +334,7 @@
#if USE(QUICK_LOOK)
if (shouldCreatePreviewLoaderForResponse(response)) {
- m_previewLoader = PreviewLoader::create(*this, response);
+ m_previewLoader = LegacyPreviewLoader::create(*this, response);
if (m_previewLoader->didReceiveResponse(response))
return;
}
Copied: trunk/Source/WebCore/loader/ios/LegacyPreviewLoader.h (from rev 251487, trunk/Source/WebCore/loader/ios/PreviewLoader.h) (0 => 251488)
--- trunk/Source/WebCore/loader/ios/LegacyPreviewLoader.h (rev 0)
+++ trunk/Source/WebCore/loader/ios/LegacyPreviewLoader.h 2019-10-23 19:34:32 UTC (rev 251488)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2009-2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/Forward.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/RetainPtr.h>
+
+OBJC_CLASS WebPreviewLoader;
+
+namespace WebCore {
+
+class LegacyPreviewLoaderClient;
+class ResourceLoader;
+class ResourceResponse;
+class SharedBuffer;
+
+class LegacyPreviewLoader {
+ WTF_MAKE_FAST_ALLOCATED;
+ WTF_MAKE_NONCOPYABLE(LegacyPreviewLoader);
+public:
+ static std::unique_ptr<LegacyPreviewLoader> create(ResourceLoader&, const ResourceResponse&);
+ ~LegacyPreviewLoader();
+
+ bool didReceiveResponse(const ResourceResponse&);
+ bool didReceiveData(const char* data, unsigned length);
+ bool didReceiveBuffer(const SharedBuffer&);
+ bool didFinishLoading();
+ void didFail();
+
+ WEBCORE_EXPORT static void setClientForTesting(RefPtr<LegacyPreviewLoaderClient>&&);
+
+private:
+ friend std::unique_ptr<LegacyPreviewLoader> std::make_unique<LegacyPreviewLoader>(ResourceLoader&, const ResourceResponse&);
+ LegacyPreviewLoader(ResourceLoader&, const ResourceResponse&);
+
+ RetainPtr<WebPreviewLoader> m_previewLoader;
+ bool m_finishedLoadingDataIntoConverter { false };
+};
+
+} // namespace WebCore
Copied: trunk/Source/WebCore/loader/ios/LegacyPreviewLoader.mm (from rev 251487, trunk/Source/WebCore/loader/ios/PreviewLoader.mm) (0 => 251488)
--- trunk/Source/WebCore/loader/ios/LegacyPreviewLoader.mm (rev 0)
+++ trunk/Source/WebCore/loader/ios/LegacyPreviewLoader.mm 2019-10-23 19:34:32 UTC (rev 251488)
@@ -0,0 +1,324 @@
+/*
+ * Copyright (C) 2009-2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "LegacyPreviewLoader.h"
+
+#if USE(QUICK_LOOK)
+
+#import "DocumentLoader.h"
+#import "Frame.h"
+#import "FrameLoader.h"
+#import "FrameLoaderClient.h"
+#import "LegacyPreviewLoaderClient.h"
+#import "Logging.h"
+#import "PreviewConverter.h"
+#import "QuickLook.h"
+#import "ResourceLoader.h"
+#import "Settings.h"
+#import <pal/spi/ios/QuickLookSPI.h>
+#import <wtf/NeverDestroyed.h>
+
+using namespace WebCore;
+
+@interface WebPreviewLoader : NSObject {
+ WeakPtr<ResourceLoader> _resourceLoader;
+ ResourceResponse _response;
+ RefPtr<LegacyPreviewLoaderClient> _client;
+ std::unique_ptr<PreviewConverter> _converter;
+ RetainPtr<NSMutableArray> _bufferedDataArray;
+ BOOL _hasLoadedPreview;
+ BOOL _hasProcessedResponse;
+ RefPtr<SharedBuffer> _bufferedData;
+ long long _lengthReceived;
+ BOOL _needsToCallDidFinishLoading;
+}
+
+- (instancetype)initWithResourceLoader:(ResourceLoader&)resourceLoader resourceResponse:(const ResourceResponse&)resourceResponse;
+- (void)appendDataArray:(NSArray<NSData *> *)dataArray;
+- (void)finishedAppending;
+- (void)failed;
+
+@property (nonatomic, readonly) BOOL shouldDecidePolicyBeforeLoading;
+
+@end
+
+@implementation WebPreviewLoader
+
+static RefPtr<LegacyPreviewLoaderClient>& testingClient()
+{
+ static NeverDestroyed<RefPtr<LegacyPreviewLoaderClient>> testingClient;
+ return testingClient.get();
+}
+
+static LegacyPreviewLoaderClient& emptyClient()
+{
+ static NeverDestroyed<LegacyPreviewLoaderClient> emptyClient;
+ return emptyClient.get();
+}
+
+- (instancetype)initWithResourceLoader:(ResourceLoader&)resourceLoader resourceResponse:(const ResourceResponse&)resourceResponse
+{
+ if (!(self = [super init]))
+ return nil;
+
+ _resourceLoader = makeWeakPtr(resourceLoader);
+ _response = resourceResponse;
+ _converter = makeUnique<PreviewConverter>(self, _response);
+ _bufferedDataArray = adoptNS([[NSMutableArray alloc] init]);
+ _shouldDecidePolicyBeforeLoading = resourceLoader.frame()->settings().shouldDecidePolicyBeforeLoadingQuickLookPreview();
+
+ if (testingClient())
+ _client = testingClient();
+ else if (auto client = resourceLoader.frameLoader()->client().createPreviewLoaderClient(_converter->previewFileName(), _converter->previewUTI()))
+ _client = WTFMove(client);
+ else
+ _client = &emptyClient();
+
+ LOG(Network, "WebPreviewConverter created with preview file name \"%s\".", _converter->previewFileName().utf8().data());
+ return self;
+}
+
+- (void)appendDataArray:(NSArray<NSData *> *)dataArray
+{
+ LOG(Network, "WebPreviewConverter appending data array with count %ld.", dataArray.count);
+ [_converter->platformConverter() appendDataArray:dataArray];
+ [_bufferedDataArray addObjectsFromArray:dataArray];
+ _client->didReceiveDataArray((CFArrayRef)dataArray);
+}
+
+- (void)finishedAppending
+{
+ LOG(Network, "WebPreviewConverter finished appending data.");
+ [_converter->platformConverter() finishedAppendingData];
+ _client->didFinishLoading();
+}
+
+- (void)failed
+{
+ LOG(Network, "WebPreviewConverter failed.");
+ [_converter->platformConverter() finishConverting];
+ _client->didFail();
+}
+
+- (void)_loadPreviewIfNeeded
+{
+ if (!_resourceLoader)
+ return;
+
+ ASSERT(!_resourceLoader->reachedTerminalState());
+ if (_hasLoadedPreview)
+ return;
+
+ _hasLoadedPreview = YES;
+ [_bufferedDataArray removeAllObjects];
+
+ ResourceResponse response { _converter->previewResponse() };
+ response.setIsQuickLook(true);
+ ASSERT(response.mimeType().length());
+
+ _resourceLoader->documentLoader()->setPreviewConverter(WTFMove(_converter));
+
+ if (_shouldDecidePolicyBeforeLoading) {
+ _hasProcessedResponse = YES;
+ _resourceLoader->didReceivePreviewResponse(response);
+ return;
+ }
+
+ _hasProcessedResponse = NO;
+ _resourceLoader->didReceiveResponse(response, [self, retainedSelf = retainPtr(self)] {
+ _hasProcessedResponse = YES;
+
+ if (!_resourceLoader)
+ return;
+
+ if (_resourceLoader->reachedTerminalState())
+ return;
+
+ if (auto bufferedData = WTFMove(_bufferedData)) {
+ _resourceLoader->didReceiveData(bufferedData->data(), bufferedData->size(), _lengthReceived, DataPayloadBytes);
+ _lengthReceived = 0;
+ }
+
+ if (_resourceLoader->reachedTerminalState())
+ return;
+
+ if (_needsToCallDidFinishLoading) {
+ _needsToCallDidFinishLoading = NO;
+ _resourceLoader->didFinishLoading(NetworkLoadMetrics { });
+ }
+ });
+}
+
+- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data lengthReceived:(long long)lengthReceived
+{
+ if (!_resourceLoader)
+ return;
+
+ ASSERT_UNUSED(connection, !connection);
+ if (_resourceLoader->reachedTerminalState())
+ return;
+
+ [self _loadPreviewIfNeeded];
+
+ auto dataLength = data.length;
+
+ // QuickLook code sends us a nil data at times. The check below is the same as the one in
+ // ResourceHandleMac.cpp added for a different bug.
+ if (!dataLength)
+ return;
+
+ if (_hasProcessedResponse) {
+ _resourceLoader->didReceiveData(reinterpret_cast<const char*>(data.bytes), dataLength, lengthReceived, DataPayloadBytes);
+ return;
+ }
+
+ if (!_bufferedData)
+ _bufferedData = SharedBuffer::create(data);
+ else
+ _bufferedData->append(data);
+ _lengthReceived += lengthReceived;
+}
+
+- (void)connectionDidFinishLoading:(NSURLConnection *)connection
+{
+ if (!_resourceLoader)
+ return;
+
+ ASSERT_UNUSED(connection, !connection);
+ if (_resourceLoader->reachedTerminalState())
+ return;
+
+ ASSERT(_hasLoadedPreview);
+
+ if (!_hasProcessedResponse) {
+ _needsToCallDidFinishLoading = YES;
+ return;
+ }
+
+ _resourceLoader->didFinishLoading(NetworkLoadMetrics { });
+}
+
+static inline bool isQuickLookPasswordError(NSError *error)
+{
+ return error.code == kQLReturnPasswordProtected && [error.domain isEqualToString:@"QuickLookErrorDomain"];
+}
+
+- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
+{
+ if (!_resourceLoader)
+ return;
+
+ ASSERT_UNUSED(connection, !connection);
+ if (_resourceLoader->reachedTerminalState())
+ return;
+
+ if (!isQuickLookPasswordError(error)) {
+ _resourceLoader->didFail(error);
+ return;
+ }
+
+ if (!_client->supportsPasswordEntry()) {
+ _resourceLoader->didFail(_resourceLoader->cannotShowURLError());
+ return;
+ }
+
+ _client->didRequestPassword([self, retainedSelf = retainPtr(self)] (const String& password) {
+ _converter = makeUnique<PreviewConverter>(self, _response, password);
+ [_converter->platformConverter() appendDataArray:_bufferedDataArray.get()];
+ [_converter->platformConverter() finishedAppendingData];
+ });
+}
+
+@end
+
+namespace WebCore {
+
+LegacyPreviewLoader::LegacyPreviewLoader(ResourceLoader& loader, const ResourceResponse& response)
+ : m_previewLoader { adoptNS([[WebPreviewLoader alloc] initWithResourceLoader:loader resourceResponse:response]) }
+{
+}
+
+LegacyPreviewLoader::~LegacyPreviewLoader()
+{
+}
+
+std::unique_ptr<LegacyPreviewLoader> LegacyPreviewLoader::create(ResourceLoader& loader, const ResourceResponse& response)
+{
+ ASSERT(PreviewConverter::supportsMIMEType(response.mimeType()));
+ return makeUnique<LegacyPreviewLoader>(loader, response);
+}
+
+bool LegacyPreviewLoader::didReceiveResponse(const ResourceResponse&)
+{
+ return ![m_previewLoader shouldDecidePolicyBeforeLoading];
+}
+
+bool LegacyPreviewLoader::didReceiveData(const char* data, unsigned length)
+{
+ if (m_finishedLoadingDataIntoConverter)
+ return false;
+
+ [m_previewLoader appendDataArray:@[ [NSData dataWithBytes:data length:length] ]];
+ return true;
+}
+
+bool LegacyPreviewLoader::didReceiveBuffer(const SharedBuffer& buffer)
+{
+ if (m_finishedLoadingDataIntoConverter)
+ return false;
+
+ [m_previewLoader appendDataArray:buffer.createNSDataArray().get()];
+ return true;
+}
+
+bool LegacyPreviewLoader::didFinishLoading()
+{
+ if (m_finishedLoadingDataIntoConverter)
+ return false;
+
+ m_finishedLoadingDataIntoConverter = true;
+ [m_previewLoader finishedAppending];
+ return true;
+}
+
+void LegacyPreviewLoader::didFail()
+{
+ if (m_finishedLoadingDataIntoConverter)
+ return;
+
+ m_finishedLoadingDataIntoConverter = true;
+ [m_previewLoader failed];
+ m_previewLoader = nullptr;
+}
+
+void LegacyPreviewLoader::setClientForTesting(RefPtr<LegacyPreviewLoaderClient>&& client)
+{
+ testingClient() = WTFMove(client);
+}
+
+} // namespace WebCore
+
+#endif // USE(QUICK_LOOK)
Deleted: trunk/Source/WebCore/loader/ios/PreviewLoader.h (251487 => 251488)
--- trunk/Source/WebCore/loader/ios/PreviewLoader.h 2019-10-23 19:25:01 UTC (rev 251487)
+++ trunk/Source/WebCore/loader/ios/PreviewLoader.h 2019-10-23 19:34:32 UTC (rev 251488)
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2009-2019 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include <wtf/Forward.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/RetainPtr.h>
-
-OBJC_CLASS WebPreviewLoader;
-
-namespace WebCore {
-
-class PreviewLoaderClient;
-class ResourceLoader;
-class ResourceResponse;
-class SharedBuffer;
-
-class PreviewLoader {
- WTF_MAKE_FAST_ALLOCATED;
- WTF_MAKE_NONCOPYABLE(PreviewLoader);
-public:
- static std::unique_ptr<PreviewLoader> create(ResourceLoader&, const ResourceResponse&);
- ~PreviewLoader();
-
- bool didReceiveResponse(const ResourceResponse&);
- bool didReceiveData(const char* data, unsigned length);
- bool didReceiveBuffer(const SharedBuffer&);
- bool didFinishLoading();
- void didFail();
-
- WEBCORE_EXPORT static void setClientForTesting(RefPtr<PreviewLoaderClient>&&);
-
-private:
- friend std::unique_ptr<PreviewLoader> std::make_unique<PreviewLoader>(ResourceLoader&, const ResourceResponse&);
- PreviewLoader(ResourceLoader&, const ResourceResponse&);
-
- RetainPtr<WebPreviewLoader> m_previewLoader;
- bool m_finishedLoadingDataIntoConverter { false };
-};
-
-} // namespace WebCore
Deleted: trunk/Source/WebCore/loader/ios/PreviewLoader.mm (251487 => 251488)
--- trunk/Source/WebCore/loader/ios/PreviewLoader.mm 2019-10-23 19:25:01 UTC (rev 251487)
+++ trunk/Source/WebCore/loader/ios/PreviewLoader.mm 2019-10-23 19:34:32 UTC (rev 251488)
@@ -1,324 +0,0 @@
-/*
- * Copyright (C) 2009-2019 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "PreviewLoader.h"
-
-#if USE(QUICK_LOOK)
-
-#import "DocumentLoader.h"
-#import "Frame.h"
-#import "FrameLoader.h"
-#import "FrameLoaderClient.h"
-#import "Logging.h"
-#import "PreviewConverter.h"
-#import "PreviewLoaderClient.h"
-#import "QuickLook.h"
-#import "ResourceLoader.h"
-#import "Settings.h"
-#import <pal/spi/ios/QuickLookSPI.h>
-#import <wtf/NeverDestroyed.h>
-
-using namespace WebCore;
-
-@interface WebPreviewLoader : NSObject {
- WeakPtr<ResourceLoader> _resourceLoader;
- ResourceResponse _response;
- RefPtr<PreviewLoaderClient> _client;
- std::unique_ptr<PreviewConverter> _converter;
- RetainPtr<NSMutableArray> _bufferedDataArray;
- BOOL _hasLoadedPreview;
- BOOL _hasProcessedResponse;
- RefPtr<SharedBuffer> _bufferedData;
- long long _lengthReceived;
- BOOL _needsToCallDidFinishLoading;
-}
-
-- (instancetype)initWithResourceLoader:(ResourceLoader&)resourceLoader resourceResponse:(const ResourceResponse&)resourceResponse;
-- (void)appendDataArray:(NSArray<NSData *> *)dataArray;
-- (void)finishedAppending;
-- (void)failed;
-
-@property (nonatomic, readonly) BOOL shouldDecidePolicyBeforeLoading;
-
-@end
-
-@implementation WebPreviewLoader
-
-static RefPtr<PreviewLoaderClient>& testingClient()
-{
- static NeverDestroyed<RefPtr<PreviewLoaderClient>> testingClient;
- return testingClient.get();
-}
-
-static PreviewLoaderClient& emptyClient()
-{
- static NeverDestroyed<PreviewLoaderClient> emptyClient;
- return emptyClient.get();
-}
-
-- (instancetype)initWithResourceLoader:(ResourceLoader&)resourceLoader resourceResponse:(const ResourceResponse&)resourceResponse
-{
- if (!(self = [super init]))
- return nil;
-
- _resourceLoader = makeWeakPtr(resourceLoader);
- _response = resourceResponse;
- _converter = makeUnique<PreviewConverter>(self, _response);
- _bufferedDataArray = adoptNS([[NSMutableArray alloc] init]);
- _shouldDecidePolicyBeforeLoading = resourceLoader.frame()->settings().shouldDecidePolicyBeforeLoadingQuickLookPreview();
-
- if (testingClient())
- _client = testingClient();
- else if (auto client = resourceLoader.frameLoader()->client().createPreviewLoaderClient(_converter->previewFileName(), _converter->previewUTI()))
- _client = WTFMove(client);
- else
- _client = &emptyClient();
-
- LOG(Network, "WebPreviewConverter created with preview file name \"%s\".", _converter->previewFileName().utf8().data());
- return self;
-}
-
-- (void)appendDataArray:(NSArray<NSData *> *)dataArray
-{
- LOG(Network, "WebPreviewConverter appending data array with count %ld.", dataArray.count);
- [_converter->platformConverter() appendDataArray:dataArray];
- [_bufferedDataArray addObjectsFromArray:dataArray];
- _client->didReceiveDataArray((CFArrayRef)dataArray);
-}
-
-- (void)finishedAppending
-{
- LOG(Network, "WebPreviewConverter finished appending data.");
- [_converter->platformConverter() finishedAppendingData];
- _client->didFinishLoading();
-}
-
-- (void)failed
-{
- LOG(Network, "WebPreviewConverter failed.");
- [_converter->platformConverter() finishConverting];
- _client->didFail();
-}
-
-- (void)_loadPreviewIfNeeded
-{
- if (!_resourceLoader)
- return;
-
- ASSERT(!_resourceLoader->reachedTerminalState());
- if (_hasLoadedPreview)
- return;
-
- _hasLoadedPreview = YES;
- [_bufferedDataArray removeAllObjects];
-
- ResourceResponse response { _converter->previewResponse() };
- response.setIsQuickLook(true);
- ASSERT(response.mimeType().length());
-
- _resourceLoader->documentLoader()->setPreviewConverter(WTFMove(_converter));
-
- if (_shouldDecidePolicyBeforeLoading) {
- _hasProcessedResponse = YES;
- _resourceLoader->didReceivePreviewResponse(response);
- return;
- }
-
- _hasProcessedResponse = NO;
- _resourceLoader->didReceiveResponse(response, [self, retainedSelf = retainPtr(self)] {
- _hasProcessedResponse = YES;
-
- if (!_resourceLoader)
- return;
-
- if (_resourceLoader->reachedTerminalState())
- return;
-
- if (auto bufferedData = WTFMove(_bufferedData)) {
- _resourceLoader->didReceiveData(bufferedData->data(), bufferedData->size(), _lengthReceived, DataPayloadBytes);
- _lengthReceived = 0;
- }
-
- if (_resourceLoader->reachedTerminalState())
- return;
-
- if (_needsToCallDidFinishLoading) {
- _needsToCallDidFinishLoading = NO;
- _resourceLoader->didFinishLoading(NetworkLoadMetrics { });
- }
- });
-}
-
-- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data lengthReceived:(long long)lengthReceived
-{
- if (!_resourceLoader)
- return;
-
- ASSERT_UNUSED(connection, !connection);
- if (_resourceLoader->reachedTerminalState())
- return;
-
- [self _loadPreviewIfNeeded];
-
- auto dataLength = data.length;
-
- // QuickLook code sends us a nil data at times. The check below is the same as the one in
- // ResourceHandleMac.cpp added for a different bug.
- if (!dataLength)
- return;
-
- if (_hasProcessedResponse) {
- _resourceLoader->didReceiveData(reinterpret_cast<const char*>(data.bytes), dataLength, lengthReceived, DataPayloadBytes);
- return;
- }
-
- if (!_bufferedData)
- _bufferedData = SharedBuffer::create(data);
- else
- _bufferedData->append(data);
- _lengthReceived += lengthReceived;
-}
-
-- (void)connectionDidFinishLoading:(NSURLConnection *)connection
-{
- if (!_resourceLoader)
- return;
-
- ASSERT_UNUSED(connection, !connection);
- if (_resourceLoader->reachedTerminalState())
- return;
-
- ASSERT(_hasLoadedPreview);
-
- if (!_hasProcessedResponse) {
- _needsToCallDidFinishLoading = YES;
- return;
- }
-
- _resourceLoader->didFinishLoading(NetworkLoadMetrics { });
-}
-
-static inline bool isQuickLookPasswordError(NSError *error)
-{
- return error.code == kQLReturnPasswordProtected && [error.domain isEqualToString:@"QuickLookErrorDomain"];
-}
-
-- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
-{
- if (!_resourceLoader)
- return;
-
- ASSERT_UNUSED(connection, !connection);
- if (_resourceLoader->reachedTerminalState())
- return;
-
- if (!isQuickLookPasswordError(error)) {
- _resourceLoader->didFail(error);
- return;
- }
-
- if (!_client->supportsPasswordEntry()) {
- _resourceLoader->didFail(_resourceLoader->cannotShowURLError());
- return;
- }
-
- _client->didRequestPassword([self, retainedSelf = retainPtr(self)] (const String& password) {
- _converter = makeUnique<PreviewConverter>(self, _response, password);
- [_converter->platformConverter() appendDataArray:_bufferedDataArray.get()];
- [_converter->platformConverter() finishedAppendingData];
- });
-}
-
-@end
-
-namespace WebCore {
-
-PreviewLoader::PreviewLoader(ResourceLoader& loader, const ResourceResponse& response)
- : m_previewLoader { adoptNS([[WebPreviewLoader alloc] initWithResourceLoader:loader resourceResponse:response]) }
-{
-}
-
-PreviewLoader::~PreviewLoader()
-{
-}
-
-std::unique_ptr<PreviewLoader> PreviewLoader::create(ResourceLoader& loader, const ResourceResponse& response)
-{
- ASSERT(PreviewConverter::supportsMIMEType(response.mimeType()));
- return makeUnique<PreviewLoader>(loader, response);
-}
-
-bool PreviewLoader::didReceiveResponse(const ResourceResponse&)
-{
- return ![m_previewLoader shouldDecidePolicyBeforeLoading];
-}
-
-bool PreviewLoader::didReceiveData(const char* data, unsigned length)
-{
- if (m_finishedLoadingDataIntoConverter)
- return false;
-
- [m_previewLoader appendDataArray:@[ [NSData dataWithBytes:data length:length] ]];
- return true;
-}
-
-bool PreviewLoader::didReceiveBuffer(const SharedBuffer& buffer)
-{
- if (m_finishedLoadingDataIntoConverter)
- return false;
-
- [m_previewLoader appendDataArray:buffer.createNSDataArray().get()];
- return true;
-}
-
-bool PreviewLoader::didFinishLoading()
-{
- if (m_finishedLoadingDataIntoConverter)
- return false;
-
- m_finishedLoadingDataIntoConverter = true;
- [m_previewLoader finishedAppending];
- return true;
-}
-
-void PreviewLoader::didFail()
-{
- if (m_finishedLoadingDataIntoConverter)
- return;
-
- m_finishedLoadingDataIntoConverter = true;
- [m_previewLoader failed];
- m_previewLoader = nullptr;
-}
-
-void PreviewLoader::setClientForTesting(RefPtr<PreviewLoaderClient>&& client)
-{
- testingClient() = WTFMove(client);
-}
-
-} // namespace WebCore
-
-#endif // USE(QUICK_LOOK)
Copied: trunk/Source/WebCore/platform/network/ios/LegacyPreviewLoaderClient.h (from rev 251487, trunk/Source/WebCore/platform/network/ios/PreviewLoaderClient.h) (0 => 251488)
--- trunk/Source/WebCore/platform/network/ios/LegacyPreviewLoaderClient.h (rev 0)
+++ trunk/Source/WebCore/platform/network/ios/LegacyPreviewLoaderClient.h 2019-10-23 19:34:32 UTC (rev 251488)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/Function.h>
+#include <wtf/RefCounted.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class LegacyPreviewLoaderClient : public RefCounted<LegacyPreviewLoaderClient> {
+public:
+ virtual ~LegacyPreviewLoaderClient() = default;
+ virtual void didReceiveDataArray(CFArrayRef) { }
+ virtual void didFinishLoading() { }
+ virtual void didFail() { }
+ virtual bool supportsPasswordEntry() const { return false; }
+ virtual void didRequestPassword(Function<void(const String&)>&& completionHandler) { completionHandler(""); }
+};
+
+} // namespace WebCore
Deleted: trunk/Source/WebCore/platform/network/ios/PreviewLoaderClient.h (251487 => 251488)
--- trunk/Source/WebCore/platform/network/ios/PreviewLoaderClient.h 2019-10-23 19:25:01 UTC (rev 251487)
+++ trunk/Source/WebCore/platform/network/ios/PreviewLoaderClient.h 2019-10-23 19:34:32 UTC (rev 251488)
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include <wtf/Function.h>
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-class PreviewLoaderClient : public RefCounted<PreviewLoaderClient> {
-public:
- virtual ~PreviewLoaderClient() = default;
- virtual void didReceiveDataArray(CFArrayRef) { }
- virtual void didFinishLoading() { }
- virtual void didFail() { }
- virtual bool supportsPasswordEntry() const { return false; }
- virtual void didRequestPassword(Function<void(const String&)>&& completionHandler) { completionHandler(""); }
-};
-
-} // namespace WebCore
Modified: trunk/Source/WebCore/testing/Internals.cpp (251487 => 251488)
--- trunk/Source/WebCore/testing/Internals.cpp 2019-10-23 19:25:01 UTC (rev 251487)
+++ trunk/Source/WebCore/testing/Internals.cpp 2019-10-23 19:34:32 UTC (rev 251488)
@@ -283,8 +283,8 @@
#endif
#if USE(QUICK_LOOK)
+#include "LegacyPreviewLoader.h"
#include "MockPreviewLoaderClient.h"
-#include "PreviewLoader.h"
#endif
#if ENABLE(APPLE_PAY)
@@ -514,7 +514,7 @@
#if USE(QUICK_LOOK)
MockPreviewLoaderClient::singleton().setPassword("");
- PreviewLoader::setClientForTesting(nullptr);
+ LegacyPreviewLoader::setClientForTesting(nullptr);
#endif
printContextForTesting() = nullptr;
@@ -4700,7 +4700,7 @@
{
#if PLATFORM(IOS_FAMILY) && USE(QUICK_LOOK)
auto& quickLookHandleClient = MockPreviewLoaderClient::singleton();
- PreviewLoader::setClientForTesting(&quickLookHandleClient);
+ LegacyPreviewLoader::setClientForTesting(&quickLookHandleClient);
quickLookHandleClient.setPassword(password);
#else
UNUSED_PARAM(password);
Modified: trunk/Source/WebCore/testing/MockPreviewLoaderClient.h (251487 => 251488)
--- trunk/Source/WebCore/testing/MockPreviewLoaderClient.h 2019-10-23 19:25:01 UTC (rev 251487)
+++ trunk/Source/WebCore/testing/MockPreviewLoaderClient.h 2019-10-23 19:34:32 UTC (rev 251488)
@@ -27,11 +27,11 @@
#if USE(QUICK_LOOK)
-#include "PreviewLoaderClient.h"
+#include "LegacyPreviewLoaderClient.h"
namespace WebCore {
-class MockPreviewLoaderClient final : public PreviewLoaderClient {
+class MockPreviewLoaderClient final : public LegacyPreviewLoaderClient {
public:
static MockPreviewLoaderClient& singleton();
Modified: trunk/Source/WebKit/ChangeLog (251487 => 251488)
--- trunk/Source/WebKit/ChangeLog 2019-10-23 19:25:01 UTC (rev 251487)
+++ trunk/Source/WebKit/ChangeLog 2019-10-23 19:34:32 UTC (rev 251488)
@@ -1,3 +1,16 @@
+2019-10-23 Andy Estes <[email protected]>
+
+ [Quick Look] Rename PreviewLoader{,Client} to LegacyPreviewLoader{,Client}
+ https://bugs.webkit.org/show_bug.cgi?id=203306
+
+ Reviewed by Tim Horton.
+
+ * WebProcess/Storage/WebSWContextManagerConnection.cpp:
+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
+ * WebProcess/WebCoreSupport/ios/WebFrameLoaderClientIOS.mm:
+ (WebKit::WebFrameLoaderClient::createPreviewLoaderClient):
+ * WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.h:
+
2019-10-22 Fujii Hironori <[email protected]>
Unreviewed build fix for non-unified source builds
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp (251487 => 251488)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp 2019-10-23 19:25:01 UTC (rev 251487)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp 2019-10-23 19:34:32 UTC (rev 251488)
@@ -62,7 +62,7 @@
#include <wtf/ProcessID.h>
#if USE(QUICK_LOOK)
-#include <WebCore/PreviewLoaderClient.h>
+#include <WebCore/LegacyPreviewLoaderClient.h>
#endif
namespace WebKit {
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h (251487 => 251488)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h 2019-10-23 19:25:01 UTC (rev 251487)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h 2019-10-23 19:34:32 UTC (rev 251488)
@@ -256,7 +256,7 @@
void forcePageTransitionIfNeeded() final;
#if USE(QUICK_LOOK)
- RefPtr<WebCore::PreviewLoaderClient> createPreviewLoaderClient(const String& fileName, const String& uti) final;
+ RefPtr<WebCore::LegacyPreviewLoaderClient> createPreviewLoaderClient(const String& fileName, const String& uti) final;
#endif
#if ENABLE(CONTENT_FILTERING)
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebFrameLoaderClientIOS.mm (251487 => 251488)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebFrameLoaderClientIOS.mm 2019-10-23 19:25:01 UTC (rev 251487)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebFrameLoaderClientIOS.mm 2019-10-23 19:34:32 UTC (rev 251488)
@@ -65,7 +65,7 @@
}
#if USE(QUICK_LOOK)
-RefPtr<PreviewLoaderClient> WebFrameLoaderClient::createPreviewLoaderClient(const String& fileName, const String& uti)
+RefPtr<LegacyPreviewLoaderClient> WebFrameLoaderClient::createPreviewLoaderClient(const String& fileName, const String& uti)
{
if (!m_frame->isMainFrame())
return nullptr;
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.h (251487 => 251488)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.h 2019-10-23 19:25:01 UTC (rev 251487)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.h 2019-10-23 19:34:32 UTC (rev 251488)
@@ -28,8 +28,8 @@
#if USE(QUICK_LOOK)
#include "QuickLookDocumentData.h"
+#include <WebCore/LegacyPreviewLoaderClient.h>
#include <WebCore/PageIdentifier.h>
-#include <WebCore/PreviewLoaderClient.h>
#include <wtf/text/WTFString.h>
namespace WebKit {
@@ -36,7 +36,7 @@
class WebFrame;
-class WebPreviewLoaderClient final : public WebCore::PreviewLoaderClient {
+class WebPreviewLoaderClient final : public WebCore::LegacyPreviewLoaderClient {
public:
static Ref<WebPreviewLoaderClient> create(const String& fileName, const String& uti, WebCore::PageIdentifier pageID)
{
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (251487 => 251488)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2019-10-23 19:25:01 UTC (rev 251487)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2019-10-23 19:34:32 UTC (rev 251488)
@@ -1,3 +1,18 @@
+2019-10-23 Andy Estes <[email protected]>
+
+ [Quick Look] Rename PreviewLoader{,Client} to LegacyPreviewLoader{,Client}
+ https://bugs.webkit.org/show_bug.cgi?id=203306
+
+ Reviewed by Tim Horton.
+
+ * WebCoreSupport/WebFrameLoaderClient.h:
+ * WebCoreSupport/WebFrameLoaderClient.mm:
+ (WebFrameLoaderClient::createPreviewLoaderClient):
+ * WebView/WebDataSource.mm:
+ (-[WebDataSource _quickLookPreviewLoaderClient]):
+ (-[WebDataSource _setQuickLookPreviewLoaderClient:]):
+ * WebView/WebDataSourceInternal.h:
+
2019-10-22 Alex Christensen <[email protected]>
Re-enable legacy TLS by default, keep runtime switch
Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h (251487 => 251488)
--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h 2019-10-23 19:25:01 UTC (rev 251487)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h 2019-10-23 19:34:32 UTC (rev 251488)
@@ -241,7 +241,7 @@
bool shouldPaintBrokenImage(const URL&) const final;
#if USE(QUICK_LOOK)
- RefPtr<WebCore::PreviewLoaderClient> createPreviewLoaderClient(const String& fileName, const String& uti) final;
+ RefPtr<WebCore::LegacyPreviewLoaderClient> createPreviewLoaderClient(const String& fileName, const String& uti) final;
#endif
#if ENABLE(CONTENT_FILTERING)
Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm (251487 => 251488)
--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm 2019-10-23 19:25:01 UTC (rev 251487)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm 2019-10-23 19:34:32 UTC (rev 251488)
@@ -152,7 +152,7 @@
#endif
#if USE(QUICK_LOOK)
-#import <WebCore/PreviewLoaderClient.h>
+#import <WebCore/LegacyPreviewLoaderClient.h>
#import <WebCore/QuickLook.h>
#import <pal/spi/cocoa/NSFileManagerSPI.h>
#endif
@@ -2186,9 +2186,9 @@
#endif
#if USE(QUICK_LOOK)
-RefPtr<WebCore::PreviewLoaderClient> WebFrameLoaderClient::createPreviewLoaderClient(const String& fileName, const String& uti)
+RefPtr<WebCore::LegacyPreviewLoaderClient> WebFrameLoaderClient::createPreviewLoaderClient(const String& fileName, const String& uti)
{
- class QuickLookDocumentWriter : public WebCore::PreviewLoaderClient {
+ class QuickLookDocumentWriter : public WebCore::LegacyPreviewLoaderClient {
public:
explicit QuickLookDocumentWriter(NSString *filePath)
: m_filePath { filePath }
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebDataSource.mm (251487 => 251488)
--- trunk/Source/WebKitLegacy/mac/WebView/WebDataSource.mm 2019-10-23 19:25:01 UTC (rev 251487)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebDataSource.mm 2019-10-23 19:34:32 UTC (rev 251488)
@@ -71,7 +71,7 @@
#endif
#if USE(QUICK_LOOK)
-#import <WebCore/PreviewLoaderClient.h>
+#import <WebCore/LegacyPreviewLoaderClient.h>
#import <WebCore/QuickLook.h>
#endif
@@ -107,7 +107,7 @@
#endif
#if USE(QUICK_LOOK)
RetainPtr<NSDictionary> _quickLookContent;
- RefPtr<WebCore::PreviewLoaderClient> _quickLookPreviewLoaderClient;
+ RefPtr<WebCore::LegacyPreviewLoaderClient> _quickLookPreviewLoaderClient;
#endif
};
@@ -416,7 +416,7 @@
}
#if USE(QUICK_LOOK)
-- (WebCore::PreviewLoaderClient*)_quickLookPreviewLoaderClient
+- (WebCore::LegacyPreviewLoaderClient*)_quickLookPreviewLoaderClient
{
return toPrivate(_private)->_quickLookPreviewLoaderClient.get();
}
@@ -426,7 +426,7 @@
toPrivate(_private)->_quickLookContent = adoptNS([quickLookContent copy]);
}
-- (void)_setQuickLookPreviewLoaderClient:(WebCore::PreviewLoaderClient*)quickLookPreviewLoaderClient
+- (void)_setQuickLookPreviewLoaderClient:(WebCore::LegacyPreviewLoaderClient*)quickLookPreviewLoaderClient
{
toPrivate(_private)->_quickLookPreviewLoaderClient = quickLookPreviewLoaderClient;
}
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebDataSourceInternal.h (251487 => 251488)
--- trunk/Source/WebKitLegacy/mac/WebView/WebDataSourceInternal.h 2019-10-23 19:25:01 UTC (rev 251487)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebDataSourceInternal.h 2019-10-23 19:34:32 UTC (rev 251488)
@@ -31,7 +31,7 @@
namespace WebCore {
class DocumentLoader;
-class PreviewLoaderClient;
+class LegacyPreviewLoaderClient;
}
class WebDocumentLoaderMac;
@@ -60,6 +60,6 @@
- (WebCore::DocumentLoader*)_documentLoader;
#if USE(QUICK_LOOK)
@property (nonatomic, copy, setter=_setQuickLookContent:) NSDictionary *_quickLookContent;
-@property (nonatomic, setter=_setQuickLookPreviewLoaderClient:) WebCore::PreviewLoaderClient* _quickLookPreviewLoaderClient;
+@property (nonatomic, setter=_setQuickLookPreviewLoaderClient:) WebCore::LegacyPreviewLoaderClient* _quickLookPreviewLoaderClient;
#endif
@end