Share sheet doesn't attach to the window
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Oct 2014 23:10:30 +0000 (23:10 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Oct 2014 23:10:30 +0000 (23:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=138062
<rdar://problem/18767397>

Reviewed by Beth Dakin.

* UIProcess/mac/WKActionMenuController.h:
WKActionMenuController is now a NSSharingService{Picker}Delegate.

* UIProcess/mac/WKActionMenuController.mm:
(-[WKActionMenuController _defaultMenuItemsForImage]):
Set us up as the NSSharingServicePicker delegate.

(-[WKActionMenuController sharingServicePicker:delegateForSharingService:]):
Set us up as the NSSharingService delegate.

(-[WKActionMenuController sharingService:sourceWindowForShareItems:sharingContentScope:]):
Return the appropriate window to attach to.

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/mac/WKActionMenuController.h
Source/WebKit2/UIProcess/mac/WKActionMenuController.mm

index ccd71e5ba4320d22383a5f2864348fa8643e75ce..1ff2e0bf686db237ff1f34901fdf75fc5ba491b7 100644 (file)
@@ -1,3 +1,24 @@
+2014-10-24  Tim Horton  <timothy_horton@apple.com>
+
+        Share sheet doesn't attach to the window
+        https://bugs.webkit.org/show_bug.cgi?id=138062
+        <rdar://problem/18767397>
+
+        Reviewed by Beth Dakin.
+
+        * UIProcess/mac/WKActionMenuController.h:
+        WKActionMenuController is now a NSSharingService{Picker}Delegate.
+
+        * UIProcess/mac/WKActionMenuController.mm:
+        (-[WKActionMenuController _defaultMenuItemsForImage]):
+        Set us up as the NSSharingServicePicker delegate.
+
+        (-[WKActionMenuController sharingServicePicker:delegateForSharingService:]):
+        Set us up as the NSSharingService delegate.
+
+        (-[WKActionMenuController sharingService:sourceWindowForShareItems:sharingContentScope:]):
+        Return the appropriate window to attach to.
+
 2014-10-24  Jer Noble  <jer.noble@apple.com>
 
         Abstractify WebOriginDataManager to support arbitrary ChildProcess supplements.
index 47b2e41f659dcf810e9f84d987f0430faed9c1fa..ac5a6bd538ffe81c5af3cdb4101e98abe5b7db4e 100644 (file)
@@ -28,6 +28,7 @@
 
 #import "ActionMenuHitTestResult.h"
 #import "WKActionMenuItemTypes.h"
+#import <AppKit/NSSharingService.h>
 #import <wtf/RetainPtr.h>
 
 namespace WebKit {
@@ -40,10 +41,9 @@ enum class ActionMenuState {
 };
 }
 
-@class NSSharingServicePicker;
 @class WKView;
 
-@interface WKActionMenuController : NSObject {
+@interface WKActionMenuController : NSObject <NSSharingServiceDelegate, NSSharingServicePickerDelegate> {
 @private
     WebKit::WebPageProxy *_page;
     WKView *_wkView;
index 07a07ec223b4655138dfb2a15709a32cc0fa9e32..e962aaec1b8b7ea2d3810432f76667f17409206c 100644 (file)
@@ -192,6 +192,7 @@ using namespace WebKit;
         RetainPtr<CGImageRef> image = bitmap->makeCGImage();
         RetainPtr<NSImage> nsImage = adoptNS([[NSImage alloc] initWithCGImage:image.get() size:NSZeroSize]);
         _sharingServicePicker = adoptNS([[NSSharingServicePicker alloc] initWithItems:@[ nsImage.get() ]]);
+        [_sharingServicePicker setDelegate:self];
         [shareItem setSubmenu:[_sharingServicePicker menu]];
     }
 
@@ -291,6 +292,20 @@ static NSString *pathToPhotoOnDisk(NSString *suggestedFilename)
     });
 }
 
+#pragma mark NSSharingServicePickerDelegate implementation
+
+- (id <NSSharingServiceDelegate>)sharingServicePicker:(NSSharingServicePicker *)sharingServicePicker delegateForSharingService:(NSSharingService *)sharingService
+{
+    return self;
+}
+
+#pragma mark NSSharingServiceDelegate implementation
+
+- (NSWindow *)sharingService:(NSSharingService *)sharingService sourceWindowForShareItems:(NSArray *)items sharingContentScope:(NSSharingContentScope *)sharingContentScope
+{
+    return _wkView.window;
+}
+
 #pragma mark Menu Items
 
 - (RetainPtr<NSMenuItem>)_createActionMenuItemForTag:(uint32_t)tag