Commit 92334812 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

PDF: Specify extension when saving with chrome.fileSystem.chooseEntry().

When calling chrome.fileSystem.chooseEntry() to perform saves, the PDF
Viewer currently sets a suggested file name that ends with ".pdf". This
is sufficient for the file pickers on Linux and Chrome OS to suggest
saving using the suggested file name. However, the file pickers on
Windows and Mac will only show the suggested file name without an
extension. So trying to save "foo.pdf" and accepting the default results
in a new file named "foo".

Fix this by setting a value for the "accepts" key in the chooseEntry()
parameter dictionary. Specify "pdf" as the extension here to get file
pickers to make the correct suggestion.

Bug: 1098072
Change-Id: I5b7a3ca7ffadfe14364fdc17b08d1a3133f8a747
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2259478
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781367}
parent 1c085dc7
......@@ -763,7 +763,12 @@ class PDFViewerElement extends PDFViewerBaseElement {
}
chrome.fileSystem.chooseEntry(
{type: 'saveFile', suggestedName: fileName}, entry => {
{
type: 'saveFile',
accepts: [{extensions: ['pdf']}],
suggestedName: fileName
},
entry => {
if (chrome.runtime.lastError) {
if (chrome.runtime.lastError.message !== 'User cancelled') {
console.log(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment