fix: pdf viewer missing resources (#27499)
* fix: pdf viewer missing resources * test: add simple regression test * 2638992: PDF Viewer: Stop respecting the PDFViewerUpdate flag.2638992
* 2439433: PDF Viewer Update: Add aria-label for thumbnails2439433
This commit is contained in:
parent
e94f97f2c9
commit
bf6a50c538
5 changed files with 19 additions and 5 deletions
1
BUILD.gn
1
BUILD.gn
|
@ -648,6 +648,7 @@ source_set("electron_lib") {
|
||||||
}
|
}
|
||||||
if (enable_pdf_viewer) {
|
if (enable_pdf_viewer) {
|
||||||
deps += [
|
deps += [
|
||||||
|
"//chrome/browser/resources/pdf:pdf_resources",
|
||||||
"//components/pdf/browser",
|
"//components/pdf/browser",
|
||||||
"//components/pdf/renderer",
|
"//components/pdf/renderer",
|
||||||
"//pdf:pdf_ppapi",
|
"//pdf:pdf_ppapi",
|
||||||
|
|
|
@ -96,6 +96,10 @@ template("electron_extra_paks") {
|
||||||
"$root_gen_dir/ui/resources/webui_generated_resources.pak",
|
"$root_gen_dir/ui/resources/webui_generated_resources.pak",
|
||||||
]
|
]
|
||||||
deps += [ "//content/browser/devtools:devtools_resources" ]
|
deps += [ "//content/browser/devtools:devtools_resources" ]
|
||||||
|
if (enable_pdf_viewer) {
|
||||||
|
sources += [ "$root_gen_dir/chrome/pdf_resources.pak" ]
|
||||||
|
deps += [ "//chrome/browser/resources/pdf:pdf_resources" ]
|
||||||
|
}
|
||||||
if (enable_print_preview) {
|
if (enable_print_preview) {
|
||||||
sources += [ "$root_gen_dir/chrome/print_preview_resources.pak" ]
|
sources += [ "$root_gen_dir/chrome/print_preview_resources.pak" ]
|
||||||
deps +=
|
deps +=
|
||||||
|
|
|
@ -39,6 +39,7 @@ void AddStringsForPdf(base::DictionaryValue* dict) {
|
||||||
{"passwordDialogTitle", IDS_PDF_PASSWORD_DIALOG_TITLE},
|
{"passwordDialogTitle", IDS_PDF_PASSWORD_DIALOG_TITLE},
|
||||||
{"passwordPrompt", IDS_PDF_NEED_PASSWORD},
|
{"passwordPrompt", IDS_PDF_NEED_PASSWORD},
|
||||||
{"passwordSubmit", IDS_PDF_PASSWORD_SUBMIT},
|
{"passwordSubmit", IDS_PDF_PASSWORD_SUBMIT},
|
||||||
|
{"thumbnailPageAriaLabel", IDS_PDF_THUMBNAIL_PAGE_ARIA_LABEL},
|
||||||
{"passwordInvalid", IDS_PDF_PASSWORD_INVALID},
|
{"passwordInvalid", IDS_PDF_PASSWORD_INVALID},
|
||||||
{"pageLoading", IDS_PDF_PAGE_LOADING},
|
{"pageLoading", IDS_PDF_PAGE_LOADING},
|
||||||
{"pageLoadFailed", IDS_PDF_PAGE_LOAD_FAILED},
|
{"pageLoadFailed", IDS_PDF_PAGE_LOAD_FAILED},
|
||||||
|
@ -66,11 +67,9 @@ void AddAdditionalDataForPdf(base::DictionaryValue* dict) {
|
||||||
dict->SetKey("pdfFormSaveEnabled",
|
dict->SetKey("pdfFormSaveEnabled",
|
||||||
base::Value(base::FeatureList::IsEnabled(
|
base::Value(base::FeatureList::IsEnabled(
|
||||||
chrome_pdf::features::kSaveEditedPDFForm)));
|
chrome_pdf::features::kSaveEditedPDFForm)));
|
||||||
dict->SetStringKey(
|
dict->SetKey("documentPropertiesEnabled",
|
||||||
"pdfViewerUpdateEnabledAttribute",
|
base::Value(base::FeatureList::IsEnabled(
|
||||||
base::FeatureList::IsEnabled(chrome_pdf::features::kPDFViewerUpdate)
|
chrome_pdf::features::kPdfViewerDocumentProperties)));
|
||||||
? "pdf-viewer-update-enabled"
|
|
||||||
: "");
|
|
||||||
dict->SetKey("presentationModeEnabled",
|
dict->SetKey("presentationModeEnabled",
|
||||||
base::Value(base::FeatureList::IsEnabled(
|
base::Value(base::FeatureList::IsEnabled(
|
||||||
chrome_pdf::features::kPdfViewerPresentationMode)));
|
chrome_pdf::features::kPdfViewerPresentationMode)));
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
#include "chrome/browser/pdf/pdf_extension_util.h" // nogncheck
|
#include "chrome/browser/pdf/pdf_extension_util.h" // nogncheck
|
||||||
|
#include "chrome/grit/pdf_resources_map.h"
|
||||||
#include "extensions/common/constants.h"
|
#include "extensions/common/constants.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -28,6 +29,8 @@ ElectronComponentExtensionResourceManager::
|
||||||
AddComponentResourceEntries(kComponentExtensionResources,
|
AddComponentResourceEntries(kComponentExtensionResources,
|
||||||
kComponentExtensionResourcesSize);
|
kComponentExtensionResourcesSize);
|
||||||
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
|
AddComponentResourceEntries(kPdfResources, kPdfResourcesSize);
|
||||||
|
|
||||||
// Register strings for the PDF viewer, so that $i18n{} replacements work.
|
// Register strings for the PDF viewer, so that $i18n{} replacements work.
|
||||||
base::Value pdf_strings(base::Value::Type::DICTIONARY);
|
base::Value pdf_strings(base::Value::Type::DICTIONARY);
|
||||||
pdf_extension_util::AddStrings(
|
pdf_extension_util::AddStrings(
|
||||||
|
|
|
@ -1280,6 +1280,13 @@ describe('chromium features', () => {
|
||||||
slashes: true
|
slashes: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('successfully loads a PDF file', async () => {
|
||||||
|
const w = new BrowserWindow({ show: false });
|
||||||
|
|
||||||
|
w.loadURL(pdfSource);
|
||||||
|
await emittedOnce(w.webContents, 'did-finish-load');
|
||||||
|
});
|
||||||
|
|
||||||
it('opens when loading a pdf resource as top level navigation', async () => {
|
it('opens when loading a pdf resource as top level navigation', async () => {
|
||||||
const w = new BrowserWindow({ show: false });
|
const w = new BrowserWindow({ show: false });
|
||||||
w.loadURL(pdfSource);
|
w.loadURL(pdfSource);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue