|
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 |
|
37 struct NPObject; |
|
38 |
|
39 namespace WebKit { |
|
40 |
|
41 class WebDataSource; |
|
42 class WebFrame; |
|
43 class WebInputEvent; |
|
44 class WebPluginContainer; |
|
45 class WebURL; |
|
46 class WebURLResponse; |
|
47 struct WebCursorInfo; |
|
48 struct WebPluginParams; |
|
49 struct WebRect; |
|
50 struct WebURLError; |
|
51 template <typename T> class WebVector; |
|
52 |
|
53 class WebPlugin { |
|
54 public: |
|
55 virtual bool initialize(WebPluginContainer*) = 0; |
|
56 virtual void destroy() = 0; |
|
57 |
|
58 virtual NPObject* scriptableObject() = 0; |
|
59 |
|
60 virtual void paint(WebCanvas*, const WebRect&) = 0; |
|
61 |
|
62 // Coordinates are relative to the containing window. |
|
63 virtual void updateGeometry( |
|
64 const WebRect& frameRect, const WebRect& clipRect, |
|
65 const WebVector<WebRect>& cutOutsRects, bool isVisible) = 0; |
|
66 |
|
67 virtual void updateFocus(bool) = 0; |
|
68 virtual void updateVisibility(bool) = 0; |
|
69 |
|
70 virtual bool acceptsInputEvents() = 0; |
|
71 virtual bool handleInputEvent(const WebInputEvent&, WebCursorInfo&) = 0; |
|
72 |
|
73 virtual void didReceiveResponse(const WebURLResponse&) = 0; |
|
74 virtual void didReceiveData(const char* data, int dataLength) = 0; |
|
75 virtual void didFinishLoading() = 0; |
|
76 virtual void didFailLoading(const WebURLError&) = 0; |
|
77 |
|
78 // Called in response to WebPluginContainer::loadFrameRequest |
|
79 virtual void didFinishLoadingFrameRequest( |
|
80 const WebURL&, void* notifyData) = 0; |
|
81 virtual void didFailLoadingFrameRequest( |
|
82 const WebURL&, void* notifyData, const WebURLError&) = 0; |
|
83 |
|
84 // Printing interface. |
|
85 // Whether the plugin supports its own paginated print. The other print |
|
86 // interface methods are called only if this method returns true. |
|
87 virtual bool supportsPaginatedPrint() { return false; } |
|
88 // Sets up printing at the given print rect and printer DPI. printableArea |
|
89 // is in points (a point is 1/72 of an inch).Returns the number of pages to |
|
90 // be printed at these settings. |
|
91 virtual int printBegin(const WebRect& printableArea, int printerDPI) { return 0; } |
|
92 // Prints the page specified by pageNumber (0-based index) into the supplied canvas. |
|
93 virtual bool printPage(int pageNumber, WebCanvas* canvas) { return false; } |
|
94 // Ends the print operation. |
|
95 virtual void printEnd() { } |
|
96 |
|
97 virtual bool hasSelection() const { return false; } |
|
98 virtual WebString selectionAsText() const { return WebString(); } |
|
99 virtual WebString selectionAsMarkup() const { return WebString(); } |
|
100 |
|
101 // Used for zooming of full page plugins. |
|
102 virtual void setZoomFactor(float scale, bool textOnly) { } |
|
103 |
|
104 // Find interface. |
|
105 // Start a new search. The plugin should search for a little bit at a time so that it |
|
106 // doesn't block the thread in case of a large document. The results, along with the |
|
107 // find's identifier, should be sent asynchronously to WebFrameClient's reportFindInPage* methods. |
|
108 // Returns true if the search started, or false if the plugin doesn't support search. |
|
109 virtual bool startFind(const WebString& searchText, bool caseSensitive, int identifier) { return false; } |
|
110 // Tells the plugin to jump forward or backward in the list of find results. |
|
111 virtual void selectFindResult(bool forward) { } |
|
112 // Tells the plugin that the user has stopped the find operation. |
|
113 virtual void stopFind() { } |
|
114 |
|
115 protected: |
|
116 ~WebPlugin() { } |
|
117 }; |
|
118 |
|
119 } // namespace WebKit |
|
120 |
|
121 #endif |