1635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project/* 28f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian * Copyright (C) 2009 Google Inc. All rights reserved. 38f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian * 4635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * Redistribution and use in source and binary forms, with or without 5635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * modification, are permitted provided that the following conditions are 6635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * met: 78f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian * 8635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * * Redistributions of source code must retain the above copyright 9635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * notice, this list of conditions and the following disclaimer. 10635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * * Redistributions in binary form must reproduce the above 11635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * copyright notice, this list of conditions and the following disclaimer 12635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * in the documentation and/or other materials provided with the 13635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * distribution. 14635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * * Neither the name of Google Inc. nor the names of its 15635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * contributors may be used to endorse or promote products derived from 16635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * this software without specific prior written permission. 178f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian * 18635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project */ 30635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 31643ca7872b450ea4efacab6188849e5aac2ba161Steve Block#ifndef WebPlugin_h 32643ca7872b450ea4efacab6188849e5aac2ba161Steve Block#define WebPlugin_h 33635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 34643ca7872b450ea4efacab6188849e5aac2ba161Steve Block#include "WebCanvas.h" 35ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24Steve Block#include "WebString.h" 36a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch#include "WebURL.h" 37635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 38643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockstruct NPObject; 39635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 40643ca7872b450ea4efacab6188849e5aac2ba161Steve Blocknamespace WebKit { 418f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian 42643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockclass WebDataSource; 43643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockclass WebFrame; 44643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockclass WebInputEvent; 45643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockclass WebPluginContainer; 46643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockclass WebURLResponse; 47643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockstruct WebCursorInfo; 48643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockstruct WebPluginParams; 49a94275402997c11dd2e778633dacf4b7e630a35dBen Murdochstruct WebPoint; 50643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockstruct WebRect; 51643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockstruct WebURLError; 52643ca7872b450ea4efacab6188849e5aac2ba161Steve Blocktemplate <typename T> class WebVector; 53635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 54643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockclass WebPlugin { 55643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockpublic: 56643ca7872b450ea4efacab6188849e5aac2ba161Steve Block virtual bool initialize(WebPluginContainer*) = 0; 57643ca7872b450ea4efacab6188849e5aac2ba161Steve Block virtual void destroy() = 0; 58643ca7872b450ea4efacab6188849e5aac2ba161Steve Block 59643ca7872b450ea4efacab6188849e5aac2ba161Steve Block virtual NPObject* scriptableObject() = 0; 60643ca7872b450ea4efacab6188849e5aac2ba161Steve Block 61643ca7872b450ea4efacab6188849e5aac2ba161Steve Block virtual void paint(WebCanvas*, const WebRect&) = 0; 62643ca7872b450ea4efacab6188849e5aac2ba161Steve Block 63643ca7872b450ea4efacab6188849e5aac2ba161Steve Block // Coordinates are relative to the containing window. 64643ca7872b450ea4efacab6188849e5aac2ba161Steve Block virtual void updateGeometry( 65643ca7872b450ea4efacab6188849e5aac2ba161Steve Block const WebRect& frameRect, const WebRect& clipRect, 66643ca7872b450ea4efacab6188849e5aac2ba161Steve Block const WebVector<WebRect>& cutOutsRects, bool isVisible) = 0; 67643ca7872b450ea4efacab6188849e5aac2ba161Steve Block 68643ca7872b450ea4efacab6188849e5aac2ba161Steve Block virtual void updateFocus(bool) = 0; 69643ca7872b450ea4efacab6188849e5aac2ba161Steve Block virtual void updateVisibility(bool) = 0; 708f72e70a9fd78eec56623b3a62e68f16b7b27e28Feng Qian 71643ca7872b450ea4efacab6188849e5aac2ba161Steve Block virtual bool acceptsInputEvents() = 0; 72643ca7872b450ea4efacab6188849e5aac2ba161Steve Block virtual bool handleInputEvent(const WebInputEvent&, WebCursorInfo&) = 0; 73635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 74643ca7872b450ea4efacab6188849e5aac2ba161Steve Block virtual void didReceiveResponse(const WebURLResponse&) = 0; 75643ca7872b450ea4efacab6188849e5aac2ba161Steve Block virtual void didReceiveData(const char* data, int dataLength) = 0; 76643ca7872b450ea4efacab6188849e5aac2ba161Steve Block virtual void didFinishLoading() = 0; 77643ca7872b450ea4efacab6188849e5aac2ba161Steve Block virtual void didFailLoading(const WebURLError&) = 0; 78643ca7872b450ea4efacab6188849e5aac2ba161Steve Block 79643ca7872b450ea4efacab6188849e5aac2ba161Steve Block // Called in response to WebPluginContainer::loadFrameRequest 80643ca7872b450ea4efacab6188849e5aac2ba161Steve Block virtual void didFinishLoadingFrameRequest( 81643ca7872b450ea4efacab6188849e5aac2ba161Steve Block const WebURL&, void* notifyData) = 0; 82643ca7872b450ea4efacab6188849e5aac2ba161Steve Block virtual void didFailLoadingFrameRequest( 83643ca7872b450ea4efacab6188849e5aac2ba161Steve Block const WebURL&, void* notifyData, const WebURLError&) = 0; 84643ca7872b450ea4efacab6188849e5aac2ba161Steve Block 85dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block // Printing interface. 86dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block // Whether the plugin supports its own paginated print. The other print 87dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block // interface methods are called only if this method returns true. 88dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block virtual bool supportsPaginatedPrint() { return false; } 89dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block // Sets up printing at the given print rect and printer DPI. printableArea 90dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block // is in points (a point is 1/72 of an inch).Returns the number of pages to 91dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block // be printed at these settings. 92dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block virtual int printBegin(const WebRect& printableArea, int printerDPI) { return 0; } 93dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block // Prints the page specified by pageNumber (0-based index) into the supplied canvas. 94dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block virtual bool printPage(int pageNumber, WebCanvas* canvas) { return false; } 95dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block // Ends the print operation. 96dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block virtual void printEnd() { } 97dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 98e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke virtual bool hasSelection() const { return false; } 99e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke virtual WebString selectionAsText() const { return WebString(); } 100e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke virtual WebString selectionAsMarkup() const { return WebString(); } 101e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke 102a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // If the given position is over a link, returns the absolute url. 103a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // Otherwise an empty url is returned. 104a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual WebURL linkAtPosition(const WebPoint& position) const { return WebURL(); } 105a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch 106e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke // Used for zooming of full page plugins. 107a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch virtual void setZoomLevel(double level, bool textOnly) { } 108e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke 109e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke // Find interface. 110e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke // Start a new search. The plugin should search for a little bit at a time so that it 111e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke // doesn't block the thread in case of a large document. The results, along with the 112e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke // find's identifier, should be sent asynchronously to WebFrameClient's reportFindInPage* methods. 113e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke // Returns true if the search started, or false if the plugin doesn't support search. 114e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke virtual bool startFind(const WebString& searchText, bool caseSensitive, int identifier) { return false; } 115e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke // Tells the plugin to jump forward or backward in the list of find results. 116e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke virtual void selectFindResult(bool forward) { } 117e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke // Tells the plugin that the user has stopped the find operation. 118e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke virtual void stopFind() { } 119ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24Steve Block 120643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockprotected: 121643ca7872b450ea4efacab6188849e5aac2ba161Steve Block ~WebPlugin() { } 122643ca7872b450ea4efacab6188849e5aac2ba161Steve Block}; 123643ca7872b450ea4efacab6188849e5aac2ba161Steve Block 124643ca7872b450ea4efacab6188849e5aac2ba161Steve Block} // namespace WebKit 125643ca7872b450ea4efacab6188849e5aac2ba161Steve Block 126643ca7872b450ea4efacab6188849e5aac2ba161Steve Block#endif 127