Changeset 180985 in webkit


Ignore:
Timestamp:
Mar 3, 2015 7:36:10 PM (9 years ago)
Author:
aestes@apple.com
Message:

[Content Filtering] Separate unblock handling into its own class
https://bugs.webkit.org/show_bug.cgi?id=142251

Reviewed by Andreas Kling.
Source/WebCore:

Unblock handling is currently supported only for one type of content filter (WebFilterEvaluator) on one
platform (iOS). Having its implementation in ContentFilter is making it difficult to support other filters and
platforms, so let's separate unblock handling into its own class called ContentFilterUnblockHandler.

  • WebCore.xcodeproj/project.pbxproj:
  • loader/DocumentLoader.cpp:

(WebCore::DocumentLoader::finishedLoading): Passed a ContentFilterUnblockHandler to FrameLoaderClient::contentFilterDidBlockLoad.
(WebCore::DocumentLoader::dataReceived): Ditto.

  • loader/FrameLoaderClient.h:
  • platform/ContentFilter.h:
  • platform/ContentFilterUnblockHandler.h: Copied from Source/WebCore/platform/ios/ContentFilterIOS.mm.

(WebCore::ContentFilterUnblockHandler::clear):

  • platform/cocoa/ContentFilterUnblockHandlerCocoa.mm: Renamed from Source/WebCore/platform/ios/ContentFilterIOS.mm.

(WebCore::ContentFilterUnblockHandler::ContentFilterUnblockHandler):
(WebCore::ContentFilterUnblockHandler::encode):
(WebCore::ContentFilterUnblockHandler::decode):
(WebCore::scheme):
(WebCore::ContentFilterUnblockHandler::handleUnblockRequestAndDispatchIfSuccessful):

  • platform/mac/ContentFilterMac.mm:

(WebCore::ContentFilter::unblockHandler):
(WebCore::ContentFilter::ContentFilter): Deleted.
(WebCore::ContentFilter::encode): Deleted.
(WebCore::ContentFilter::decode): Deleted.

Source/WebKit/mac:

Adopted ContentFilterUnblockHandler.

  • WebCoreSupport/WebFrameLoaderClient.h:
  • WebCoreSupport/WebFrameLoaderClient.mm:

(WebFrameLoaderClient::dispatchDidStartProvisionalLoad):

  • WebView/WebFrame.mm:

(-[WebFrame _contentFilterDidHandleNavigationAction:]):

  • WebView/WebFrameInternal.h:

Source/WebKit2:

Adopted ContentFilterUnblockHandler.

  • Shared/WebCoreArgumentCoders.h:
  • Shared/mac/WebCoreArgumentCodersMac.mm:

(IPC::ArgumentCoder<ContentFilterUnblockHandler>::encode):
(IPC::ArgumentCoder<ContentFilterUnblockHandler>::decode):
(IPC::ArgumentCoder<ContentFilter>::encode): Deleted.
(IPC::ArgumentCoder<ContentFilter>::decode): Deleted.

  • UIProcess/Cocoa/WebPageProxyCocoa.mm:

(WebKit::WebPageProxy::contentFilterDidBlockLoadForFrame):

  • UIProcess/WebFrameProxy.cpp:

(WebKit::WebFrameProxy::didStartProvisionalLoad):
(WebKit::WebFrameProxy::contentFilterDidHandleNavigationAction):

  • UIProcess/WebFrameProxy.h:

(WebKit::WebFrameProxy::setContentFilterUnblockHandler):
(WebKit::WebFrameProxy::setContentFilterForBlockedLoad): Deleted.

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

(WebKit::WebFrameLoaderClient::contentFilterDidBlockLoad):

  • WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
Location:
trunk/Source
Files:
21 edited
1 copied
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r180984 r180985  
     12015-03-03  Andy Estes  <aestes@apple.com>
     2
     3        [Content Filtering] Separate unblock handling into its own class
     4        https://bugs.webkit.org/show_bug.cgi?id=142251
     5
     6        Reviewed by Andreas Kling.
     7
     8        Unblock handling is currently supported only for one type of content filter (WebFilterEvaluator) on one
     9        platform (iOS). Having its implementation in ContentFilter is making it difficult to support other filters and
     10        platforms, so let's separate unblock handling into its own class called ContentFilterUnblockHandler.
     11
     12        * WebCore.xcodeproj/project.pbxproj:
     13        * loader/DocumentLoader.cpp:
     14        (WebCore::DocumentLoader::finishedLoading): Passed a ContentFilterUnblockHandler to FrameLoaderClient::contentFilterDidBlockLoad.
     15        (WebCore::DocumentLoader::dataReceived): Ditto.
     16        * loader/FrameLoaderClient.h:
     17        * platform/ContentFilter.h:
     18        * platform/ContentFilterUnblockHandler.h: Copied from Source/WebCore/platform/ios/ContentFilterIOS.mm.
     19        (WebCore::ContentFilterUnblockHandler::clear):
     20        * platform/cocoa/ContentFilterUnblockHandlerCocoa.mm: Renamed from Source/WebCore/platform/ios/ContentFilterIOS.mm.
     21        (WebCore::ContentFilterUnblockHandler::ContentFilterUnblockHandler):
     22        (WebCore::ContentFilterUnblockHandler::encode):
     23        (WebCore::ContentFilterUnblockHandler::decode):
     24        (WebCore::scheme):
     25        (WebCore::ContentFilterUnblockHandler::handleUnblockRequestAndDispatchIfSuccessful):
     26        * platform/mac/ContentFilterMac.mm:
     27        (WebCore::ContentFilter::unblockHandler):
     28        (WebCore::ContentFilter::ContentFilter): Deleted.
     29        (WebCore::ContentFilter::encode): Deleted.
     30        (WebCore::ContentFilter::decode): Deleted.
     31
    1322015-03-03  Alexey Proskuryakov  <ap@apple.com>
    233
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r180978 r180985  
    10451045                26FAE4CE1852E3A5004C8C46 /* SynchronousResourceHandleCFURLConnectionDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26FAE4CA1852E3A5004C8C46 /* SynchronousResourceHandleCFURLConnectionDelegate.cpp */; };
    10461046                26FAE4CF1852E3A5004C8C46 /* SynchronousResourceHandleCFURLConnectionDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 26FAE4CB1852E3A5004C8C46 /* SynchronousResourceHandleCFURLConnectionDelegate.h */; };
    1047                 2903716516BA11BC00FEFDF0 /* ContentFilterIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2903716416BA11BC00FEFDF0 /* ContentFilterIOS.mm */; };
    10481047                2917B5611473496C0052C9D0 /* LayerFlushScheduler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2917B55E1473496C0052C9D0 /* LayerFlushScheduler.cpp */; };
    10491048                2917B5621473496C0052C9D0 /* LayerFlushScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = 2917B55F1473496C0052C9D0 /* LayerFlushScheduler.h */; settings = {ATTRIBUTES = (Private, ); }; };
    10501049                2917B5631473496C0052C9D0 /* LayerFlushSchedulerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2917B5601473496C0052C9D0 /* LayerFlushSchedulerClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
    10511050                2917B566147349950052C9D0 /* LayerFlushSchedulerMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2917B565147349950052C9D0 /* LayerFlushSchedulerMac.cpp */; };
    1052                 2919A1E916B3376600787213 /* ContentFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 2919A1E816B3376600787213 /* ContentFilter.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1051                2919A1E916B3376600787213 /* ContentFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 2919A1E816B3376600787213 /* ContentFilter.h */; };
    10531052                2919A1EB16B3378900787213 /* ContentFilterMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2919A1EA16B3378900787213 /* ContentFilterMac.mm */; };
    10541053                2934940A16C02C0700901318 /* PlatformSpeechSynthesisVoice.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2527CC9316BF92EC009DDAC0 /* PlatformSpeechSynthesisVoice.cpp */; };
     
    37653764                A136A00C1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A136A00A1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.cpp */; };
    37663765                A136A00D1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.h in Headers */ = {isa = PBXBuildFile; fileRef = A136A00B1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.h */; };
     3766                A14090FB1AA51E1D0091191A /* ContentFilterUnblockHandlerCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = A14090FA1AA51E1D0091191A /* ContentFilterUnblockHandlerCocoa.mm */; };
     3767                A14090FD1AA51E480091191A /* ContentFilterUnblockHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = A14090FC1AA51E480091191A /* ContentFilterUnblockHandler.h */; settings = {ATTRIBUTES = (Private, ); }; };
    37673768                A14832B0187F618D00DA63A6 /* WAKAppKitStubs.h in Headers */ = {isa = PBXBuildFile; fileRef = A148328C187F508700DA63A6 /* WAKAppKitStubs.h */; settings = {ATTRIBUTES = (Private, ); }; };
    37683769                A14832B1187F61E100DA63A6 /* WAKAppKitStubs.m in Sources */ = {isa = PBXBuildFile; fileRef = A148328D187F508700DA63A6 /* WAKAppKitStubs.m */; };
     
    80878088                26FAE4CA1852E3A5004C8C46 /* SynchronousResourceHandleCFURLConnectionDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SynchronousResourceHandleCFURLConnectionDelegate.cpp; sourceTree = "<group>"; };
    80888089                26FAE4CB1852E3A5004C8C46 /* SynchronousResourceHandleCFURLConnectionDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SynchronousResourceHandleCFURLConnectionDelegate.h; sourceTree = "<group>"; };
    8089                 2903716416BA11BC00FEFDF0 /* ContentFilterIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ContentFilterIOS.mm; path = ios/ContentFilterIOS.mm; sourceTree = "<group>"; };
    80908090                2917B55E1473496C0052C9D0 /* LayerFlushScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LayerFlushScheduler.cpp; path = ca/LayerFlushScheduler.cpp; sourceTree = "<group>"; };
    80918091                2917B55F1473496C0052C9D0 /* LayerFlushScheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LayerFlushScheduler.h; path = ca/LayerFlushScheduler.h; sourceTree = "<group>"; };
     
    1098510985                A136A00A1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLHttpRequestProgressEventThrottle.cpp; sourceTree = "<group>"; };
    1098610986                A136A00B1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLHttpRequestProgressEventThrottle.h; sourceTree = "<group>"; };
     10987                A14090FA1AA51E1D0091191A /* ContentFilterUnblockHandlerCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ContentFilterUnblockHandlerCocoa.mm; sourceTree = "<group>"; };
     10988                A14090FC1AA51E480091191A /* ContentFilterUnblockHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentFilterUnblockHandler.h; sourceTree = "<group>"; };
    1098710989                A148328C187F508700DA63A6 /* WAKAppKitStubs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WAKAppKitStubs.h; path = ios/wak/WAKAppKitStubs.h; sourceTree = "<group>"; };
    1098810990                A148328D187F508700DA63A6 /* WAKAppKitStubs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WAKAppKitStubs.m; path = ios/wak/WAKAppKitStubs.m; sourceTree = "<group>"; };
     
    1861918621                        children = (
    1862018622                                A148328B187F506800DA63A6 /* wak */,
    18621                                 2903716416BA11BC00FEFDF0 /* ContentFilterIOS.mm */,
    1862218623                                2655414B1489AA2B000DFC5D /* CursorIOS.cpp */,
    1862318624                                31EAF97C121435A400E7C1BF /* DeviceMotionClientIOS.h */,
     
    1869218693                        isa = PBXGroup;
    1869318694                        children = (
     18695                                A14090FA1AA51E1D0091191A /* ContentFilterUnblockHandlerCocoa.mm */,
    1869418696                                5D8C4DBD1428222C0026CE72 /* DisplaySleepDisablerCocoa.cpp */,
    1869518697                                5D8C4DBE1428222C0026CE72 /* DisplaySleepDisablerCocoa.h */,
     
    2147721479                                BCC8CFCA0986CD2400140BF2 /* ColorData.gperf */,
    2147821480                                2919A1E816B3376600787213 /* ContentFilter.h */,
     21481                                A14090FC1AA51E480091191A /* ContentFilterUnblockHandler.h */,
    2147921482                                41D015C90F4B5C71004A662F /* ContentType.cpp */,
    2148021483                                41D015C80F4B5C71004A662F /* ContentType.h */,
     
    2418024183                                85ECBEF70AA7626900544F0B /* DOMHTMLParamElement.h in Headers */,
    2418124184                                85E711C20AC5D5350053270F /* DOMHTMLParamElementInternal.h in Headers */,
     24185                                A14090FD1AA51E480091191A /* ContentFilterUnblockHandler.h in Headers */,
    2418224186                                85183B480AA6926100F19FA3 /* DOMHTMLPreElement.h in Headers */,
    2418324187                                85E711C30AC5D5350053270F /* DOMHTMLPreElementInternal.h in Headers */,
     
    2742127425                                4ACBC0BE12713CBD0094F9B2 /* ClassList.cpp in Sources */,
    2742227426                                BC904B760D10998F00680D32 /* ClassNodeList.cpp in Sources */,
     27427                                A14090FB1AA51E1D0091191A /* ContentFilterUnblockHandlerCocoa.mm in Sources */,
    2742327428                                BCC0657D0F3CE1B700CD2D87 /* ClientRect.cpp in Sources */,
    2742427429                                BCC065800F3CE1B700CD2D87 /* ClientRectList.cpp in Sources */,
     
    2744727452                                BC5EB9800E82072500B25965 /* ContentData.cpp in Sources */,
    2744827453                                57B791A314C6A62900F202D1 /* ContentDistributor.cpp in Sources */,
    27449                                 2903716516BA11BC00FEFDF0 /* ContentFilterIOS.mm in Sources */,
    2745027454                                2919A1EB16B3378900787213 /* ContentFilterMac.mm in Sources */,
    2745127455                                97C471DB12F925BD0086354B /* ContentSecurityPolicy.cpp in Sources */,
  • trunk/Source/WebCore/loader/DocumentLoader.cpp

    r179958 r180985  
    413413            dataReceived(m_mainResource.get(), data, length);
    414414
    415         if (m_contentFilter->didBlockData())
    416             frameLoader()->client().contentFilterDidBlockLoad(WTF::move(m_contentFilter));
     415        if (m_contentFilter->didBlockData()) {
     416            frameLoader()->client().contentFilterDidBlockLoad(m_contentFilter->unblockHandler());
     417            m_contentFilter = nullptr;
     418        }
    417419    }
    418420#endif
     
    875877        loadWasBlockedBeforeFinishing = m_contentFilter->didBlockData();
    876878
    877         if (loadWasBlockedBeforeFinishing)
    878             frameLoader()->client().contentFilterDidBlockLoad(WTF::move(m_contentFilter));
     879        if (loadWasBlockedBeforeFinishing) {
     880            frameLoader()->client().contentFilterDidBlockLoad(m_contentFilter->unblockHandler());
     881            m_contentFilter = nullptr;
     882        }
    879883    }
    880884#endif
  • trunk/Source/WebCore/loader/FrameLoaderClient.h

    r179626 r180985  
    3838#include <wtf/Forward.h>
    3939#include <wtf/Vector.h>
     40
     41#if ENABLE(CONTENT_FILTERING)
     42#include "ContentFilterUnblockHandler.h"
     43#endif
    4044
    4145#if PLATFORM(COCOA)
     
    99103#endif
    100104
    101 #if ENABLE(CONTENT_FILTERING)
    102     class ContentFilter;
    103 #endif
    104 
    105105    typedef std::function<void (PolicyAction)> FramePolicyFunction;
    106106
     
    340340
    341341#if ENABLE(CONTENT_FILTERING)
    342         virtual void contentFilterDidBlockLoad(std::unique_ptr<ContentFilter>) { }
     342        virtual void contentFilterDidBlockLoad(ContentFilterUnblockHandler) { }
    343343#endif
    344344    };
  • trunk/Source/WebCore/platform/ContentFilter.h

    r175283 r180985  
    2929#if ENABLE(CONTENT_FILTERING)
    3030
     31#include "ContentFilterUnblockHandler.h"
    3132#include <wtf/PassRefPtr.h>
    3233#include <wtf/RetainPtr.h>
    3334
    34 #if PLATFORM(IOS)
    35 #include <functional>
    36 #endif
    37 
    3835#if PLATFORM(COCOA)
    3936OBJC_CLASS NSData;
    40 OBJC_CLASS NSKeyedArchiver;
    41 OBJC_CLASS NSKeyedUnarchiver;
    4237OBJC_CLASS WebFilterEvaluator;
    4338#endif
     
    6863    bool didBlockData() const;
    6964    const char* getReplacementData(int& length) const;
    70 
    71 #if PLATFORM(COCOA)
    72     WEBCORE_EXPORT ContentFilter();
    73     WEBCORE_EXPORT void encode(NSKeyedArchiver *) const;
    74     WEBCORE_EXPORT static bool decode(NSKeyedUnarchiver *, ContentFilter&);
    75 #endif
    76 
    77 #if PLATFORM(IOS)
    78     WEBCORE_EXPORT bool handleUnblockRequestAndDispatchIfSuccessful(const ResourceRequest&, std::function<void()>);
    79 #endif
     65    ContentFilterUnblockHandler unblockHandler() const;
    8066
    8167private:
  • trunk/Source/WebCore/platform/ContentFilterUnblockHandler.h

    r180984 r180985  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #import "config.h"
    27 #import "ContentFilter.h"
     26#ifndef ContentFilterUnblockHandler_h
     27#define ContentFilterUnblockHandler_h
    2828
    29 #if PLATFORM(IOS) && ENABLE(CONTENT_FILTERING)
     29#if ENABLE(CONTENT_FILTERING)
    3030
    31 #import "ResourceRequest.h"
    32 #import "WebCoreThreadRun.h"
    33 #import "WebFilterEvaluatorSPI.h"
     31#include <functional>
     32#include <wtf/RetainPtr.h>
     33
     34OBJC_CLASS NSKeyedArchiver;
     35OBJC_CLASS NSKeyedUnarchiver;
     36OBJC_CLASS WebFilterEvaluator;
    3437
    3538namespace WebCore {
    3639
    37 static inline const char* scheme()
    38 {
    39     static const char contentFilterScheme[] = "x-apple-content-filter";
    40     return contentFilterScheme;
    41 }
     40class ResourceRequest;
    4241
    43 bool ContentFilter::handleUnblockRequestAndDispatchIfSuccessful(const ResourceRequest& request, std::function<void()> function)
    44 {
    45     if (!request.url().protocolIs(scheme()))
    46         return false;
     42class ContentFilterUnblockHandler {
     43public:
     44    ContentFilterUnblockHandler() = default;
     45    explicit ContentFilterUnblockHandler(WebFilterEvaluator *evaluator) : m_webFilterEvaluator { evaluator } { }
    4746
    48     if (!equalIgnoringCase(request.url().host(), "unblock"))
    49         return false;
     47    void clear() { m_webFilterEvaluator = nullptr; }
     48    WEBCORE_EXPORT void encode(NSKeyedArchiver *) const;
     49    WEBCORE_EXPORT static bool decode(NSKeyedUnarchiver *, ContentFilterUnblockHandler&);
    5050
    51     [m_platformContentFilter unblockWithCompletion:^(BOOL unblocked, NSError *) {
    52         if (unblocked)
    53             function();
    54     }];
    55     return true;
    56 }
     51#if PLATFORM(IOS)
     52    WEBCORE_EXPORT bool handleUnblockRequestAndDispatchIfSuccessful(const ResourceRequest&, std::function<void()>);
     53#endif
     54
     55private:
     56    RetainPtr<WebFilterEvaluator> m_webFilterEvaluator;
     57};
    5758
    5859} // namespace WebCore
    5960
    60 #endif // PLATFORM(IOS) && ENABLE(CONTENT_FILTERING)
     61#endif // ENABLE(CONTENT_FILTERING)
     62
     63#endif // ContentFilterUnblockHandler_h
  • trunk/Source/WebCore/platform/cocoa/ContentFilterUnblockHandlerCocoa.mm

    r180984 r180985  
    2525
    2626#import "config.h"
    27 #import "ContentFilter.h"
     27#import "ContentFilterUnblockHandler.h"
    2828
    29 #if PLATFORM(IOS) && ENABLE(CONTENT_FILTERING)
     29#if ENABLE(CONTENT_FILTERING)
    3030
    3131#import "ResourceRequest.h"
    32 #import "WebCoreThreadRun.h"
     32#import "SoftLinking.h"
    3333#import "WebFilterEvaluatorSPI.h"
     34#import <objc/runtime.h>
     35
     36SOFT_LINK_PRIVATE_FRAMEWORK(WebContentAnalysis);
     37SOFT_LINK_CLASS(WebContentAnalysis, WebFilterEvaluator);
    3438
    3539namespace WebCore {
    3640
     41static NSString * const platformContentFilterKey = @"platformContentFilter";
     42
     43void ContentFilterUnblockHandler::encode(NSKeyedArchiver *archiver) const
     44{
     45    if ([getWebFilterEvaluatorClass() conformsToProtocol:@protocol(NSSecureCoding)])
     46        [archiver encodeObject:m_webFilterEvaluator.get() forKey:platformContentFilterKey];
     47}
     48
     49bool ContentFilterUnblockHandler::decode(NSKeyedUnarchiver *unarchiver, ContentFilterUnblockHandler& unblockHandler)
     50{
     51    @try {
     52        if ([getWebFilterEvaluatorClass() conformsToProtocol:@protocol(NSSecureCoding)])
     53            unblockHandler.m_webFilterEvaluator = (WebFilterEvaluator *)[unarchiver decodeObjectOfClass:getWebFilterEvaluatorClass() forKey:platformContentFilterKey];
     54        return true;
     55    } @catch (NSException *exception) {
     56        LOG_ERROR("The platform content filter being decoded is not a WebFilterEvaluator.");
     57    }
     58   
     59    return false;
     60}
     61
     62#if PLATFORM(IOS)
    3763static inline const char* scheme()
    3864{
    39     static const char contentFilterScheme[] = "x-apple-content-filter";
    40     return contentFilterScheme;
     65    return "x-apple-content-filter";
    4166}
    4267
    43 bool ContentFilter::handleUnblockRequestAndDispatchIfSuccessful(const ResourceRequest& request, std::function<void()> function)
     68bool ContentFilterUnblockHandler::handleUnblockRequestAndDispatchIfSuccessful(const ResourceRequest& request, std::function<void()> function)
    4469{
     70    if (!m_webFilterEvaluator)
     71        return false;
     72
    4573    if (!request.url().protocolIs(scheme()))
    4674        return false;
     
    4977        return false;
    5078
    51     [m_platformContentFilter unblockWithCompletion:^(BOOL unblocked, NSError *) {
     79    [m_webFilterEvaluator unblockWithCompletion:^(BOOL unblocked, NSError *) {
    5280        if (unblocked)
    5381            function();
     
    5583    return true;
    5684}
     85#endif
    5786
    5887} // namespace WebCore
  • trunk/Source/WebCore/platform/mac/ContentFilterMac.mm

    r180708 r180985  
    4545namespace WebCore {
    4646
    47 ContentFilter::ContentFilter()
    48 #if HAVE(NE_FILTER_SOURCE)
    49     : m_neFilterSourceStatus(NEFilterSourceStatusNeedsMoreData)
    50     , m_neFilterSourceQueue(0)
    51 #endif
    52 {
    53 }
    54 
    5547ContentFilter::ContentFilter(const ResourceResponse& response)
    5648#if HAVE(NE_FILTER_SOURCE)
     
    203195}
    204196
    205 static NSString * const platformContentFilterKey = @"platformContentFilter";
    206 
    207 void ContentFilter::encode(NSKeyedArchiver *archiver) const
    208 {
    209     if ([getWebFilterEvaluatorClass() conformsToProtocol:@protocol(NSSecureCoding)])
    210         [archiver encodeObject:m_platformContentFilter.get() forKey:platformContentFilterKey];
    211 }
    212 
    213 bool ContentFilter::decode(NSKeyedUnarchiver *unarchiver, ContentFilter& contentFilter)
    214 {
    215     @try {
    216         if ([getWebFilterEvaluatorClass() conformsToProtocol:@protocol(NSSecureCoding)])
    217             contentFilter.m_platformContentFilter = (WebFilterEvaluator *)[unarchiver decodeObjectOfClass:getWebFilterEvaluatorClass() forKey:platformContentFilterKey];
    218         return true;
    219     } @catch (NSException *exception) {
    220         LOG_ERROR("The platform content filter being decoded is not a WebFilterEvaluator.");
    221     }
    222 
    223     return false;
     197ContentFilterUnblockHandler ContentFilter::unblockHandler() const
     198{
     199    return ContentFilterUnblockHandler { m_platformContentFilter.get() };
    224200}
    225201
  • trunk/Source/WebKit/mac/ChangeLog

    r180963 r180985  
     12015-03-03  Andy Estes  <aestes@apple.com>
     2
     3        [Content Filtering] Separate unblock handling into its own class
     4        https://bugs.webkit.org/show_bug.cgi?id=142251
     5
     6        Reviewed by Andreas Kling.
     7       
     8        Adopted ContentFilterUnblockHandler.
     9
     10        * WebCoreSupport/WebFrameLoaderClient.h:
     11        * WebCoreSupport/WebFrameLoaderClient.mm:
     12        (WebFrameLoaderClient::dispatchDidStartProvisionalLoad):
     13        * WebView/WebFrame.mm:
     14        (-[WebFrame _contentFilterDidHandleNavigationAction:]):
     15        * WebView/WebFrameInternal.h:
     16
    1172015-03-03  Chris Dumez  <cdumez@apple.com>
    218
  • trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h

    r176912 r180985  
    240240#endif
    241241
    242     virtual void contentFilterDidBlockLoad(std::unique_ptr<WebCore::ContentFilter>) override;
     242    void contentFilterDidBlockLoad(WebCore::ContentFilterUnblockHandler) override;
    243243
    244244    RetainPtr<WebFrame> m_webFrame;
  • trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm

    r179409 r180985  
    663663    ASSERT(!m_webFrame->_private->provisionalURL);
    664664    m_webFrame->_private->provisionalURL = core(m_webFrame.get())->loader().provisionalDocumentLoader()->url().string();
    665     m_webFrame->_private->contentFilterForBlockedLoad = nullptr;
     665    m_webFrame->_private->contentFilterUnblockHandler.clear();
    666666
    667667    WebView *webView = getWebView(m_webFrame.get());
     
    22402240#endif
    22412241
    2242 void WebFrameLoaderClient::contentFilterDidBlockLoad(std::unique_ptr<WebCore::ContentFilter> contentFilter)
    2243 {
    2244     m_webFrame->_private->contentFilterForBlockedLoad = WTF::move(contentFilter);
     2242void WebFrameLoaderClient::contentFilterDidBlockLoad(WebCore::ContentFilterUnblockHandler unblockHandler)
     2243{
     2244    m_webFrame->_private->contentFilterUnblockHandler = WTF::move(unblockHandler);
    22452245}
    22462246
  • trunk/Source/WebKit/mac/WebView/WebFrame.mm

    r180704 r180985  
    10061006{
    10071007#if PLATFORM(IOS)
    1008     if (ContentFilter *contentFilter = _private->contentFilterForBlockedLoad.get()) {
    1009         RetainPtr<WebFrame> retainedMainFrame = [[self webView] mainFrame];
    1010         return contentFilter->handleUnblockRequestAndDispatchIfSuccessful(request, [retainedMainFrame] {
    1011             WebThreadRun(^ {
    1012                 [retainedMainFrame reload];
    1013             });
     1008    RetainPtr<WebFrame> retainedMainFrame = [[self webView] mainFrame];
     1009    return _private->contentFilterUnblockHandler.handleUnblockRequestAndDispatchIfSuccessful(request, [retainedMainFrame] {
     1010        WebThreadRun(^ {
     1011            [retainedMainFrame reload];
    10141012        });
    1015     }
    1016 #endif
    1017 
     1013    });
     1014#else
    10181015    return NO;
     1016#endif
    10191017}
    10201018
  • trunk/Source/WebKit/mac/WebView/WebFrameInternal.h

    r177450 r180985  
    3131#import "WebFramePrivate.h"
    3232#import "WebPreferencesPrivate.h"
    33 #import <WebCore/ContentFilter.h>
     33#import <WebCore/ContentFilterUnblockHandler.h>
    3434#import <WebCore/EditAction.h>
    3535#import <WebCore/FrameLoaderTypes.h>
     
    9393    BOOL isCommitting;
    9494#endif
    95     std::unique_ptr<WebCore::ContentFilter> contentFilterForBlockedLoad;
     95    WebCore::ContentFilterUnblockHandler contentFilterUnblockHandler;
    9696}
    9797@end
  • trunk/Source/WebKit2/ChangeLog

    r180982 r180985  
     12015-03-03  Andy Estes  <aestes@apple.com>
     2
     3        [Content Filtering] Separate unblock handling into its own class
     4        https://bugs.webkit.org/show_bug.cgi?id=142251
     5
     6        Reviewed by Andreas Kling.
     7
     8        Adopted ContentFilterUnblockHandler.
     9
     10        * Shared/WebCoreArgumentCoders.h:
     11        * Shared/mac/WebCoreArgumentCodersMac.mm:
     12        (IPC::ArgumentCoder<ContentFilterUnblockHandler>::encode):
     13        (IPC::ArgumentCoder<ContentFilterUnblockHandler>::decode):
     14        (IPC::ArgumentCoder<ContentFilter>::encode): Deleted.
     15        (IPC::ArgumentCoder<ContentFilter>::decode): Deleted.
     16        * UIProcess/Cocoa/WebPageProxyCocoa.mm:
     17        (WebKit::WebPageProxy::contentFilterDidBlockLoadForFrame):
     18        * UIProcess/WebFrameProxy.cpp:
     19        (WebKit::WebFrameProxy::didStartProvisionalLoad):
     20        (WebKit::WebFrameProxy::contentFilterDidHandleNavigationAction):
     21        * UIProcess/WebFrameProxy.h:
     22        (WebKit::WebFrameProxy::setContentFilterUnblockHandler):
     23        (WebKit::WebFrameProxy::setContentFilterForBlockedLoad): Deleted.
     24        * UIProcess/WebPageProxy.h:
     25        * UIProcess/WebPageProxy.messages.in:
     26        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
     27        (WebKit::WebFrameLoaderClient::contentFilterDidBlockLoad):
     28        * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
     29
    1302015-03-03  Chris Dumez  <cdumez@apple.com>
    231
  • trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.h

    r180882 r180985  
    112112#if ENABLE(CONTENT_FILTERING)
    113113namespace WebCore {
    114 class ContentFilter;
     114class ContentFilterUnblockHandler;
    115115}
    116116#endif
     
    444444
    445445#if ENABLE(CONTENT_FILTERING)
    446 template<> struct ArgumentCoder<WebCore::ContentFilter> {
    447     static void encode(ArgumentEncoder&, const WebCore::ContentFilter&);
    448     static bool decode(ArgumentDecoder&, WebCore::ContentFilter&);
     446template<> struct ArgumentCoder<WebCore::ContentFilterUnblockHandler> {
     447    static void encode(ArgumentEncoder&, const WebCore::ContentFilterUnblockHandler&);
     448    static bool decode(ArgumentDecoder&, WebCore::ContentFilterUnblockHandler&);
    449449};
    450450#endif
  • trunk/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm

    r177593 r180985  
    3232#import "WebKitSystemInterface.h"
    3333#import <WebCore/CertificateInfo.h>
    34 #import <WebCore/ContentFilter.h>
     34#import <WebCore/ContentFilterUnblockHandler.h>
    3535#import <WebCore/Credential.h>
    3636#import <WebCore/KeyboardEvent.h>
     
    408408}
    409409
    410 void ArgumentCoder<ContentFilter>::encode(ArgumentEncoder& encoder, const ContentFilter& contentFilter)
     410void ArgumentCoder<ContentFilterUnblockHandler>::encode(ArgumentEncoder& encoder, const ContentFilterUnblockHandler& contentFilterUnblockHandler)
    411411{
    412412    RetainPtr<NSMutableData> data = adoptNS([[NSMutableData alloc] init]);
    413413    RetainPtr<NSKeyedArchiver> archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]);
    414414    [archiver setRequiresSecureCoding:YES];
    415     contentFilter.encode(archiver.get());
     415    contentFilterUnblockHandler.encode(archiver.get());
    416416    [archiver finishEncoding];
    417417    IPC::encode(encoder, reinterpret_cast<CFDataRef>(data.get()));
    418418}
    419419
    420 bool ArgumentCoder<ContentFilter>::decode(ArgumentDecoder& decoder, ContentFilter& contentFilter)
     420bool ArgumentCoder<ContentFilterUnblockHandler>::decode(ArgumentDecoder& decoder, ContentFilterUnblockHandler& contentFilterUnblockHandler)
    421421{
    422422    RetainPtr<CFDataRef> data;
     
    426426    RetainPtr<NSKeyedUnarchiver> unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:(NSData *)data.get()]);
    427427    [unarchiver setRequiresSecureCoding:YES];
    428     if (!ContentFilter::decode(unarchiver.get(), contentFilter))
     428    if (!ContentFilterUnblockHandler::decode(unarchiver.get(), contentFilterUnblockHandler))
    429429        return false;
    430430
  • trunk/Source/WebKit2/UIProcess/Cocoa/WebPageProxyCocoa.mm

    r174400 r180985  
    7373}
    7474
    75 void WebPageProxy::contentFilterDidBlockLoadForFrame(const WebCore::ContentFilter& contentFilter, uint64_t frameID)
     75void WebPageProxy::contentFilterDidBlockLoadForFrame(const WebCore::ContentFilterUnblockHandler& unblockHandler, uint64_t frameID)
    7676{
    7777    if (WebFrameProxy* frame = m_process->webFrame(frameID))
    78         frame->setContentFilterForBlockedLoad(std::make_unique<WebCore::ContentFilter>(contentFilter));
     78        frame->setContentFilterUnblockHandler(unblockHandler);
    7979}
    8080
  • trunk/Source/WebKit2/UIProcess/WebFrameProxy.cpp

    r178688 r180985  
    129129    m_frameLoadState.didStartProvisionalLoad(url);
    130130#if ENABLE(CONTENT_FILTERING)
    131     m_contentFilterForBlockedLoad = nullptr;
     131    m_contentFilterUnblockHandler.clear();
    132132#endif
    133133}
     
    238238{
    239239#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     }
     240    RefPtr<WebPageProxy> retainedPage = m_page;
     241    return m_contentFilterUnblockHandler.handleUnblockRequestAndDispatchIfSuccessful(request, [retainedPage] {
     242        retainedPage->reload(false);
     243    });
     244#else
     245    return false;
    246246#endif
    247 
    248     return false;
    249247}
    250248#endif
  • trunk/Source/WebKit2/UIProcess/WebFrameProxy.h

    r178688 r180985  
    3737
    3838#if ENABLE(CONTENT_FILTERING)
    39 #include <WebCore/ContentFilter.h>
     39#include <WebCore/ContentFilterUnblockHandler.h>
    4040#endif
    4141
     
    124124
    125125#if ENABLE(CONTENT_FILTERING)
    126     void setContentFilterForBlockedLoad(std::unique_ptr<WebCore::ContentFilter> contentFilter) { m_contentFilterForBlockedLoad = WTF::move(contentFilter); }
     126    void setContentFilterUnblockHandler(WebCore::ContentFilterUnblockHandler contentFilterUnblockHandler) { m_contentFilterUnblockHandler = WTF::move(contentFilterUnblockHandler); }
    127127    bool contentFilterDidHandleNavigationAction(const WebCore::ResourceRequest&);
    128128#endif
     
    143143
    144144#if ENABLE(CONTENT_FILTERING)
    145     std::unique_ptr<WebCore::ContentFilter> m_contentFilterForBlockedLoad;
     145    WebCore::ContentFilterUnblockHandler m_contentFilterUnblockHandler;
    146146#endif
    147147};
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r180886 r180985  
    13671367
    13681368#if ENABLE(CONTENT_FILTERING)
    1369     void contentFilterDidBlockLoadForFrame(const WebCore::ContentFilter&, uint64_t frameID);
     1369    void contentFilterDidBlockLoadForFrame(const WebCore::ContentFilterUnblockHandler&, uint64_t frameID);
    13701370#endif
    13711371
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in

    r180768 r180985  
    415415
    416416#if ENABLE(CONTENT_FILTERING)
    417     ContentFilterDidBlockLoadForFrame(WebCore::ContentFilter contentFilter, uint64_t frameID)
     417    ContentFilterDidBlockLoadForFrame(WebCore::ContentFilterUnblockHandler unblockHandler, uint64_t frameID)
    418418#endif
    419419
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

    r179955 r180985  
    16471647
    16481648#if ENABLE(CONTENT_FILTERING)
    1649 void WebFrameLoaderClient::contentFilterDidBlockLoad(std::unique_ptr<WebCore::ContentFilter> contentFilter)
     1649void WebFrameLoaderClient::contentFilterDidBlockLoad(WebCore::ContentFilterUnblockHandler unblockHandler)
    16501650{
    16511651    if (WebPage* webPage = m_frame->page())
    1652         webPage->send(Messages::WebPageProxy::ContentFilterDidBlockLoadForFrame(*contentFilter, m_frame->frameID()));
     1652        webPage->send(Messages::WebPageProxy::ContentFilterDidBlockLoadForFrame(unblockHandler, m_frame->frameID()));
    16531653}
    16541654#endif
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h

    r176915 r180985  
    233233
    234234#if ENABLE(CONTENT_FILTERING)
    235     virtual void contentFilterDidBlockLoad(std::unique_ptr<WebCore::ContentFilter>) override;
     235    void contentFilterDidBlockLoad(WebCore::ContentFilterUnblockHandler) override;
    236236#endif
    237237
Note: See TracChangeset for help on using the changeset viewer.