Skip to content

Commit

Permalink
[Win][MiniBrowser] Download a file, if a MIME type is not supported.
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=259518

Reviewed by Fujii Hironori.

If you select content with an unsupported MIME type, the binary data of
that file will be displayed. Therefore, for such content, download the
file.

* Tools/MiniBrowser/win/WebKitBrowserWindow.cpp:
(WebKitBrowserWindow::decidePolicyForNavigationResponse):

Canonical link: https://commits.webkit.org/266320@main
  • Loading branch information
kshukuwa authored and fujii committed Jul 26, 2023
1 parent a6c7c6f commit feb7a3b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Tools/MiniBrowser/win/WebKitBrowserWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,21 @@ void WebKitBrowserWindow::decidePolicyForNavigationResponse(WKPageRef page, WKNa
text << L"URL: " << createString(adoptWK(WKURLResponseCopyURL(response.get())).get());
MessageBox(thisWindow.m_hMainWnd, text.str().c_str(), L"No Content", MB_OK | MB_ICONWARNING);
}
WKFramePolicyListenerUse(listener);

if (WKNavigationResponseCanShowMIMEType(navigationResponse))
WKFramePolicyListenerUse(listener);
else {
std::wstringstream text;
text << L"Do you want to save this file?" << std::endl;
text << std::endl;
text << L"MIME type: " << createString(adoptWK(WKURLResponseCopyMIMEType(response.get())).get()) << std::endl;
text << L"URL: " << createString(adoptWK(WKURLResponseCopyURL(response.get())).get());

if (MessageBox(thisWindow.hwnd(), text.str().c_str(), L"Unsupported MIME type", MB_OKCANCEL | MB_ICONWARNING) == IDOK)
WKFramePolicyListenerDownload(listener);
else
WKFramePolicyListenerIgnore(listener);
}
}

void WebKitBrowserWindow::didFailProvisionalNavigation(WKPageRef page, WKNavigationRef navigation, WKErrorRef error, WKTypeRef userData, const void* clientInfo)
Expand Down

0 comments on commit feb7a3b

Please sign in to comment.