1cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// found in the LICENSE file. 4cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 5cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#ifndef PDF_PDF_ENGINE_H_ 6cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#define PDF_PDF_ENGINE_H_ 7cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 8cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "build/build_config.h" 9cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 10cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#if defined(OS_WIN) 11cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include <windows.h> 12cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#endif 13cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 14cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include <string> 15cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include <vector> 16cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 17cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "base/strings/string16.h" 18cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 19cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "ppapi/c/dev/pp_cursor_type_dev.h" 20cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "ppapi/c/dev/ppp_printing_dev.h" 21cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "ppapi/c/ppb_input_event.h" 22cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "ppapi/cpp/completion_callback.h" 23cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "ppapi/cpp/image_data.h" 24cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "ppapi/cpp/rect.h" 25cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "ppapi/cpp/size.h" 26cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "ppapi/cpp/url_loader.h" 27cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 28cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)namespace pp { 29cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)class InputEvent; 30cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)} 31cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 32116680a4aac90f2aa7413d9095a592090648e557Ben Murdochconst uint32 kBackgroundColor = 0xFFCCCCCC; 33cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 34cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)namespace chrome_pdf { 35cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 36cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)class Stream; 37cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 38cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#if defined(OS_MACOSX) 39cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)const uint32 kDefaultKeyModifier = PP_INPUTEVENT_MODIFIER_METAKEY; 40cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#else // !OS_MACOSX 41cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)const uint32 kDefaultKeyModifier = PP_INPUTEVENT_MODIFIER_CONTROLKEY; 42cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#endif // OS_MACOSX 43cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 44cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// Do one time initialization of the SDK. data is platform specific, on Windows 45cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// it's the instance of the DLL and it's unused on other platforms. 46cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)bool InitializeSDK(void* data); 47cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// Tells the SDK that we're shutting down. 48cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)void ShutdownSDK(); 49cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 50cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// This class encapsulates a PDF rendering engine. 51cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)class PDFEngine { 52cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) public: 53cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 54cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) enum DocumentPermission { 55cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) PERMISSION_COPY, 56cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) PERMISSION_COPY_ACCESSIBLE, 57cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) PERMISSION_PRINT_LOW_QUALITY, 58cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) PERMISSION_PRINT_HIGH_QUALITY, 59cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) }; 60cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 61cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // The interface that's provided to the rendering engine. 62cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) class Client { 63cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) public: 64cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Informs the client about the document's size in pixels. 65cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void DocumentSizeUpdated(const pp::Size& size) = 0; 66cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 67cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Informs the client that the given rect needs to be repainted. 68cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void Invalidate(const pp::Rect& rect) = 0; 69cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 70cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Informs the client to scroll the plugin area by the given offset. 71cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void Scroll(const pp::Point& point) = 0; 72cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 73cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Scroll the horizontal/vertical scrollbars to a given position. 74cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void ScrollToX(int position) = 0; 75cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void ScrollToY(int position) = 0; 76cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 77cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Scroll to the specified page. 78cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void ScrollToPage(int page) = 0; 79cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 80cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Navigate to the given url. 81cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void NavigateTo(const std::string& url, bool open_in_new_tab) = 0; 82cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 83cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Updates the cursor. 84cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void UpdateCursor(PP_CursorType_Dev cursor) = 0; 85cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 86cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Updates the tick marks in the vertical scrollbar. 87cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void UpdateTickMarks(const std::vector<pp::Rect>& tickmarks) = 0; 88cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 89cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Updates the number of find results for the current search term. If 90cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // there are no matches 0 should be passed in. Only when the plugin has 91cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // finished searching should it pass in the final count with final_result 92cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // set to true. 93cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void NotifyNumberOfFindResultsChanged(int total, 94cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) bool final_result) = 0; 95cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 96cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Updates the index of the currently selected search item. 97cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void NotifySelectedFindResultChanged(int current_find_index) = 0; 98cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 99cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Prompts the user for a password to open this document. The callback is 100cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // called when the password is retrieved. 101cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void GetDocumentPassword( 102cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) pp::CompletionCallbackWithOutput<pp::Var> callback) = 0; 103cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 104cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Puts up an alert with the given message. 105cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void Alert(const std::string& message) = 0; 106cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 107cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Puts up a confirm with the given message, and returns true if the user 108cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // presses OK, or false if they press cancel. 109cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual bool Confirm(const std::string& message) = 0; 110cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 111cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Puts up a prompt with the given message and default answer and returns 112cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // the answer. 113cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual std::string Prompt(const std::string& question, 114cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const std::string& default_answer) = 0; 115cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 116cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Returns the url of the pdf. 117cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual std::string GetURL() = 0; 118cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 119cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Send an email. 120cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void Email(const std::string& to, 121cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const std::string& cc, 122cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const std::string& bcc, 123cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const std::string& subject, 124cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const std::string& body) = 0; 125cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 126cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Put up the print dialog. 127cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void Print() = 0; 128cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 129cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Submit the data using HTTP POST. 130cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void SubmitForm(const std::string& url, 131cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const void* data, 132cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) int length) = 0; 133cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 134cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Pops up a file selection dialog and returns the result. 135cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual std::string ShowFileSelectionDialog() = 0; 136cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 137cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Creates and returns new URL loader for partial document requests. 138cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual pp::URLLoader CreateURLLoader() = 0; 139cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 140cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Calls the client's OnCallback() function in delay_in_ms with the given 141cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // id. 142cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void ScheduleCallback(int id, int delay_in_ms) = 0; 143cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 144cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Searches the given string for "term" and returns the results. Unicode- 145cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // aware. 146cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) struct SearchStringResult { 147cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) int start_index; 148cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) int length; 149cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) }; 150cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void SearchString(const base::char16* string, 151cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const base::char16* term, 152cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) bool case_sensitive, 153cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) std::vector<SearchStringResult>* results) = 0; 154cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 155cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Notifies the client that the engine has painted a page from the document. 156cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void DocumentPaintOccurred() = 0; 157cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 158cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Notifies the client that the document has finished loading. 159cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void DocumentLoadComplete(int page_count) = 0; 160cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 161cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Notifies the client that the document has failed to load. 162cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void DocumentLoadFailed() = 0; 163cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 164cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual pp::Instance* GetPluginInstance() = 0; 165cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 166cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Notifies that an unsupported feature in the PDF was encountered. 167cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void DocumentHasUnsupportedFeature(const std::string& feature) = 0; 168cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 169cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Notifies the client about document load progress. 170cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void DocumentLoadProgress(uint32 available, uint32 doc_size) = 0; 171cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 172cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Notifies the client about focus changes for form text fields. 173cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void FormTextFieldFocusChange(bool in_focus) = 0; 174cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 175cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Returns true if the plugin has been opened within print preview. 176cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual bool IsPrintPreview() = 0; 177cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) }; 178cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 179cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Factory method to create an instance of the PDF Engine. 180cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) static PDFEngine* Create(Client* client); 181cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 182cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual ~PDFEngine() {} 183cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Most of these functions are similar to the Pepper functions of the same 184cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // name, so not repeating the description here unless it's different. 185cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual bool New(const char* url) = 0; 186cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual bool New(const char* url, 187cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const char* headers) = 0; 188cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void PageOffsetUpdated(const pp::Point& page_offset) = 0; 189cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void PluginSizeUpdated(const pp::Size& size) = 0; 190cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void ScrolledToXPosition(int position) = 0; 191cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void ScrolledToYPosition(int position) = 0; 192cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Paint is called a series of times. Before these n calls are made, PrePaint 193cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // is called once. After Paint is called n times, PostPaint is called once. 194cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void PrePaint() = 0; 195cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void Paint(const pp::Rect& rect, 196cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) pp::ImageData* image_data, 197cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) std::vector<pp::Rect>* ready, 198cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) std::vector<pp::Rect>* pending) = 0; 199cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void PostPaint() = 0; 200cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual bool HandleDocumentLoad(const pp::URLLoader& loader) = 0; 201cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual bool HandleEvent(const pp::InputEvent& event) = 0; 202cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual uint32_t QuerySupportedPrintOutputFormats() = 0; 203cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void PrintBegin() = 0; 204cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual pp::Resource PrintPages( 205cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const PP_PrintPageNumberRange_Dev* page_ranges, 206cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) uint32_t page_range_count, 207cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const PP_PrintSettings_Dev& print_settings) = 0; 208cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void PrintEnd() = 0; 209cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void StartFind(const char* text, bool case_sensitive) = 0; 210cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual bool SelectFindResult(bool forward) = 0; 211cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void StopFind() = 0; 212cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void ZoomUpdated(double new_zoom_level) = 0; 213cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void RotateClockwise() = 0; 214cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void RotateCounterclockwise() = 0; 215cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual std::string GetSelectedText() = 0; 216cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual std::string GetLinkAtPosition(const pp::Point& point) = 0; 217cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual bool IsSelecting() = 0; 218cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Checks the permissions associated with this document. 219cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual bool HasPermission(DocumentPermission permission) const = 0; 220cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void SelectAll() = 0; 221cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Gets the number of pages in the document. 222cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual int GetNumberOfPages() = 0; 223cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Gets the 0-based page number of |destination|, or -1 if it does not exist. 224cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual int GetNamedDestinationPage(const std::string& destination) = 0; 225cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Gets the index of the first visible page, or -1 if none are visible. 226cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual int GetFirstVisiblePage() = 0; 227cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Gets the index of the most visible page, or -1 if none are visible. 228cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual int GetMostVisiblePage() = 0; 229cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Gets the rectangle of the page including shadow. 230cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual pp::Rect GetPageRect(int index) = 0; 231cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Gets the rectangle of the page excluding any additional areas. 232cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual pp::Rect GetPageContentsRect(int index) = 0; 233cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Gets the offset of the vertical scrollbar from the top in document 234cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // coordinates. 235cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual int GetVerticalScrollbarYPosition() = 0; 236cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Paints page thumbnail to the ImageData. 237cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void PaintThumbnail(pp::ImageData* image_data, int index) = 0; 238cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Set color / grayscale rendering modes. 239cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void SetGrayscale(bool grayscale) = 0; 240cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Callback for timer that's set with ScheduleCallback(). 241cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void OnCallback(int id) = 0; 242cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Gets the JSON representation of the PDF file 243cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual std::string GetPageAsJSON(int index) = 0; 244cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Gets the PDF document's print scaling preference. True if the document can 245cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // be scaled to fit. 246cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual bool GetPrintScaling() = 0; 247cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 248cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Append blank pages to make a 1-page document to a |num_pages| document. 249cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Always retain the first page data. 250cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void AppendBlankPages(int num_pages) = 0; 251cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Append the first page of the document loaded with the |engine| to this 252cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // document at page |index|. 253cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void AppendPage(PDFEngine* engine, int index) = 0; 254cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 255cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Allow client to query and reset scroll positions in document coordinates. 256cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Note that this is meant for cases where the device scale factor changes, 257cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // and not for general scrolling - the engine will not repaint due to this. 258cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual pp::Point GetScrollPosition() = 0; 259cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void SetScrollPosition(const pp::Point& position) = 0; 260cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 261cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual bool IsProgressiveLoad() = 0; 262cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)}; 263cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 264cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// Interface for exports that wrap the PDF engine. 265cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)class PDFEngineExports { 266cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) public: 267cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) struct RenderingSettings { 268cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) RenderingSettings(int dpi_x, 269cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) int dpi_y, 270cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const pp::Rect& bounds, 271cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) bool fit_to_bounds, 272cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) bool stretch_to_bounds, 273cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) bool keep_aspect_ratio, 274cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) bool center_in_bounds, 275cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) bool autorotate) 276cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) : dpi_x(dpi_x), dpi_y(dpi_y), bounds(bounds), 277cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) fit_to_bounds(fit_to_bounds), stretch_to_bounds(stretch_to_bounds), 278cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) keep_aspect_ratio(keep_aspect_ratio), 279cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) center_in_bounds(center_in_bounds), autorotate(autorotate) { 280cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) } 281cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) int dpi_x; 282cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) int dpi_y; 283cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) pp::Rect bounds; 284cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) bool fit_to_bounds; 285cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) bool stretch_to_bounds; 286cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) bool keep_aspect_ratio; 287cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) bool center_in_bounds; 288cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) bool autorotate; 289cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) }; 290cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 291cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) PDFEngineExports() {} 292cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual ~PDFEngineExports() {} 293cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) static PDFEngineExports* Create(); 294cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#if defined(OS_WIN) 295cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // See the definition of RenderPDFPageToDC in pdf.cc for details. 296cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual bool RenderPDFPageToDC(const void* pdf_buffer, 297cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) int buffer_size, 298cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) int page_number, 299cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const RenderingSettings& settings, 300cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) HDC dc) = 0; 301cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#endif // OS_WIN 302cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // See the definition of RenderPDFPageToBitmap in pdf.cc for details. 303cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual bool RenderPDFPageToBitmap(const void* pdf_buffer, 304cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) int pdf_buffer_size, 305cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) int page_number, 306cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const RenderingSettings& settings, 307cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) void* bitmap_buffer) = 0; 308116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 309cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual bool GetPDFDocInfo(const void* pdf_buffer, 310cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) int buffer_size, 311cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) int* page_count, 312cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) double* max_page_width) = 0; 313116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 314116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // See the definition of GetPDFPageSizeByIndex in pdf.cc for details. 315116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual bool GetPDFPageSizeByIndex(const void* pdf_buffer, 316116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch int pdf_buffer_size, int page_number, 317116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch double* width, double* height) = 0; 318cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)}; 319cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 320cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)} // namespace chrome_pdf 321cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 322cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#endif // PDF_PDF_ENGINE_H_ 323