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.
4
5#ifndef PDF_PDFIUM_PDFIUM_ENGINE_H_
6#define PDF_PDFIUM_PDFIUM_ENGINE_H_
7
8#include <map>
9#include <string>
10#include <utility>
11#include <vector>
12
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 "third_party/pdfium/fpdfsdk/include/fpdf_dataavail.h"
24#include "third_party/pdfium/fpdfsdk/include/fpdf_progressive.h"
25#include "third_party/pdfium/fpdfsdk/include/fpdfformfill.h"
26#include "third_party/pdfium/fpdfsdk/include/fpdfview.h"
27
28namespace pp {
29class KeyboardInputEvent;
30class MouseInputEvent;
31}
32
33namespace chrome_pdf {
34
35class ShadowMatrix;
36
37class PDFiumEngine : public PDFEngine,
38                     public DocumentLoader::Client,
39                     public FPDF_FORMFILLINFO,
40                     public IPDF_JSPLATFORM,
41                     public IFSDK_PAUSE {
42 public:
43  explicit PDFiumEngine(PDFEngine::Client* client);
44  virtual ~PDFiumEngine();
45
46  // PDFEngine implementation.
47  virtual bool New(const char* url);
48  virtual bool New(const char* url,
49                   const char* headers);
50  virtual void PageOffsetUpdated(const pp::Point& page_offset);
51  virtual void PluginSizeUpdated(const pp::Size& size);
52  virtual void ScrolledToXPosition(int position);
53  virtual void ScrolledToYPosition(int position);
54  virtual void PrePaint();
55  virtual void Paint(const pp::Rect& rect,
56                     pp::ImageData* image_data,
57                     std::vector<pp::Rect>* ready,
58                     std::vector<pp::Rect>* pending);
59  virtual void PostPaint();
60  virtual bool HandleDocumentLoad(const pp::URLLoader& loader);
61  virtual bool HandleEvent(const pp::InputEvent& event);
62  virtual uint32_t QuerySupportedPrintOutputFormats();
63  virtual void PrintBegin();
64  virtual pp::Resource PrintPages(
65      const PP_PrintPageNumberRange_Dev* page_ranges,
66      uint32_t page_range_count,
67      const PP_PrintSettings_Dev& print_settings);
68  virtual void PrintEnd();
69  virtual void StartFind(const char* text, bool case_sensitive);
70  virtual bool SelectFindResult(bool forward);
71  virtual void StopFind();
72  virtual void ZoomUpdated(double new_zoom_level);
73  virtual void RotateClockwise();
74  virtual void RotateCounterclockwise();
75  virtual std::string GetSelectedText();
76  virtual std::string GetLinkAtPosition(const pp::Point& point);
77  virtual bool IsSelecting();
78  virtual bool HasPermission(DocumentPermission permission) const;
79  virtual void SelectAll();
80  virtual int GetNumberOfPages();
81  virtual int GetNamedDestinationPage(const std::string& destination);
82  virtual int GetFirstVisiblePage();
83  virtual int GetMostVisiblePage();
84  virtual pp::Rect GetPageRect(int index);
85  virtual pp::Rect GetPageContentsRect(int index);
86  virtual int GetVerticalScrollbarYPosition() { return position_.y(); }
87  virtual void PaintThumbnail(pp::ImageData* image_data, int index);
88  virtual void SetGrayscale(bool grayscale);
89  virtual void OnCallback(int id);
90  virtual std::string GetPageAsJSON(int index);
91  virtual bool GetPrintScaling();
92  virtual void AppendBlankPages(int num_pages);
93  virtual void AppendPage(PDFEngine* engine, int index);
94  virtual pp::Point GetScrollPosition();
95  virtual void SetScrollPosition(const pp::Point& position);
96  virtual bool IsProgressiveLoad();
97
98  // DocumentLoader::Client implementation.
99  virtual pp::Instance* GetPluginInstance();
100  virtual pp::URLLoader CreateURLLoader();
101  virtual void OnPartialDocumentLoaded();
102  virtual void OnPendingRequestComplete();
103  virtual void OnNewDataAvailable();
104  virtual void OnDocumentComplete();
105
106  void UnsupportedFeature(int type);
107
108  std::string current_find_text() const { return current_find_text_; }
109
110  FPDF_DOCUMENT doc() { return doc_; }
111  FPDF_FORMHANDLE form() { return form_; }
112
113 private:
114  // This helper class is used to detect the difference in selection between
115  // construction and destruction.  At destruction, it invalidates all the
116  // parts that are newly selected, along with all the parts that used to be
117  // selected but are not anymore.
118  class SelectionChangeInvalidator {
119   public:
120    explicit SelectionChangeInvalidator(PDFiumEngine* engine);
121    ~SelectionChangeInvalidator();
122   private:
123    // Sets the given container to the all the currently visible selection
124    // rectangles, in screen coordinates.
125    void GetVisibleSelectionsScreenRects(std::vector<pp::Rect>* rects);
126
127    PDFiumEngine* engine_;
128    // Screen rectangles that were selected on construction.
129    std::vector<pp::Rect> old_selections_;
130    // The origin at the time this object was constructed.
131    pp::Point previous_origin_;
132  };
133
134  // Used to store mouse down state to handle it in other mouse event handlers.
135  class MouseDownState {
136   public:
137    MouseDownState(const PDFiumPage::Area& area,
138                   const PDFiumPage::LinkTarget& target);
139    ~MouseDownState();
140
141    void Set(const PDFiumPage::Area& area,
142             const PDFiumPage::LinkTarget& target);
143    void Reset();
144    bool Matches(const PDFiumPage::Area& area,
145                 const PDFiumPage::LinkTarget& target) const;
146
147   private:
148    PDFiumPage::Area area_;
149    PDFiumPage::LinkTarget target_;
150
151    DISALLOW_COPY_AND_ASSIGN(MouseDownState);
152  };
153
154  friend class SelectionChangeInvalidator;
155
156  struct FileAvail : public FX_FILEAVAIL {
157    DocumentLoader* loader;
158  };
159
160  struct DownloadHints : public FX_DOWNLOADHINTS {
161    DocumentLoader* loader;
162  };
163
164  // PDFium interface to get block of data.
165  static int GetBlock(void* param, unsigned long position,
166                      unsigned char* buffer, unsigned long size);
167
168  // PDFium interface to check is block of data is available.
169  static bool IsDataAvail(FX_FILEAVAIL* param,
170                          size_t offset, size_t size);
171
172  // PDFium interface to request download of the block of data.
173  static void AddSegment(FX_DOWNLOADHINTS* param,
174                         size_t offset, size_t size);
175
176  // We finished getting the pdf file, so load it. This will complete
177  // asynchronously (due to password fetching) and may be run multiple times.
178  void LoadDocument();
179
180  // Try loading the document. Returns true if the document is successfully
181  // loaded or is already loaded otherwise it will return false. If
182  // |with_password| is set to true, the document will be loaded with
183  // |password|. If the document could not be loaded and needs a password,
184  // |needs_password| will be set to true.
185  bool TryLoadingDoc(bool with_password,
186                     const std::string& password,
187                     bool* needs_password);
188
189  // Ask the user for the document password and then continue loading the
190  // document.
191  void GetPasswordAndLoad();
192
193  // Called when the password has been retrieved.
194  void OnGetPasswordComplete(int32_t result,
195                             const pp::Var& password);
196
197  // Continues loading the document when the password has been retrieved, or if
198  // there is no password.
199  void ContinueLoadingDocument(bool has_password,
200                               const std::string& password);
201
202  // Finish loading the document and notify the client that the document has
203  // been loaded. This should only be run after |doc_| has been loaded and the
204  // document is fully downloaded. If this has been run once, it will result in
205  // a no-op.
206  void FinishLoadingDocument();
207
208  // Loads information about the pages in the document and calculate the
209  // document size.
210  void LoadPageInfo(bool reload);
211
212  // Calculate which pages should be displayed right now.
213  void CalculateVisiblePages();
214
215  // Returns true iff the given page index is visible.  CalculateVisiblePages
216  // must have been called first.
217  bool IsPageVisible(int index) const;
218
219  // Checks if a page is now available, and if so marks it as such and returns
220  // true.  Otherwise, it will return false and will add the index to the given
221  // array if it's not already there.
222  bool CheckPageAvailable(int index, std::vector<int>* pending);
223
224  // Helper function to get a given page's size in pixels.  This is not part of
225  // PDFiumPage because we might not have that structure when we need this.
226  pp::Size GetPageSize(int index);
227
228  void UpdateTickMarks();
229
230  // Called to continue searching so we don't block the main thread.
231  void ContinueFind(int32_t result);
232
233  // Inserts a find result into find_results_, which is sorted.
234  void AddFindResult(const PDFiumRange& result);
235
236  // Search a page using PDFium's methods.  Doesn't work with unicode.  This
237  // function is just kept arount in case PDFium code is fixed.
238  void SearchUsingPDFium(const base::string16& term,
239                         bool case_sensitive,
240                         bool first_search,
241                         int character_to_start_searching_from,
242                         int current_page);
243
244  // Search a page ourself using ICU.
245  void SearchUsingICU(const base::string16& term,
246                      bool case_sensitive,
247                      bool first_search,
248                      int character_to_start_searching_from,
249                      int current_page);
250
251  // Input event handlers.
252  bool OnMouseDown(const pp::MouseInputEvent& event);
253  bool OnMouseUp(const pp::MouseInputEvent& event);
254  bool OnMouseMove(const pp::MouseInputEvent& event);
255  bool OnKeyDown(const pp::KeyboardInputEvent& event);
256  bool OnKeyUp(const pp::KeyboardInputEvent& event);
257  bool OnChar(const pp::KeyboardInputEvent& event);
258
259  FPDF_DOCUMENT CreateSinglePageRasterPdf(
260      double source_page_width,
261      double source_page_height,
262      const PP_PrintSettings_Dev& print_settings,
263      PDFiumPage* page_to_print);
264
265  pp::Buffer_Dev PrintPagesAsRasterPDF(
266      const PP_PrintPageNumberRange_Dev* page_ranges,
267      uint32_t page_range_count,
268      const PP_PrintSettings_Dev& print_settings);
269
270  pp::Buffer_Dev PrintPagesAsPDF(const PP_PrintPageNumberRange_Dev* page_ranges,
271                                 uint32_t page_range_count,
272                                 const PP_PrintSettings_Dev& print_settings);
273
274  pp::Buffer_Dev GetFlattenedPrintData(const FPDF_DOCUMENT& doc);
275  void FitContentsToPrintableAreaIfRequired(
276      const FPDF_DOCUMENT& doc,
277      const PP_PrintSettings_Dev& print_settings);
278  void SaveSelectedFormForPrint();
279
280  // Given a mouse event, returns which page and character location it's closest
281  // to.
282  PDFiumPage::Area GetCharIndex(const pp::MouseInputEvent& event,
283                                int* page_index,
284                                int* char_index,
285                                PDFiumPage::LinkTarget* target);
286  PDFiumPage::Area GetCharIndex(const pp::Point& point,
287                                int* page_index,
288                                int* char_index,
289                                PDFiumPage::LinkTarget* target);
290
291  void OnSingleClick(int page_index, int char_index);
292  void OnMultipleClick(int click_count, int page_index, int char_index);
293
294  // Starts a progressive paint operation given a rectangle in screen
295  // coordinates. Returns the index in progressive_rects_.
296  int StartPaint(int page_index, const pp::Rect& dirty);
297
298  // Continues a paint operation that was started earlier.  Returns true if the
299  // paint is done, or false if it needs to be continued.
300  bool ContinuePaint(int progressive_index, pp::ImageData* image_data);
301
302  // Called once PDFium is finished rendering a page so that we draw our
303  // borders, highlighting etc.
304  void FinishPaint(int progressive_index, pp::ImageData* image_data);
305
306  // Stops any paints that are in progress.
307  void CancelPaints();
308
309  // Invalidates all pages. Use this when some global parameter, such as page
310  // orientation, has changed.
311  void InvalidateAllPages();
312
313  // If the page is narrower than the document size, paint the extra space
314  // with the page background.
315  void FillPageSides(int progressive_index);
316
317  void PaintPageShadow(int progressive_index, pp::ImageData* image_data);
318
319  // Highlight visible find results and selections.
320  void DrawSelections(int progressive_index, pp::ImageData* image_data);
321
322  // Paints an page that hasn't finished downloading.
323  void PaintUnavailablePage(int page_index,
324                            const pp::Rect& dirty,
325                            pp::ImageData* image_data);
326
327  // Given a page index, returns the corresponding index in progressive_rects_,
328  // or -1 if it doesn't exist.
329  int GetProgressiveIndex(int page_index) const;
330
331  // Creates a FPDF_BITMAP from a rectangle in screen coordinates.
332  FPDF_BITMAP CreateBitmap(const pp::Rect& rect,
333                           pp::ImageData* image_data) const;
334
335  // Given a rectangle in screen coordinates, returns the coordinates in the
336  // units that PDFium rendering functions expect.
337  void GetPDFiumRect(int page_index, const pp::Rect& rect, int* start_x,
338                     int* start_y, int* size_x, int* size_y) const;
339
340  // Returns the rendering flags to pass to PDFium.
341  int GetRenderingFlags() const;
342
343  // Returns the currently visible rectangle in document coordinates.
344  pp::Rect GetVisibleRect() const;
345
346  // Returns a page's rect in screen coordinates, as well as its surrounding
347  // border areas and bottom separator.
348  pp::Rect GetPageScreenRect(int page_index) const;
349
350  // Given a rectangle in document coordinates, returns the rectange into screen
351  // coordinates (i.e. 0,0 is top left corner of plugin area).  If it's not
352  // visible, an empty rectangle is returned.
353  pp::Rect GetScreenRect(const pp::Rect& rect) const;
354
355  // Highlights the given rectangle.
356  void Highlight(void* buffer,
357                 int stride,
358                 const pp::Rect& rect,
359                 std::vector<pp::Rect>* highlighted_rects);
360
361  // Helper function to convert a device to page coordinates.  If the page is
362  // not yet loaded, page_x and page_y will be set to 0.
363  void DeviceToPage(int page_index,
364                    float device_x,
365                    float device_y,
366                    double* page_x,
367                    double* page_y);
368
369  // Helper function to get the index of a given FPDF_PAGE.  Returns -1 if not
370  // found.
371  int GetVisiblePageIndex(FPDF_PAGE page);
372
373  // Helper function to change the current page, running page open/close
374  // triggers as necessary.
375  void SetCurrentPage(int index);
376
377  // Transform |page| contents to fit in the selected printer paper size.
378  void TransformPDFPageForPrinting(FPDF_PAGE page,
379                                   const PP_PrintSettings_Dev& print_settings);
380
381  void DrawPageShadow(const pp::Rect& page_rect,
382                      const pp::Rect& shadow_rect,
383                      const pp::Rect& clip_rect,
384                      pp::ImageData* image_data);
385
386  void GetRegion(const pp::Point& location,
387                 pp::ImageData* image_data,
388                 void** region,
389                 int* stride) const;
390
391  // Called when the selection changes.
392  void OnSelectionChanged();
393
394  // FPDF_FORMFILLINFO callbacks.
395  static void Form_Invalidate(FPDF_FORMFILLINFO* param,
396                              FPDF_PAGE page,
397                              double left,
398                              double top,
399                              double right,
400                              double bottom);
401  static void Form_OutputSelectedRect(FPDF_FORMFILLINFO* param,
402                                      FPDF_PAGE page,
403                                      double left,
404                                      double top,
405                                      double right,
406                                      double bottom);
407  static void Form_SetCursor(FPDF_FORMFILLINFO* param, int cursor_type);
408  static int Form_SetTimer(FPDF_FORMFILLINFO* param,
409                           int elapse,
410                           TimerCallback timer_func);
411  static void Form_KillTimer(FPDF_FORMFILLINFO* param, int timer_id);
412  static FPDF_SYSTEMTIME Form_GetLocalTime(FPDF_FORMFILLINFO* param);
413  static void Form_OnChange(FPDF_FORMFILLINFO* param);
414  static FPDF_PAGE Form_GetPage(FPDF_FORMFILLINFO* param,
415                                FPDF_DOCUMENT document,
416                                int page_index);
417  static FPDF_PAGE Form_GetCurrentPage(FPDF_FORMFILLINFO* param,
418                                       FPDF_DOCUMENT document);
419  static int Form_GetRotation(FPDF_FORMFILLINFO* param, FPDF_PAGE page);
420  static void Form_ExecuteNamedAction(FPDF_FORMFILLINFO* param,
421                                      FPDF_BYTESTRING named_action);
422  static void Form_SetTextFieldFocus(FPDF_FORMFILLINFO* param,
423                                     FPDF_WIDESTRING value,
424                                     FPDF_DWORD valueLen,
425                                     FPDF_BOOL is_focus);
426  static void Form_DoURIAction(FPDF_FORMFILLINFO* param, FPDF_BYTESTRING uri);
427  static void Form_DoGoToAction(FPDF_FORMFILLINFO* param,
428                                int page_index,
429                                int zoom_mode,
430                                float* position_array,
431                                int size_of_array);
432
433  // IPDF_JSPLATFORM callbacks.
434  static int Form_Alert(IPDF_JSPLATFORM* param,
435                        FPDF_WIDESTRING message,
436                        FPDF_WIDESTRING title,
437                        int type,
438                        int icon);
439  static void Form_Beep(IPDF_JSPLATFORM* param, int type);
440  static int Form_Response(IPDF_JSPLATFORM* param,
441                           FPDF_WIDESTRING question,
442                           FPDF_WIDESTRING title,
443                           FPDF_WIDESTRING default_response,
444                           FPDF_WIDESTRING label,
445                           FPDF_BOOL password,
446                           void* response,
447                           int length);
448  static int Form_GetFilePath(IPDF_JSPLATFORM* param,
449                              void* file_path,
450                              int length);
451  static void Form_Mail(IPDF_JSPLATFORM* param,
452                        void* mail_data,
453                        int length,
454                        FPDF_BOOL ui,
455                        FPDF_WIDESTRING to,
456                        FPDF_WIDESTRING subject,
457                        FPDF_WIDESTRING cc,
458                        FPDF_WIDESTRING bcc,
459                        FPDF_WIDESTRING message);
460  static void Form_Print(IPDF_JSPLATFORM* param,
461                         FPDF_BOOL ui,
462                         int start,
463                         int end,
464                         FPDF_BOOL silent,
465                         FPDF_BOOL shrink_to_fit,
466                         FPDF_BOOL print_as_image,
467                         FPDF_BOOL reverse,
468                         FPDF_BOOL annotations);
469  static void Form_SubmitForm(IPDF_JSPLATFORM* param,
470                              void* form_data,
471                              int length,
472                              FPDF_WIDESTRING url);
473  static void Form_GotoPage(IPDF_JSPLATFORM* param, int page_number);
474  static int Form_Browse(IPDF_JSPLATFORM* param, void* file_path, int length);
475
476  // IFSDK_PAUSE callbacks
477  static FPDF_BOOL Pause_NeedToPauseNow(IFSDK_PAUSE* param);
478
479  PDFEngine::Client* client_;
480  pp::Size document_size_;  // Size of document in pixels.
481
482  // The scroll position in screen coordinates.
483  pp::Point position_;
484  // The offset of the page into the viewport.
485  pp::Point page_offset_;
486  // The plugin size in screen coordinates.
487  pp::Size plugin_size_;
488  double current_zoom_;
489  unsigned int current_rotation_;
490
491  DocumentLoader doc_loader_;  // Main document's loader.
492  std::string url_;
493  std::string headers_;
494  pp::CompletionCallbackFactory<PDFiumEngine> find_factory_;
495
496  pp::CompletionCallbackFactory<PDFiumEngine> password_factory_;
497  int32_t password_tries_remaining_;
498
499  // The current text used for searching.
500  std::string current_find_text_;
501
502  // The PDFium wrapper object for the document.
503  FPDF_DOCUMENT doc_;
504
505  // The PDFium wrapper for form data.  Used even if there are no form controls
506  // on the page.
507  FPDF_FORMHANDLE form_;
508
509  // The page(s) of the document. Store a vector of pointers so that when the
510  // vector is resized we don't close the pages that are used in pending
511  // paints.
512  std::vector<PDFiumPage*> pages_;
513
514  // The indexes of the pages currently visible.
515  std::vector<int> visible_pages_;
516
517  // The indexes of the pages pending download.
518  std::vector<int> pending_pages_;
519
520  // During handling of input events we don't want to unload any pages in
521  // callbacks to us from PDFium, since the current page can change while PDFium
522  // code still has a pointer to it.
523  bool defer_page_unload_;
524  std::vector<int> deferred_page_unloads_;
525
526  // Used for selection.  There could be more than one range if selection spans
527  // more than one page.
528  std::vector<PDFiumRange> selection_;
529  // True if we're in the middle of selection.
530  bool selecting_;
531
532  MouseDownState mouse_down_state_;
533
534  // Used for searching.
535  typedef std::vector<PDFiumRange> FindResults;
536  FindResults find_results_;
537  // Which page to search next.
538  int next_page_to_search_;
539  // Where to stop searching.
540  int last_page_to_search_;
541  int last_character_index_to_search_;  // -1 if search until end of page.
542  // Which result the user has currently selected.
543  int current_find_index_;
544
545  // Permissions bitfield.
546  unsigned long permissions_;
547
548  // Interface structure to provide access to document stream.
549  FPDF_FILEACCESS file_access_;
550  // Interface structure to check data availability in the document stream.
551  FileAvail file_availability_;
552  // Interface structure to request data chunks from the document stream.
553  DownloadHints download_hints_;
554  // Pointer to the document availability interface.
555  FPDF_AVAIL fpdf_availability_;
556
557  pp::Size default_page_size_;
558
559  // Used to manage timers that form fill API needs.  The pair holds the timer
560  // period, in ms, and the callback function.
561  std::map<int, std::pair<int, TimerCallback> > timers_;
562  int next_timer_id_;
563
564  // Holds the page index of the last page that the mouse clicked on.
565  int last_page_mouse_down_;
566
567  // Holds the page index of the first visible page; refreshed by calling
568  // CalculateVisiblePages()
569  int first_visible_page_;
570
571  // Holds the page index of the most visible page; refreshed by calling
572  // CalculateVisiblePages()
573  int most_visible_page_;
574
575  // Set to true after FORM_DoDocumentJSAction/FORM_DoDocumentOpenAction have
576  // been called. Only after that can we call FORM_DoPageAAction.
577  bool called_do_document_action_;
578
579  // Records parts of form fields that need to be highlighted at next paint, in
580  // screen coordinates.
581  std::vector<pp::Rect> form_highlights_;
582
583  // Whether to render in grayscale or in color.
584  bool render_grayscale_;
585
586  // The link currently under the cursor.
587  std::string link_under_cursor_;
588
589  // Pending progressive paints.
590  struct ProgressivePaint {
591    pp::Rect rect;  // In screen coordinates.
592    FPDF_BITMAP bitmap;
593    int page_index;
594    // Temporary used to figure out if in a series of Paint() calls whether this
595    // pending paint was updated or not.
596    int painted_;
597  };
598  std::vector<ProgressivePaint> progressive_paints_;
599
600  // Keeps track of when we started the last progressive paint, so that in our
601  // callback we can determine if we need to pause.
602  base::Time last_progressive_start_time_;
603
604  // The timeout to use for the current progressive paint.
605  int progressive_paint_timeout_;
606
607  // Shadow matrix for generating the page shadow bitmap.
608  scoped_ptr<ShadowMatrix> page_shadow_;
609
610  // Set to true if the user is being prompted for their password. Will be set
611  // to false after the user finishes getting their password.
612  bool getting_password_;
613};
614
615// Create a local variable of this when calling PDFium functions which can call
616// our global callback when an unsupported feature is reached.
617class ScopedUnsupportedFeature {
618 public:
619  explicit ScopedUnsupportedFeature(PDFiumEngine* engine);
620  ~ScopedUnsupportedFeature();
621 private:
622  PDFiumEngine* engine_;
623  PDFiumEngine* old_engine_;
624};
625
626class PDFiumEngineExports : public PDFEngineExports {
627 public:
628  PDFiumEngineExports() {}
629#if defined(OS_WIN)
630  // See the definition of RenderPDFPageToDC in pdf.cc for details.
631  virtual bool RenderPDFPageToDC(const void* pdf_buffer,
632                                 int buffer_size,
633                                 int page_number,
634                                 const RenderingSettings& settings,
635                                 HDC dc);
636#endif  // OS_WIN
637  virtual bool RenderPDFPageToBitmap(const void* pdf_buffer,
638                                     int pdf_buffer_size,
639                                     int page_number,
640                                     const RenderingSettings& settings,
641                                     void* bitmap_buffer);
642
643  virtual bool GetPDFDocInfo(const void* pdf_buffer,
644                             int buffer_size,
645                             int* page_count,
646                             double* max_page_width);
647
648  // See the definition of GetPDFPageSizeByIndex in pdf.cc for details.
649  virtual bool GetPDFPageSizeByIndex(const void* pdf_buffer,
650                                     int pdf_buffer_size, int page_number,
651                                     double* width, double* height);
652};
653
654}  // namespace chrome_pdf
655
656#endif  // PDF_PDFIUM_PDFIUM_ENGINE_H_
657