Skip to content

Commit bb95f04

Browse files
committed
[GENERIC viewer] Display a warning message, using the errorWrapper, for documents with signatures (PR 13214 follow-up, issue 13215)
To simplify the overall implementation, given that it only applies to the GENERIC-viewer, this patch purposely re-uses the existing `errorWrapper`-functionality to display the message. While that one is mostly intended for actual *errors*, by re-using it here we considerably reduce the amount of code/complexity necessary for supporting this new warning. It's obviously possible to re-factor/improve this later on, but the patch should do just fine here since it'll indeed inform users (of the GENERIC-viewer) about unverified signatures. Finally this patch also tweaks the background-color of the `errorWrapper`, making it 20 percent lighter respectively darker (depending on the theme) to make it "stand out" a little bit less.[1] While it may perhaps be useful to re-style/re-factor the `errorWrapper`, this patch probably isn't the right place for doing that. --- [1] Note how in the MOZCENTRAL-viewer, which instead uses the browser notification-bar, we're purposely using a neutral colour to not draw too much attention draw to the notification-bar.
1 parent 4ac1082 commit bb95f04

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

l10n/en-US/viewer.properties

+3
Original file line numberDiff line numberDiff line change
@@ -246,3 +246,6 @@ password_cancel=Cancel
246246
printing_not_supported=Warning: Printing is not fully supported by this browser.
247247
printing_not_ready=Warning: The PDF is not fully loaded for printing.
248248
web_fonts_disabled=Web fonts are disabled: unable to use embedded PDF fonts.
249+
# LOCALIZATION NOTE (unsupported_feature_signatures): Should contain the same
250+
# exact string as in the `chrome.properties` file.
251+
unsupported_feature_signatures=This PDF document contains digital signatures. Validation of signatures is not supported.

web/app.js

+15-3
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class DefaultExternalServices {
198198
const PDFViewerApplication = {
199199
initialBookmark: document.location.hash.substring(1),
200200
_initializedCapability: createPromiseCapability(),
201-
fellback: false,
201+
_fellback: false,
202202
appConfig: null,
203203
pdfDocument: null,
204204
pdfLoadingTask: null,
@@ -830,6 +830,7 @@ const PDFViewerApplication = {
830830
this.pdfDocumentProperties.setDocument(null);
831831
}
832832
webViewerResetPermissions();
833+
this._fellback = false;
833834
this.store = null;
834835
this.isInitialViewSet = false;
835836
this.downloadComplete = false;
@@ -1056,10 +1057,21 @@ const PDFViewerApplication = {
10561057
}
10571058
// Only trigger the fallback once so we don't spam the user with messages
10581059
// for one PDF.
1059-
if (this.fellback) {
1060+
if (this._fellback) {
10601061
return;
10611062
}
1062-
this.fellback = true;
1063+
this._fellback = true;
1064+
1065+
// Ensure that, for signatures, a warning is shown in non-Firefox builds.
1066+
if (
1067+
(typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) &&
1068+
featureId === UNSUPPORTED_FEATURES.signatures
1069+
) {
1070+
this.l10n.get("unsupported_feature_signatures").then(msg => {
1071+
this._otherError(msg);
1072+
});
1073+
}
1074+
10631075
this.externalServices
10641076
.fallback({
10651077
featureId,

web/l10n_utils.js

+2
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ const DEFAULT_L10N_STRINGS = {
8181
printing_not_ready: "Warning: The PDF is not fully loaded for printing.",
8282
web_fonts_disabled:
8383
"Web fonts are disabled: unable to use embedded PDF fonts.",
84+
unsupported_feature_signatures:
85+
"This PDF document contains digital signatures. Validation of signatures is not supported.",
8486
};
8587

8688
function getL10nFallback(key, args) {

web/viewer.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
--main-color: rgba(12, 12, 13, 1);
2828
--body-bg-color: rgba(237, 237, 240, 1);
29-
--errorWrapper-bg-color: rgba(255, 74, 74, 1);
29+
--errorWrapper-bg-color: rgba(255, 110, 110, 1);
3030
--progressBar-color: rgba(10, 132, 255, 1);
3131
--progressBar-indeterminate-bg-color: rgba(221, 221, 222, 1);
3232
--progressBar-indeterminate-blend-color: rgba(116, 177, 239, 1);
@@ -101,7 +101,7 @@
101101
:root {
102102
--main-color: rgba(249, 249, 250, 1);
103103
--body-bg-color: rgba(42, 42, 46, 1);
104-
--errorWrapper-bg-color: rgba(199, 17, 17, 1);
104+
--errorWrapper-bg-color: rgba(169, 14, 14, 1);
105105
--progressBar-color: rgba(0, 96, 223, 1);
106106
--progressBar-indeterminate-bg-color: rgba(40, 40, 43, 1);
107107
--progressBar-indeterminate-blend-color: rgba(20, 68, 133, 1);

0 commit comments

Comments
 (0)