Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: pdf/pdfium/pdfium_engine.cc

Issue 2006793003: PDF: Always call FPDFAvail_IsDocAvail() when loading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: call FPDFAvail_IsDocAvail one more time Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/pdfium/pdfium_engine.cc
diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc
index 17ef03f6a74428bc7d918c7b84c373affcdc221e..b3a6d9523d1c2a86b8e58b03d9b27b302a5bdcbc 100644
--- a/pdf/pdfium/pdfium_engine.cc
+++ b/pdf/pdfium/pdfium_engine.cc
@@ -298,7 +298,7 @@ FPDF_SYSFONTINFO g_font_info = {
};
#endif // defined(OS_LINUX)
-PDFiumEngine* g_engine_for_unsupported;
+PDFiumEngine* g_engine_for_unsupported = nullptr;
void Unsupported_Handler(UNSUPPORT_INFO*, int type) {
if (!g_engine_for_unsupported) {
@@ -1049,6 +1049,7 @@ void PDFiumEngine::OnPartialDocumentLoaded() {
void PDFiumEngine::OnPendingRequestComplete() {
if (!doc_ || !form_) {
+ DCHECK(fpdf_availability_);
LoadDocument();
return;
}
@@ -2445,8 +2446,13 @@ void PDFiumEngine::LoadDocument() {
bool PDFiumEngine::TryLoadingDoc(const std::string& password,
bool* needs_password) {
*needs_password = false;
- if (doc_)
+ if (doc_) {
+ // This is probably not necessary, because it should have already been
+ // called below in the |doc_| initialization path. However, the previous
+ // call may have failed, so call it again for good measure.
+ FPDFAvail_IsDocAvail(fpdf_availability_, &download_hints_);
return true;
+ }
const char* password_cstr = nullptr;
if (!password.empty()) {
@@ -2459,11 +2465,16 @@ bool PDFiumEngine::TryLoadingDoc(const std::string& password,
} else {
doc_ = FPDFAvail_GetDocument(fpdf_availability_, password_cstr);
}
+ if (!doc_) {
+ if (FPDF_GetLastError() == FPDF_ERR_PASSWORD)
+ *needs_password = true;
+ return false;
+ }
- if (!doc_ && FPDF_GetLastError() == FPDF_ERR_PASSWORD)
- *needs_password = true;
-
- return !!doc_;
+ // Always call FPDFAvail_IsDocAvail() so PDFium initializes internal data
+ // structures.
+ FPDFAvail_IsDocAvail(fpdf_availability_, &download_hints_);
+ return true;
}
void PDFiumEngine::GetPasswordAndLoad() {
« no previous file with comments | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698