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

Side by Side Diff: pdf/pdfium/pdfium_engine.cc

Issue 803733002: Roll PDFium (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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/pdf_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 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 18 matching lines...) Expand all
29 #include "ppapi/cpp/private/pdf.h" 29 #include "ppapi/cpp/private/pdf.h"
30 #include "ppapi/cpp/trusted/browser_font_trusted.h" 30 #include "ppapi/cpp/trusted/browser_font_trusted.h"
31 #include "ppapi/cpp/url_response_info.h" 31 #include "ppapi/cpp/url_response_info.h"
32 #include "ppapi/cpp/var.h" 32 #include "ppapi/cpp/var.h"
33 #include "third_party/pdfium/fpdfsdk/include/fpdf_ext.h" 33 #include "third_party/pdfium/fpdfsdk/include/fpdf_ext.h"
34 #include "third_party/pdfium/fpdfsdk/include/fpdf_flatten.h" 34 #include "third_party/pdfium/fpdfsdk/include/fpdf_flatten.h"
35 #include "third_party/pdfium/fpdfsdk/include/fpdf_searchex.h" 35 #include "third_party/pdfium/fpdfsdk/include/fpdf_searchex.h"
36 #include "third_party/pdfium/fpdfsdk/include/fpdf_sysfontinfo.h" 36 #include "third_party/pdfium/fpdfsdk/include/fpdf_sysfontinfo.h"
37 #include "third_party/pdfium/fpdfsdk/include/fpdf_transformpage.h" 37 #include "third_party/pdfium/fpdfsdk/include/fpdf_transformpage.h"
38 #include "third_party/pdfium/fpdfsdk/include/fpdfedit.h" 38 #include "third_party/pdfium/fpdfsdk/include/fpdfedit.h"
39 #include "third_party/pdfium/fpdfsdk/include/fpdfoom.h"
40 #include "third_party/pdfium/fpdfsdk/include/fpdfppo.h" 39 #include "third_party/pdfium/fpdfsdk/include/fpdfppo.h"
41 #include "third_party/pdfium/fpdfsdk/include/fpdfsave.h" 40 #include "third_party/pdfium/fpdfsdk/include/fpdfsave.h"
42 #include "third_party/pdfium/fpdfsdk/include/pdfwindow/PDFWindow.h" 41 #include "third_party/pdfium/fpdfsdk/include/pdfwindow/PDFWindow.h"
43 #include "third_party/pdfium/fpdfsdk/include/pdfwindow/PWL_FontMap.h" 42 #include "third_party/pdfium/fpdfsdk/include/pdfwindow/PWL_FontMap.h"
44 #include "ui/events/keycodes/keyboard_codes.h" 43 #include "ui/events/keycodes/keyboard_codes.h"
45 44
46 namespace chrome_pdf { 45 namespace chrome_pdf {
47 46
48 namespace { 47 namespace {
49 48
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 EnumFonts, 282 EnumFonts,
284 MapFont, 283 MapFont,
285 0, 284 0,
286 GetFontData, 285 GetFontData,
287 0, 286 0,
288 0, 287 0,
289 DeleteFont 288 DeleteFont
290 }; 289 };
291 #endif // defined(OS_LINUX) 290 #endif // defined(OS_LINUX)
292 291
293 void OOM_Handler(_OOM_INFO*) {
294 // Kill the process. This is important for security, since the code doesn't
295 // NULL-check many memory allocations. If a malloc fails, returns NULL, and
296 // the buffer is then used, it provides a handy mapping of memory starting at
297 // address 0 for an attacker to utilize.
298 abort();
299 }
300
301 OOM_INFO g_oom_info = {
302 1,
303 OOM_Handler
304 };
305
306 PDFiumEngine* g_engine_for_unsupported; 292 PDFiumEngine* g_engine_for_unsupported;
307 293
308 void Unsupported_Handler(UNSUPPORT_INFO*, int type) { 294 void Unsupported_Handler(UNSUPPORT_INFO*, int type) {
309 if (!g_engine_for_unsupported) { 295 if (!g_engine_for_unsupported) {
310 NOTREACHED(); 296 NOTREACHED();
311 return; 297 return;
312 } 298 }
313 299
314 g_engine_for_unsupported->UnsupportedFeature(type); 300 g_engine_for_unsupported->UnsupportedFeature(type);
315 } 301 }
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 base::ReplaceChars(*text, kCr, kBlank, text); 508 base::ReplaceChars(*text, kCr, kBlank, text);
523 #elif defined(OS_WIN) 509 #elif defined(OS_WIN)
524 // Do nothing 510 // Do nothing
525 #else 511 #else
526 NOTIMPLEMENTED(); 512 NOTIMPLEMENTED();
527 #endif 513 #endif
528 } 514 }
529 515
530 } // namespace 516 } // namespace
531 517
532 bool InitializeSDK(void* data) { 518 bool InitializeSDK() {
533 FPDF_InitLibrary(data); 519 FPDF_InitLibrary();
534 520
535 #if defined(OS_LINUX) 521 #if defined(OS_LINUX)
536 // Font loading doesn't work in the renderer sandbox in Linux. 522 // Font loading doesn't work in the renderer sandbox in Linux.
537 FPDF_SetSystemFontInfo(&g_font_info); 523 FPDF_SetSystemFontInfo(&g_font_info);
538 #endif 524 #endif
539 525
540 FSDK_SetOOMHandler(&g_oom_info);
541 FSDK_SetUnSpObjProcessHandler(&g_unsuppored_info); 526 FSDK_SetUnSpObjProcessHandler(&g_unsuppored_info);
542 527
543 return true; 528 return true;
544 } 529 }
545 530
546 void ShutdownSDK() { 531 void ShutdownSDK() {
547 FPDF_DestroyLibrary(); 532 FPDF_DestroyLibrary();
548 } 533 }
549 534
550 PDFEngine* PDFEngine::Create(PDFEngine::Client* client) { 535 PDFEngine* PDFEngine::Create(PDFEngine::Client* client) {
(...skipping 3345 matching lines...) Expand 10 before | Expand all | Expand 10 after
3896 double* height) { 3881 double* height) {
3897 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); 3882 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL);
3898 if (!doc) 3883 if (!doc)
3899 return false; 3884 return false;
3900 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 3885 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
3901 FPDF_CloseDocument(doc); 3886 FPDF_CloseDocument(doc);
3902 return success; 3887 return success;
3903 } 3888 }
3904 3889
3905 } // namespace chrome_pdf 3890 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « pdf/pdf_engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698