2 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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
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.
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.
34 #include "WebCanvas.h"
35 #include "WebString.h"
45 class WebPluginContainer;
48 struct WebPluginParams;
52 template <typename T> class WebVector;
56 virtual bool initialize(WebPluginContainer*) = 0;
57 virtual void destroy() = 0;
59 virtual NPObject* scriptableObject() = 0;
61 virtual void paint(WebCanvas*, const WebRect&) = 0;
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;
68 // If the plugin instance is backed by an OpenGL texture, return its ID in the
69 // compositors namespace. Otherwise return 0. Returns 0 by default.
70 virtual unsigned getBackingTextureId() { return 0; }
72 virtual void updateFocus(bool) = 0;
73 virtual void updateVisibility(bool) = 0;
75 virtual bool acceptsInputEvents() = 0;
76 virtual bool handleInputEvent(const WebInputEvent&, WebCursorInfo&) = 0;
78 virtual void didReceiveResponse(const WebURLResponse&) = 0;
79 virtual void didReceiveData(const char* data, int dataLength) = 0;
80 virtual void didFinishLoading() = 0;
81 virtual void didFailLoading(const WebURLError&) = 0;
83 // Called in response to WebPluginContainer::loadFrameRequest
84 virtual void didFinishLoadingFrameRequest(
85 const WebURL&, void* notifyData) = 0;
86 virtual void didFailLoadingFrameRequest(
87 const WebURL&, void* notifyData, const WebURLError&) = 0;
89 // Printing interface.
90 // Whether the plugin supports its own paginated print. The other print
91 // interface methods are called only if this method returns true.
92 virtual bool supportsPaginatedPrint() { return false; }
93 // Sets up printing at the given print rect and printer DPI. printableArea
94 // is in points (a point is 1/72 of an inch).Returns the number of pages to
95 // be printed at these settings.
96 virtual int printBegin(const WebRect& printableArea, int printerDPI) { return 0; }
97 // Prints the page specified by pageNumber (0-based index) into the supplied canvas.
98 virtual bool printPage(int pageNumber, WebCanvas* canvas) { return false; }
99 // Ends the print operation.
100 virtual void printEnd() { }
102 virtual bool hasSelection() const { return false; }
103 virtual WebString selectionAsText() const { return WebString(); }
104 virtual WebString selectionAsMarkup() const { return WebString(); }
106 // If the given position is over a link, returns the absolute url.
107 // Otherwise an empty url is returned.
108 virtual WebURL linkAtPosition(const WebPoint& position) const { return WebURL(); }
110 // Used for zooming of full page plugins.
111 virtual void setZoomLevel(double level, bool textOnly) { }
114 // Start a new search. The plugin should search for a little bit at a time so that it
115 // doesn't block the thread in case of a large document. The results, along with the
116 // find's identifier, should be sent asynchronously to WebFrameClient's reportFindInPage* methods.
117 // Returns true if the search started, or false if the plugin doesn't support search.
118 virtual bool startFind(const WebString& searchText, bool caseSensitive, int identifier) { return false; }
119 // Tells the plugin to jump forward or backward in the list of find results.
120 virtual void selectFindResult(bool forward) { }
121 // Tells the plugin that the user has stopped the find operation.
122 virtual void stopFind() { }
128 } // namespace WebKit