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" |
11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/numerics/safe_conversions.h" | 14 #include "base/numerics/safe_conversions.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/string_piece.h" | 17 #include "base/strings/string_piece.h" |
18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
20 #include "base/values.h" | 20 #include "base/values.h" |
| 21 #include "gin/public/gin_embedders.h" |
21 #include "pdf/draw_utils.h" | 22 #include "pdf/draw_utils.h" |
22 #include "pdf/pdfium/pdfium_api_string_buffer_adapter.h" | 23 #include "pdf/pdfium/pdfium_api_string_buffer_adapter.h" |
23 #include "pdf/pdfium/pdfium_mem_buffer_file_read.h" | 24 #include "pdf/pdfium/pdfium_mem_buffer_file_read.h" |
24 #include "pdf/pdfium/pdfium_mem_buffer_file_write.h" | 25 #include "pdf/pdfium/pdfium_mem_buffer_file_write.h" |
25 #include "ppapi/c/pp_errors.h" | 26 #include "ppapi/c/pp_errors.h" |
26 #include "ppapi/c/pp_input_event.h" | 27 #include "ppapi/c/pp_input_event.h" |
27 #include "ppapi/c/ppb_core.h" | 28 #include "ppapi/c/ppb_core.h" |
28 #include "ppapi/c/private/ppb_pdf.h" | 29 #include "ppapi/c/private/ppb_pdf.h" |
29 #include "ppapi/cpp/dev/memory_dev.h" | 30 #include "ppapi/cpp/dev/memory_dev.h" |
30 #include "ppapi/cpp/input_event.h" | 31 #include "ppapi/cpp/input_event.h" |
31 #include "ppapi/cpp/instance.h" | 32 #include "ppapi/cpp/instance.h" |
32 #include "ppapi/cpp/module.h" | 33 #include "ppapi/cpp/module.h" |
33 #include "ppapi/cpp/private/pdf.h" | 34 #include "ppapi/cpp/private/pdf.h" |
34 #include "ppapi/cpp/trusted/browser_font_trusted.h" | 35 #include "ppapi/cpp/trusted/browser_font_trusted.h" |
35 #include "ppapi/cpp/url_response_info.h" | 36 #include "ppapi/cpp/url_response_info.h" |
36 #include "ppapi/cpp/var.h" | 37 #include "ppapi/cpp/var.h" |
37 #include "ppapi/cpp/var_dictionary.h" | 38 #include "ppapi/cpp/var_dictionary.h" |
38 #include "printing/units.h" | 39 #include "printing/units.h" |
39 #include "third_party/pdfium/public/fpdf_edit.h" | 40 #include "third_party/pdfium/public/fpdf_edit.h" |
40 #include "third_party/pdfium/public/fpdf_ext.h" | 41 #include "third_party/pdfium/public/fpdf_ext.h" |
41 #include "third_party/pdfium/public/fpdf_flatten.h" | 42 #include "third_party/pdfium/public/fpdf_flatten.h" |
42 #include "third_party/pdfium/public/fpdf_ppo.h" | 43 #include "third_party/pdfium/public/fpdf_ppo.h" |
43 #include "third_party/pdfium/public/fpdf_save.h" | 44 #include "third_party/pdfium/public/fpdf_save.h" |
44 #include "third_party/pdfium/public/fpdf_searchex.h" | 45 #include "third_party/pdfium/public/fpdf_searchex.h" |
45 #include "third_party/pdfium/public/fpdf_sysfontinfo.h" | 46 #include "third_party/pdfium/public/fpdf_sysfontinfo.h" |
46 #include "third_party/pdfium/public/fpdf_transformpage.h" | 47 #include "third_party/pdfium/public/fpdf_transformpage.h" |
47 #include "ui/events/keycodes/keyboard_codes.h" | 48 #include "ui/events/keycodes/keyboard_codes.h" |
| 49 #include "v8/include/v8.h" |
48 | 50 |
49 using printing::ConvertUnit; | 51 using printing::ConvertUnit; |
50 using printing::ConvertUnitDouble; | 52 using printing::ConvertUnitDouble; |
51 using printing::kPointsPerInch; | 53 using printing::kPointsPerInch; |
52 using printing::kPixelsPerInch; | 54 using printing::kPixelsPerInch; |
53 | 55 |
54 namespace chrome_pdf { | 56 namespace chrome_pdf { |
55 | 57 |
56 namespace { | 58 namespace { |
57 | 59 |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 FPDF_FORMFILLINFO::FFI_GetPlatform = Form_GetPlatform; | 650 FPDF_FORMFILLINFO::FFI_GetPlatform = Form_GetPlatform; |
649 FPDF_FORMFILLINFO::FFI_PopupMenu = Form_PopupMenu; | 651 FPDF_FORMFILLINFO::FFI_PopupMenu = Form_PopupMenu; |
650 FPDF_FORMFILLINFO::FFI_PostRequestURL = Form_PostRequestURL; | 652 FPDF_FORMFILLINFO::FFI_PostRequestURL = Form_PostRequestURL; |
651 FPDF_FORMFILLINFO::FFI_PutRequestURL = Form_PutRequestURL; | 653 FPDF_FORMFILLINFO::FFI_PutRequestURL = Form_PutRequestURL; |
652 FPDF_FORMFILLINFO::FFI_UploadTo = Form_UploadTo; | 654 FPDF_FORMFILLINFO::FFI_UploadTo = Form_UploadTo; |
653 FPDF_FORMFILLINFO::FFI_DownloadFromURL = Form_DownloadFromURL; | 655 FPDF_FORMFILLINFO::FFI_DownloadFromURL = Form_DownloadFromURL; |
654 FPDF_FORMFILLINFO::FFI_OpenFile = Form_OpenFile; | 656 FPDF_FORMFILLINFO::FFI_OpenFile = Form_OpenFile; |
655 FPDF_FORMFILLINFO::FFI_GotoURL = Form_GotoURL; | 657 FPDF_FORMFILLINFO::FFI_GotoURL = Form_GotoURL; |
656 FPDF_FORMFILLINFO::FFI_GetLanguage = Form_GetLanguage; | 658 FPDF_FORMFILLINFO::FFI_GetLanguage = Form_GetLanguage; |
657 #endif // PDF_USE_XFA | 659 #endif // PDF_USE_XFA |
658 IPDF_JSPLATFORM::version = 1; | 660 IPDF_JSPLATFORM::version = 2; |
659 IPDF_JSPLATFORM::app_alert = Form_Alert; | 661 IPDF_JSPLATFORM::app_alert = Form_Alert; |
660 IPDF_JSPLATFORM::app_beep = Form_Beep; | 662 IPDF_JSPLATFORM::app_beep = Form_Beep; |
661 IPDF_JSPLATFORM::app_response = Form_Response; | 663 IPDF_JSPLATFORM::app_response = Form_Response; |
662 IPDF_JSPLATFORM::Doc_getFilePath = Form_GetFilePath; | 664 IPDF_JSPLATFORM::Doc_getFilePath = Form_GetFilePath; |
663 IPDF_JSPLATFORM::Doc_mail = Form_Mail; | 665 IPDF_JSPLATFORM::Doc_mail = Form_Mail; |
664 IPDF_JSPLATFORM::Doc_print = Form_Print; | 666 IPDF_JSPLATFORM::Doc_print = Form_Print; |
665 IPDF_JSPLATFORM::Doc_submitForm = Form_SubmitForm; | 667 IPDF_JSPLATFORM::Doc_submitForm = Form_SubmitForm; |
666 IPDF_JSPLATFORM::Doc_gotoPage = Form_GotoPage; | 668 IPDF_JSPLATFORM::Doc_gotoPage = Form_GotoPage; |
667 IPDF_JSPLATFORM::Field_browse = Form_Browse; | 669 IPDF_JSPLATFORM::Field_browse = Form_Browse; |
| 670 IPDF_JSPLATFORM::m_isolate = v8::Isolate::GetCurrent(); |
| 671 IPDF_JSPLATFORM::m_v8EmbedderSlot = gin::kEmbedderPDFium; |
668 | 672 |
669 IFSDK_PAUSE::version = 1; | 673 IFSDK_PAUSE::version = 1; |
670 IFSDK_PAUSE::user = NULL; | 674 IFSDK_PAUSE::user = NULL; |
671 IFSDK_PAUSE::NeedToPauseNow = Pause_NeedToPauseNow; | 675 IFSDK_PAUSE::NeedToPauseNow = Pause_NeedToPauseNow; |
672 } | 676 } |
673 | 677 |
674 PDFiumEngine::~PDFiumEngine() { | 678 PDFiumEngine::~PDFiumEngine() { |
675 for (size_t i = 0; i < pages_.size(); ++i) | 679 for (size_t i = 0; i < pages_.size(); ++i) |
676 pages_[i]->Unload(); | 680 pages_[i]->Unload(); |
677 | 681 |
(...skipping 3361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4039 double* height) { | 4043 double* height) { |
4040 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); | 4044 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); |
4041 if (!doc) | 4045 if (!doc) |
4042 return false; | 4046 return false; |
4043 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 4047 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; |
4044 FPDF_CloseDocument(doc); | 4048 FPDF_CloseDocument(doc); |
4045 return success; | 4049 return success; |
4046 } | 4050 } |
4047 | 4051 |
4048 } // namespace chrome_pdf | 4052 } // namespace chrome_pdf |
OLD | NEW |