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

Side by Side 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: nit Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "pdf/pdfium/pdfium_engine.h" 5 #include "pdf/pdfium/pdfium_engine.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 EnumFonts, 291 EnumFonts,
292 MapFont, 292 MapFont,
293 0, 293 0,
294 GetFontData, 294 GetFontData,
295 0, 295 0,
296 0, 296 0,
297 DeleteFont 297 DeleteFont
298 }; 298 };
299 #endif // defined(OS_LINUX) 299 #endif // defined(OS_LINUX)
300 300
301 PDFiumEngine* g_engine_for_unsupported; 301 PDFiumEngine* g_engine_for_unsupported = nullptr;
302 302
303 void Unsupported_Handler(UNSUPPORT_INFO*, int type) { 303 void Unsupported_Handler(UNSUPPORT_INFO*, int type) {
304 if (!g_engine_for_unsupported) { 304 if (!g_engine_for_unsupported) {
305 NOTREACHED(); 305 NOTREACHED();
306 return; 306 return;
307 } 307 }
308 308
309 g_engine_for_unsupported->UnsupportedFeature(type); 309 g_engine_for_unsupported->UnsupportedFeature(type);
310 } 310 }
311 311
(...skipping 2072 matching lines...) Expand 10 before | Expand all | Expand 10 after
2384 } 2384 }
2385 2385
2386 CalculateVisiblePages(); 2386 CalculateVisiblePages();
2387 if (document_size_ != old_document_size) 2387 if (document_size_ != old_document_size)
2388 client_->DocumentSizeUpdated(document_size_); 2388 client_->DocumentSizeUpdated(document_size_);
2389 } 2389 }
2390 2390
2391 void PDFiumEngine::LoadDocument() { 2391 void PDFiumEngine::LoadDocument() {
2392 // Check if the document is ready for loading. If it isn't just bail for now, 2392 // Check if the document is ready for loading. If it isn't just bail for now,
2393 // we will call LoadDocument() again later. 2393 // we will call LoadDocument() again later.
2394 if (!doc_ && !doc_loader_.IsDocumentComplete() && 2394 if (!doc_ && !doc_loader_.IsDocumentComplete())
2395 !FPDFAvail_IsDocAvail(fpdf_availability_, &download_hints_)) {
Wei Li 2016/05/24 00:21:27 Should these conditions be ORed instead?
Lei Zhang 2016/05/25 17:16:36 No, we have to continue past this point to turn |d
2396 return; 2395 return;
2397 } 2396
2397 // Always call FPDFAvail_IsDocAvail() so PDFium initializes internal data
2398 // structures.
2399 if (!FPDFAvail_IsDocAvail(fpdf_availability_, &download_hints_))
2400 return;
2398 2401
2399 // If we're in the middle of getting a password, just return. We will retry 2402 // If we're in the middle of getting a password, just return. We will retry
2400 // loading the document after we get the password anyway. 2403 // loading the document after we get the password anyway.
2401 if (getting_password_) 2404 if (getting_password_)
2402 return; 2405 return;
2403 2406
2404 ScopedUnsupportedFeature scoped_unsupported_feature(this); 2407 ScopedUnsupportedFeature scoped_unsupported_feature(this);
2405 bool needs_password = false; 2408 bool needs_password = false;
2406 if (TryLoadingDoc(false, std::string(), &needs_password)) { 2409 if (TryLoadingDoc(false, std::string(), &needs_password)) {
2407 ContinueLoadingDocument(false, std::string()); 2410 ContinueLoadingDocument(false, std::string());
(...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after
3877 FPDF_DOCUMENT doc = 3880 FPDF_DOCUMENT doc =
3878 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); 3881 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr);
3879 if (!doc) 3882 if (!doc)
3880 return false; 3883 return false;
3881 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 3884 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
3882 FPDF_CloseDocument(doc); 3885 FPDF_CloseDocument(doc);
3883 return success; 3886 return success;
3884 } 3887 }
3885 3888
3886 } // namespace chrome_pdf 3889 } // namespace chrome_pdf
OLDNEW
« 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