Changeset 210864 in webkit


Ignore:
Timestamp:
Jan 18, 2017, 12:29:26 PM (9 years ago)
Author:
aestes@apple.com
Message:

[QuickLook] Support password-protected documents
https://bugs.webkit.org/show_bug.cgi?id=167153
<rdar://problem/28544527>

Reviewed by Alex Christensen.

Source/WebCore:

Added support for previewing password-protected documents. If a document is
password-protected, QLPreviewConverter will call -connection:didFailWithError: with an error
code of kQLReturnPasswordProtected. When this happens, QuickLookHandle will ask the client
for a password, create a new QLPreviewConverter with the password specified in an options
dictionary, and replay the buffered input data into the converter. QLPreviewConverter will
then send the converted document data to its delegate as usual.

Password entry UI will be added later; this patch implements the necessary QuickLookHandle
logic and adds support for testing.

Test: quicklook/password-protected.html

  • PlatformMac.cmake:
  • WebCore.xcodeproj/project.pbxproj:
  • loader/ios/QuickLook.h: Declared setClientForTesting().
  • loader/ios/QuickLook.mm:

(testingClient): Created a static RefPtr to hold the testing client.
(testingOrEmptyClient): Returns the testing client if it's set, otherwise returns the empty client.
(-[WebPreviewConverter initWithResourceLoader:resourceResponse:quickLookHandle:]):
Initialized _client to testingOrEmptyClient(), stored the ResourceResponse's nsURLResponse()
in _originalResponse, and initialized _bufferedDataArray.
(-[WebPreviewConverter setClient:]): Ignore the new client if there is already a testing client.
(-[WebPreviewConverter appendDataArray:]): Stored the data array in _bufferedDataArray.
(-[WebPreviewConverter _sendDidReceiveResponseIfNecessary]): Cleared _bufferedDataArray.
(-[WebPreviewConverter connection:didReceiveData:lengthReceived:]): Changed the
UNUSED_PARAM() to an ASSERT_UNUSED().
(-[WebPreviewConverter connectionDidFinishLoading:]): Ditto.
(-[WebPreviewConverter connection:didFailWithError:]): If the error code is
kQLReturnPasswordProtected and the domain is QuickLookErrorDomain, request a password from
the client then create a new QLPreviewConverter with the password specified in the options dictionary.
(WebCore::QuickLookHandle::setClientForTesting): Set testingClient() to the specified client.

  • platform/ios/QuickLookSoftLink.h: Soft-linked kQLPreviewOptionPasswordKey.
  • platform/ios/QuickLookSoftLink.mm: Ditto.
  • platform/network/ios/QuickLookHandleClient.h:

(WebCore::QuickLookHandleClient::supportsPasswordEntry): Added. Tells QuickLookHandle
whether the client supports password entry.
(WebCore::QuickLookHandleClient::didRequestPassword): Added. Asks the client to specify a
password in the completionHandler lambda.

  • platform/spi/ios/QuickLookSPI.h: Declared kQLReturnPasswordProtected for the public SDK

and asserted that its value is 4.

  • testing/Internals.cpp:

(WebCore::Internals::resetToConsistentState): Reset the MockQuickLookHandleClient password
to the empty string and uninstalled the testing client.
(WebCore::Internals::setQuickLookPassword): Installed the testing client and set a password
on the MockQuickLookHandleClient.

  • testing/Internals.h:
  • testing/Internals.idl: Defined Internals.setQuickLookPassword().
  • testing/MockQuickLookHandleClient.cpp: Added.

(WebCore::MockQuickLookHandleClient::singleton): Returned a shared MockQuickLookHandleClient.
(WebCore::MockQuickLookHandleClient::didRequestPassword): Dispatched a lambda on the
main-or-Web-thread run loop to call the completionHandler with the specified password.
This simulates the delay that would happen when prompting the user for a password.

  • testing/MockQuickLookHandleClient.h: Added.

LayoutTests:

  • platform/ios-simulator/TestExpectations: Temporarily skipped the new test until the

necessary support is available in QuickLook.framework.

  • quicklook/password-protected-expected.html: Added.
  • quicklook/password-protected.html: Added.
  • quicklook/resources/password-protected.pages: Added.
Location:
trunk
Files:
3 added
14 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r210862 r210864  
     12017-01-18  Andy Estes  <aestes@apple.com>
     2
     3        [QuickLook] Support password-protected documents
     4        https://bugs.webkit.org/show_bug.cgi?id=167153
     5        <rdar://problem/28544527>
     6
     7        Reviewed by Alex Christensen.
     8
     9        * platform/ios-simulator/TestExpectations: Temporarily skipped the new test until the
     10        necessary support is available in QuickLook.framework.
     11        * quicklook/password-protected-expected.html: Added.
     12        * quicklook/password-protected.html: Added.
     13        * quicklook/resources/password-protected.pages: Added.
     14
    1152017-01-18  Youenn Fablet  <youenn@apple.com>
    216
  • trunk/LayoutTests/platform/ios-simulator/TestExpectations

    r210848 r210864  
    28312831# editing/caret/ios/emoji.html is used instead.
    28322832editing/caret/emoji.html [ Failure ]
     2833
     2834# Requires changes to QuickLook.framework tracked by rdar://problem/28544527
     2835quicklook/password-protected.html [ Skip ]
  • trunk/Source/WebCore/ChangeLog

    r210862 r210864  
     12017-01-18  Andy Estes  <aestes@apple.com>
     2
     3        [QuickLook] Support password-protected documents
     4        https://bugs.webkit.org/show_bug.cgi?id=167153
     5        <rdar://problem/28544527>
     6
     7        Reviewed by Alex Christensen.
     8
     9        Added support for previewing password-protected documents. If a document is
     10        password-protected, QLPreviewConverter will call -connection:didFailWithError: with an error
     11        code of kQLReturnPasswordProtected. When this happens, QuickLookHandle will ask the client
     12        for a password, create a new QLPreviewConverter with the password specified in an options
     13        dictionary, and replay the buffered input data into the converter. QLPreviewConverter will
     14        then send the converted document data to its delegate as usual.
     15       
     16        Password entry UI will be added later; this patch implements the necessary QuickLookHandle
     17        logic and adds support for testing.
     18
     19        Test: quicklook/password-protected.html
     20
     21        * PlatformMac.cmake:
     22        * WebCore.xcodeproj/project.pbxproj:
     23        * loader/ios/QuickLook.h: Declared setClientForTesting().
     24        * loader/ios/QuickLook.mm:
     25        (testingClient): Created a static RefPtr to hold the testing client.
     26        (testingOrEmptyClient): Returns the testing client if it's set, otherwise returns the empty client.
     27        (-[WebPreviewConverter initWithResourceLoader:resourceResponse:quickLookHandle:]):
     28        Initialized _client to testingOrEmptyClient(), stored the ResourceResponse's nsURLResponse()
     29        in _originalResponse, and initialized _bufferedDataArray.
     30        (-[WebPreviewConverter setClient:]): Ignore the new client if there is already a testing client.
     31        (-[WebPreviewConverter appendDataArray:]): Stored the data array in _bufferedDataArray.
     32        (-[WebPreviewConverter _sendDidReceiveResponseIfNecessary]): Cleared _bufferedDataArray.
     33        (-[WebPreviewConverter connection:didReceiveData:lengthReceived:]): Changed the
     34        UNUSED_PARAM() to an ASSERT_UNUSED().
     35        (-[WebPreviewConverter connectionDidFinishLoading:]): Ditto.
     36        (-[WebPreviewConverter connection:didFailWithError:]): If the error code is
     37        kQLReturnPasswordProtected and the domain is QuickLookErrorDomain, request a password from
     38        the client then create a new QLPreviewConverter with the password specified in the options dictionary.
     39        (WebCore::QuickLookHandle::setClientForTesting): Set testingClient() to the specified client.
     40        * platform/ios/QuickLookSoftLink.h: Soft-linked kQLPreviewOptionPasswordKey.
     41        * platform/ios/QuickLookSoftLink.mm: Ditto.
     42        * platform/network/ios/QuickLookHandleClient.h:
     43        (WebCore::QuickLookHandleClient::supportsPasswordEntry): Added. Tells QuickLookHandle
     44        whether the client supports password entry.
     45        (WebCore::QuickLookHandleClient::didRequestPassword): Added. Asks the client to specify a
     46        password in the completionHandler lambda.
     47        * platform/spi/ios/QuickLookSPI.h: Declared kQLReturnPasswordProtected for the public SDK
     48        and asserted that its value is 4.
     49        * testing/Internals.cpp:
     50        (WebCore::Internals::resetToConsistentState): Reset the MockQuickLookHandleClient password
     51        to the empty string and uninstalled the testing client.
     52        (WebCore::Internals::setQuickLookPassword): Installed the testing client and set a password
     53        on the MockQuickLookHandleClient.
     54        * testing/Internals.h:
     55        * testing/Internals.idl: Defined Internals.setQuickLookPassword().
     56        * testing/MockQuickLookHandleClient.cpp: Added.
     57        (WebCore::MockQuickLookHandleClient::singleton): Returned a shared MockQuickLookHandleClient.
     58        (WebCore::MockQuickLookHandleClient::didRequestPassword): Dispatched a lambda on the
     59        main-or-Web-thread run loop to call the completionHandler with the specified password.
     60        This simulates the delay that would happen when prompting the user for a password.
     61        * testing/MockQuickLookHandleClient.h: Added.
     62
    1632017-01-18  Youenn Fablet  <youenn@apple.com>
    264
  • trunk/Source/WebCore/PlatformMac.cmake

    r210532 r210864  
    748748    testing/MockContentFilter.cpp
    749749    testing/MockContentFilterSettings.cpp
     750    testing/MockQuickLookHandleClient.cpp
    750751
    751752    testing/cocoa/WebArchiveDumpSupport.mm
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r210844 r210864  
    38903890                A136A00C1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A136A00A1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.cpp */; };
    38913891                A136A00D1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.h in Headers */ = {isa = PBXBuildFile; fileRef = A136A00B1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.h */; };
     3892                A140618B1E2ECA0A0032B34E /* MockQuickLookHandleClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A14061891E2ECA0A0032B34E /* MockQuickLookHandleClient.cpp */; };
     3893                A140618C1E2ECA0A0032B34E /* MockQuickLookHandleClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A140618A1E2ECA0A0032B34E /* MockQuickLookHandleClient.h */; };
    38923894                A14090FB1AA51E1D0091191A /* ContentFilterUnblockHandlerCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = A14090FA1AA51E1D0091191A /* ContentFilterUnblockHandlerCocoa.mm */; };
    38933895                A14090FD1AA51E480091191A /* ContentFilterUnblockHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = A14090FC1AA51E480091191A /* ContentFilterUnblockHandler.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    1155511557                A136A00A1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLHttpRequestProgressEventThrottle.cpp; sourceTree = "<group>"; };
    1155611558                A136A00B1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLHttpRequestProgressEventThrottle.h; sourceTree = "<group>"; };
     11559                A14061891E2ECA0A0032B34E /* MockQuickLookHandleClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MockQuickLookHandleClient.cpp; sourceTree = "<group>"; };
     11560                A140618A1E2ECA0A0032B34E /* MockQuickLookHandleClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockQuickLookHandleClient.h; sourceTree = "<group>"; };
    1155711561                A14090FA1AA51E1D0091191A /* ContentFilterUnblockHandlerCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ContentFilterUnblockHandlerCocoa.mm; sourceTree = "<group>"; };
    1155811562                A14090FC1AA51E480091191A /* ContentFilterUnblockHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentFilterUnblockHandler.h; sourceTree = "<group>"; };
     
    1661316617                                2DAAE32C19DCAF6000E002D2 /* MockPageOverlayClient.cpp */,
    1661416618                                2DAAE32D19DCAF6000E002D2 /* MockPageOverlayClient.h */,
     16619                                A14061891E2ECA0A0032B34E /* MockQuickLookHandleClient.cpp */,
     16620                                A140618A1E2ECA0A0032B34E /* MockQuickLookHandleClient.h */,
    1661516621                                EB081CD81696084400553730 /* TypeConversions.h */,
    1661616622                                EB081CD91696084400553730 /* TypeConversions.idl */,
     
    2480824814                                417DA6DA13734E6E007C57FB /* Internals.h in Headers */,
    2480924815                                A7BF7EE014C9175A0014489D /* InternalSettings.h in Headers */,
     24816                                A140618C1E2ECA0A0032B34E /* MockQuickLookHandleClient.h in Headers */,
    2481024817                                53E29E5F167A8A1900586D3D /* InternalSettingsGenerated.h in Headers */,
    2481124818                                51714EB11CF665CE004723C4 /* JSGCObservation.h in Headers */,
     
    2873628743                                51058ADD1D6792C1009A538C /* MockGamepadProvider.cpp in Sources */,
    2873728744                                CDF4B7311E03D00700E235A2 /* MockCDMFactory.cpp in Sources */,
     28745                                A140618B1E2ECA0A0032B34E /* MockQuickLookHandleClient.cpp in Sources */,
    2873828746                                2D6F3E901C1ECB270061DBD4 /* MockPageOverlay.cpp in Sources */,
    2873928747                                CDF4B7321E03D06000E235A2 /* JSMockCDMFactory.cpp in Sources */,
  • trunk/Source/WebCore/loader/ios/QuickLook.h

    r210796 r210864  
    8383
    8484    WEBCORE_EXPORT void setClient(Ref<QuickLookHandleClient>&&);
     85    WEBCORE_EXPORT static void setClientForTesting(RefPtr<QuickLookHandleClient>&&);
    8586
    8687    WEBCORE_EXPORT String previewFileName() const;
  • trunk/Source/WebCore/loader/ios/QuickLook.mm

    r210796 r210864  
    179179}
    180180
     181static RefPtr<QuickLookHandleClient>& testingClient()
     182{
     183    static NeverDestroyed<RefPtr<QuickLookHandleClient>> testingClient;
     184    return testingClient.get();
     185}
     186
    181187static QuickLookHandleClient& emptyClient()
    182188{
    183189    static NeverDestroyed<QuickLookHandleClient> emptyClient;
    184190    return emptyClient.get();
     191}
     192
     193static QuickLookHandleClient& testingOrEmptyClient()
     194{
     195    if (testingClient())
     196        return *testingClient();
     197    return emptyClient();
    185198}
    186199
     
    189202    QuickLookHandle* _handle;
    190203    RefPtr<QuickLookHandleClient> _client;
     204    RetainPtr<NSURLResponse> _originalResponse;
    191205    RetainPtr<QLPreviewConverter> _platformConverter;
    192206    RetainPtr<NSURLResponse> _previewResponse;
     207    RetainPtr<NSMutableArray> _bufferedDataArray;
    193208    BOOL _hasSentDidReceiveResponse;
    194209    BOOL _hasFailed;
     
    215230    _resourceLoader = &resourceLoader;
    216231    _handle = &quickLookHandle;
    217     _client = &emptyClient();
    218     _platformConverter = adoptNS([allocQLPreviewConverterInstance() initWithConnection:nil delegate:self response:resourceResponse.nsURLResponse() options:nil]);
     232    _client = &testingOrEmptyClient();
     233    _originalResponse = resourceResponse.nsURLResponse();
     234    _platformConverter = adoptNS([allocQLPreviewConverterInstance() initWithConnection:nil delegate:self response:_originalResponse.get() options:nil]);
    219235    _previewResponse = [_platformConverter previewResponse];
     236    _bufferedDataArray = adoptNS([[NSMutableArray alloc] init]);
    220237
    221238    LOG(Network, "WebPreviewConverter created with preview file name \"%s\".", [_platformConverter previewFileName]);
     
    225242- (void)setClient:(Ref<QuickLookHandleClient>&&)client
    226243{
    227     _client = WTFMove(client);
     244    if (!testingClient())
     245        _client = WTFMove(client);
    228246}
    229247
     
    232250    LOG(Network, "WebPreviewConverter appending data array with count %ld.", dataArray.count);
    233251    [_platformConverter appendDataArray:dataArray];
     252    [_bufferedDataArray addObjectsFromArray:dataArray];
    234253    _client->didReceiveDataArray((CFArrayRef)dataArray);
    235254}
     
    256275- (void)_sendDidReceiveResponseIfNecessary
    257276{
     277    [_bufferedDataArray removeAllObjects];
     278
    258279    if (_hasSentDidReceiveResponse || _hasFailed)
    259280        return;
     
    276297- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data lengthReceived:(long long)lengthReceived
    277298{
    278     UNUSED_PARAM(connection);
     299    ASSERT_UNUSED(connection, !connection);
    279300    [self _sendDidReceiveResponseIfNecessary];
    280301    if (_hasFailed)
     
    289310- (void)connectionDidFinishLoading:(NSURLConnection *)connection
    290311{
    291     UNUSED_PARAM(connection);
     312    ASSERT_UNUSED(connection, !connection);
    292313    if (_hasFailed)
    293314        return;
     
    299320- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
    300321{
    301     UNUSED_PARAM(connection);
     322    ASSERT_UNUSED(connection, !connection);
     323
     324    if (error.code == kQLReturnPasswordProtected && [error.domain isEqualToString:@"QuickLookErrorDomain"]) {
     325        if (!_client->supportsPasswordEntry()) {
     326            _resourceLoader->didFail(_resourceLoader->cannotShowURLError());
     327            return;
     328        }
     329
     330        _client->didRequestPassword([retainedSelf = retainPtr(self)] (const String& password) {
     331            NSDictionary *passwordOption = @{ (NSString *)kQLPreviewOptionPasswordKey : password };
     332            auto converterWithPassword = adoptNS([allocQLPreviewConverterInstance() initWithConnection:nil delegate:retainedSelf.get() response:retainedSelf->_originalResponse.get() options:passwordOption]);
     333            [converterWithPassword appendDataArray:retainedSelf->_bufferedDataArray.get()];
     334            [converterWithPassword finishedAppendingData];
     335            retainedSelf->_previewResponse = [converterWithPassword previewResponse];
     336            retainedSelf->_platformConverter = WTFMove(converterWithPassword);
     337        });
     338        return;
     339    }
     340
    302341    [self _sendDidReceiveResponseIfNecessary];
    303342    if (!_hasFailed)
     
    388427}
    389428
     429void QuickLookHandle::setClientForTesting(RefPtr<QuickLookHandleClient>&& client)
     430{
     431    testingClient() = WTFMove(client);
     432}
     433
    390434String QuickLookHandle::previewFileName() const
    391435{
  • trunk/Source/WebCore/platform/ios/QuickLookSoftLink.h

    r183598 r210864  
    11/*
    2  * Copyright (C) 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4444#define QLPreviewScheme get_QuickLook_QLPreviewScheme()
    4545
     46SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, QuickLook, kQLPreviewOptionPasswordKey, CFStringRef)
     47#define kQLPreviewOptionPasswordKey get_QuickLook_kQLPreviewOptionPasswordKey()
     48
    4649#endif // USE(QUICK_LOOK)
  • trunk/Source/WebCore/platform/ios/QuickLookSoftLink.mm

    r183598 r210864  
    11/*
    2  * Copyright (C) 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4141SOFT_LINK_POINTER_FOR_SOURCE(WebCore, QuickLook, QLPreviewScheme, NSString *)
    4242
     43SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, QuickLook, kQLPreviewOptionPasswordKey, CFStringRef)
     44
    4345#endif // USE(QUICK_LOOK)
  • trunk/Source/WebCore/platform/network/ios/QuickLookHandleClient.h

    r167207 r210864  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #ifndef QuickLookHandleClient_h
    27 #define QuickLookHandleClient_h
     26#pragma once
    2827
    2928#if USE(QUICK_LOOK)
    3029
    3130#include <CoreFoundation/CoreFoundation.h>
     31#include <wtf/Function.h>
    3232#include <wtf/RefCounted.h>
     33#include <wtf/text/WTFString.h>
    3334
    3435namespace WebCore {
     
    4041    virtual void didFinishLoading() { }
    4142    virtual void didFail() { }
     43    virtual bool supportsPasswordEntry() const { return false; }
     44    virtual void didRequestPassword(Function<void(const String&)>&& completionHandler) { completionHandler(""); }
    4245};
    4346
     
    4548
    4649#endif // USE(QUICK_LOOK)
    47 
    48 #endif // QuickLookHandleClient_h
  • trunk/Source/WebCore/platform/spi/ios/QuickLookSPI.h

    r205488 r210864  
    11/*
    2  * Copyright (C) 2014-2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4848@end
    4949
     50#define kQLReturnPasswordProtected 1 << 2
     51
    5052#endif
     53
     54static_assert(kQLReturnPasswordProtected == 4, "kQLReturnPasswordProtected should equal 4.");
    5155
    5256WTF_EXTERN_C_BEGIN
  • trunk/Source/WebCore/testing/Internals.cpp

    r210859 r210864  
    225225#endif
    226226
     227#if USE(QUICK_LOOK)
     228#include "MockQuickLookHandleClient.h"
     229#include "QuickLook.h"
     230#endif
     231
    227232using JSC::CallData;
    228233using JSC::CallType;
     
    425430
    426431    page.setShowAllPlugins(false);
     432
     433#if USE(QUICK_LOOK)
     434    MockQuickLookHandleClient::singleton().setPassword("");
     435    QuickLookHandle::setClientForTesting(nullptr);
     436#endif
    427437}
    428438
     
    36533663}
    36543664
     3665#if USE(QUICK_LOOK)
     3666void Internals::setQuickLookPassword(const String& password)
     3667{
     3668    auto& quickLookHandleClient = MockQuickLookHandleClient::singleton();
     3669    QuickLookHandle::setClientForTesting(&quickLookHandleClient);
     3670    quickLookHandleClient.setPassword(password);
     3671}
     3672#endif
     3673
    36553674} // namespace WebCore
  • trunk/Source/WebCore/testing/Internals.h

    r210560 r210864  
    532532    Vector<String> accessKeyModifiers() const;
    533533
     534#if USE(QUICK_LOOK)
     535    void setQuickLookPassword(const String&);
     536#endif
     537
    534538private:
    535539    explicit Internals(Document&);
  • trunk/Source/WebCore/testing/Internals.idl

    r210560 r210864  
    11/*
    22 * Copyright (C) 2012 Google Inc. All rights reserved.
    3  * Copyright (C) 2013-2016 Apple Inc. All rights reserved.
     3 * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    505505
    506506    sequence<DOMString> accessKeyModifiers();
    507 };
     507
     508#if defined(WTF_PLATFORM_IOS) && WTF_PLATFORM_IOS
     509    void setQuickLookPassword(DOMString password);
     510#endif
     511};
  • trunk/Source/WebCore/testing/MockQuickLookHandleClient.cpp

    r210863 r210864  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #ifndef QuickLookHandleClient_h
    27 #define QuickLookHandleClient_h
     26#include "config.h"
     27#include "MockQuickLookHandleClient.h"
    2828
    2929#if USE(QUICK_LOOK)
    3030
    31 #include <CoreFoundation/CoreFoundation.h>
    32 #include <wtf/RefCounted.h>
     31#include <wtf/MainThread.h>
     32#include <wtf/RunLoop.h>
    3333
    3434namespace WebCore {
    3535
    36 class QuickLookHandleClient : public RefCounted<QuickLookHandleClient> {
    37 public:
    38     virtual ~QuickLookHandleClient() { }
    39     virtual void didReceiveDataArray(CFArrayRef) { }
    40     virtual void didFinishLoading() { }
    41     virtual void didFail() { }
    42 };
     36MockQuickLookHandleClient& MockQuickLookHandleClient::singleton()
     37{
     38    static NeverDestroyed<MockQuickLookHandleClient> sharedClient;
     39    return sharedClient.get();
     40}
     41
     42void MockQuickLookHandleClient::didRequestPassword(Function<void(const String&)>&& completionHandler)
     43{
     44    ASSERT(isMainThread());
     45    RunLoop::current().dispatch([completionHandler = WTFMove(completionHandler), password = m_password] {
     46        completionHandler(password);
     47    });
     48}
    4349
    4450} // namespace WebCore
    4551
    4652#endif // USE(QUICK_LOOK)
    47 
    48 #endif // QuickLookHandleClient_h
  • trunk/Source/WebCore/testing/MockQuickLookHandleClient.h

    r210863 r210864  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #ifndef QuickLookHandleClient_h
    27 #define QuickLookHandleClient_h
     26#pragma once
    2827
    2928#if USE(QUICK_LOOK)
    3029
    31 #include <CoreFoundation/CoreFoundation.h>
    32 #include <wtf/RefCounted.h>
     30#include "QuickLookHandleClient.h"
     31#include <wtf/NeverDestroyed.h>
    3332
    3433namespace WebCore {
    3534
    36 class QuickLookHandleClient : public RefCounted<QuickLookHandleClient> {
     35class MockQuickLookHandleClient final : public QuickLookHandleClient {
    3736public:
    38     virtual ~QuickLookHandleClient() { }
    39     virtual void didReceiveDataArray(CFArrayRef) { }
    40     virtual void didFinishLoading() { }
    41     virtual void didFail() { }
     37    static MockQuickLookHandleClient& singleton();
     38
     39    void setPassword(const String& password) { m_password = password; }
     40
     41    bool supportsPasswordEntry() const override { return true; }
     42    void didRequestPassword(Function<void(const String&)>&&) override;
     43
     44private:
     45    friend class NeverDestroyed<MockQuickLookHandleClient>;
     46    MockQuickLookHandleClient() = default;
     47
     48    String m_password;
    4249};
    4350
     
    4552
    4653#endif // USE(QUICK_LOOK)
    47 
    48 #endif // QuickLookHandleClient_h
Note: See TracChangeset for help on using the changeset viewer.