Changeset 171252 in webkit


Ignore:
Timestamp:
Jul 18, 2014 5:19:26 PM (10 years ago)
Author:
aestes@apple.com
Message:

[iOS] Tapping "Allow Website" on a restricted page does not bring up the keypad
https://bugs.webkit.org/show_bug.cgi?id=135072
<rdar://problem/17528188>

Reviewed by David Kilzer.

Source/WebCore:
No new tests. Content filtering is not testable from WebKit.

  • WebCore.exp.in: Exported necessary ContentFilter symbols.
  • loader/DocumentLoader.cpp:

(WebCore::DocumentLoader::finishedLoading): Called FrameLoaderClient::contentFilterDidBlockLoad().
(WebCore::DocumentLoader::responseReceived): Created a new ContentFilter.
(WebCore::DocumentLoader::dataReceived): Called FrameLoaderClient::contentFilterDidBlockLoad().
(WebCore::DocumentLoader::setContentFilterForBlockedLoad): Deleted.
(WebCore::DocumentLoader::handleContentFilterRequest): Deleted.

  • loader/DocumentLoader.h:
  • loader/FrameLoaderClient.h:

(WebCore::FrameLoaderClient::contentFilterDidBlockLoad):

  • loader/PolicyChecker.cpp:

(WebCore::PolicyChecker::checkNavigationPolicy): Removed the check for unblock navigations, as this is now
handled at the WebKit layer.

  • platform/ContentFilter.h: ContentFilter no longer needs to be RefCounted, so made various changes in order to

make it compatible with unique_ptr.

  • platform/ios/ContentFilterIOS.mm:

(WebCore::scheme): Changed from a public member function to a static inline free function.
(WebCore::ContentFilter::handleUnblockRequestAndDispatchIfSuccessful): Renamed from requestUnblockAndDispatchIfSuccessful.

  • platform/mac/ContentFilterMac.mm:

(WebCore::ContentFilter::ContentFilter): Added a default constructor for use during message decoding.
(WebCore::ContentFilter::addData): Removed calls to ref() and deref(). These were never actually needed since
we were dispatching the block synchronously.
(WebCore::ContentFilter::finishedAddingData): Ditto.
(WebCore::ContentFilter::encode): Encoded m_platformContentFilter to the NSKeyedArchiver if it conforms to NSSecureCoding.
(WebCore::ContentFilter::decode): Decoded m_platformContentFilter from the NSKeyedUnarchiver if it conforms to NSSecureCoding.
(WebCore::ContentFilter::create): Deleted.

Source/WebKit/mac:

  • WebCoreSupport/WebFrameLoaderClient.h: Override contentFilterDidBlockLoad().
  • WebCoreSupport/WebFrameLoaderClient.mm:

(WebFrameLoaderClient::dispatchDidStartProvisionalLoad): Reset contentFilterForBlockedLoad to nullptr.
(WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction): Check if this is navigation represents an
unblock request and ignore if so.

  • WebView/WebFrame.mm:

(-[WebFrame _contentFilterDidHandleNavigationAction:]): Called ContentFilter::handleUnblockRequestAndDispatchIfSuccessful().
If the unblock is successful, reload the main frame.

  • WebView/WebFrameInternal.h:

Source/WebKit2:

  • Shared/WebCoreArgumentCoders.h: Declared an ArgumentCoder for WebCore::ContentFilter.
  • Shared/mac/WebCoreArgumentCodersMac.mm:

(IPC::ArgumentCoder<ContentFilter>::encode): Encoded the ContentFilter using a NSKeyedArchiver.
(IPC::ArgumentCoder<ContentFilter>::decode): Decoded the ContentFilter using a NSKeyedUnarchiver.

  • UIProcess/Cocoa/WebPageProxyCocoa.mm:

(WebKit::WebPageProxy::contentFilterDidBlockLoadForFrame): Called WebFrameProxy::setContentFilterForBlockedLoad().

  • UIProcess/WebFrameProxy.cpp:

(WebKit::WebFrameProxy::didStartProvisionalLoad): Reset m_contentFilterForBlockedLoad to nullptr.
(WebKit::WebFrameProxy::contentFilterDidHandleNavigationAction): Called ContentFilter::handleUnblockRequestAndDispatchIfSuccessful().
If the unblock is successful, reload the WebPageProxy.

  • UIProcess/WebFrameProxy.h:

(WebKit::WebFrameProxy::setContentFilterForBlockedLoad):

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::decidePolicyForNavigationAction): Check if this is navigation represents an unblock
request and ignore if so.

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in: Defined ContentFilterDidBlockLoadForFrame.
  • WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:

(WebKit::WebFrameLoaderClient::contentFilterDidBlockLoad): Sent ContentFilterDidBlockLoadForFrame to the WebPageProxy.

  • WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
Location:
trunk/Source
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r171250 r171252  
     12014-07-18  Andy Estes  <aestes@apple.com>
     2
     3        [iOS] Tapping "Allow Website" on a restricted page does not bring up the keypad
     4        https://bugs.webkit.org/show_bug.cgi?id=135072
     5        <rdar://problem/17528188>
     6
     7        Reviewed by David Kilzer.
     8
     9        No new tests. Content filtering is not testable from WebKit.
     10
     11        * WebCore.exp.in: Exported necessary ContentFilter symbols.
     12        * loader/DocumentLoader.cpp:
     13        (WebCore::DocumentLoader::finishedLoading): Called FrameLoaderClient::contentFilterDidBlockLoad().
     14        (WebCore::DocumentLoader::responseReceived): Created a new ContentFilter.
     15        (WebCore::DocumentLoader::dataReceived): Called FrameLoaderClient::contentFilterDidBlockLoad().
     16        (WebCore::DocumentLoader::setContentFilterForBlockedLoad): Deleted.
     17        (WebCore::DocumentLoader::handleContentFilterRequest): Deleted.
     18        * loader/DocumentLoader.h:
     19        * loader/FrameLoaderClient.h:
     20        (WebCore::FrameLoaderClient::contentFilterDidBlockLoad):
     21        * loader/PolicyChecker.cpp:
     22        (WebCore::PolicyChecker::checkNavigationPolicy): Removed the check for unblock navigations, as this is now
     23        handled at the WebKit layer.
     24        * platform/ContentFilter.h: ContentFilter no longer needs to be RefCounted, so made various changes in order to
     25        make it compatible with unique_ptr.
     26        * platform/ios/ContentFilterIOS.mm:
     27        (WebCore::scheme): Changed from a public member function to a static inline free function.
     28        (WebCore::ContentFilter::handleUnblockRequestAndDispatchIfSuccessful): Renamed from requestUnblockAndDispatchIfSuccessful.
     29        * platform/mac/ContentFilterMac.mm:
     30        (WebCore::ContentFilter::ContentFilter): Added a default constructor for use during message decoding.
     31        (WebCore::ContentFilter::addData): Removed calls to ref() and deref(). These were never actually needed since
     32        we were dispatching the block synchronously.
     33        (WebCore::ContentFilter::finishedAddingData): Ditto.
     34        (WebCore::ContentFilter::encode): Encoded m_platformContentFilter to the NSKeyedArchiver if it conforms to NSSecureCoding.
     35        (WebCore::ContentFilter::decode): Decoded m_platformContentFilter from the NSKeyedUnarchiver if it conforms to NSSecureCoding.
     36        (WebCore::ContentFilter::create): Deleted.
     37
    1382014-07-18  Simon Fraser  <simon.fraser@apple.com>
    239
  • trunk/Source/WebCore/WebCore.exp.in

    r171203 r171252  
    34633463__ZN7WebCore4Page11setViewModeENS0_8ViewModeE
    34643464#endif
     3465
     3466#if USE(CONTENT_FILTERING)
     3467#if PLATFORM(IOS)
     3468__ZN7WebCore13ContentFilter43handleUnblockRequestAndDispatchIfSuccessfulERKNS_15ResourceRequestENSt3__18functionIFvvEEE
     3469#endif
     3470__ZN7WebCore13ContentFilter6decodeEP17NSKeyedUnarchiverRS0_
     3471__ZN7WebCore13ContentFilterC1Ev
     3472__ZN7WebCore13ContentFilterD1Ev
     3473__ZNK7WebCore13ContentFilter6encodeEP15NSKeyedArchiver
     3474#endif
  • trunk/Source/WebCore/loader/DocumentLoader.cpp

    r170984 r171252  
    414414
    415415        if (m_contentFilter->didBlockData())
    416             setContentFilterForBlockedLoad(m_contentFilter);
     416            frameLoader()->client().contentFilterDidBlockLoad(WTF::move(m_contentFilter));
    417417    }
    418418#endif
     
    665665#if USE(CONTENT_FILTERING)
    666666    if (response.url().protocolIsInHTTPFamily() && ContentFilter::isEnabled())
    667         m_contentFilter = ContentFilter::create(response);
     667        m_contentFilter = std::make_unique<ContentFilter>(response);
    668668#endif
    669669
     
    875875
    876876        if (loadWasBlockedBeforeFinishing)
    877             setContentFilterForBlockedLoad(m_contentFilter);
     877            frameLoader()->client().contentFilterDidBlockLoad(WTF::move(m_contentFilter));
    878878    }
    879879#endif
     
    15661566}
    15671567
    1568 #if USE(CONTENT_FILTERING)
    1569 void DocumentLoader::setContentFilterForBlockedLoad(PassRefPtr<ContentFilter> contentFilter)
    1570 {
    1571     ASSERT(!m_contentFilterForBlockedLoad);
    1572     ASSERT(contentFilter);
    1573     ASSERT(contentFilter->didBlockData());
    1574     m_contentFilterForBlockedLoad = contentFilter;
    1575 }
    1576 
    1577 bool DocumentLoader::handleContentFilterRequest(const ResourceRequest& request)
    1578 {
    1579     // FIXME: Remove PLATFORM(IOS)-guard once we upstream ContentFilterIOS.mm and
    1580     // implement ContentFilter::requestUnblockAndDispatchIfSuccessful() for Mac.
    1581 #if PLATFORM(IOS)
    1582     if (!m_contentFilterForBlockedLoad)
    1583         return false;
    1584 
    1585     if (!request.url().protocolIs(ContentFilter::scheme()))
    1586         return false;
    1587 
    1588     if (equalIgnoringCase(request.url().host(), "unblock")) {
    1589         // Tell the FrameLoader to reload if the unblock is successful.
    1590         m_contentFilterForBlockedLoad->requestUnblockAndDispatchIfSuccessful(bind(&FrameLoader::reload, &(m_frame->loader()), false));
    1591         return true;
    1592     }
    1593 
    1594     return false;
    1595 #else
    1596     UNUSED_PARAM(request);
    1597     return false;
    1598 #endif
    1599 }
    1600 #endif
    1601 
    16021568} // namespace WebCore
  • trunk/Source/WebCore/loader/DocumentLoader.h

    r170113 r171252  
    257257        void checkLoadComplete();
    258258
    259 #if USE(CONTENT_FILTERING)
    260         void setContentFilterForBlockedLoad(PassRefPtr<ContentFilter>);
    261         bool handleContentFilterRequest(const ResourceRequest&);
    262 #endif
    263 
    264259        // The URL of the document resulting from this DocumentLoader.
    265260        URL documentURL() const;
     
    416411
    417412#if USE(CONTENT_FILTERING)
    418         RefPtr<ContentFilter> m_contentFilter;
    419         RefPtr<ContentFilter> m_contentFilterForBlockedLoad;
     413        std::unique_ptr<ContentFilter> m_contentFilter;
    420414#endif
    421415    };
  • trunk/Source/WebCore/loader/FrameLoaderClient.h

    r171239 r171252  
    9999#endif
    100100
     101#if USE(CONTENT_FILTERING)
     102    class ContentFilter;
     103#endif
     104
    101105    typedef std::function<void (PolicyAction)> FramePolicyFunction;
    102106
     
    332336        virtual void didCreateQuickLookHandle(QuickLookHandle&) { }
    333337#endif
     338
     339#if USE(CONTENT_FILTERING)
     340        virtual void contentFilterDidBlockLoad(std::unique_ptr<ContentFilter>) { }
     341#endif
    334342    };
    335343
  • trunk/Source/WebCore/loader/PolicyChecker.cpp

    r170774 r171252  
    4747#endif
    4848
    49 #if USE(CONTENT_FILTERING)
    50 #include "ContentFilter.h"
    51 #endif
    52 
    5349namespace WebCore {
    5450
     
    110106#endif
    111107
    112 #if USE(CONTENT_FILTERING)
    113     if (DocumentLoader* documentLoader = m_frame.loader().documentLoader()) {
    114         if (documentLoader->handleContentFilterRequest(request)) {
    115             continueAfterNavigationPolicy(PolicyIgnore);
    116             return;
    117         }
    118     }
    119 #endif
    120 
    121108    m_delegateIsDecidingNavigationPolicy = true;
    122109    m_frame.loader().client().dispatchDecidePolicyForNavigationAction(action, request, formState, [this](PolicyAction action) {
  • trunk/Source/WebCore/platform/ContentFilter.h

    r163657 r171252  
    3131#include <wtf/PassRefPtr.h>
    3232#include <wtf/RetainPtr.h>
    33 #include <wtf/ThreadSafeRefCounted.h>
    3433
    3534#if PLATFORM(IOS)
    36 #include <wtf/Functional.h>
     35#include <functional>
    3736#endif
    3837
    3938#if PLATFORM(COCOA)
    40 OBJC_CLASS NSMutableData;
     39OBJC_CLASS NSData;
     40OBJC_CLASS NSKeyedArchiver;
     41OBJC_CLASS NSKeyedUnarchiver;
    4142OBJC_CLASS WebFilterEvaluator;
    4243#endif
     
    4546
    4647#if HAVE(NE_FILTER_SOURCE)
    47 #import <atomic>
    4848#import <dispatch/dispatch.h>
    4949OBJC_CLASS NEFilterSource;
     50OBJC_CLASS NSMutableData;
    5051#endif
    5152
    5253namespace WebCore {
    5354
     55class ResourceRequest;
    5456class ResourceResponse;
    5557
    56 class ContentFilter : public ThreadSafeRefCounted<ContentFilter> {
     58class ContentFilter {
    5759public:
    58     static PassRefPtr<ContentFilter> create(const ResourceResponse&);
    5960    static bool isEnabled();
    6061
    61     virtual ~ContentFilter();
     62    explicit ContentFilter(const ResourceResponse&);
     63    ~ContentFilter();
    6264
    6365    void addData(const char* data, int length);
     
    6668    bool didBlockData() const;
    6769    const char* getReplacementData(int& length) const;
    68    
     70
     71#if PLATFORM(COCOA)
     72    ContentFilter();
     73    void encode(NSKeyedArchiver *) const;
     74    static bool decode(NSKeyedUnarchiver *, ContentFilter&);
     75#endif
     76
    6977#if PLATFORM(IOS)
    70     static const char* scheme();
    71     void requestUnblockAndDispatchIfSuccessful(Function<void()>);
     78    bool handleUnblockRequestAndDispatchIfSuccessful(const ResourceRequest&, std::function<void()>);
    7279#endif
    7380
    7481private:
    75     explicit ContentFilter(const ResourceResponse&);
    76    
    7782#if PLATFORM(COCOA)
    7883    RetainPtr<WebFilterEvaluator> m_platformContentFilter;
     
    8186
    8287#if HAVE(NE_FILTER_SOURCE)
    83     std::atomic<long> m_neFilterSourceStatus;
     88    long m_neFilterSourceStatus;
    8489    RetainPtr<NEFilterSource> m_neFilterSource;
    8590    dispatch_queue_t m_neFilterSourceQueue;
  • trunk/Source/WebCore/platform/ios/ContentFilterIOS.mm

    r161589 r171252  
    2929#if PLATFORM(IOS) && USE(CONTENT_FILTERING)
    3030
     31#import "ResourceRequest.h"
    3132#import "WebCoreThreadRun.h"
    3233
     
    4142namespace WebCore {
    4243
    43 const char* ContentFilter::scheme()
     44static inline const char* scheme()
    4445{
    4546    static const char contentFilterScheme[] = "x-apple-content-filter";
    4647    return contentFilterScheme;
    4748}
    48    
    49 void ContentFilter::requestUnblockAndDispatchIfSuccessful(Function<void()> function)
     49
     50bool ContentFilter::handleUnblockRequestAndDispatchIfSuccessful(const ResourceRequest& request, std::function<void()> function)
    5051{
     52    if (!request.url().protocolIs(scheme()))
     53        return false;
     54
     55    if (!equalIgnoringCase(request.url().host(), "unblock"))
     56        return false;
     57
    5158    [m_platformContentFilter unblockWithCompletion:^(BOOL unblocked, NSError *) {
    52         if (unblocked) {
    53             WebThreadRun(^{
    54                 function();
    55             });
    56         }
     59        if (unblocked)
     60            function();
    5761    }];
     62    return true;
    5863}
    5964
  • trunk/Source/WebCore/platform/mac/ContentFilterMac.mm

    r167023 r171252  
    8686namespace WebCore {
    8787
    88 PassRefPtr<ContentFilter> ContentFilter::create(const ResourceResponse& response)
    89 {
    90     return adoptRef(new ContentFilter(response));
     88ContentFilter::ContentFilter()
     89#if HAVE(NE_FILTER_SOURCE)
     90    : m_neFilterSourceStatus(NEFilterSourceStatusNeedsMoreData)
     91    , m_neFilterSourceQueue(0)
     92#endif
     93{
    9194}
    9295
     
    151154    [m_originalData appendBytes:data length:length];
    152155
    153     ref();
    154156    dispatch_semaphore_t neFilterSourceSemaphore = dispatch_semaphore_create(0);
    155157    [m_neFilterSource addData:[NSData dataWithBytes:(void*)data length:length] withCompletionQueue:m_neFilterSourceQueue completionHandler:^(NEFilterSourceStatus status, NSData *) {
    156158        m_neFilterSourceStatus = status;
    157         deref();
    158159        dispatch_semaphore_signal(neFilterSourceSemaphore);
    159160    }];
     
    180181        return;
    181182
    182     ref();
    183183    dispatch_semaphore_t neFilterSourceSemaphore = dispatch_semaphore_create(0);
    184184    [m_neFilterSource dataCompleteWithCompletionQueue:m_neFilterSourceQueue completionHandler:^(NEFilterSourceStatus status, NSData *) {
    185185        m_neFilterSourceStatus = status;
    186         deref();
    187186        dispatch_semaphore_signal(neFilterSourceSemaphore);
    188187    }];
     
    235234}
    236235
     236static NSString * const platformContentFilterKey = @"platformContentFilter";
     237
     238void ContentFilter::encode(NSKeyedArchiver *archiver) const
     239{
     240    if ([getWebFilterEvaluatorClass() conformsToProtocol:@protocol(NSSecureCoding)])
     241        [archiver encodeObject:m_platformContentFilter.get() forKey:platformContentFilterKey];
     242}
     243
     244bool ContentFilter::decode(NSKeyedUnarchiver *unarchiver, ContentFilter& contentFilter)
     245{
     246    @try {
     247        if ([getWebFilterEvaluatorClass() conformsToProtocol:@protocol(NSSecureCoding)])
     248            contentFilter.m_platformContentFilter = (WebFilterEvaluator *)[unarchiver decodeObjectOfClass:getWebFilterEvaluatorClass() forKey:platformContentFilterKey];
     249        return true;
     250    } @catch (NSException *exception) {
     251        LOG_ERROR("The platform content filter being decoded is not a WebFilterEvaluator.");
     252    }
     253
     254    return false;
     255}
     256
    237257} // namespace WebCore
    238258
  • trunk/Source/WebKit/mac/ChangeLog

    r171212 r171252  
     12014-07-18  Andy Estes  <aestes@apple.com>
     2
     3        [iOS] Tapping "Allow Website" on a restricted page does not bring up the keypad
     4        https://bugs.webkit.org/show_bug.cgi?id=135072
     5        <rdar://problem/17528188>
     6
     7        Reviewed by David Kilzer.
     8
     9        * WebCoreSupport/WebFrameLoaderClient.h: Override contentFilterDidBlockLoad().
     10        * WebCoreSupport/WebFrameLoaderClient.mm:
     11        (WebFrameLoaderClient::dispatchDidStartProvisionalLoad): Reset contentFilterForBlockedLoad to nullptr.
     12        (WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction): Check if this is navigation represents an
     13        unblock request and ignore if so.
     14        * WebView/WebFrame.mm:
     15        (-[WebFrame _contentFilterDidHandleNavigationAction:]): Called ContentFilter::handleUnblockRequestAndDispatchIfSuccessful().
     16        If the unblock is successful, reload the main frame.
     17        * WebView/WebFrameInternal.h:
     18
    1192014-07-17  David Kilzer  <ddkilzer@apple.com>
    220
  • trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h

    r168079 r171252  
    236236#endif
    237237
     238    virtual void contentFilterDidBlockLoad(std::unique_ptr<WebCore::ContentFilter>) override;
     239
    238240    RetainPtr<WebFrame> m_webFrame;
    239241
  • trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm

    r170984 r171252  
    668668    ASSERT(!m_webFrame->_private->provisionalURL);
    669669    m_webFrame->_private->provisionalURL = core(m_webFrame.get())->loader().provisionalDocumentLoader()->url().string();
     670    m_webFrame->_private->contentFilterForBlockedLoad = nullptr;
    670671
    671672    WebView *webView = getWebView(m_webFrame.get());
     
    882883void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(const NavigationAction& action, const ResourceRequest& request, PassRefPtr<FormState> formState, FramePolicyFunction function)
    883884{
     885    if ([m_webFrame _contentFilterDidHandleNavigationAction:request]) {
     886        function(PolicyIgnore);
     887        return;
     888    }
     889
    884890    WebView *webView = getWebView(m_webFrame.get());
    885891    [[webView _policyDelegateForwarder] webView:webView
     
    22392245#endif
    22402246
     2247void WebFrameLoaderClient::contentFilterDidBlockLoad(std::unique_ptr<WebCore::ContentFilter> contentFilter)
     2248{
     2249    m_webFrame->_private->contentFilterForBlockedLoad = WTF::move(contentFilter);
     2250}
     2251
    22412252@implementation WebFramePolicyListener
    22422253
  • trunk/Source/WebKit/mac/WebView/WebFrame.mm

    r170710 r171252  
    10021002}
    10031003
     1004- (BOOL)_contentFilterDidHandleNavigationAction:(const WebCore::ResourceRequest &)request
     1005{
     1006#if PLATFORM(IOS)
     1007    if (ContentFilter *contentFilter = _private->contentFilterForBlockedLoad.get()) {
     1008        RetainPtr<WebFrame> retainedMainFrame = [[self webView] mainFrame];
     1009        return contentFilter->handleUnblockRequestAndDispatchIfSuccessful(request, [retainedMainFrame] {
     1010            WebThreadRun(^ {
     1011                [retainedMainFrame reload];
     1012            });
     1013        });
     1014    }
     1015#endif
     1016
     1017    return NO;
     1018}
     1019
    10041020@end
    10051021
  • trunk/Source/WebKit/mac/WebView/WebFrameInternal.h

    r165676 r171252  
    3131#import "WebFramePrivate.h"
    3232#import "WebPreferencesPrivate.h"
     33#import <WebCore/ContentFilter.h>
    3334#import <WebCore/EditAction.h>
    3435#import <WebCore/FrameLoaderTypes.h>
     
    9192#if PLATFORM(IOS)
    9293    BOOL isCommitting;
    93 #endif   
     94#endif
     95    std::unique_ptr<WebCore::ContentFilter> contentFilterForBlockedLoad;
    9496}
    9597@end
     
    183185- (void)_commitData:(NSData *)data;
    184186
     187- (BOOL)_contentFilterDidHandleNavigationAction:(const WebCore::ResourceRequest&)request;
     188
    185189@end
    186190
  • trunk/Source/WebKit2/ChangeLog

    r171250 r171252  
     12014-07-18  Andy Estes  <aestes@apple.com>
     2
     3        [iOS] Tapping "Allow Website" on a restricted page does not bring up the keypad
     4        https://bugs.webkit.org/show_bug.cgi?id=135072
     5        <rdar://problem/17528188>
     6
     7        Reviewed by David Kilzer.
     8
     9        * Shared/WebCoreArgumentCoders.h: Declared an ArgumentCoder for WebCore::ContentFilter.
     10        * Shared/mac/WebCoreArgumentCodersMac.mm:
     11        (IPC::ArgumentCoder<ContentFilter>::encode): Encoded the ContentFilter using a NSKeyedArchiver.
     12        (IPC::ArgumentCoder<ContentFilter>::decode): Decoded the ContentFilter using a NSKeyedUnarchiver.
     13        * UIProcess/Cocoa/WebPageProxyCocoa.mm:
     14        (WebKit::WebPageProxy::contentFilterDidBlockLoadForFrame): Called WebFrameProxy::setContentFilterForBlockedLoad().
     15        * UIProcess/WebFrameProxy.cpp:
     16        (WebKit::WebFrameProxy::didStartProvisionalLoad): Reset m_contentFilterForBlockedLoad to nullptr.
     17        (WebKit::WebFrameProxy::contentFilterDidHandleNavigationAction): Called ContentFilter::handleUnblockRequestAndDispatchIfSuccessful().
     18        If the unblock is successful, reload the WebPageProxy.
     19        * UIProcess/WebFrameProxy.h:
     20        (WebKit::WebFrameProxy::setContentFilterForBlockedLoad):
     21        * UIProcess/WebPageProxy.cpp:
     22        (WebKit::WebPageProxy::decidePolicyForNavigationAction): Check if this is navigation represents an unblock
     23        request and ignore if so.
     24        * UIProcess/WebPageProxy.h:
     25        * UIProcess/WebPageProxy.messages.in: Defined ContentFilterDidBlockLoadForFrame.
     26        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
     27        (WebKit::WebFrameLoaderClient::contentFilterDidBlockLoad): Sent ContentFilterDidBlockLoadForFrame to the WebPageProxy.
     28        * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
     29
    1302014-07-18  Simon Fraser  <simon.fraser@apple.com>
    231
  • trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.h

    r170406 r171252  
    106106#endif
    107107
     108#if USE(CONTENT_FILTERING)
     109namespace WebCore {
     110class ContentFilter;
     111}
     112#endif
     113
    108114namespace IPC {
    109115
     
    437443};
    438444
     445#if USE(CONTENT_FILTERING)
     446template<> struct ArgumentCoder<WebCore::ContentFilter> {
     447    static void encode(ArgumentEncoder&, const WebCore::ContentFilter&);
     448    static bool decode(ArgumentDecoder&, WebCore::ContentFilter&);
     449};
     450#endif
     451
    439452} // namespace IPC
    440453
  • trunk/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm

    r170685 r171252  
    3232#import "WebKitSystemInterface.h"
    3333#import <WebCore/CertificateInfo.h>
     34#import <WebCore/ContentFilter.h>
    3435#import <WebCore/KeyboardEvent.h>
    3536#import <WebCore/ResourceError.h>
     
    301302}
    302303
     304void ArgumentCoder<ContentFilter>::encode(ArgumentEncoder& encoder, const ContentFilter& contentFilter)
     305{
     306    RetainPtr<NSMutableData> data = adoptNS([[NSMutableData alloc] init]);
     307    RetainPtr<NSKeyedArchiver> archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]);
     308    [archiver setRequiresSecureCoding:YES];
     309    contentFilter.encode(archiver.get());
     310    [archiver finishEncoding];
     311    IPC::encode(encoder, reinterpret_cast<CFDataRef>(data.get()));
     312}
     313
     314bool ArgumentCoder<ContentFilter>::decode(ArgumentDecoder& decoder, ContentFilter& contentFilter)
     315{
     316    RetainPtr<CFDataRef> data;
     317    if (!IPC::decode(decoder, data))
     318        return false;
     319
     320    RetainPtr<NSKeyedUnarchiver> unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:(NSData *)data.get()]);
     321    [unarchiver setRequiresSecureCoding:YES];
     322    if (!ContentFilter::decode(unarchiver.get(), contentFilter))
     323        return false;
     324
     325    [unarchiver finishDecoding];
     326    return true;
     327}
     328
    303329} // namespace IPC
  • trunk/Source/WebKit2/UIProcess/Cocoa/WebPageProxyCocoa.mm

    r170779 r171252  
    7373}
    7474
     75void WebPageProxy::contentFilterDidBlockLoadForFrame(const WebCore::ContentFilter& contentFilter, uint64_t frameID)
     76{
     77    if (WebFrameProxy* frame = m_process->webFrame(frameID))
     78        frame->setContentFilterForBlockedLoad(std::make_unique<WebCore::ContentFilter>(contentFilter));
    7579}
     80
     81}
  • trunk/Source/WebKit2/UIProcess/WebFrameProxy.cpp

    r170660 r171252  
    128128{
    129129    m_frameLoadState.didStartProvisionalLoad(url);
     130#if USE(CONTENT_FILTERING)
     131    m_contentFilterForBlockedLoad = nullptr;
     132#endif
    130133}
    131134
     
    231234}
    232235
     236#if USE(CONTENT_FILTERING)
     237bool WebFrameProxy::contentFilterDidHandleNavigationAction(const WebCore::ResourceRequest& request)
     238{
     239#if PLATFORM(IOS)
     240    if (m_contentFilterForBlockedLoad) {
     241        RefPtr<WebPageProxy> retainedPage = m_page;
     242        return m_contentFilterForBlockedLoad->handleUnblockRequestAndDispatchIfSuccessful(request, [retainedPage] {
     243            retainedPage->reload(false);
     244        });
     245    }
     246#endif
     247
     248    return false;
     249}
     250#endif
     251
    233252} // namespace WebKit
  • trunk/Source/WebKit2/UIProcess/WebFrameProxy.h

    r170660 r171252  
    3535#include <wtf/PassRefPtr.h>
    3636#include <wtf/text/WTFString.h>
     37
     38#if USE(CONTENT_FILTERING)
     39#include <WebCore/ContentFilter.h>
     40#endif
    3741
    3842namespace IPC {
     
    114118    WebFormSubmissionListenerProxy* setUpFormSubmissionListenerProxy(uint64_t listenerID);
    115119
     120#if USE(CONTENT_FILTERING)
     121    void setContentFilterForBlockedLoad(std::unique_ptr<WebCore::ContentFilter> contentFilter) { m_contentFilterForBlockedLoad = WTF::move(contentFilter); }
     122    bool contentFilterDidHandleNavigationAction(const WebCore::ResourceRequest&);
     123#endif
     124
    116125private:
    117126    WebFrameProxy(WebPageProxy* page, uint64_t frameID);
     
    127136    RefPtr<WebFrameListenerProxy> m_activeListener;
    128137    uint64_t m_frameID;
     138
     139#if USE(CONTENT_FILTERING)
     140    std::unique_ptr<WebCore::ContentFilter> m_contentFilterForBlockedLoad;
     141#endif
    129142};
    130143
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r171239 r171252  
    28552855    }
    28562856
     2857#if USE(CONTENT_FILTERING)
     2858    if (frame->contentFilterDidHandleNavigationAction(request)) {
     2859        receivedPolicyAction = true;
     2860        policyAction = PolicyIgnore;
     2861        return;
     2862    }
     2863#endif
     2864
    28572865    ASSERT(!m_inDecidePolicyForNavigationAction);
    28582866
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r171239 r171252  
    12721272#endif
    12731273
     1274#if USE(CONTENT_FILTERING)
     1275    void contentFilterDidBlockLoadForFrame(const WebCore::ContentFilter&, uint64_t frameID);
     1276#endif
     1277
    12741278    uint64_t generateNavigationID();
    12751279
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in

    r171239 r171252  
    406406
    407407    WillChangeCurrentHistoryItem()
     408
     409#if USE(CONTENT_FILTERING)
     410    ContentFilterDidBlockLoadForFrame(WebCore::ContentFilter contentFilter, uint64_t frameID)
     411#endif
    408412}
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

    r171239 r171252  
    16311631}
    16321632
     1633#if USE(CONTENT_FILTERING)
     1634void WebFrameLoaderClient::contentFilterDidBlockLoad(std::unique_ptr<WebCore::ContentFilter> contentFilter)
     1635{
     1636    if (WebPage* webPage = m_frame->page())
     1637        webPage->send(Messages::WebPageProxy::ContentFilterDidBlockLoadForFrame(*contentFilter, m_frame->frameID()));
     1638}
     1639#endif
     1640
    16331641} // namespace WebKit
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h

    r171239 r171252  
    229229#endif
    230230
     231#if USE(CONTENT_FILTERING)
     232    virtual void contentFilterDidBlockLoad(std::unique_ptr<WebCore::ContentFilter>) override;
     233#endif
     234
    231235    WebFrame* m_frame;
    232236    RefPtr<PluginView> m_pluginView;
Note: See TracChangeset for help on using the changeset viewer.