| 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 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <algorithm> | 11 #include <algorithm> |
| 12 #include <memory> | 12 #include <memory> |
| 13 #include <set> | 13 #include <set> |
| 14 | 14 |
| 15 #include "base/auto_reset.h" | 15 #include "base/auto_reset.h" |
| 16 #include "base/i18n/encoding_detection.h" | 16 #include "base/i18n/encoding_detection.h" |
| 17 #include "base/i18n/icu_string_conversions.h" | 17 #include "base/i18n/icu_string_conversions.h" |
| 18 #include "base/lazy_instance.h" | 18 #include "base/lazy_instance.h" |
| 19 #include "base/logging.h" | 19 #include "base/logging.h" |
| 20 #include "base/macros.h" | 20 #include "base/macros.h" |
| 21 #include "base/memory/ptr_util.h" | 21 #include "base/memory/ptr_util.h" |
| 22 #include "base/numerics/safe_conversions.h" | 22 #include "base/numerics/safe_conversions.h" |
| 23 #include "base/stl_util.h" | 23 #include "base/stl_util.h" |
| 24 #include "base/strings/string_number_conversions.h" | 24 #include "base/strings/string_number_conversions.h" |
| 25 #include "base/strings/string_piece.h" | 25 #include "base/strings/string_piece.h" |
| 26 #include "base/strings/string_util.h" | 26 #include "base/strings/string_util.h" |
| 27 #include "base/strings/utf_string_conversions.h" | 27 #include "base/strings/utf_string_conversions.h" |
| 28 #include "base/threading/thread_task_runner_handle.h" |
| 28 #include "gin/array_buffer.h" | 29 #include "gin/array_buffer.h" |
| 29 #include "gin/public/gin_embedders.h" | 30 #include "gin/public/gin_embedders.h" |
| 30 #include "gin/public/isolate_holder.h" | 31 #include "gin/public/isolate_holder.h" |
| 31 #include "pdf/draw_utils.h" | 32 #include "pdf/draw_utils.h" |
| 32 #include "pdf/pdfium/pdfium_api_string_buffer_adapter.h" | 33 #include "pdf/pdfium/pdfium_api_string_buffer_adapter.h" |
| 33 #include "pdf/pdfium/pdfium_mem_buffer_file_read.h" | 34 #include "pdf/pdfium/pdfium_mem_buffer_file_read.h" |
| 34 #include "pdf/pdfium/pdfium_mem_buffer_file_write.h" | 35 #include "pdf/pdfium/pdfium_mem_buffer_file_write.h" |
| 35 #include "ppapi/c/pp_errors.h" | 36 #include "ppapi/c/pp_errors.h" |
| 36 #include "ppapi/c/pp_input_event.h" | 37 #include "ppapi/c/pp_input_event.h" |
| 37 #include "ppapi/c/ppb_core.h" | 38 #include "ppapi/c/ppb_core.h" |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 FPDF_GetMetaText(doc, key.c_str(), string_adapter.GetData(), size)); | 600 FPDF_GetMetaText(doc, key.c_str(), string_adapter.GetData(), size)); |
| 600 return base::UTF16ToUTF8(value); | 601 return base::UTF16ToUTF8(value); |
| 601 } | 602 } |
| 602 | 603 |
| 603 gin::IsolateHolder* g_isolate_holder = nullptr; | 604 gin::IsolateHolder* g_isolate_holder = nullptr; |
| 604 | 605 |
| 605 void SetUpV8() { | 606 void SetUpV8() { |
| 606 gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode, | 607 gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode, |
| 607 gin::IsolateHolder::kStableV8Extras, | 608 gin::IsolateHolder::kStableV8Extras, |
| 608 gin::ArrayBufferAllocator::SharedInstance()); | 609 gin::ArrayBufferAllocator::SharedInstance()); |
| 609 g_isolate_holder = | 610 g_isolate_holder = new gin::IsolateHolder(base::ThreadTaskRunnerHandle::Get(), |
| 610 new gin::IsolateHolder(gin::IsolateHolder::kSingleThread); | 611 gin::IsolateHolder::kSingleThread); |
| 611 g_isolate_holder->isolate()->Enter(); | 612 g_isolate_holder->isolate()->Enter(); |
| 612 } | 613 } |
| 613 | 614 |
| 614 void TearDownV8() { | 615 void TearDownV8() { |
| 615 g_isolate_holder->isolate()->Exit(); | 616 g_isolate_holder->isolate()->Exit(); |
| 616 delete g_isolate_holder; | 617 delete g_isolate_holder; |
| 617 g_isolate_holder = nullptr; | 618 g_isolate_holder = nullptr; |
| 618 } | 619 } |
| 619 | 620 |
| 620 } // namespace | 621 } // namespace |
| (...skipping 3517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4138 FPDF_DOCUMENT doc = | 4139 FPDF_DOCUMENT doc = |
| 4139 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); | 4140 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); |
| 4140 if (!doc) | 4141 if (!doc) |
| 4141 return false; | 4142 return false; |
| 4142 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 4143 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; |
| 4143 FPDF_CloseDocument(doc); | 4144 FPDF_CloseDocument(doc); |
| 4144 return success; | 4145 return success; |
| 4145 } | 4146 } |
| 4146 | 4147 |
| 4147 } // namespace chrome_pdf | 4148 } // namespace chrome_pdf |
| OLD | NEW |