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 #ifndef PDF_PDFIUM_PDFIUM_ENGINE_H_ | 5 #ifndef PDF_PDFIUM_PDFIUM_ENGINE_H_ |
| 6 #define PDF_PDFIUM_PDFIUM_ENGINE_H_ | 6 #define PDF_PDFIUM_PDFIUM_ENGINE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 pp::FloatRect* out_bounds) override; | 101 pp::FloatRect* out_bounds) override; |
| 102 bool GetPrintScaling() override; | 102 bool GetPrintScaling() override; |
| 103 int GetCopiesToPrint() override; | 103 int GetCopiesToPrint() override; |
| 104 int GetDuplexType() override; | 104 int GetDuplexType() override; |
| 105 bool GetPageSizeAndUniformity(pp::Size* size) override; | 105 bool GetPageSizeAndUniformity(pp::Size* size) override; |
| 106 void AppendBlankPages(int num_pages) override; | 106 void AppendBlankPages(int num_pages) override; |
| 107 void AppendPage(PDFEngine* engine, int index) override; | 107 void AppendPage(PDFEngine* engine, int index) override; |
| 108 #if defined(PDF_ENABLE_XFA) | 108 #if defined(PDF_ENABLE_XFA) |
| 109 void SetScrollPosition(const pp::Point& position) override; | 109 void SetScrollPosition(const pp::Point& position) override; |
| 110 #endif | 110 #endif |
| 111 bool IsProgressiveLoad() override; | |
| 112 std::string GetMetadata(const std::string& key) override; | 111 std::string GetMetadata(const std::string& key) override; |
| 113 | 112 |
| 114 // DocumentLoader::Client implementation. | 113 // DocumentLoader::Client implementation. |
| 115 pp::Instance* GetPluginInstance() override; | 114 pp::Instance* GetPluginInstance() override; |
| 116 pp::URLLoader CreateURLLoader() override; | 115 std::unique_ptr<URLLoaderWrapper> CreateURLLoader() override; |
| 117 void OnPartialDocumentLoaded() override; | |
| 118 void OnPendingRequestComplete() override; | 116 void OnPendingRequestComplete() override; |
| 119 void OnNewDataAvailable() override; | 117 void OnNewDataAvailable() override; |
| 120 void OnDocumentComplete() override; | 118 void OnDocumentComplete() override; |
| 119 void OnDocumentCanceled() override; | |
| 120 void CancelBrowserDownload() override; | |
| 121 | 121 |
| 122 void UnsupportedFeature(int type); | 122 void UnsupportedFeature(int type); |
| 123 | 123 |
| 124 std::string current_find_text() const { return current_find_text_; } | 124 std::string current_find_text() const { return current_find_text_; } |
| 125 | 125 |
| 126 FPDF_DOCUMENT doc() { return doc_; } | 126 FPDF_DOCUMENT doc() { return doc_; } |
| 127 FPDF_FORMHANDLE form() { return form_; } | 127 FPDF_FORMHANDLE form() { return form_; } |
| 128 | 128 |
| 129 private: | 129 private: |
| 130 // This helper class is used to detect the difference in selection between | 130 // This helper class is used to detect the difference in selection between |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 private: | 183 private: |
| 184 bool valid_; // Whether |index_| is valid or not. | 184 bool valid_; // Whether |index_| is valid or not. |
| 185 size_t index_; // The current search result, 0-based. | 185 size_t index_; // The current search result, 0-based. |
| 186 | 186 |
| 187 DISALLOW_COPY_AND_ASSIGN(FindTextIndex); | 187 DISALLOW_COPY_AND_ASSIGN(FindTextIndex); |
| 188 }; | 188 }; |
| 189 | 189 |
| 190 friend class SelectionChangeInvalidator; | 190 friend class SelectionChangeInvalidator; |
| 191 | 191 |
| 192 struct FileAvail : public FX_FILEAVAIL { | 192 struct FileAvail : public FX_FILEAVAIL { |
| 193 DocumentLoader* loader; | 193 PDFiumEngine* engine; |
| 194 }; | 194 }; |
| 195 | 195 |
| 196 struct DownloadHints : public FX_DOWNLOADHINTS { | 196 struct DownloadHints : public FX_DOWNLOADHINTS { |
| 197 DocumentLoader* loader; | 197 PDFiumEngine* engine; |
| 198 }; | 198 }; |
| 199 | 199 |
| 200 // PDFium interface to get block of data. | 200 // PDFium interface to get block of data. |
| 201 static int GetBlock(void* param, unsigned long position, | 201 static int GetBlock(void* param, unsigned long position, |
| 202 unsigned char* buffer, unsigned long size); | 202 unsigned char* buffer, unsigned long size); |
| 203 | 203 |
| 204 // PDFium interface to check is block of data is available. | 204 // PDFium interface to check is block of data is available. |
| 205 static FPDF_BOOL IsDataAvail(FX_FILEAVAIL* param, | 205 static FPDF_BOOL IsDataAvail(FX_FILEAVAIL* param, |
| 206 size_t offset, size_t size); | 206 size_t offset, size_t size); |
| 207 | 207 |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 592 | 592 |
| 593 // The scroll position in screen coordinates. | 593 // The scroll position in screen coordinates. |
| 594 pp::Point position_; | 594 pp::Point position_; |
| 595 // The offset of the page into the viewport. | 595 // The offset of the page into the viewport. |
| 596 pp::Point page_offset_; | 596 pp::Point page_offset_; |
| 597 // The plugin size in screen coordinates. | 597 // The plugin size in screen coordinates. |
| 598 pp::Size plugin_size_; | 598 pp::Size plugin_size_; |
| 599 double current_zoom_; | 599 double current_zoom_; |
| 600 unsigned int current_rotation_; | 600 unsigned int current_rotation_; |
| 601 | 601 |
| 602 DocumentLoader doc_loader_; // Main document's loader. | 602 std::unique_ptr<DocumentLoader> doc_loader_; // Main document's loader. |
| 603 std::string url_; | 603 std::string url_; |
| 604 std::string headers_; | 604 std::string headers_; |
| 605 pp::CompletionCallbackFactory<PDFiumEngine> find_factory_; | 605 pp::CompletionCallbackFactory<PDFiumEngine> find_factory_; |
| 606 | 606 |
| 607 pp::CompletionCallbackFactory<PDFiumEngine> password_factory_; | 607 pp::CompletionCallbackFactory<PDFiumEngine> password_factory_; |
| 608 int32_t password_tries_remaining_; | 608 int32_t password_tries_remaining_; |
| 609 | 609 |
| 610 // The current text used for searching. | 610 // The current text used for searching. |
| 611 std::string current_find_text_; | 611 std::string current_find_text_; |
| 612 | 612 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 723 // The timeout to use for the current progressive paint. | 723 // The timeout to use for the current progressive paint. |
| 724 int progressive_paint_timeout_; | 724 int progressive_paint_timeout_; |
| 725 | 725 |
| 726 // Shadow matrix for generating the page shadow bitmap. | 726 // Shadow matrix for generating the page shadow bitmap. |
| 727 std::unique_ptr<ShadowMatrix> page_shadow_; | 727 std::unique_ptr<ShadowMatrix> page_shadow_; |
| 728 | 728 |
| 729 // Set to true if the user is being prompted for their password. Will be set | 729 // Set to true if the user is being prompted for their password. Will be set |
| 730 // to false after the user finishes getting their password. | 730 // to false after the user finishes getting their password. |
| 731 bool getting_password_; | 731 bool getting_password_; |
| 732 | 732 |
| 733 bool should_process_pending_request_complete_ = true; | |
|
Lei Zhang
2016/10/05 07:18:08
Comment to explain what this does? Maybe "process_
snake
2016/10/05 14:14:10
Done.
| |
| 734 | |
| 733 DISALLOW_COPY_AND_ASSIGN(PDFiumEngine); | 735 DISALLOW_COPY_AND_ASSIGN(PDFiumEngine); |
| 734 }; | 736 }; |
| 735 | 737 |
| 736 // Create a local variable of this when calling PDFium functions which can call | 738 // Create a local variable of this when calling PDFium functions which can call |
| 737 // our global callback when an unsupported feature is reached. | 739 // our global callback when an unsupported feature is reached. |
| 738 class ScopedUnsupportedFeature { | 740 class ScopedUnsupportedFeature { |
| 739 public: | 741 public: |
| 740 explicit ScopedUnsupportedFeature(PDFiumEngine* engine); | 742 explicit ScopedUnsupportedFeature(PDFiumEngine* engine); |
| 741 ~ScopedUnsupportedFeature(); | 743 ~ScopedUnsupportedFeature(); |
| 742 | 744 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 772 bool GetPDFPageSizeByIndex(const void* pdf_buffer, | 774 bool GetPDFPageSizeByIndex(const void* pdf_buffer, |
| 773 int pdf_buffer_size, | 775 int pdf_buffer_size, |
| 774 int page_number, | 776 int page_number, |
| 775 double* width, | 777 double* width, |
| 776 double* height) override; | 778 double* height) override; |
| 777 }; | 779 }; |
| 778 | 780 |
| 779 } // namespace chrome_pdf | 781 } // namespace chrome_pdf |
| 780 | 782 |
| 781 #endif // PDF_PDFIUM_PDFIUM_ENGINE_H_ | 783 #endif // PDF_PDFIUM_PDFIUM_ENGINE_H_ |
| OLD | NEW |