Add some SPI headers for NSExtension and NSSharingService{Picker}
https://bugs.webkit.org/show_bug.cgi?id=138027

Reviewed by Anders Carlsson.

* WebCore.xcodeproj/project.pbxproj:
* platform/spi/cocoa/NSExtensionSPI.h: Added.
* platform/spi/mac/NSSharingServicePickerSPI.h: Added.
* platform/spi/mac/NSSharingServiceSPI.h: Added.
Add modern SPI headers for NSExtension, and NSSharingService{Picker}.

* rendering/RenderThemeMac.mm:
Replace redefinitions with an SPI header #import.

* UIProcess/API/mac/WKView.mm:
* UIProcess/mac/ServicesController.mm:
* UIProcess/mac/WebContextMenuProxyMac.mm:
Replace redefinitions with SPI header #imports.

* Misc/WebSharingServicePickerController.h:
* Misc/WebSharingServicePickerController.mm:
* WebCoreSupport/WebSelectionServiceController.mm:
* WebCoreSupport/WebContextMenuClient.mm:
Fix a sorting issue.
Replace redefinitions with SPI header #imports.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@175147 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index bcc75e4..2bc341a 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,19 @@
+2014-10-23  Tim Horton  <timothy_horton@apple.com>
+
+        Add some SPI headers for NSExtension and NSSharingService{Picker}
+        https://bugs.webkit.org/show_bug.cgi?id=138027
+
+        Reviewed by Anders Carlsson.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/spi/cocoa/NSExtensionSPI.h: Added.
+        * platform/spi/mac/NSSharingServicePickerSPI.h: Added.
+        * platform/spi/mac/NSSharingServiceSPI.h: Added.
+        Add modern SPI headers for NSExtension, and NSSharingService{Picker}.
+
+        * rendering/RenderThemeMac.mm:
+        Replace redefinitions with an SPI header #import.
+
 2014-10-23  Eric Carlson  <eric.carlson@apple.com>
 
         [Mac] don't update caption user style sheet during parsing
diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
index 3bf40e0..d1ec37b 100644
--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -1134,6 +1134,9 @@
 		2D9A247515B9C2E300D34527 /* DOMDOMSecurityPolicyInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D9A247115B9C29500D34527 /* DOMDOMSecurityPolicyInternal.h */; };
 		2D9A247615B9C2F400D34527 /* DOMDOMSecurityPolicy.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 2D9A247015B9C29500D34527 /* DOMDOMSecurityPolicy.h */; };
 		2D9F0E1314FF1CBF00BA0FF7 /* linearSRGB.icc in Resources */ = {isa = PBXBuildFile; fileRef = 2D9F0E1214FF1CBF00BA0FF7 /* linearSRGB.icc */; };
+		2DCB837919F99BBA00A7FBE4 /* NSSharingServicePickerSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DCB837719F99BBA00A7FBE4 /* NSSharingServicePickerSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		2DCB837A19F99BBA00A7FBE4 /* NSSharingServiceSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DCB837819F99BBA00A7FBE4 /* NSSharingServiceSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		2DDB97F419F9AECA002025D8 /* NSExtensionSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DDB97F319F9AECA002025D8 /* NSExtensionSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		2DE70023192FE82A00B0975C /* DisplayRefreshMonitorMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DE70022192FE82A00B0975C /* DisplayRefreshMonitorMac.h */; };
 		2E0888D41148848A00AF4265 /* JSDOMFormData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E0888D21148848A00AF4265 /* JSDOMFormData.cpp */; };
 		2E0888D51148848A00AF4265 /* JSDOMFormData.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E0888D31148848A00AF4265 /* JSDOMFormData.h */; };
@@ -8156,6 +8159,9 @@
 		2D9F0E1214FF1CBF00BA0FF7 /* linearSRGB.icc */ = {isa = PBXFileReference; lastKnownFileType = file; path = linearSRGB.icc; sourceTree = "<group>"; };
 		2DAAE32C19DCAF6000E002D2 /* MockPageOverlayClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MockPageOverlayClient.cpp; sourceTree = "<group>"; };
 		2DAAE32D19DCAF6000E002D2 /* MockPageOverlayClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockPageOverlayClient.h; sourceTree = "<group>"; };
+		2DCB837719F99BBA00A7FBE4 /* NSSharingServicePickerSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSSharingServicePickerSPI.h; sourceTree = "<group>"; };
+		2DCB837819F99BBA00A7FBE4 /* NSSharingServiceSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSSharingServiceSPI.h; sourceTree = "<group>"; };
+		2DDB97F319F9AECA002025D8 /* NSExtensionSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSExtensionSPI.h; sourceTree = "<group>"; };
 		2DE70022192FE82A00B0975C /* DisplayRefreshMonitorMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayRefreshMonitorMac.h; sourceTree = "<group>"; };
 		2E0888C3114883A900AF4265 /* DOMFormData.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DOMFormData.idl; sourceTree = "<group>"; };
 		2E0888D21148848A00AF4265 /* JSDOMFormData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMFormData.cpp; sourceTree = "<group>"; };
@@ -16248,6 +16254,7 @@
 		653EF83719A043AE0052202C /* cocoa */ = {
 			isa = PBXGroup;
 			children = (
+				2DDB97F319F9AECA002025D8 /* NSExtensionSPI.h */,
 				653EF83819A043AE0052202C /* NSURLFileTypeMappingsSPI.h */,
 				1CF7E26E19D881EF00DD8F98 /* CGFontUnicodeSupportSPI.h */,
 			);
@@ -17596,6 +17603,8 @@
 		9348428019F1A9190009D5AE /* mac */ = {
 			isa = PBXGroup;
 			children = (
+				2DCB837719F99BBA00A7FBE4 /* NSSharingServicePickerSPI.h */,
+				2DCB837819F99BBA00A7FBE4 /* NSSharingServiceSPI.h */,
 				9348428119F1A9190009D5AE /* NSViewSPI.h */,
 			);
 			path = mac;
@@ -24367,6 +24376,7 @@
 				514C76700CE923A1007EF3CD /* FormData.h in Headers */,
 				085B92BB0EFDE73D00E6123C /* FormDataBuilder.h in Headers */,
 				A8136D380973A8E700D74463 /* FormDataList.h in Headers */,
+				2DCB837A19F99BBA00A7FBE4 /* NSSharingServiceSPI.h in Headers */,
 				7EE6846712D26E3800E79415 /* FormDataStreamCFNet.h in Headers */,
 				514C764E0CE9234E007EF3CD /* FormDataStreamMac.h in Headers */,
 				9B50B1DE17CD4C0F0087F63C /* FormNamedItem.h in Headers */,
@@ -25004,6 +25014,7 @@
 				1A0D57410A5C7867007EDD4C /* JSOverflowEvent.h in Headers */,
 				E1284BB110449FFA00EAEB52 /* JSPageTransitionEvent.h in Headers */,
 				FDA15EB212B03EE1003A583A /* JSPannerNode.h in Headers */,
+				2DCB837919F99BBA00A7FBE4 /* NSSharingServicePickerSPI.h in Headers */,
 				8A9A587511E84C81008ACFD1 /* JSPerformance.h in Headers */,
 				8A9A587111E84C36008ACFD1 /* JSPerformanceNavigation.h in Headers */,
 				8A9A588811E84F37008ACFD1 /* JSPerformanceTiming.h in Headers */,
@@ -25691,6 +25702,7 @@
 				A76E5F7F135E0DCF00A69837 /* RenderedDocumentMarker.h in Headers */,
 				9B32CDA913DF7FA900F34D13 /* RenderedPosition.h in Headers */,
 				E43A023B17EB370A004CDD25 /* RenderElement.h in Headers */,
+				2DDB97F419F9AECA002025D8 /* NSExtensionSPI.h in Headers */,
 				0F5B7A5510F65D7A00376302 /* RenderEmbeddedObject.h in Headers */,
 				A8EA73C40A1900E300A8EF5F /* RenderFieldset.h in Headers */,
 				066C77310AB603FD00238CC4 /* RenderFileUploadControl.h in Headers */,
diff --git a/Source/WebCore/platform/spi/cocoa/NSExtensionSPI.h b/Source/WebCore/platform/spi/cocoa/NSExtensionSPI.h
new file mode 100644
index 0000000..dfcb3a8
--- /dev/null
+++ b/Source/WebCore/platform/spi/cocoa/NSExtensionSPI.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#import <Foundation/NSExtension.h>
+
+#elif __OBJC2__
+
+@interface NSExtension
+@end
+
+@interface NSExtension (Private)
++ (id)beginMatchingExtensionsWithAttributes:(NSDictionary *)attributes completion:(void (^)(NSArray *matchingExtensions, NSError *error))handler;
+@end
+
+#endif
diff --git a/Source/WebCore/platform/spi/mac/NSSharingServicePickerSPI.h b/Source/WebCore/platform/spi/mac/NSSharingServicePickerSPI.h
new file mode 100644
index 0000000..6a8df1d
--- /dev/null
+++ b/Source/WebCore/platform/spi/mac/NSSharingServicePickerSPI.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+#if USE(APPLE_INTERNAL_SDK) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
+
+#import <AppKit/NSSharingService_Private.h>
+
+#else
+
+#import <AppKit/NSSharingService.h>
+
+typedef NS_ENUM(NSInteger, NSSharingServicePickerStyle) {
+    NSSharingServicePickerStyleMenu = 0,
+    NSSharingServicePickerStyleRollover = 1,
+    NSSharingServicePickerStyleTextSelection = 2,
+    NSSharingServicePickerStyleDataDetector = 3
+} NS_ENUM_AVAILABLE_MAC(10_10);
+
+@interface NSSharingServicePicker (Private)
+@property NSSharingServicePickerStyle style;
+- (NSMenu *)menu;
+@end
+
+#endif
diff --git a/Source/WebCore/platform/spi/mac/NSSharingServiceSPI.h b/Source/WebCore/platform/spi/mac/NSSharingServiceSPI.h
new file mode 100644
index 0000000..ef9210f
--- /dev/null
+++ b/Source/WebCore/platform/spi/mac/NSSharingServiceSPI.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+#if USE(APPLE_INTERNAL_SDK) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
+
+#import <AppKit/NSSharingService_Private.h>
+
+#else
+
+#import <AppKit/NSSharingService.h>
+
+typedef NS_ENUM(NSInteger, NSSharingServiceType) {
+    NSSharingServiceTypeShare = 0,
+    NSSharingServiceTypeViewer = 1,
+    NSSharingServiceTypeEditor = 2
+} NS_ENUM_AVAILABLE_MAC(10_10);
+
+typedef NS_OPTIONS(NSUInteger, NSSharingServiceMask) {
+    NSSharingServiceMaskShare = (1 << NSSharingServiceTypeShare),
+    NSSharingServiceMaskViewer = (1 << NSSharingServiceTypeViewer),
+    NSSharingServiceMaskEditor = (1 << NSSharingServiceTypeEditor),
+
+    NSSharingServiceMaskAllTypes = 0xFFFF
+} NS_ENUM_AVAILABLE_MAC(10_10);
+
+@interface NSSharingService (Private)
++ (NSArray *)sharingServicesForItems:(NSArray *)items mask:(NSSharingServiceMask)maskForFiltering;
+@property (readonly) NSSharingServiceType type;
+@end
+
+#endif
diff --git a/Source/WebCore/rendering/RenderThemeMac.mm b/Source/WebCore/rendering/RenderThemeMac.mm
index e785bed..5a80c26 100644
--- a/Source/WebCore/rendering/RenderThemeMac.mm
+++ b/Source/WebCore/rendering/RenderThemeMac.mm
@@ -44,6 +44,7 @@
 #import "LocalCurrentGraphicsContext.h"
 #import "LocalizedStrings.h"
 #import "MediaControlElements.h"
+#import "NSSharingServicePickerSPI.h"
 #import "Page.h"
 #import "PaintInfo.h"
 #import "RenderLayer.h"
@@ -89,14 +90,6 @@
 #define APPKIT_PRIVATE_CLASS
 #endif
 
-#if __has_include(<AppKit/NSSharingService_Private.h>)
-#import <AppKit/NSSharingService_Private.h>
-#else
-typedef enum {
-    NSSharingServicePickerStyleRollover = 1
-} NSSharingServicePickerStyle;
-#endif
-
 #if __has_include(<AppKit/NSServicesRolloverButtonCell.h>)
 #import <AppKit/NSServicesRolloverButtonCell.h>
 #else
diff --git a/Source/WebKit/mac/ChangeLog b/Source/WebKit/mac/ChangeLog
index 24767ca..c985bd9 100644
--- a/Source/WebKit/mac/ChangeLog
+++ b/Source/WebKit/mac/ChangeLog
@@ -1,5 +1,19 @@
 2014-10-23  Tim Horton  <timothy_horton@apple.com>
 
+        Add some SPI headers for NSExtension and NSSharingService{Picker}
+        https://bugs.webkit.org/show_bug.cgi?id=138027
+
+        Reviewed by Anders Carlsson.
+
+        * Misc/WebSharingServicePickerController.h:
+        * Misc/WebSharingServicePickerController.mm:
+        * WebCoreSupport/WebSelectionServiceController.mm:
+        * WebCoreSupport/WebContextMenuClient.mm:
+        Fix a sorting issue.
+        Replace redefinitions with SPI header #imports.
+
+2014-10-23  Tim Horton  <timothy_horton@apple.com>
+
         Crashes under WebSelectionServiceController::hasRelevantSelectionServices
         https://bugs.webkit.org/show_bug.cgi?id=138013
 
diff --git a/Source/WebKit/mac/Misc/WebSharingServicePickerController.h b/Source/WebKit/mac/Misc/WebSharingServicePickerController.h
index ab33afe..a3cbcb1 100644
--- a/Source/WebKit/mac/Misc/WebSharingServicePickerController.h
+++ b/Source/WebKit/mac/Misc/WebSharingServicePickerController.h
@@ -26,30 +26,10 @@
 #if ENABLE(SERVICE_CONTROLS)
 
 #import <wtf/RetainPtr.h>
+#import <WebCore/NSSharingServicePickerSPI.h>
+#import <WebCore/NSSharingServiceSPI.h>
 
-@class NSSharingServicePicker;
 @class WebSharingServicePickerController;
-@protocol NSSharingServiceDelegate;
-@protocol NSSharingServicePickerDelegate;
-
-#if __has_include(<AppKit/NSSharingService_Private.h>)
-#import <AppKit/NSSharingService_Private.h>
-#else
-typedef NS_ENUM(NSInteger, NSSharingServicePickerStyle) {
-    NSSharingServicePickerStyleMenu = 0,
-    NSSharingServicePickerStyleRollover = 1,
-    NSSharingServicePickerStyleTextSelection = 2,
-    NSSharingServicePickerStyleDataDetector = 3
-} NS_ENUM_AVAILABLE_MAC(10_10);
-
-typedef NS_ENUM(NSInteger, NSSharingServiceType) {
-    NSSharingServiceTypeShare = 0,
-    NSSharingServiceTypeViewer = 1,
-    NSSharingServiceTypeEditor = 2
-} NS_ENUM_AVAILABLE_MAC(10_10);
-
-typedef NSUInteger NSSharingServiceMask;
-#endif
 
 namespace WebCore {
 class FloatRect;
diff --git a/Source/WebKit/mac/Misc/WebSharingServicePickerController.mm b/Source/WebKit/mac/Misc/WebSharingServicePickerController.mm
index 097608a..34787ba 100644
--- a/Source/WebKit/mac/Misc/WebSharingServicePickerController.mm
+++ b/Source/WebKit/mac/Misc/WebSharingServicePickerController.mm
@@ -29,36 +29,15 @@
 
 #import "WebContextMenuClient.h"
 #import "WebViewInternal.h"
-#import <AppKit/NSSharingService.h>
 #import <WebCore/BitmapImage.h>
+#import <WebCore/ContextMenuController.h>
 #import <WebCore/Document.h>
 #import <WebCore/Editor.h>
 #import <WebCore/FocusController.h>
 #import <WebCore/Frame.h>
 #import <WebCore/FrameSelection.h>
-#import <WebCore/ContextMenuController.h>
 #import <WebCore/Page.h>
 
-@interface NSSharingServicePicker (Private)
-@property NSSharingServicePickerStyle style;
-- (NSMenu *)menu;
-@end
-
-@interface NSSharingService (Private)
-@property (readonly) NSSharingServiceType type;
-@end
-
-#if __has_include(<AppKit/NSItemProvider.h>)
-#import <AppKit/NSItemProvider.h>
-#else
-// FIXME: We should properly disable code that interacts with NSItemProvider/NSSharingServicePicker in 32-bit.
-@interface NSItemProvider : NSObject
-@property (copy, readonly) NSArray *registeredTypeIdentifiers;
-- (instancetype)initWithItem:(id <NSSecureCoding>)item typeIdentifier:(NSString *)typeIdentifier;
-- (void)loadItemForTypeIdentifier:(NSString *)typeIdentifier options:(NSDictionary *)options completionHandler:(void (^)(id <NSSecureCoding> item, NSError *error))completionHandler;
-@end
-#endif
-
 static NSString *serviceControlsPasteboardName = @"WebKitServiceControlsPasteboard";
 
 using namespace WebCore;
diff --git a/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm b/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm
index 2faf896..d08b171b 100644
--- a/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm
+++ b/Source/WebKit/mac/WebCoreSupport/WebContextMenuClient.mm
@@ -30,7 +30,6 @@
 
 #import "WebContextMenuClient.h"
 
-#import <WebCore/BitmapImage.h>
 #import "WebDelegateImplementationCaching.h"
 #import "WebElementDictionary.h"
 #import "WebFrame.h"
@@ -44,6 +43,7 @@
 #import "WebUIDelegatePrivate.h"
 #import "WebView.h"
 #import "WebViewInternal.h"
+#import <WebCore/BitmapImage.h>
 #import <WebCore/ContextMenu.h>
 #import <WebCore/ContextMenuController.h>
 #import <WebCore/Document.h>
@@ -52,6 +52,7 @@
 #import <WebCore/GraphicsContext.h>
 #import <WebCore/ImageBuffer.h>
 #import <WebCore/LocalizedStrings.h>
+#import <WebCore/NSSharingServicePickerSPI.h>
 #import <WebCore/Page.h>
 #import <WebCore/RenderBox.h>
 #import <WebCore/RenderObject.h>
diff --git a/Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.mm b/Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.mm
index 2711a5d..140b10c 100644
--- a/Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.mm
+++ b/Source/WebKit/mac/WebCoreSupport/WebSelectionServiceController.mm
@@ -30,27 +30,12 @@
 #import "WebViewInternal.h"
 #import <WebCore/FrameSelection.h>
 #import <WebCore/HTMLConverter.h>
+#import <WebCore/NSSharingServiceSPI.h>
 #import <WebCore/Range.h>
 #import <wtf/NeverDestroyed.h>
 
 using namespace WebCore;
 
-#if __has_include(<AppKit/NSSharingService_Private.h>)
-#import <AppKit/NSSharingService_Private.h>
-#else
-typedef NS_OPTIONS(NSUInteger, NSSharingServiceMask) {
-    NSSharingServiceMaskShare = (1 << NSSharingServiceTypeShare),
-    NSSharingServiceMaskViewer = (1 << NSSharingServiceTypeViewer),
-    NSSharingServiceMaskEditor = (1 << NSSharingServiceTypeEditor),
-    
-    NSSharingServiceMaskAllTypes = 0xFFFF
-} NS_ENUM_AVAILABLE_MAC(10_10);
-#endif
-
-@interface NSSharingService (WKDetails)
-+ (NSArray *)sharingServicesForItems:(NSArray *)items mask:(NSSharingServiceMask)maskForFiltering;
-@end
-
 WebSelectionServiceController::WebSelectionServiceController(WebView *webView) 
     : m_webView(webView)
 {
diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog
index 72fe83a..888d1c6 100644
--- a/Source/WebKit2/ChangeLog
+++ b/Source/WebKit2/ChangeLog
@@ -1,3 +1,15 @@
+2014-10-23  Tim Horton  <timothy_horton@apple.com>
+
+        Add some SPI headers for NSExtension and NSSharingService{Picker}
+        https://bugs.webkit.org/show_bug.cgi?id=138027
+
+        Reviewed by Anders Carlsson.
+
+        * UIProcess/API/mac/WKView.mm:
+        * UIProcess/mac/ServicesController.mm:
+        * UIProcess/mac/WebContextMenuProxyMac.mm:
+        Replace redefinitions with SPI header #imports.
+
 2014-10-23  Benjamin Poulain  <bpoulain@apple.com>
 
         [iOS WK2] Make sure any dynamic viewport update schedules a layer tree commit
diff --git a/Source/WebKit2/UIProcess/API/mac/WKView.mm b/Source/WebKit2/UIProcess/API/mac/WKView.mm
index e1e18c3..141a31c 100644
--- a/Source/WebKit2/UIProcess/API/mac/WKView.mm
+++ b/Source/WebKit2/UIProcess/API/mac/WKView.mm
@@ -76,7 +76,6 @@
 #import "WebProcessProxy.h"
 #import "WebSystemInterface.h"
 #import "_WKThumbnailViewInternal.h"
-#import <AppKit/NSSharingService.h>
 #import <ImageIO/ImageIO.h>
 #import <ImageKit/ImageKit.h>
 #import <QuartzCore/QuartzCore.h>
@@ -90,6 +89,7 @@
 #import <WebCore/FileSystem.h>
 #import <WebCore/KeyboardEvent.h>
 #import <WebCore/LocalizedStrings.h>
+#import <WebCore/NSSharingServicePickerSPI.h>
 #import <WebCore/NSViewSPI.h>
 #import <WebCore/PlatformEventFactoryMac.h>
 #import <WebCore/PlatformScreen.h>
@@ -153,11 +153,6 @@
 CGError CGSGetScreenRectForWindow(CGSConnectionID cid, CGSWindowID wid, CGRect *rect);
 };
 
-// FIXME: This needs to be in an SPI header.
-@interface NSSharingServicePicker (WKNSSharingServicePickerDetails)
-- (NSMenu *)menu;
-@end
-
 SOFT_LINK_FRAMEWORK_IN_UMBRELLA(Quartz, ImageKit)
 SOFT_LINK_CLASS(ImageKit, IKSlideshow)
 
diff --git a/Source/WebKit2/UIProcess/mac/ServicesController.mm b/Source/WebKit2/UIProcess/mac/ServicesController.mm
index 7f1a02b..0ce81ba 100644
--- a/Source/WebKit2/UIProcess/mac/ServicesController.mm
+++ b/Source/WebKit2/UIProcess/mac/ServicesController.mm
@@ -30,56 +30,11 @@
 
 #import "WebContext.h"
 #import "WebProcessMessages.h"
-#import <AppKit/NSSharingService.h>
+#import <WebCore/NSExtensionSPI.h>
+#import <WebCore/NSSharingServicePickerSPI.h>
+#import <WebCore/NSSharingServiceSPI.h>
 #import <wtf/NeverDestroyed.h>
 
-#if __has_include(<AppKit/NSSharingService_Private.h>)
-#import <AppKit/NSSharingService_Private.h>
-#else
-typedef NS_ENUM(NSInteger, NSSharingServicePickerStyle) {
-    NSSharingServicePickerStyleMenu = 0,
-    NSSharingServicePickerStyleRollover = 1,
-    NSSharingServicePickerStyleTextSelection = 2,
-    NSSharingServicePickerStyleDataDetector = 3
-} NS_ENUM_AVAILABLE_MAC(10_10);
-
-typedef NS_ENUM(NSInteger, NSSharingServiceType) {
-    NSSharingServiceTypeShare = 0,
-    NSSharingServiceTypeViewer = 1,
-    NSSharingServiceTypeEditor = 2
-} NS_ENUM_AVAILABLE_MAC(10_10);
-
-typedef NS_OPTIONS(NSUInteger, NSSharingServiceMask) {
-    NSSharingServiceMaskShare = (1 << NSSharingServiceTypeShare),
-    NSSharingServiceMaskViewer = (1 << NSSharingServiceTypeViewer),
-    NSSharingServiceMaskEditor = (1 << NSSharingServiceTypeEditor),
-
-    NSSharingServiceMaskAllTypes = 0xFFFF
-} NS_ENUM_AVAILABLE_MAC(10_10);
-#endif
-
-@interface NSSharingServicePicker (WKDetails)
-@property NSSharingServicePickerStyle style;
-- (NSMenu *)menu;
-@end
-
-@interface NSSharingService (WKDetails)
-+ (NSArray *)sharingServicesForItems:(NSArray *)items mask:(NSSharingServiceMask)maskForFiltering;
-@end
-
-#ifdef __LP64__
-#if __has_include(<Foundation/NSExtension.h>)
-#import <Foundation/NSExtension.h>
-#else
-@interface NSExtension
-@end
-#endif
-
-@interface NSExtension (WKDetails)
-+ (id)beginMatchingExtensionsWithAttributes:(NSDictionary *)attributes completion:(void (^)(NSArray *matchingExtensions, NSError *error))handler;
-@end
-#endif // __LP64__
-
 namespace WebKit {
 
 ServicesController& ServicesController::shared()
diff --git a/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm
index 58ad991..0a8e267 100644
--- a/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm
+++ b/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm
@@ -40,39 +40,11 @@
 #import "WKView.h"
 #import <WebCore/GraphicsContext.h>
 #import <WebCore/IntRect.h>
+#import <WebCore/NSSharingServicePickerSPI.h>
+#import <WebCore/NSSharingServiceSPI.h>
 #import <WebKitSystemInterface.h>
 #import <wtf/RetainPtr.h>
 
-#if ENABLE(SERVICE_CONTROLS)
-#import <AppKit/NSSharingService.h>
-
-#if __has_include(<AppKit/NSSharingService_Private.h>)
-#import <AppKit/NSSharingService_Private.h>
-#else
-typedef enum {
-    NSSharingServicePickerStyleMenu = 0,
-    NSSharingServicePickerStyleRollover = 1,
-    NSSharingServicePickerStyleTextSelection = 2
-} NSSharingServicePickerStyle;
-
-typedef enum {
-    NSSharingServiceTypeEditor = 2
-} NSSharingServiceType;
-
-typedef NSUInteger NSSharingServiceMask;
-#endif
-
-@interface NSSharingServicePicker (Details)
-@property NSSharingServicePickerStyle style;
-- (NSMenu *)menu;
-@end
-
-@interface NSSharingService (Private)
-@property (readonly) NSSharingServiceType type;
-@end
-
-#endif // ENABLE(SERVICE_CONTROLS)
-
 using namespace WebCore;
 
 @interface WKUserDataWrapper : NSObject {