Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/i18n/icu_encoding_detection.h" | 9 #include "base/i18n/icu_encoding_detection.h" |
| 10 #include "base/i18n/icu_string_conversions.h" | 10 #include "base/i18n/icu_string_conversions.h" |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 584 PDFiumAPIStringBufferSizeInBytesAdapter<base::string16> string_adapter( | 584 PDFiumAPIStringBufferSizeInBytesAdapter<base::string16> string_adapter( |
| 585 &value, size, false); | 585 &value, size, false); |
| 586 string_adapter.Close( | 586 string_adapter.Close( |
| 587 FPDF_GetMetaText(doc, key.c_str(), string_adapter.GetData(), size)); | 587 FPDF_GetMetaText(doc, key.c_str(), string_adapter.GetData(), size)); |
| 588 return base::UTF16ToUTF8(value); | 588 return base::UTF16ToUTF8(value); |
| 589 } | 589 } |
| 590 | 590 |
| 591 } // namespace | 591 } // namespace |
| 592 | 592 |
| 593 bool InitializeSDK() { | 593 bool InitializeSDK() { |
| 594 FPDF_InitLibrary(); | 594 FPDF_LIBRARY_CONFIG config; |
| 595 config.version = 2; | |
| 596 config.m_pUserFontPaths = nullptr; | |
| 597 config.m_pIsolate = v8::Isolate::GetCurrent(); | |
|
Tom Sepez
2015/10/03 01:07:13
What do we give up if we pass a nullptr here, forc
Lei Zhang
2015/10/03 01:09:05
Possibly just giving up some efficiency, but local
| |
| 598 config.m_v8EmbedderSlot = gin::kEmbedderPDFium; | |
| 599 FPDF_InitLibraryWithConfig(&config); | |
| 595 | 600 |
| 596 #if defined(OS_LINUX) | 601 #if defined(OS_LINUX) |
| 597 // Font loading doesn't work in the renderer sandbox in Linux. | 602 // Font loading doesn't work in the renderer sandbox in Linux. |
| 598 FPDF_SetSystemFontInfo(&g_font_info); | 603 FPDF_SetSystemFontInfo(&g_font_info); |
| 599 #endif | 604 #endif |
| 600 | 605 |
| 601 FSDK_SetUnSpObjProcessHandler(&g_unsuppored_info); | 606 FSDK_SetUnSpObjProcessHandler(&g_unsuppored_info); |
| 602 | 607 |
| 603 return true; | 608 return true; |
| 604 } | 609 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 683 FPDF_FORMFILLINFO::FFI_GetPlatform = Form_GetPlatform; | 688 FPDF_FORMFILLINFO::FFI_GetPlatform = Form_GetPlatform; |
| 684 FPDF_FORMFILLINFO::FFI_PopupMenu = Form_PopupMenu; | 689 FPDF_FORMFILLINFO::FFI_PopupMenu = Form_PopupMenu; |
| 685 FPDF_FORMFILLINFO::FFI_PostRequestURL = Form_PostRequestURL; | 690 FPDF_FORMFILLINFO::FFI_PostRequestURL = Form_PostRequestURL; |
| 686 FPDF_FORMFILLINFO::FFI_PutRequestURL = Form_PutRequestURL; | 691 FPDF_FORMFILLINFO::FFI_PutRequestURL = Form_PutRequestURL; |
| 687 FPDF_FORMFILLINFO::FFI_UploadTo = Form_UploadTo; | 692 FPDF_FORMFILLINFO::FFI_UploadTo = Form_UploadTo; |
| 688 FPDF_FORMFILLINFO::FFI_DownloadFromURL = Form_DownloadFromURL; | 693 FPDF_FORMFILLINFO::FFI_DownloadFromURL = Form_DownloadFromURL; |
| 689 FPDF_FORMFILLINFO::FFI_OpenFile = Form_OpenFile; | 694 FPDF_FORMFILLINFO::FFI_OpenFile = Form_OpenFile; |
| 690 FPDF_FORMFILLINFO::FFI_GotoURL = Form_GotoURL; | 695 FPDF_FORMFILLINFO::FFI_GotoURL = Form_GotoURL; |
| 691 FPDF_FORMFILLINFO::FFI_GetLanguage = Form_GetLanguage; | 696 FPDF_FORMFILLINFO::FFI_GetLanguage = Form_GetLanguage; |
| 692 #endif // PDF_USE_XFA | 697 #endif // PDF_USE_XFA |
| 693 IPDF_JSPLATFORM::version = 2; | 698 IPDF_JSPLATFORM::version = 3; |
| 694 IPDF_JSPLATFORM::app_alert = Form_Alert; | 699 IPDF_JSPLATFORM::app_alert = Form_Alert; |
| 695 IPDF_JSPLATFORM::app_beep = Form_Beep; | 700 IPDF_JSPLATFORM::app_beep = Form_Beep; |
| 696 IPDF_JSPLATFORM::app_response = Form_Response; | 701 IPDF_JSPLATFORM::app_response = Form_Response; |
| 697 IPDF_JSPLATFORM::Doc_getFilePath = Form_GetFilePath; | 702 IPDF_JSPLATFORM::Doc_getFilePath = Form_GetFilePath; |
| 698 IPDF_JSPLATFORM::Doc_mail = Form_Mail; | 703 IPDF_JSPLATFORM::Doc_mail = Form_Mail; |
| 699 IPDF_JSPLATFORM::Doc_print = Form_Print; | 704 IPDF_JSPLATFORM::Doc_print = Form_Print; |
| 700 IPDF_JSPLATFORM::Doc_submitForm = Form_SubmitForm; | 705 IPDF_JSPLATFORM::Doc_submitForm = Form_SubmitForm; |
| 701 IPDF_JSPLATFORM::Doc_gotoPage = Form_GotoPage; | 706 IPDF_JSPLATFORM::Doc_gotoPage = Form_GotoPage; |
| 702 IPDF_JSPLATFORM::Field_browse = Form_Browse; | 707 IPDF_JSPLATFORM::Field_browse = Form_Browse; |
| 703 IPDF_JSPLATFORM::m_isolate = v8::Isolate::GetCurrent(); | |
| 704 IPDF_JSPLATFORM::m_v8EmbedderSlot = gin::kEmbedderPDFium; | |
| 705 | 708 |
| 706 IFSDK_PAUSE::version = 1; | 709 IFSDK_PAUSE::version = 1; |
| 707 IFSDK_PAUSE::user = NULL; | 710 IFSDK_PAUSE::user = NULL; |
| 708 IFSDK_PAUSE::NeedToPauseNow = Pause_NeedToPauseNow; | 711 IFSDK_PAUSE::NeedToPauseNow = Pause_NeedToPauseNow; |
| 709 } | 712 } |
| 710 | 713 |
| 711 PDFiumEngine::~PDFiumEngine() { | 714 PDFiumEngine::~PDFiumEngine() { |
| 712 for (size_t i = 0; i < pages_.size(); ++i) | 715 for (size_t i = 0; i < pages_.size(); ++i) |
| 713 pages_[i]->Unload(); | 716 pages_[i]->Unload(); |
| 714 | 717 |
| (...skipping 3370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4085 double* height) { | 4088 double* height) { |
| 4086 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); | 4089 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); |
| 4087 if (!doc) | 4090 if (!doc) |
| 4088 return false; | 4091 return false; |
| 4089 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 4092 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; |
| 4090 FPDF_CloseDocument(doc); | 4093 FPDF_CloseDocument(doc); |
| 4091 return success; | 4094 return success; |
| 4092 } | 4095 } |
| 4093 | 4096 |
| 4094 } // namespace chrome_pdf | 4097 } // namespace chrome_pdf |
| OLD | NEW |