[Content Filtering] Add a HAVE(PARENTAL_CONTROLS) and use it
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Apr 2015 08:54:41 +0000 (08:54 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Apr 2015 08:54:41 +0000 (08:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=143559

Reviewed by David Kilzer.

Source/WebCore:

* loader/ContentFilter.cpp:
(WebCore::ContentFilter::types): Only registered ParentalControlsContentFilter if HAVE(PARENTAL_CONTROLS).
* platform/ContentFilterUnblockHandler.h: Changed PLATFORM(IOS) to HAVE(PARENTAL_CONTROLS).
* platform/cocoa/ContentFilterUnblockHandlerCocoa.mm:
(WebCore::ContentFilterUnblockHandler::wrapWithDecisionHandler): Ditto.
(WebCore::ContentFilterUnblockHandler::needsUIProcess): Ditto.
(WebCore::ContentFilterUnblockHandler::encode): Ditto.
(WebCore::ContentFilterUnblockHandler::decode): Ditto.
(WebCore::ContentFilterUnblockHandler::canHandleRequest): Ditto.
(WebCore::ContentFilterUnblockHandler::requestUnblockAsync): Ditto.
* platform/cocoa/ParentalControlsContentFilter.mm: Wrapped the file with HAVE(PARENTAL_CONTROLS)

Source/WTF:

Added PLATFORM(WATCHOS). Used PLATFORM() since Watch OS is just a variant of OS(IOS).
Defined HAVE(PARENTAL_CONTROLS) to be true on all Cocoa platforms except Watch OS.

* wtf/Platform.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182596 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/wtf/Platform.h
Source/WebCore/ChangeLog
Source/WebCore/loader/ContentFilter.cpp
Source/WebCore/platform/ContentFilterUnblockHandler.h
Source/WebCore/platform/cocoa/ContentFilterUnblockHandlerCocoa.mm
Source/WebCore/platform/cocoa/ParentalControlsContentFilter.mm

index b0de443..ec79691 100644 (file)
@@ -1,3 +1,15 @@
+2015-04-09  Andy Estes  <aestes@apple.com>
+
+        [Content Filtering] Add a HAVE(PARENTAL_CONTROLS) and use it
+        https://bugs.webkit.org/show_bug.cgi?id=143559
+
+        Reviewed by David Kilzer.
+
+        Added PLATFORM(WATCHOS). Used PLATFORM() since Watch OS is just a variant of OS(IOS).
+        Defined HAVE(PARENTAL_CONTROLS) to be true on all Cocoa platforms except Watch OS.
+
+        * wtf/Platform.h:
+
 2015-04-08  Alex Christensen  <achristensen@webkit.org> and Patrick Gansterer  <paroga@webkit.org>
 
         Add CMake build system for WinCairo port.
index 4f6503e..1c315e2 100644 (file)
 #define WTF_PLATFORM_APPLETV 1
 #endif
 
+/* PLATFORM(WATCHOS) */
+#if defined(TARGET_OS_WATCH) && TARGET_OS_WATCH
+#define WTF_PLATFORM_WATCHOS 1
+#endif
+
 /* Graphics engines */
 
 /* USE(CG) and PLATFORM(CI) */
 #define HAVE_OUT_OF_PROCESS_LAYER_HOSTING 1
 #define HAVE_DTRACE 1
 
+#if !PLATFORM(WATCHOS)
+#define HAVE_PARENTAL_CONTROLS 1
+#endif
+
 #endif
 
 #if PLATFORM(MAC)
index 1f02d8e..1807cfb 100644 (file)
@@ -1,3 +1,22 @@
+2015-04-09  Andy Estes  <aestes@apple.com>
+
+        [Content Filtering] Add a HAVE(PARENTAL_CONTROLS) and use it
+        https://bugs.webkit.org/show_bug.cgi?id=143559
+
+        Reviewed by David Kilzer.
+
+        * loader/ContentFilter.cpp:
+        (WebCore::ContentFilter::types): Only registered ParentalControlsContentFilter if HAVE(PARENTAL_CONTROLS).
+        * platform/ContentFilterUnblockHandler.h: Changed PLATFORM(IOS) to HAVE(PARENTAL_CONTROLS).
+        * platform/cocoa/ContentFilterUnblockHandlerCocoa.mm:
+        (WebCore::ContentFilterUnblockHandler::wrapWithDecisionHandler): Ditto.
+        (WebCore::ContentFilterUnblockHandler::needsUIProcess): Ditto.
+        (WebCore::ContentFilterUnblockHandler::encode): Ditto.
+        (WebCore::ContentFilterUnblockHandler::decode): Ditto.
+        (WebCore::ContentFilterUnblockHandler::canHandleRequest): Ditto.
+        (WebCore::ContentFilterUnblockHandler::requestUnblockAsync): Ditto.
+        * platform/cocoa/ParentalControlsContentFilter.mm: Wrapped the file with HAVE(PARENTAL_CONTROLS)
+
 2015-04-09  Sergio Villar Senin  <svillar@igalia.com>
 
         Unreviewed, added CSS Grid Layout to features.json file.
index 6d8e88e..32a873e 100644 (file)
@@ -47,7 +47,9 @@ Vector<ContentFilter::Type>& ContentFilter::types()
 {
     static NeverDestroyed<Vector<ContentFilter::Type>> types {
         Vector<ContentFilter::Type> {
+#if HAVE(PARENTAL_CONTROLS)
             type<ParentalControlsContentFilter>(),
+#endif
 #if HAVE(NETWORK_EXTENSION)
             type<NetworkExtensionContentFilter>()
 #endif
index 7d044cc..f02aad2 100644 (file)
@@ -50,7 +50,7 @@ public:
 
     ContentFilterUnblockHandler() = default;
     WEBCORE_EXPORT ContentFilterUnblockHandler(String unblockURLHost, UnblockRequesterFunction);
-#if PLATFORM(IOS)
+#if HAVE(PARENTAL_CONTROLS)
     ContentFilterUnblockHandler(String unblockURLHost, RetainPtr<WebFilterEvaluator>);
 #endif
 
@@ -69,7 +69,7 @@ private:
     String m_unblockURLHost;
     URL m_unreachableURL;
     UnblockRequesterFunction m_unblockRequester;
-#if PLATFORM(IOS)
+#if HAVE(PARENTAL_CONTROLS)
     RetainPtr<WebFilterEvaluator> m_webFilterEvaluator;
 #endif
 };
index e1ca137..3b67e4d 100644 (file)
 #endif
 
 #if PLATFORM(IOS)
-#import "SoftLinking.h"
 #import "WebCoreThreadRun.h"
+#endif
+
+#if HAVE(PARENTAL_CONTROLS)
+#import "SoftLinking.h"
 #import "WebFilterEvaluatorSPI.h"
 
 SOFT_LINK_PRIVATE_FRAMEWORK(WebContentAnalysis);
@@ -60,7 +63,7 @@ ContentFilterUnblockHandler::ContentFilterUnblockHandler(String unblockURLHost,
     LOG(ContentFiltering, "Creating ContentFilterUnblockHandler with an unblock requester and unblock URL host <%s>.\n", unblockURLHost.ascii().data());
 }
 
-#if PLATFORM(IOS)
+#if HAVE(PARENTAL_CONTROLS)
 ContentFilterUnblockHandler::ContentFilterUnblockHandler(String unblockURLHost, RetainPtr<WebFilterEvaluator> evaluator)
     : m_unblockURLHost { WTF::move(unblockURLHost) }
     , m_webFilterEvaluator { WTF::move(evaluator) }
@@ -78,7 +81,7 @@ void ContentFilterUnblockHandler::wrapWithDecisionHandler(const DecisionHandlerF
             decisionHandler(unblocked);
         });
     }};
-#if PLATFORM(IOS)
+#if HAVE(PARENTAL_CONTROLS)
     m_webFilterEvaluator = nullptr;
 #endif
     std::swap(m_unblockRequester, wrappedRequester);
@@ -86,7 +89,7 @@ void ContentFilterUnblockHandler::wrapWithDecisionHandler(const DecisionHandlerF
 
 bool ContentFilterUnblockHandler::needsUIProcess() const
 {
-#if PLATFORM(IOS)
+#if HAVE(PARENTAL_CONTROLS)
     return m_webFilterEvaluator;
 #else
     return false;
@@ -99,7 +102,7 @@ void ContentFilterUnblockHandler::encode(NSCoder *coder) const
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
     [coder encodeObject:m_unblockURLHost forKey:unblockURLHostKey];
     [coder encodeObject:(NSURL *)m_unreachableURL forKey:unreachableURLKey];
-#if PLATFORM(IOS)
+#if HAVE(PARENTAL_CONTROLS)
     [coder encodeObject:m_webFilterEvaluator.get() forKey:webFilterEvaluatorKey];
 #endif
     END_BLOCK_OBJC_EXCEPTIONS;
@@ -111,7 +114,7 @@ bool ContentFilterUnblockHandler::decode(NSCoder *coder, ContentFilterUnblockHan
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
     unblockHandler.m_unblockURLHost = [coder decodeObjectOfClass:[NSString class] forKey:unblockURLHostKey];
     unblockHandler.m_unreachableURL = [coder decodeObjectOfClass:[NSURL class] forKey:unreachableURLKey];
-#if PLATFORM(IOS)
+#if HAVE(PARENTAL_CONTROLS)
     unblockHandler.m_webFilterEvaluator = [coder decodeObjectOfClass:getWebFilterEvaluatorClass() forKey:webFilterEvaluatorKey];
 #endif
     return true;
@@ -122,7 +125,7 @@ bool ContentFilterUnblockHandler::decode(NSCoder *coder, ContentFilterUnblockHan
 bool ContentFilterUnblockHandler::canHandleRequest(const ResourceRequest& request) const
 {
     if (!m_unblockRequester) {
-#if PLATFORM(IOS)
+#if HAVE(PARENTAL_CONTROLS)
         if (!m_webFilterEvaluator)
             return false;
 #else
@@ -151,7 +154,7 @@ static inline void dispatchToMainThread(void (^block)())
 
 void ContentFilterUnblockHandler::requestUnblockAsync(DecisionHandlerFunction decisionHandler) const
 {
-#if PLATFORM(IOS)
+#if HAVE(PARENTAL_CONTROLS)
     if (m_webFilterEvaluator) {
         [m_webFilterEvaluator unblockWithCompletion:[decisionHandler](BOOL unblocked, NSError *) {
             dispatchToMainThread([decisionHandler, unblocked] {
index cdc1f51..a36ea1f 100644 (file)
@@ -26,6 +26,8 @@
 #import "config.h"
 #import "ParentalControlsContentFilter.h"
 
+#if HAVE(PARENTAL_CONTROLS)
+
 #import "ContentFilterUnblockHandler.h"
 #import "Logging.h"
 #import "ResourceResponse.h"
@@ -129,3 +131,5 @@ void ParentalControlsContentFilter::updateFilterState()
 }
 
 } // namespace WebCore
+
+#endif // HAVE(PARENTAL_CONTROLS)