OSDN Git Service

Merge WebKit at r71558: Initial merge by git.
[android-x86/external-webkit.git] / WebKit / chromium / public / WebPlugin.h
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     // 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; }
71
72     virtual void updateFocus(bool) = 0;
73     virtual void updateVisibility(bool) = 0;
74
75     virtual bool acceptsInputEvents() = 0;
76     virtual bool handleInputEvent(const WebInputEvent&, WebCursorInfo&) = 0;
77
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;
82
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;
88
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() { }
101
102     virtual bool hasSelection() const { return false; }
103     virtual WebString selectionAsText() const { return WebString(); }
104     virtual WebString selectionAsMarkup() const { return WebString(); }
105
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(); }
109
110     // Used for zooming of full page plugins.
111     virtual void setZoomLevel(double level, bool textOnly) { }
112
113     // Find interface.
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() { }
123
124 protected:
125     ~WebPlugin() { }
126 };
127
128 } // namespace WebKit
129
130 #endif