Changeset 238941 in webkit


Ignore:
Timestamp:
Dec 6, 2018 2:11:45 PM (5 years ago)
Author:
timothy_horton@apple.com
Message:

Web Share API: share overlay does not stick to the Safari window
https://bugs.webkit.org/show_bug.cgi?id=192469
<rdar://problem/46074833>

Reviewed by Wenson Hsieh.

  • UIProcess/Cocoa/WKShareSheet.mm:

(-[WKShareSheet sharingServicePicker:didChooseSharingService:]):
(-[WKShareSheet sharingServicePicker:delegateForSharingService:]):
(-[WKShareSheet sharingService:sourceWindowForShareItems:sharingContentScope:]):
(-[WKShareSheet sharingService:didFailToShareItems:error:]):
(-[WKShareSheet sharingService:didShareItems:]):
Implement another NSSharingServicePickerDelegate method to return
an *NSSharingService* delegate when needed.

Implement an NSSharingServiceDelegate method to return the window that
the service's UI should attach to.

Also, instead of notifying the Web Content process when a service is picked
(or not) in the NSSharingServicePicker, wait until the share has completed
(or failed) to send didComplete. This both makes the return completion
value more accurate (matching iOS, if you cancel the share during the
recipient choice step, it will now fail), and avoids explicitly tearing
down the NSSharingServicePicker too early, which breaks the UI attaching mechanism.

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r238939 r238941  
     12018-12-06  Tim Horton  <timothy_horton@apple.com>
     2
     3        Web Share API: share overlay does not stick to the Safari window
     4        https://bugs.webkit.org/show_bug.cgi?id=192469
     5        <rdar://problem/46074833>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        * UIProcess/Cocoa/WKShareSheet.mm:
     10        (-[WKShareSheet sharingServicePicker:didChooseSharingService:]):
     11        (-[WKShareSheet sharingServicePicker:delegateForSharingService:]):
     12        (-[WKShareSheet sharingService:sourceWindowForShareItems:sharingContentScope:]):
     13        (-[WKShareSheet sharingService:didFailToShareItems:error:]):
     14        (-[WKShareSheet sharingService:didShareItems:]):
     15        Implement another NSSharingServicePickerDelegate method to return
     16        an *NSSharingService* delegate when needed.
     17
     18        Implement an NSSharingServiceDelegate method to return the window that
     19        the service's UI should attach to.
     20
     21        Also, instead of notifying the Web Content process when a service is picked
     22        (or not) in the NSSharingServicePicker, wait until the share has completed
     23        (or failed) to send didComplete. This both makes the return completion
     24        value more accurate (matching iOS, if you cancel the share during the
     25        recipient choice step, it will now fail), and avoids explicitly tearing
     26        down the NSSharingServicePicker too early, which breaks the UI attaching mechanism.
     27
    1282018-12-06  Wenson Hsieh  <wenson_hsieh@apple.com>
    229
  • trunk/Source/WebKit/UIProcess/Cocoa/WKShareSheet.mm

    r237266 r238941  
    4343
    4444#if PLATFORM(MAC)
    45 @interface WKShareSheet () <NSSharingServicePickerDelegate>
     45@interface WKShareSheet () <NSSharingServiceDelegate, NSSharingServicePickerDelegate>
    4646@end
    4747#endif
     
    125125- (void)sharingServicePicker:(NSSharingServicePicker *)sharingServicePicker didChooseSharingService:(NSSharingService *)service
    126126{
    127     [self _didCompleteWithSuccess:!!service];
     127    if (service)
     128        return;
     129
     130    [self _didCompleteWithSuccess:NO];
    128131    [self dispatchDidDismiss];
    129132}
     133
     134- (id <NSSharingServiceDelegate>)sharingServicePicker:(NSSharingServicePicker *)sharingServicePicker delegateForSharingService:(NSSharingService *)sharingService
     135{
     136    return self;
     137}
     138
     139- (NSWindow *)sharingService:(NSSharingService *)sharingService sourceWindowForShareItems:(NSArray *)items sharingContentScope:(NSSharingContentScope *)sharingContentScope
     140{
     141    return [_webView window];
     142}
     143
     144- (void)sharingService:(NSSharingService *)sharingService didFailToShareItems:(NSArray *)items error:(NSError *)error
     145{
     146    [self _didCompleteWithSuccess:NO];
     147    [self dispatchDidDismiss];
     148}
     149
     150- (void)sharingService:(NSSharingService *)sharingService didShareItems:(NSArray *)items
     151{
     152    [self _didCompleteWithSuccess:YES];
     153    [self dispatchDidDismiss];
     154}
     155
    130156#endif
    131157
Note: See TracChangeset for help on using the changeset viewer.