Changeset 231949 in webkit


Ignore:
Timestamp:
May 18, 2018 1:11:17 AM (6 years ago)
Author:
timothy_horton@apple.com
Message:

Stop softlinking QuickLook when loading from client-registered schemes
https://bugs.webkit.org/show_bug.cgi?id=185716
<rdar://problem/40303227>

Reviewed by Dan Bernstein.

No new tests, just a performance improvement.

  • dom/Document.cpp:
  • platform/SchemeRegistry.cpp:
  • platform/ios/QuickLook.h:
  • platform/ios/QuickLook.mm:

(WebCore::isQuickLookPreviewURL):
(WebCore::QLPreviewProtocol): Deleted.
Hard-code the QuickLook preview URL scheme, instead of loading the QuickLook
framework to retrieve it. It will never change, and just in case it does,
add an ASSERT (which does load QuickLook) so that we'll find out.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r231948 r231949  
     12018-05-18  Tim Horton  <timothy_horton@apple.com>
     2
     3        Stop softlinking QuickLook when loading from client-registered schemes
     4        https://bugs.webkit.org/show_bug.cgi?id=185716
     5        <rdar://problem/40303227>
     6
     7        Reviewed by Dan Bernstein.
     8
     9        No new tests, just a performance improvement.
     10
     11        * dom/Document.cpp:
     12        * platform/SchemeRegistry.cpp:
     13        * platform/ios/QuickLook.h:
     14        * platform/ios/QuickLook.mm:
     15        (WebCore::isQuickLookPreviewURL):
     16        (WebCore::QLPreviewProtocol): Deleted.
     17        Hard-code the QuickLook preview URL scheme, instead of loading the QuickLook
     18        framework to retrieve it. It will never change, and just in case it does,
     19        add an ASSERT (which does load QuickLook) so that we'll find out.
     20
    1212018-05-18  Antoine Quint  <graouts@apple.com>
    222
  • trunk/Source/WebCore/dom/Document.cpp

    r231935 r231949  
    72817281{
    72827282    const URL& responseURL = m_frame->loader().activeDocumentLoader()->responseURL();
    7283     ASSERT(responseURL.protocolIs(QLPreviewProtocol()));
     7283    ASSERT(responseURL.protocolIs(QLPreviewProtocol));
    72847284
    72857285    auto securityOrigin = SecurityOrigin::create(responseURL);
     
    72877287    setSecurityOriginPolicy(SecurityOriginPolicy::create(WTFMove(securityOrigin)));
    72887288
    7289     static NeverDestroyed<String> quickLookCSP = makeString("default-src ", QLPreviewProtocol(), ": 'unsafe-inline'; base-uri 'none'; sandbox allow-same-origin allow-scripts");
     7289    static NeverDestroyed<String> quickLookCSP = makeString("default-src ", QLPreviewProtocol, ": 'unsafe-inline'; base-uri 'none'; sandbox allow-same-origin allow-scripts");
    72907290    RELEASE_ASSERT(contentSecurityPolicy());
    72917291    // The sandbox directive is only allowed if the policy is from an HTTP header.
  • trunk/Source/WebCore/platform/SchemeRegistry.cpp

    r230205 r231949  
    9090#endif
    9191#if USE(QUICK_LOOK)
    92             QLPreviewProtocol(),
     92            QLPreviewProtocol,
    9393#endif
    9494#if ENABLE(CONTENT_FILTERING)
  • trunk/Source/WebCore/platform/ios/QuickLook.h

    r214268 r231949  
    4141WEBCORE_EXPORT void removeQLPreviewConverterForURL(NSURL *);
    4242WEBCORE_EXPORT RetainPtr<NSURLRequest> registerQLPreviewConverterIfNeeded(NSURL *, NSString *mimeType, NSData *);
    43 WEBCORE_EXPORT const char* QLPreviewProtocol();
    4443WEBCORE_EXPORT bool isQuickLookPreviewURL(const URL&);
    4544WEBCORE_EXPORT NSString *createTemporaryFileForQuickLook(NSString *fileName);
    4645
     46extern const char* QLPreviewProtocol;
     47
    4748} // namespace WebCore
  • trunk/Source/WebCore/platform/ios/QuickLook.mm

    r230303 r231949  
    4040
    4141namespace WebCore {
     42
     43const char* QLPreviewProtocol = "x-apple-ql-id";
    4244
    4345NSSet *QLPreviewGetSupportedMIMETypesSet()
     
    9799}
    98100
    99 const char* QLPreviewProtocol()
    100 {
    101     static const char* const previewProtocol = fastStrDup([QLPreviewScheme UTF8String]);
    102     return previewProtocol;
    103 }
    104 
    105101bool isQuickLookPreviewURL(const URL& url)
    106102{
    107     // Use some known protocols as a short-cut to avoid loading the QuickLook framework.
    108     if (url.protocolIsInHTTPFamily() || url.isBlankURL() || url.protocolIsBlob() || url.protocolIsData() || SchemeRegistry::shouldTreatURLSchemeAsLocal(url.protocol().toString()))
    109         return false;
    110     return url.protocolIs(QLPreviewProtocol());
     103    ASSERT([QLPreviewScheme isEqualToString:@(QLPreviewProtocol)]);
     104    return url.protocolIs(QLPreviewProtocol);
    111105}
    112106
Note: See TracChangeset for help on using the changeset viewer.