RESOLVED FIXED 237245
Trigger PDF download in captive portal mode instead of using PDF viewer
https://bugs.webkit.org/show_bug.cgi?id=237245
Summary Trigger PDF download in captive portal mode instead of using PDF viewer
Tim Nguyen (:ntim)
Reported 2022-02-27 03:02:50 PST
I think that was the decision taken since PDF.js is not in a good enough state atm.
Attachments
Patch (4.16 KB, patch)
2022-03-14 07:04 PDT, Tim Nguyen (:ntim)
no flags
Patch (8.30 KB, patch)
2022-03-17 09:50 PDT, pascoe@apple.com
no flags
Patch (8.38 KB, patch)
2022-03-17 13:48 PDT, pascoe@apple.com
no flags
Patch (7.44 KB, patch)
2022-03-18 08:36 PDT, pascoe@apple.com
no flags
Patch for landing (6.16 KB, patch)
2022-03-18 08:44 PDT, pascoe@apple.com
no flags
Radar WebKit Bug Importer
Comment 1 2022-02-27 03:03:54 PST
Tim Nguyen (:ntim)
Comment 2 2022-03-14 07:04:26 PDT
pascoe@apple.com
Comment 3 2022-03-17 09:50:11 PDT
Alex Christensen
Comment 4 2022-03-17 10:36:00 PDT
Comment on attachment 454982 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=454982&action=review > Source/WebKit/UIProcess/WebPageProxy.cpp:3466 > + auto mimeType = MIMETypeRegistry::mimeTypeForPath(navigation->currentRequest().url().path().toString()); This seems a little light weight. Don't we even want to look at the mime type of the response?
Tim Nguyen (:ntim)
Comment 5 2022-03-17 12:32:10 PDT
Comment on attachment 454982 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=454982&action=review >> Source/WebKit/UIProcess/WebPageProxy.cpp:3466 >> + auto mimeType = MIMETypeRegistry::mimeTypeForPath(navigation->currentRequest().url().path().toString()); > > This seems a little light weight. Don't we even want to look at the mime type of the response? There's no access to the response at this point. Do you have a suggestion of a good place to put this where there is access to the response?
Chris Dumez
Comment 6 2022-03-17 12:36:31 PDT
Comment on attachment 454982 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=454982&action=review >>> Source/WebKit/UIProcess/WebPageProxy.cpp:3466 >>> + auto mimeType = MIMETypeRegistry::mimeTypeForPath(navigation->currentRequest().url().path().toString()); >> >> This seems a little light weight. Don't we even want to look at the mime type of the response? > > There's no access to the response at this point. Do you have a suggestion of a good place to put this where there is access to the response? WebPageProxy::receivedPolicyDecision or WebPageProxy::decidePolicyForResponseShared. This is always frequently where we trigger downloads.
Chris Dumez
Comment 7 2022-03-17 12:38:10 PDT
(In reply to Tim Nguyen (:ntim) from comment #5) > Comment on attachment 454982 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=454982&action=review > > >> Source/WebKit/UIProcess/WebPageProxy.cpp:3466 > >> + auto mimeType = MIMETypeRegistry::mimeTypeForPath(navigation->currentRequest().url().path().toString()); > > > > This seems a little light weight. Don't we even want to look at the mime type of the response? > > There's no access to the response at this point. Do you have a suggestion of > a good place to put this where there is access to the response? Purely relying on the URL ending with .pdf is weak and will miss plenty of cases where we're actually loading a PDF. Like Alex says, we need to check the content type in the resource response.
pascoe@apple.com
Comment 8 2022-03-17 13:48:59 PDT
Tim Nguyen (:ntim)
Comment 9 2022-03-17 14:43:31 PDT
Comment on attachment 455019 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=455019&action=review > Source/WebKit/UIProcess/WebPageProxy.cpp:5735 > + auto captivePortalMode = (policies ? policies->captivePortalModeEnabled() : shouldEnableCaptivePortalMode()) ? WebProcessProxy::CaptivePortalMode::Enabled : WebProcessProxy::CaptivePortalMode::Disabled; > + if (captivePortalMode == WebProcessProxy::CaptivePortalMode::Enabled && MIMETypeRegistry::isPDFOrPostScriptMIMEType(navigationResponse->response().mimeType())) I'm not sure if this works, but I think you can do: ``` if (process->captivePortalMode() == WebProcessProxy::CaptivePortalMode::Enabled) ``` directly, instead of checking through policies. Though I might be wrong :)
Chris Dumez
Comment 10 2022-03-18 07:18:20 PDT
Comment on attachment 455019 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=455019&action=review r=me with Tim's proposed change. >> Source/WebKit/UIProcess/WebPageProxy.cpp:5735 >> + if (captivePortalMode == WebProcessProxy::CaptivePortalMode::Enabled && MIMETypeRegistry::isPDFOrPostScriptMIMEType(navigationResponse->response().mimeType())) > > I'm not sure if this works, but I think you can do: > > ``` > if (process->captivePortalMode() == WebProcessProxy::CaptivePortalMode::Enabled) > ``` > > directly, instead of checking through policies. Though I might be wrong :) I agree with Tim here. His proposal is simpler and I believe it would work since we would have already switched to a captive-portal-mode process earlier (during navigation policy decision).
pascoe@apple.com
Comment 11 2022-03-18 08:36:44 PDT
Tim Nguyen (:ntim)
Comment 12 2022-03-18 08:41:25 PDT
Comment on attachment 455095 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=455095&action=review > Source/WebKit/UIProcess/WebPageProxy.cpp:5726 > + process, navigationResponse] (PolicyAction policyAction, API::WebsitePolicies* policies, ProcessSwapRequestedByClient processSwapRequestedByClient, RefPtr<SafeBrowsingWarning>&& safeBrowsingWarning, std::optional<NavigatingToAppBoundDomain> isNavigatingToAppBoundDomain) mutable { nit: please undo this change, which should no longer be necessary
pascoe@apple.com
Comment 13 2022-03-18 08:44:31 PDT
Created attachment 455096 [details] Patch for landing
pascoe@apple.com
Comment 14 2022-03-18 08:45:30 PDT
Thank you Tim, Chris, and Alex for the comments and review!
EWS
Comment 15 2022-03-18 12:12:22 PDT
Committed r291491 (248603@main): <https://commits.webkit.org/248603@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 455096 [details].
Note You need to log in before you can comment on or make changes to this bug.