Skip to content

Commit

Permalink
Cherry-pick eeef2a2. rdar://123468009
Browse files Browse the repository at this point in the history
    Close extension popup web views when the web content process terminates or window.close is called
    https://bugs.webkit.org/show_bug.cgi?id=270130
    rdar://123468009

    Reviewed by Timothy Hatcher.

    On iOS, this will lead to the UIViewController being closed, which leads to a better experience for the client.

    On Mac, if the web view lives in an NSPanel, WebKit will close the window that the web view is in.

    * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionActionCocoa.mm:
    (-[_WKWebExtensionActionWebViewDelegate webViewWebContentProcessDidTerminate:]):
    (-[_WKWebExtensionActionWebViewDelegate webViewDidClose:]):

    Canonical link: https://commits.webkit.org/275360@main
  • Loading branch information
b-weinstein authored and Mohsin Qureshi committed Mar 5, 2024
1 parent 75d1637 commit 040e359
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,15 @@ - (void)webViewWebContentProcessDidTerminate:(WKWebView *)webView
if (!_webExtensionAction)
return;

_webExtensionAction->popupDidClose();
_webExtensionAction->closePopupWebView();
}

- (void)webViewDidClose:(WKWebView *)webView
{
if (!_webExtensionAction)
return;

_webExtensionAction->popupDidClose();
_webExtensionAction->closePopupWebView();
}

@end
Expand Down Expand Up @@ -672,10 +672,18 @@ - (void)_dismissPopup
void WebExtensionAction::closePopupWebView()
{
[m_popupWebView _close];

#if PLATFORM(IOS_FAMILY)
[m_popupViewController dismissViewControllerAnimated:YES completion:nil];
#endif

#if PLATFORM(MAC)
auto *window = m_popupWebView.get().window;
// FIXME: Instead of checking this window type, this should be handled more like iOS.
if ([window isKindOfClass:NSPanel.class])
[window close];
#endif

popupDidClose();
}

Expand Down

0 comments on commit 040e359

Please sign in to comment.