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
3 // found in the LICENSE file.
5 #ifndef PDF_PDFIUM_PDFIUM_ENGINE_H_
6 #define PDF_PDFIUM_PDFIUM_ENGINE_H_
13 #include "base/memory/scoped_ptr.h"
14 #include "base/time/time.h"
15 #include "pdf/document_loader.h"
16 #include "pdf/pdf_engine.h"
17 #include "pdf/pdfium/pdfium_page.h"
18 #include "pdf/pdfium/pdfium_range.h"
19 #include "ppapi/cpp/completion_callback.h"
20 #include "ppapi/cpp/dev/buffer_dev.h"
21 #include "ppapi/cpp/image_data.h"
22 #include "ppapi/cpp/point.h"
23 #include "ppapi/cpp/var_array.h"
24 #include "third_party/pdfium/fpdfsdk/include/fpdf_dataavail.h"
25 #include "third_party/pdfium/fpdfsdk/include/fpdf_progressive.h"
26 #include "third_party/pdfium/fpdfsdk/include/fpdfformfill.h"
27 #include "third_party/pdfium/fpdfsdk/include/fpdfview.h"
30 class KeyboardInputEvent
;
31 class MouseInputEvent
;
35 namespace chrome_pdf
{
39 class PDFiumEngine
: public PDFEngine
,
40 public DocumentLoader::Client
,
41 public FPDF_FORMFILLINFO
,
42 public IPDF_JSPLATFORM
,
45 explicit PDFiumEngine(PDFEngine::Client
* client
);
46 virtual ~PDFiumEngine();
48 // PDFEngine implementation.
49 virtual bool New(const char* url
);
50 virtual bool New(const char* url
,
52 virtual void PageOffsetUpdated(const pp::Point
& page_offset
);
53 virtual void PluginSizeUpdated(const pp::Size
& size
);
54 virtual void ScrolledToXPosition(int position
);
55 virtual void ScrolledToYPosition(int position
);
56 virtual void PrePaint();
57 virtual void Paint(const pp::Rect
& rect
,
58 pp::ImageData
* image_data
,
59 std::vector
<pp::Rect
>* ready
,
60 std::vector
<pp::Rect
>* pending
);
61 virtual void PostPaint();
62 virtual bool HandleDocumentLoad(const pp::URLLoader
& loader
);
63 virtual bool HandleEvent(const pp::InputEvent
& event
);
64 virtual uint32_t QuerySupportedPrintOutputFormats();
65 virtual void PrintBegin();
66 virtual pp::Resource
PrintPages(
67 const PP_PrintPageNumberRange_Dev
* page_ranges
,
68 uint32_t page_range_count
,
69 const PP_PrintSettings_Dev
& print_settings
);
70 virtual void PrintEnd();
71 virtual void StartFind(const char* text
, bool case_sensitive
);
72 virtual bool SelectFindResult(bool forward
);
73 virtual void StopFind();
74 virtual void ZoomUpdated(double new_zoom_level
);
75 virtual void RotateClockwise();
76 virtual void RotateCounterclockwise();
77 virtual std::string
GetSelectedText();
78 virtual std::string
GetLinkAtPosition(const pp::Point
& point
);
79 virtual bool IsSelecting();
80 virtual bool HasPermission(DocumentPermission permission
) const;
81 virtual void SelectAll();
82 virtual int GetNumberOfPages();
83 virtual pp::VarArray
GetBookmarks();
84 virtual int GetNamedDestinationPage(const std::string
& destination
);
85 virtual int GetFirstVisiblePage();
86 virtual int GetMostVisiblePage();
87 virtual pp::Rect
GetPageRect(int index
);
88 virtual pp::Rect
GetPageContentsRect(int index
);
89 virtual int GetVerticalScrollbarYPosition() { return position_
.y(); }
90 virtual void PaintThumbnail(pp::ImageData
* image_data
, int index
);
91 virtual void SetGrayscale(bool grayscale
);
92 virtual void OnCallback(int id
);
93 virtual std::string
GetPageAsJSON(int index
);
94 virtual bool GetPrintScaling();
95 virtual int GetCopiesToPrint();
96 virtual int GetDuplexType();
97 virtual bool GetPageSizeAndUniformity(pp::Size
* size
);
98 virtual void AppendBlankPages(int num_pages
);
99 virtual void AppendPage(PDFEngine
* engine
, int index
);
100 virtual pp::Point
GetScrollPosition();
101 virtual void SetScrollPosition(const pp::Point
& position
);
102 virtual bool IsProgressiveLoad();
104 // DocumentLoader::Client implementation.
105 virtual pp::Instance
* GetPluginInstance();
106 virtual pp::URLLoader
CreateURLLoader();
107 virtual void OnPartialDocumentLoaded();
108 virtual void OnPendingRequestComplete();
109 virtual void OnNewDataAvailable();
110 virtual void OnDocumentComplete();
112 void UnsupportedFeature(int type
);
114 std::string
current_find_text() const { return current_find_text_
; }
116 FPDF_DOCUMENT
doc() { return doc_
; }
117 FPDF_FORMHANDLE
form() { return form_
; }
120 // This helper class is used to detect the difference in selection between
121 // construction and destruction. At destruction, it invalidates all the
122 // parts that are newly selected, along with all the parts that used to be
123 // selected but are not anymore.
124 class SelectionChangeInvalidator
{
126 explicit SelectionChangeInvalidator(PDFiumEngine
* engine
);
127 ~SelectionChangeInvalidator();
129 // Sets the given container to the all the currently visible selection
130 // rectangles, in screen coordinates.
131 void GetVisibleSelectionsScreenRects(std::vector
<pp::Rect
>* rects
);
133 PDFiumEngine
* engine_
;
134 // Screen rectangles that were selected on construction.
135 std::vector
<pp::Rect
> old_selections_
;
136 // The origin at the time this object was constructed.
137 pp::Point previous_origin_
;
140 // Used to store mouse down state to handle it in other mouse event handlers.
141 class MouseDownState
{
143 MouseDownState(const PDFiumPage::Area
& area
,
144 const PDFiumPage::LinkTarget
& target
);
147 void Set(const PDFiumPage::Area
& area
,
148 const PDFiumPage::LinkTarget
& target
);
150 bool Matches(const PDFiumPage::Area
& area
,
151 const PDFiumPage::LinkTarget
& target
) const;
154 PDFiumPage::Area area_
;
155 PDFiumPage::LinkTarget target_
;
157 DISALLOW_COPY_AND_ASSIGN(MouseDownState
);
160 // Used to store the state of a text search.
161 class FindTextIndex
{
166 bool valid() const { return valid_
; }
169 size_t GetIndex() const;
170 void SetIndex(size_t index
);
171 size_t IncrementIndex();
174 bool valid_
; // Whether |index_| is valid or not.
175 size_t index_
; // The current search result, 0-based.
177 DISALLOW_COPY_AND_ASSIGN(FindTextIndex
);
180 friend class SelectionChangeInvalidator
;
182 struct FileAvail
: public FX_FILEAVAIL
{
183 DocumentLoader
* loader
;
186 struct DownloadHints
: public FX_DOWNLOADHINTS
{
187 DocumentLoader
* loader
;
190 // PDFium interface to get block of data.
191 static int GetBlock(void* param
, unsigned long position
,
192 unsigned char* buffer
, unsigned long size
);
194 // PDFium interface to check is block of data is available.
195 static bool IsDataAvail(FX_FILEAVAIL
* param
,
196 size_t offset
, size_t size
);
198 // PDFium interface to request download of the block of data.
199 static void AddSegment(FX_DOWNLOADHINTS
* param
,
200 size_t offset
, size_t size
);
202 // We finished getting the pdf file, so load it. This will complete
203 // asynchronously (due to password fetching) and may be run multiple times.
206 // Try loading the document. Returns true if the document is successfully
207 // loaded or is already loaded otherwise it will return false. If
208 // |with_password| is set to true, the document will be loaded with
209 // |password|. If the document could not be loaded and needs a password,
210 // |needs_password| will be set to true.
211 bool TryLoadingDoc(bool with_password
,
212 const std::string
& password
,
213 bool* needs_password
);
215 // Ask the user for the document password and then continue loading the
217 void GetPasswordAndLoad();
219 // Called when the password has been retrieved.
220 void OnGetPasswordComplete(int32_t result
,
221 const pp::Var
& password
);
223 // Continues loading the document when the password has been retrieved, or if
224 // there is no password.
225 void ContinueLoadingDocument(bool has_password
,
226 const std::string
& password
);
228 // Finish loading the document and notify the client that the document has
229 // been loaded. This should only be run after |doc_| has been loaded and the
230 // document is fully downloaded. If this has been run once, it will result in
232 void FinishLoadingDocument();
234 // Loads information about the pages in the document and calculate the
236 void LoadPageInfo(bool reload
);
238 // Calculate which pages should be displayed right now.
239 void CalculateVisiblePages();
241 // Returns true iff the given page index is visible. CalculateVisiblePages
242 // must have been called first.
243 bool IsPageVisible(int index
) const;
245 // Checks if a page is now available, and if so marks it as such and returns
246 // true. Otherwise, it will return false and will add the index to the given
247 // array if it's not already there.
248 bool CheckPageAvailable(int index
, std::vector
<int>* pending
);
250 // Helper function to get a given page's size in pixels. This is not part of
251 // PDFiumPage because we might not have that structure when we need this.
252 pp::Size
GetPageSize(int index
);
254 void GetAllScreenRectsUnion(std::vector
<PDFiumRange
>* rect_range
,
255 const pp::Point
& offset_point
,
256 std::vector
<pp::Rect
>* rect_vector
);
258 void UpdateTickMarks();
260 // Called to continue searching so we don't block the main thread.
261 void ContinueFind(int32_t result
);
263 // Inserts a find result into find_results_, which is sorted.
264 void AddFindResult(const PDFiumRange
& result
);
266 // Search a page using PDFium's methods. Doesn't work with unicode. This
267 // function is just kept arount in case PDFium code is fixed.
268 void SearchUsingPDFium(const base::string16
& term
,
271 int character_to_start_searching_from
,
274 // Search a page ourself using ICU.
275 void SearchUsingICU(const base::string16
& term
,
278 int character_to_start_searching_from
,
281 // Input event handlers.
282 bool OnMouseDown(const pp::MouseInputEvent
& event
);
283 bool OnMouseUp(const pp::MouseInputEvent
& event
);
284 bool OnMouseMove(const pp::MouseInputEvent
& event
);
285 bool OnKeyDown(const pp::KeyboardInputEvent
& event
);
286 bool OnKeyUp(const pp::KeyboardInputEvent
& event
);
287 bool OnChar(const pp::KeyboardInputEvent
& event
);
289 FPDF_DOCUMENT
CreateSinglePageRasterPdf(
290 double source_page_width
,
291 double source_page_height
,
292 const PP_PrintSettings_Dev
& print_settings
,
293 PDFiumPage
* page_to_print
);
295 pp::Buffer_Dev
PrintPagesAsRasterPDF(
296 const PP_PrintPageNumberRange_Dev
* page_ranges
,
297 uint32_t page_range_count
,
298 const PP_PrintSettings_Dev
& print_settings
);
300 pp::Buffer_Dev
PrintPagesAsPDF(const PP_PrintPageNumberRange_Dev
* page_ranges
,
301 uint32_t page_range_count
,
302 const PP_PrintSettings_Dev
& print_settings
);
304 pp::Buffer_Dev
GetFlattenedPrintData(const FPDF_DOCUMENT
& doc
);
305 void FitContentsToPrintableAreaIfRequired(
306 const FPDF_DOCUMENT
& doc
,
307 const PP_PrintSettings_Dev
& print_settings
);
308 void SaveSelectedFormForPrint();
310 // Given a mouse event, returns which page and character location it's closest
312 PDFiumPage::Area
GetCharIndex(const pp::MouseInputEvent
& event
,
316 PDFiumPage::LinkTarget
* target
);
317 PDFiumPage::Area
GetCharIndex(const pp::Point
& point
,
321 PDFiumPage::LinkTarget
* target
);
323 void OnSingleClick(int page_index
, int char_index
);
324 void OnMultipleClick(int click_count
, int page_index
, int char_index
);
326 // Starts a progressive paint operation given a rectangle in screen
327 // coordinates. Returns the index in progressive_rects_.
328 int StartPaint(int page_index
, const pp::Rect
& dirty
);
330 // Continues a paint operation that was started earlier. Returns true if the
331 // paint is done, or false if it needs to be continued.
332 bool ContinuePaint(int progressive_index
, pp::ImageData
* image_data
);
334 // Called once PDFium is finished rendering a page so that we draw our
335 // borders, highlighting etc.
336 void FinishPaint(int progressive_index
, pp::ImageData
* image_data
);
338 // Stops any paints that are in progress.
341 // Invalidates all pages. Use this when some global parameter, such as page
342 // orientation, has changed.
343 void InvalidateAllPages();
345 // If the page is narrower than the document size, paint the extra space
346 // with the page background.
347 void FillPageSides(int progressive_index
);
349 void PaintPageShadow(int progressive_index
, pp::ImageData
* image_data
);
351 // Highlight visible find results and selections.
352 void DrawSelections(int progressive_index
, pp::ImageData
* image_data
);
354 // Paints an page that hasn't finished downloading.
355 void PaintUnavailablePage(int page_index
,
356 const pp::Rect
& dirty
,
357 pp::ImageData
* image_data
);
359 // Given a page index, returns the corresponding index in progressive_rects_,
360 // or -1 if it doesn't exist.
361 int GetProgressiveIndex(int page_index
) const;
363 // Creates a FPDF_BITMAP from a rectangle in screen coordinates.
364 FPDF_BITMAP
CreateBitmap(const pp::Rect
& rect
,
365 pp::ImageData
* image_data
) const;
367 // Given a rectangle in screen coordinates, returns the coordinates in the
368 // units that PDFium rendering functions expect.
369 void GetPDFiumRect(int page_index
, const pp::Rect
& rect
, int* start_x
,
370 int* start_y
, int* size_x
, int* size_y
) const;
372 // Returns the rendering flags to pass to PDFium.
373 int GetRenderingFlags() const;
375 // Returns the currently visible rectangle in document coordinates.
376 pp::Rect
GetVisibleRect() const;
378 // Returns a page's rect in screen coordinates, as well as its surrounding
379 // border areas and bottom separator.
380 pp::Rect
GetPageScreenRect(int page_index
) const;
382 // Given a rectangle in document coordinates, returns the rectange into screen
383 // coordinates (i.e. 0,0 is top left corner of plugin area). If it's not
384 // visible, an empty rectangle is returned.
385 pp::Rect
GetScreenRect(const pp::Rect
& rect
) const;
387 // Highlights the given rectangle.
388 void Highlight(void* buffer
,
390 const pp::Rect
& rect
,
391 std::vector
<pp::Rect
>* highlighted_rects
);
393 // Helper function to convert a device to page coordinates. If the page is
394 // not yet loaded, page_x and page_y will be set to 0.
395 void DeviceToPage(int page_index
,
401 // Helper function to get the index of a given FPDF_PAGE. Returns -1 if not
403 int GetVisiblePageIndex(FPDF_PAGE page
);
405 // Helper function to change the current page, running page open/close
406 // triggers as necessary.
407 void SetCurrentPage(int index
);
409 // Transform |page| contents to fit in the selected printer paper size.
410 void TransformPDFPageForPrinting(FPDF_PAGE page
,
411 const PP_PrintSettings_Dev
& print_settings
);
413 void DrawPageShadow(const pp::Rect
& page_rect
,
414 const pp::Rect
& shadow_rect
,
415 const pp::Rect
& clip_rect
,
416 pp::ImageData
* image_data
);
418 void GetRegion(const pp::Point
& location
,
419 pp::ImageData
* image_data
,
423 // Called when the selection changes.
424 void OnSelectionChanged();
426 // Common code shared by RotateClockwise() and RotateCounterclockwise().
427 void RotateInternal();
429 // Setting selection status of document.
430 void SetSelecting(bool selecting
);
432 // FPDF_FORMFILLINFO callbacks.
433 static void Form_Invalidate(FPDF_FORMFILLINFO
* param
,
439 static void Form_OutputSelectedRect(FPDF_FORMFILLINFO
* param
,
445 static void Form_SetCursor(FPDF_FORMFILLINFO
* param
, int cursor_type
);
446 static int Form_SetTimer(FPDF_FORMFILLINFO
* param
,
448 TimerCallback timer_func
);
449 static void Form_KillTimer(FPDF_FORMFILLINFO
* param
, int timer_id
);
450 static FPDF_SYSTEMTIME
Form_GetLocalTime(FPDF_FORMFILLINFO
* param
);
451 static void Form_OnChange(FPDF_FORMFILLINFO
* param
);
452 static FPDF_PAGE
Form_GetPage(FPDF_FORMFILLINFO
* param
,
453 FPDF_DOCUMENT document
,
455 static FPDF_PAGE
Form_GetCurrentPage(FPDF_FORMFILLINFO
* param
,
456 FPDF_DOCUMENT document
);
457 static int Form_GetRotation(FPDF_FORMFILLINFO
* param
, FPDF_PAGE page
);
458 static void Form_ExecuteNamedAction(FPDF_FORMFILLINFO
* param
,
459 FPDF_BYTESTRING named_action
);
460 static void Form_SetTextFieldFocus(FPDF_FORMFILLINFO
* param
,
461 FPDF_WIDESTRING value
,
464 static void Form_DoURIAction(FPDF_FORMFILLINFO
* param
, FPDF_BYTESTRING uri
);
465 static void Form_DoGoToAction(FPDF_FORMFILLINFO
* param
,
468 float* position_array
,
471 // IPDF_JSPLATFORM callbacks.
472 static int Form_Alert(IPDF_JSPLATFORM
* param
,
473 FPDF_WIDESTRING message
,
474 FPDF_WIDESTRING title
,
477 static void Form_Beep(IPDF_JSPLATFORM
* param
, int type
);
478 static int Form_Response(IPDF_JSPLATFORM
* param
,
479 FPDF_WIDESTRING question
,
480 FPDF_WIDESTRING title
,
481 FPDF_WIDESTRING default_response
,
482 FPDF_WIDESTRING label
,
486 static int Form_GetFilePath(IPDF_JSPLATFORM
* param
,
489 static void Form_Mail(IPDF_JSPLATFORM
* param
,
494 FPDF_WIDESTRING subject
,
497 FPDF_WIDESTRING message
);
498 static void Form_Print(IPDF_JSPLATFORM
* param
,
503 FPDF_BOOL shrink_to_fit
,
504 FPDF_BOOL print_as_image
,
506 FPDF_BOOL annotations
);
507 static void Form_SubmitForm(IPDF_JSPLATFORM
* param
,
510 FPDF_WIDESTRING url
);
511 static void Form_GotoPage(IPDF_JSPLATFORM
* param
, int page_number
);
512 static int Form_Browse(IPDF_JSPLATFORM
* param
, void* file_path
, int length
);
515 static void Form_EmailTo(FPDF_FORMFILLINFO
* param
,
516 FPDF_FILEHANDLER
* file_handler
,
518 FPDF_WIDESTRING subject
,
521 FPDF_WIDESTRING message
);
522 static void Form_DisplayCaret(FPDF_FORMFILLINFO
* param
,
529 static void Form_SetCurrentPage(FPDF_FORMFILLINFO
* param
,
530 FPDF_DOCUMENT document
,
532 static int Form_GetCurrentPageIndex(FPDF_FORMFILLINFO
* param
,
533 FPDF_DOCUMENT document
);
534 static void Form_GetPageViewRect(FPDF_FORMFILLINFO
* param
,
540 static int Form_GetPlatform(FPDF_FORMFILLINFO
* param
,
543 static FPDF_BOOL
Form_PopupMenu(FPDF_FORMFILLINFO
* param
,
549 static FPDF_BOOL
Form_PostRequestURL(FPDF_FORMFILLINFO
* param
,
551 FPDF_WIDESTRING data
,
552 FPDF_WIDESTRING content_type
,
553 FPDF_WIDESTRING encode
,
554 FPDF_WIDESTRING header
,
555 FPDF_BSTR
* response
);
556 static FPDF_BOOL
Form_PutRequestURL(FPDF_FORMFILLINFO
* param
,
558 FPDF_WIDESTRING data
,
559 FPDF_WIDESTRING encode
);
560 static void Form_UploadTo(FPDF_FORMFILLINFO
* param
,
561 FPDF_FILEHANDLER
* file_handler
,
563 FPDF_WIDESTRING dest
);
564 static FPDF_LPFILEHANDLER
Form_DownloadFromURL(FPDF_FORMFILLINFO
* param
,
565 FPDF_WIDESTRING url
);
566 static FPDF_FILEHANDLER
* Form_OpenFile(FPDF_FORMFILLINFO
* param
,
570 static void Form_GotoURL(FPDF_FORMFILLINFO
* param
,
571 FPDF_DOCUMENT document
,
572 FPDF_WIDESTRING url
);
573 static int Form_GetLanguage(FPDF_FORMFILLINFO
* param
,
576 #endif // PDF_USE_XFA
578 // IFSDK_PAUSE callbacks
579 static FPDF_BOOL
Pause_NeedToPauseNow(IFSDK_PAUSE
* param
);
581 PDFEngine::Client
* client_
;
582 pp::Size document_size_
; // Size of document in pixels.
584 // The scroll position in screen coordinates.
586 // The offset of the page into the viewport.
587 pp::Point page_offset_
;
588 // The plugin size in screen coordinates.
589 pp::Size plugin_size_
;
590 double current_zoom_
;
591 unsigned int current_rotation_
;
593 DocumentLoader doc_loader_
; // Main document's loader.
595 std::string headers_
;
596 pp::CompletionCallbackFactory
<PDFiumEngine
> find_factory_
;
598 pp::CompletionCallbackFactory
<PDFiumEngine
> password_factory_
;
599 int32_t password_tries_remaining_
;
601 // The current text used for searching.
602 std::string current_find_text_
;
604 // The PDFium wrapper object for the document.
607 // The PDFium wrapper for form data. Used even if there are no form controls
609 FPDF_FORMHANDLE form_
;
611 // The page(s) of the document. Store a vector of pointers so that when the
612 // vector is resized we don't close the pages that are used in pending
614 std::vector
<PDFiumPage
*> pages_
;
616 // The indexes of the pages currently visible.
617 std::vector
<int> visible_pages_
;
619 // The indexes of the pages pending download.
620 std::vector
<int> pending_pages_
;
622 // During handling of input events we don't want to unload any pages in
623 // callbacks to us from PDFium, since the current page can change while PDFium
624 // code still has a pointer to it.
625 bool defer_page_unload_
;
626 std::vector
<int> deferred_page_unloads_
;
628 // Used for selection. There could be more than one range if selection spans
629 // more than one page.
630 std::vector
<PDFiumRange
> selection_
;
631 // True if we're in the middle of selection.
634 MouseDownState mouse_down_state_
;
636 // Used for searching.
637 typedef std::vector
<PDFiumRange
> FindResults
;
638 FindResults find_results_
;
639 // Which page to search next.
640 int next_page_to_search_
;
641 // Where to stop searching.
642 int last_page_to_search_
;
643 int last_character_index_to_search_
; // -1 if search until end of page.
644 // Which result the user has currently selected.
645 FindTextIndex current_find_index_
;
646 // Where to resume searching.
647 FindTextIndex resume_find_index_
;
649 // Permissions bitfield.
650 unsigned long permissions_
;
652 // Interface structure to provide access to document stream.
653 FPDF_FILEACCESS file_access_
;
654 // Interface structure to check data availability in the document stream.
655 FileAvail file_availability_
;
656 // Interface structure to request data chunks from the document stream.
657 DownloadHints download_hints_
;
658 // Pointer to the document availability interface.
659 FPDF_AVAIL fpdf_availability_
;
661 pp::Size default_page_size_
;
663 // Used to manage timers that form fill API needs. The pair holds the timer
664 // period, in ms, and the callback function.
665 std::map
<int, std::pair
<int, TimerCallback
> > timers_
;
668 // Holds the page index of the last page that the mouse clicked on.
669 int last_page_mouse_down_
;
671 // Holds the page index of the first visible page; refreshed by calling
672 // CalculateVisiblePages()
673 int first_visible_page_
;
675 // Holds the page index of the most visible page; refreshed by calling
676 // CalculateVisiblePages()
677 int most_visible_page_
;
679 // Set to true after FORM_DoDocumentJSAction/FORM_DoDocumentOpenAction have
680 // been called. Only after that can we call FORM_DoPageAAction.
681 bool called_do_document_action_
;
683 // Records parts of form fields that need to be highlighted at next paint, in
684 // screen coordinates.
685 std::vector
<pp::Rect
> form_highlights_
;
687 // Whether to render in grayscale or in color.
688 bool render_grayscale_
;
690 // The link currently under the cursor.
691 std::string link_under_cursor_
;
693 // Pending progressive paints.
694 struct ProgressivePaint
{
695 pp::Rect rect
; // In screen coordinates.
698 // Temporary used to figure out if in a series of Paint() calls whether this
699 // pending paint was updated or not.
702 std::vector
<ProgressivePaint
> progressive_paints_
;
704 // Keeps track of when we started the last progressive paint, so that in our
705 // callback we can determine if we need to pause.
706 base::Time last_progressive_start_time_
;
708 // The timeout to use for the current progressive paint.
709 int progressive_paint_timeout_
;
711 // Shadow matrix for generating the page shadow bitmap.
712 scoped_ptr
<ShadowMatrix
> page_shadow_
;
714 // Set to true if the user is being prompted for their password. Will be set
715 // to false after the user finishes getting their password.
716 bool getting_password_
;
718 DISALLOW_COPY_AND_ASSIGN(PDFiumEngine
);
721 // Create a local variable of this when calling PDFium functions which can call
722 // our global callback when an unsupported feature is reached.
723 class ScopedUnsupportedFeature
{
725 explicit ScopedUnsupportedFeature(PDFiumEngine
* engine
);
726 ~ScopedUnsupportedFeature();
728 PDFiumEngine
* engine_
;
729 PDFiumEngine
* old_engine_
;
732 class PDFiumEngineExports
: public PDFEngineExports
{
734 PDFiumEngineExports() {}
736 // See the definition of RenderPDFPageToDC in pdf.cc for details.
737 virtual bool RenderPDFPageToDC(const void* pdf_buffer
,
740 const RenderingSettings
& settings
,
743 virtual bool RenderPDFPageToBitmap(const void* pdf_buffer
,
746 const RenderingSettings
& settings
,
747 void* bitmap_buffer
);
749 virtual bool GetPDFDocInfo(const void* pdf_buffer
,
752 double* max_page_width
);
754 // See the definition of GetPDFPageSizeByIndex in pdf.cc for details.
755 virtual bool GetPDFPageSizeByIndex(const void* pdf_buffer
,
756 int pdf_buffer_size
, int page_number
,
757 double* width
, double* height
);
760 } // namespace chrome_pdf
762 #endif // PDF_PDFIUM_PDFIUM_ENGINE_H_