Expose Safe Browsing SPI
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 20 Jan 2018 06:40:33 +0000 (06:40 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 20 Jan 2018 06:40:33 +0000 (06:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=181804
<rdar://problem/36626946>

Patch by Zach Li <zacharyli323@gmail.com> on 2018-01-19
Reviewed by Dan Bernstein.

If client is using Apple internal SDK, then we can just import the header; if not,
then we declare necessary symbols that client will need.

* Configurations/WebKit.xcconfig:
Only link against SafariSafeBrowsing framework on macOS High Sierra
and iOS 11 and above. Weak link against SafariSafeBrowsing framework
because it is not present on the Base system.

* Platform/spi/Cocoa/SafeBrowsingSPI.h: Added.

* WebKit.xcodeproj/project.pbxproj:
Added SafeBrowsingSPI.h.

* WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/11/SafariSafeBrowsing.framework/SafariSafeBrowsing.tbd:
Added.

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

Source/WebKit/ChangeLog
Source/WebKit/Configurations/WebKit.xcconfig
Source/WebKit/Platform/spi/Cocoa/SafeBrowsingSPI.h [new file with mode: 0644]
Source/WebKit/WebKit.xcodeproj/project.pbxproj
WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/11/SafariSafeBrowsing.framework/SafariSafeBrowsing.tbd [new file with mode: 0644]

index 0706181..409cc34 100644 (file)
@@ -1,3 +1,27 @@
+2018-01-19  Zach Li  <zacharyli323@gmail.com>
+
+        Expose Safe Browsing SPI
+        https://bugs.webkit.org/show_bug.cgi?id=181804
+        <rdar://problem/36626946>
+
+        Reviewed by Dan Bernstein.
+
+        If client is using Apple internal SDK, then we can just import the header; if not,
+        then we declare necessary symbols that client will need.
+
+        * Configurations/WebKit.xcconfig:
+        Only link against SafariSafeBrowsing framework on macOS High Sierra
+        and iOS 11 and above. Weak link against SafariSafeBrowsing framework
+        because it is not present on the Base system.
+
+        * Platform/spi/Cocoa/SafeBrowsingSPI.h: Added.
+
+        * WebKit.xcodeproj/project.pbxproj:
+        Added SafeBrowsingSPI.h.
+
+        * WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/11/SafariSafeBrowsing.framework/SafariSafeBrowsing.tbd:
+        Added.
+
 2018-01-19  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed build fix, removed unused lambda capture.
index 343af96..ee538d7 100644 (file)
@@ -55,7 +55,7 @@ LIBWEBRTC_LIBRARY_DIR[sdk=macosx*] = $(LIBWEBRTC_LIBRARY_DIR_USE_OVERRIDE_FRAMEW
 LIBWEBRTC_LIBRARY_DIR_USE_OVERRIDE_FRAMEWORKS_DIR_NO = $(WEBCORE_FRAMEWORKS_DIR)/WebCore.framework/Versions/A/Frameworks;
 LIBWEBRTC_LIBRARY_DIR_USE_OVERRIDE_FRAMEWORKS_DIR_YES = $(WK_OVERRIDE_FRAMEWORKS_DIR);
 
-OTHER_LDFLAGS = $(inherited) -F"$(SDK_DIR)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks" $(UNEXPORTED_SYMBOL_LDFLAGS) $(ASAN_OTHER_LDFLAGS) $(FRAMEWORK_AND_LIBRARY_LDFLAGS) $(OTHER_LDFLAGS_PLATFORM) $(WK_RELOCATABLE_FRAMEWORK_LDFLAGS) $(WK_CORE_PREDICTION_LDFLAGS) -framework WebKitLegacy;
+OTHER_LDFLAGS = $(inherited) -F"$(SDK_DIR)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks" $(UNEXPORTED_SYMBOL_LDFLAGS) $(ASAN_OTHER_LDFLAGS) $(FRAMEWORK_AND_LIBRARY_LDFLAGS) $(OTHER_LDFLAGS_PLATFORM) $(WK_RELOCATABLE_FRAMEWORK_LDFLAGS) $(WK_CORE_PREDICTION_LDFLAGS) -framework WebKitLegacy $(WK_SAFE_BROWSING_LDFLAGS);
 OTHER_LDFLAGS_PLATFORM[sdk=macosx*] = $(LIBWEBRTC_LDFLAGS);
 OTHER_LDFLAGS_PLATFORM[sdk=iphoneos*] = -lAccessibility $(LIBWEBRTC_LDFLAGS);
 OTHER_LDFLAGS_PLATFORM[sdk=iphonesimulator*] = -lAccessibility $(LIBWEBRTC_LDFLAGS);
@@ -86,3 +86,8 @@ WK_RELOCATABLE_FRAMEWORK_LDFLAGS_YES = -Wl,-not_for_dyld_shared_cache;
 WK_CORE_PREDICTION_LDFLAGS = $(WK_CORE_PREDICTION_LDFLAGS_$(WK_HAVE_CORE_PREDICTION));
 WK_CORE_PREDICTION_LDFLAGS_YES = -framework CorePrediction;
 WK_CORE_PREDICTION_LDFLAGS_YES[sdk=macosx*] = -weak_framework CorePrediction;
+
+WK_SAFE_BROWSING_LDFLAGS[sdk=iphone*] = -framework SafariSafeBrowsing;
+WK_SAFE_BROWSING_LDFLAGS[sdk=iphone*10.*] = ;
+WK_SAFE_BROWSING_LDFLAGS[sdk=macosx*] = $(WK_SAFE_BROWSING_LDFLAGS$(WK_MACOS_1013));
+WK_SAFE_BROWSING_LDFLAGS_MACOS_SINCE_1013 = -weak_framework SafariSafeBrowsing;
diff --git a/Source/WebKit/Platform/spi/Cocoa/SafeBrowsingSPI.h b/Source/WebKit/Platform/spi/Cocoa/SafeBrowsingSPI.h
new file mode 100644 (file)
index 0000000..a3f60a6
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000)
+
+#import <Foundation/Foundation.h>
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#import <SafariSafeBrowsing/SafariSafeBrowsing.h>
+
+#else
+
+typedef NSString * SSBProvider NS_STRING_ENUM;
+
+WTF_EXTERN_C_BEGIN
+
+extern SSBProvider const SSBProviderGoogle;
+extern SSBProvider const SSBProviderTencent;
+
+WTF_EXTERN_C_END
+
+@interface SSBServiceLookupResult : NSObject <NSCopying, NSSecureCoding>
+
+@property (nonatomic, readonly) SSBProvider provider;
+
+@property (nonatomic, readonly, getter=isPhishing) BOOL phishing;
+@property (nonatomic, readonly, getter=isMalware) BOOL malware;
+@property (nonatomic, readonly, getter=isUnwantedSoftware) BOOL unwantedSoftware;
+
+@property (nonatomic, readonly, getter=isKnownToBeUnsafe) BOOL knownToBeUnsafe;
+
+@end
+
+@interface SSBLookupResult : NSObject <NSCopying, NSSecureCoding>
+
+@property (nonatomic, readonly) NSArray<SSBServiceLookupResult *> *serviceLookupResults;
+
+@end
+
+@interface SSBLookupContext : NSObject
+
++ (SSBLookupContext *)sharedLookupContext;
+
+- (void)lookUpURL:(NSURL *)URL completionHandler:(void (^)(SSBLookupResult *, NSError *))completionHandler;
+
+@end
+
+#endif
+
+#endif
+
index c5bed0d..a2bc58f 100644 (file)
@@ -65,6 +65,7 @@
                07A5EBBB1C7BA43E00B9CA69 /* WKFrameHandleRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A5EBB91C7BA43E00B9CA69 /* WKFrameHandleRef.cpp */; };
                07A5EBBC1C7BA43E00B9CA69 /* WKFrameHandleRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 07A5EBBA1C7BA43E00B9CA69 /* WKFrameHandleRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0EDE85032004E75D00030560 /* WebsitePopUpPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = 0EDE85022004E74900030560 /* WebsitePopUpPolicy.h */; };
+               0E97D74D200E900400BF6643 /* SafeBrowsingSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 0E97D74C200E8FF300BF6643 /* SafeBrowsingSPI.h */; };
                0F08CF521D63C13A00B48DF1 /* WKFormSelectPicker.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F08CF511D63C13A00B48DF1 /* WKFormSelectPicker.h */; };
                0F08CF541D63C14000B48DF1 /* WKFormSelectPopover.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F08CF531D63C14000B48DF1 /* WKFormSelectPopover.h */; };
                0F0C365818C051BA00F607D7 /* RemoteLayerTreeHostIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F0C365718C051BA00F607D7 /* RemoteLayerTreeHostIOS.mm */; };
                0867D6A5FE840307C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
                089C1667FE841158C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
                0EDE85022004E74900030560 /* WebsitePopUpPolicy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebsitePopUpPolicy.h; sourceTree = "<group>"; };
+               0E97D74C200E8FF300BF6643 /* SafeBrowsingSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SafeBrowsingSPI.h; sourceTree = "<group>"; };
                0F08CF511D63C13A00B48DF1 /* WKFormSelectPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKFormSelectPicker.h; path = ios/forms/WKFormSelectPicker.h; sourceTree = "<group>"; };
                0F08CF531D63C14000B48DF1 /* WKFormSelectPopover.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKFormSelectPopover.h; path = ios/forms/WKFormSelectPopover.h; sourceTree = "<group>"; };
                0F0C365718C051BA00F607D7 /* RemoteLayerTreeHostIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteLayerTreeHostIOS.mm; sourceTree = "<group>"; };
                                37C21CAD1E994C0C0029D5F9 /* CorePredictionSPI.h */,
                                A1FB68261F6E51C100C43F9F /* CrashReporterClientSPI.h */,
                                3754D5441B3A29FD003A4C7F /* NSInvocationSPI.h */,
+                               0E97D74C200E8FF300BF6643 /* SafeBrowsingSPI.h */,
                                37B47E2C1D64DB76005F4EFF /* objcSPI.h */,
                        );
                        path = Cocoa;
                                BC5C75C814954DA600BC4775 /* WKConnectionInternal.h in Headers */,
                                BC4A6297147313A0006C681A /* WKConnectionRef.h in Headers */,
                                5CD286541E7235B10094FDC8 /* WKContentRuleList.h in Headers */,
+                               0E97D74D200E900400BF6643 /* SafeBrowsingSPI.h in Headers */,
                                5CD286551E7235B80094FDC8 /* WKContentRuleListInternal.h in Headers */,
                                5CD286511E7235990094FDC8 /* WKContentRuleListStore.h in Headers */,
                                5CD286571E7235C90094FDC8 /* WKContentRuleListStoreInternal.h in Headers */,
diff --git a/WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/11/SafariSafeBrowsing.framework/SafariSafeBrowsing.tbd b/WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/11/SafariSafeBrowsing.framework/SafariSafeBrowsing.tbd
new file mode 100644 (file)
index 0000000..c195839
--- /dev/null
@@ -0,0 +1,29 @@
+--- !tapi-tbd-v2
+archs:
+  - armv7
+  - armv7s
+  - arm64
+  - i386
+  - x86_64
+exports:
+  -
+    archs:
+      - armv7
+      - armv7s
+      - arm64
+      - i386
+      - x86_64
+    symbols:
+      - _SSBProviderGoogle
+      - _SSBProviderTencent
+      - __ZN12SafeBrowsing7Service4mainEv
+    objc-classes:
+      - _SSBLookupContext
+      - _SSBLookupResult
+      - _SSBServiceLookupResult
+install-name: /System/Library/PrivateFrameworks/SafariSafeBrowsing.framework/SafariSafeBrowsing
+current-version: 0
+compatibility-version: 0
+objc-constraint: none
+platform: ios
+...