mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Refactor the password
handling so that it's stored in the PdfManager
s, instead of in the XRef
We're already passing in a, currently unused, `PdfManager` instance when initializing the `XRef`. To avoid having to pass a single `password` parameter around, we could thus simply get the `password` through the `PdfManager` instance instead.
This commit is contained in:
parent
27513cd23b
commit
14b8523314
3 changed files with 19 additions and 16 deletions
|
@ -52,6 +52,10 @@ var BasePdfManager = (function BasePdfManagerClosure() {
|
|||
return this._docId;
|
||||
},
|
||||
|
||||
get password() {
|
||||
return this._password;
|
||||
},
|
||||
|
||||
get docBaseUrl() {
|
||||
var docBaseUrl = null;
|
||||
if (this._docBaseUrl) {
|
||||
|
@ -106,7 +110,7 @@ var BasePdfManager = (function BasePdfManagerClosure() {
|
|||
},
|
||||
|
||||
updatePassword: function BasePdfManager_updatePassword(password) {
|
||||
this.pdfDocument.xref.password = this.password = password;
|
||||
this._password = password;
|
||||
},
|
||||
|
||||
terminate: function BasePdfManager_terminate() {
|
||||
|
@ -121,10 +125,11 @@ var LocalPdfManager = (function LocalPdfManagerClosure() {
|
|||
function LocalPdfManager(docId, data, password, evaluatorOptions,
|
||||
docBaseUrl) {
|
||||
this._docId = docId;
|
||||
this._password = password;
|
||||
this._docBaseUrl = docBaseUrl;
|
||||
this.evaluatorOptions = evaluatorOptions;
|
||||
var stream = new Stream(data);
|
||||
this.pdfDocument = new PDFDocument(this, stream, password);
|
||||
this.pdfDocument = new PDFDocument(this, stream);
|
||||
this._loadedStreamCapability = createPromiseCapability();
|
||||
this._loadedStreamCapability.resolve(stream);
|
||||
}
|
||||
|
@ -171,6 +176,7 @@ var NetworkPdfManager = (function NetworkPdfManagerClosure() {
|
|||
function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions,
|
||||
docBaseUrl) {
|
||||
this._docId = docId;
|
||||
this._password = args.password;
|
||||
this._docBaseUrl = docBaseUrl;
|
||||
this.msgHandler = args.msgHandler;
|
||||
this.evaluatorOptions = evaluatorOptions;
|
||||
|
@ -183,8 +189,7 @@ var NetworkPdfManager = (function NetworkPdfManagerClosure() {
|
|||
rangeChunkSize: args.rangeChunkSize
|
||||
};
|
||||
this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
|
||||
this.pdfDocument = new PDFDocument(this, this.streamManager.getStream(),
|
||||
args.password);
|
||||
this.pdfDocument = new PDFDocument(this, this.streamManager.getStream());
|
||||
}
|
||||
|
||||
Util.inherit(NetworkPdfManager, BasePdfManager, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue