mirror of
https://github.com/electron/electron.git
synced 2026-01-09 15:38:08 -05:00
* chore: bump chromium in DEPS to 117.0.5899.0 * 4686653: webui: Filter out non-chrome scheme URLs in WebUIConfigMap https://chromium-review.googlesource.com/c/chromium/src/+/4686653 * 4696355: Remove deprecated version of base::CommandLine::CopySwitchesFrom() https://chromium-review.googlesource.com/c/chromium/src/+/4696355 * chore: fixup patch indices * 4603888: Reland "Enable raw_ref check on linux" https://chromium-review.googlesource.com/c/chromium/src/+/4603888 * chore: bump chromium in DEPS to 117.0.5901.0 * chore: update patches * chore: bump chromium in DEPS to 117.0.5903.0 * chore: bump chromium in DEPS to 117.0.5903.2 * chore: bump chromium in DEPS to 117.0.5905.0 * 4706792: Printing: Add debug code for a DispatchBeforePrintEvent() failure https://chromium-review.googlesource.com/c/chromium/src/+/4706792 * 4704786: Refactor libunwind build rules/flags https://chromium-review.googlesource.com/c/chromium/src/+/4704786 * 4701710: [Linux Ui] Set toolkit dark preference based on FDO dark preference https://chromium-review.googlesource.com/c/chromium/src/+/4701710 * chore: fixup patch indices * chore: bump chromium in DEPS to 117.0.5907.0 * chore: bump chromium in DEPS to 117.0.5909.2 * chore: update patches * chore: bump chromium in DEPS to 117.0.5911.0 * chore: update patches * chore: build-what-we-include * fix: set allowFileAccess on devtools extensions correctly Ref: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/4714725 * 4670615: Reland "[iterator-helpers] Shipping iterator helpers" https://chromium-review.googlesource.com/c/v8/v8/+/4670615 --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: Samuel Attard <marshallofsound@electronjs.org>
87 lines
3.4 KiB
Diff
87 lines
3.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Shelley Vohr <shelley.vohr@gmail.com>
|
|
Date: Mon, 17 Jan 2022 23:47:54 +0100
|
|
Subject: fix: crash when saving edited PDF files
|
|
|
|
This commit fixes a crash that persists any time a user attempts to
|
|
download an edited PDF. This was happening because the logic flow for
|
|
downloading of any edited PDF triggers a call to
|
|
chrome.fileSystem.chooseEntry, which we do not support and which
|
|
therefore causes unmapped page access crashes.
|
|
|
|
This patch can be removed should we choose to support chrome.fileSystem
|
|
or support it enough to fix the crash.
|
|
|
|
diff --git a/chrome/browser/resources/pdf/pdf_viewer.ts b/chrome/browser/resources/pdf/pdf_viewer.ts
|
|
index b68423ffe09246ec7ba2935873774c7c452b5952..936ab4b4e12546ca93da27f264559c97f51509ae 100644
|
|
--- a/chrome/browser/resources/pdf/pdf_viewer.ts
|
|
+++ b/chrome/browser/resources/pdf/pdf_viewer.ts
|
|
@@ -895,26 +895,12 @@ export class PdfViewerElement extends PdfViewerBaseElement {
|
|
dataArray = [result.dataToSave];
|
|
}
|
|
|
|
+ const a = document.createElement('a');
|
|
+ a.download = this.attachments_[index].name;
|
|
const blob = new Blob(dataArray);
|
|
- const fileName = this.attachments_[index].name;
|
|
- chrome.fileSystem.chooseEntry(
|
|
- {type: 'saveFile', suggestedName: fileName},
|
|
- (entry?: FileSystemFileEntry) => {
|
|
- if (chrome.runtime.lastError) {
|
|
- if (chrome.runtime.lastError.message !== 'User cancelled') {
|
|
- console.error(
|
|
- 'chrome.fileSystem.chooseEntry failed: ' +
|
|
- chrome.runtime.lastError.message);
|
|
- }
|
|
- return;
|
|
- }
|
|
- entry!.createWriter((writer: FileWriter) => {
|
|
- writer.write(blob);
|
|
- // Unblock closing the window now that the user has saved
|
|
- // successfully.
|
|
- chrome.mimeHandlerPrivate.setShowBeforeUnloadDialog(false);
|
|
- });
|
|
- });
|
|
+ a.href = URL.createObjectURL(blob);
|
|
+ a.click();
|
|
+ URL.revokeObjectURL(a.href);
|
|
}
|
|
|
|
/**
|
|
@@ -1022,30 +1008,12 @@ export class PdfViewerElement extends PdfViewerBaseElement {
|
|
fileName = fileName + '.pdf';
|
|
}
|
|
|
|
- // Create blob before callback to avoid race condition.
|
|
+ const a = document.createElement('a');
|
|
+ a.download = fileName;
|
|
const blob = new Blob([result.dataToSave], {type: 'application/pdf'});
|
|
- chrome.fileSystem.chooseEntry(
|
|
- {
|
|
- type: 'saveFile',
|
|
- accepts: [{description: '*.pdf', extensions: ['pdf']}],
|
|
- suggestedName: fileName,
|
|
- },
|
|
- (entry?: FileSystemFileEntry) => {
|
|
- if (chrome.runtime.lastError) {
|
|
- if (chrome.runtime.lastError.message !== 'User cancelled') {
|
|
- console.error(
|
|
- 'chrome.fileSystem.chooseEntry failed: ' +
|
|
- chrome.runtime.lastError.message);
|
|
- }
|
|
- return;
|
|
- }
|
|
- entry!.createWriter((writer: FileWriter) => {
|
|
- writer.write(blob);
|
|
- // Unblock closing the window now that the user has saved
|
|
- // successfully.
|
|
- chrome.mimeHandlerPrivate.setShowBeforeUnloadDialog(false);
|
|
- });
|
|
- });
|
|
+ a.href = URL.createObjectURL(blob);
|
|
+ a.click();
|
|
+ URL.revokeObjectURL(a.href);
|
|
|
|
// <if expr="enable_ink">
|
|
// Saving in Annotation mode is destructive: crbug.com/919364
|