Bug 212795 - Add WKUIDelegate SPI to confirm before opening a PDF
Summary: Add WKUIDelegate SPI to confirm before opening a PDF
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-06-04 18:04 PDT by Alex Christensen
Modified: 2020-06-05 13:16 PDT (History)
3 users (show)

See Also:


Attachments
Patch (17.17 KB, patch)
2020-06-04 18:05 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (17.19 KB, patch)
2020-06-04 20:00 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Christensen 2020-06-04 18:04:42 PDT
Add WKUIDelegate SPI to confirm before opening a PDF
Comment 1 Alex Christensen 2020-06-04 18:05:38 PDT
Created attachment 401106 [details]
Patch
Comment 2 Alex Christensen 2020-06-04 18:05:40 PDT
<rdar://problem/58715847>
Comment 3 Tim Horton 2020-06-04 18:12:29 PDT
Comment on attachment 401106 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=401106&action=review

> Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h:118
> +- (void)_webView:(WKWebView *)webView confirmPDFOpeningFromFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));

I don't love the name. I don't have a great alternative.

shouldAllowPDFToOpenFromFrame? canOpenPDFFromFrame?

> Source/WebKit/UIProcess/mac/WebPageProxyMac.mm:510
> +    FileSystem::setMetadataURL(nsPath.get(), originatingURLString);

Nice
Comment 4 Alex Christensen 2020-06-04 20:00:47 PDT
Created attachment 401110 [details]
Patch
Comment 5 EWS 2020-06-04 20:28:50 PDT
Committed r262592: <https://trac.webkit.org/changeset/262592>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 401110 [details].
Comment 6 Darin Adler 2020-06-05 12:49:00 PDT
Comment on attachment 401110 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=401110&action=review

> Source/WebKit/UIProcess/mac/WebPageProxyMac.mm:517
> +        if (allowed)
> +            return;
> +        [[NSWorkspace sharedWorkspace] openURL:[NSURL fileURLWithPath:nsPath.get() isDirectory:NO]];

This reads as if it’s backwards.

> Source/WebKit/UIProcess/mac/WebPageProxyMac.mm:533
> +        if (allowed)
> +            return;
> +        [[NSWorkspace sharedWorkspace] openURL:[NSURL fileURLWithPath:pdfFilename isDirectory:NO]];

This reads as if it’s backwards.
Comment 7 Tim Horton 2020-06-05 12:51:52 PDT
Oh no, I must need glasses :|
Comment 8 Alex Christensen 2020-06-05 13:16:30 PDT
Oops!  That's what I get for making the code look nicer after verifying it works.
http://trac.webkit.org/r262649