1 /* 2 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #ifndef WebPlugin_h 32 #define WebPlugin_h 33 34 #include "WebCanvas.h" 35 #include "WebString.h" 36 #include "WebURL.h" 37 38 struct NPObject; 39 40 namespace WebKit { 41 42 class WebDataSource; 43 class WebFrame; 44 class WebInputEvent; 45 class WebPluginContainer; 46 class WebURLResponse; 47 struct WebCursorInfo; 48 struct WebPluginParams; 49 struct WebPoint; 50 struct WebRect; 51 struct WebURLError; 52 template <typename T> class WebVector; 53 54 class WebPlugin { 55 public: 56 virtual bool initialize(WebPluginContainer*) = 0; 57 virtual void destroy() = 0; 58 59 virtual NPObject* scriptableObject() = 0; 60 61 virtual void paint(WebCanvas*, const WebRect&) = 0; 62 63 // Coordinates are relative to the containing window. 64 virtual void updateGeometry( 65 const WebRect& frameRect, const WebRect& clipRect, 66 const WebVector<WebRect>& cutOutsRects, bool isVisible) = 0; 67 68 virtual void updateFocus(bool) = 0; 69 virtual void updateVisibility(bool) = 0; 70 71 virtual bool acceptsInputEvents() = 0; 72 virtual bool handleInputEvent(const WebInputEvent&, WebCursorInfo&) = 0; 73 74 virtual void didReceiveResponse(const WebURLResponse&) = 0; 75 virtual void didReceiveData(const char* data, int dataLength) = 0; 76 virtual void didFinishLoading() = 0; 77 virtual void didFailLoading(const WebURLError&) = 0; 78 79 // Called in response to WebPluginContainer::loadFrameRequest 80 virtual void didFinishLoadingFrameRequest( 81 const WebURL&, void* notifyData) = 0; 82 virtual void didFailLoadingFrameRequest( 83 const WebURL&, void* notifyData, const WebURLError&) = 0; 84 85 // Printing interface. 86 // Whether the plugin supports its own paginated print. The other print 87 // interface methods are called only if this method returns true. supportsPaginatedPrint()88 virtual bool supportsPaginatedPrint() { return false; } 89 // Sets up printing at the given print rect and printer DPI. printableArea 90 // is in points (a point is 1/72 of an inch).Returns the number of pages to 91 // be printed at these settings. printBegin(const WebRect & printableArea,int printerDPI)92 virtual int printBegin(const WebRect& printableArea, int printerDPI) { return 0; } 93 // Prints the page specified by pageNumber (0-based index) into the supplied canvas. printPage(int pageNumber,WebCanvas * canvas)94 virtual bool printPage(int pageNumber, WebCanvas* canvas) { return false; } 95 // Ends the print operation. printEnd()96 virtual void printEnd() { } 97 hasSelection()98 virtual bool hasSelection() const { return false; } selectionAsText()99 virtual WebString selectionAsText() const { return WebString(); } selectionAsMarkup()100 virtual WebString selectionAsMarkup() const { return WebString(); } 101 102 // If the given position is over a link, returns the absolute url. 103 // Otherwise an empty url is returned. linkAtPosition(const WebPoint & position)104 virtual WebURL linkAtPosition(const WebPoint& position) const { return WebURL(); } 105 106 // Used for zooming of full page plugins. setZoomLevel(double level,bool textOnly)107 virtual void setZoomLevel(double level, bool textOnly) { } 108 109 // Find interface. 110 // Start a new search. The plugin should search for a little bit at a time so that it 111 // doesn't block the thread in case of a large document. The results, along with the 112 // find's identifier, should be sent asynchronously to WebFrameClient's reportFindInPage* methods. 113 // Returns true if the search started, or false if the plugin doesn't support search. startFind(const WebString & searchText,bool caseSensitive,int identifier)114 virtual bool startFind(const WebString& searchText, bool caseSensitive, int identifier) { return false; } 115 // Tells the plugin to jump forward or backward in the list of find results. selectFindResult(bool forward)116 virtual void selectFindResult(bool forward) { } 117 // Tells the plugin that the user has stopped the find operation. stopFind()118 virtual void stopFind() { } 119 120 protected: ~WebPlugin()121 ~WebPlugin() { } 122 }; 123 124 } // namespace WebKit 125 126 #endif 127