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

Handle chrome.fileSystem.chooseEntry() errors in the PDF Viewer.

When the user cancels a save operation, chrome.fileSystem.chooseEntry()
does not pass back a valid entry. Use chrome.runtime.lastError to check
for this condition.

Change-Id: I54e655ec74b4d3c07f06cf981677751a2d38acab
Reviewed-on: https://chromium-review.googlesource.com/c/1446867Reviewed-by: default avatarDan Beam <dbeam@chromium.org>
Reviewed-by: default avatardstockwell <dstockwell@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#627693}
parent dad87ecc
......@@ -1148,6 +1148,14 @@ PDFViewer.prototype = {
chrome.fileSystem.chooseEntry(
{type: 'saveFile', suggestedName: fileName}, entry => {
if (chrome.runtime.lastError) {
if (chrome.runtime.lastError.message != 'User cancelled') {
console.log(
'chrome.fileSystem.chooseEntry failed: ' +
chrome.runtime.lastError.message);
}
return;
}
entry.createWriter(writer => {
writer.write(
new Blob([result.dataToSave], {type: 'application/pdf'}));
......
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