2 * Copyright (C) 2009, 2012 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 "../platform/WebCanvas.h"
35 #include "../platform/WebString.h"
36 #include "../platform/WebURL.h"
37 #include "WebDragOperation.h"
38 #include "WebDragStatus.h"
39 #include "WebWidget.h"
49 class WebPluginContainer;
51 struct WebCompositionUnderline;
53 struct WebPluginParams;
54 struct WebPrintParams;
57 struct WebTextInputInfo;
59 template <typename T> class WebVector;
63 virtual bool initialize(WebPluginContainer*) = 0;
64 virtual void destroy() = 0;
66 virtual WebPluginContainer* container() const { return 0; }
67 virtual void containerDidDetachFromParent() { }
69 virtual NPObject* scriptableObject() = 0;
70 virtual struct _NPP* pluginNPP() { return 0; }
72 // Returns true if the form submission value is successfully obtained
73 // from the plugin. The value would be associated with the name attribute
74 // of the corresponding object element.
75 virtual bool getFormValue(WebString&) { return false; }
76 virtual bool supportsKeyboardFocus() const { return false; }
77 virtual bool supportsEditCommands() const { return false; }
78 // Returns true if this plugin supports input method, which implements
79 // setComposition() and confirmComposition() below.
80 virtual bool supportsInputMethod() const { return false; }
82 virtual bool canProcessDrag() const { return false; }
84 virtual void paint(WebCanvas*, const WebRect&) = 0;
86 // Coordinates are relative to the containing window.
87 virtual void updateGeometry(
88 const WebRect& frameRect, const WebRect& clipRect,
89 const WebVector<WebRect>& cutOutsRects, bool isVisible) = 0;
91 virtual void updateFocus(bool) = 0;
92 virtual void updateVisibility(bool) = 0;
94 virtual bool acceptsInputEvents() = 0;
95 virtual bool handleInputEvent(const WebInputEvent&, WebCursorInfo&) = 0;
97 virtual bool handleDragStatusUpdate(WebDragStatus, const WebDragData&, WebDragOperationsMask, const WebPoint& position, const WebPoint& screenPosition) { return false; }
99 virtual void didReceiveResponse(const WebURLResponse&) = 0;
100 virtual void didReceiveData(const char* data, int dataLength) = 0;
101 virtual void didFinishLoading() = 0;
102 virtual void didFailLoading(const WebURLError&) = 0;
104 // Called in response to WebPluginContainer::loadFrameRequest
105 virtual void didFinishLoadingFrameRequest(
106 const WebURL&, void* notifyData) = 0;
107 virtual void didFailLoadingFrameRequest(
108 const WebURL&, void* notifyData, const WebURLError&) = 0;
110 // Printing interface.
111 // Whether the plugin supports its own paginated print. The other print
112 // interface methods are called only if this method returns true.
113 virtual bool supportsPaginatedPrint() { return false; }
114 // Returns true if the printed content should not be scaled to
115 // the printer's printable area.
116 virtual bool isPrintScalingDisabled() { return false; }
118 // Sets up printing with the specified printParams. Returns the number of
119 // pages to be printed at these settings.
120 virtual int printBegin(const WebPrintParams& printParams) { return 0; }
122 // Prints the page specified by pageNumber (0-based index) into the supplied canvas.
123 virtual bool printPage(int pageNumber, WebCanvas* canvas) { return false; }
124 // Ends the print operation.
125 virtual void printEnd() { }
127 virtual bool hasSelection() const { return false; }
128 virtual WebString selectionAsText() const { return WebString(); }
129 virtual WebString selectionAsMarkup() const { return WebString(); }
131 virtual bool executeEditCommand(const WebString& name) { return false; }
132 virtual bool executeEditCommand(const WebString& name, const WebString& value) { return false; }
134 // Sets composition text from input method, and returns true if the
135 // composition is set successfully.
136 virtual bool setComposition(const WebString& text, const WebVector<WebCompositionUnderline>& underlines, int selectionStart, int selectionEnd) { return false; }
137 // Confirms an ongoing composition and returns true if there is an ongoing
138 // composition or the text is inserted.
139 virtual bool confirmComposition(const WebString& text, WebWidget::ConfirmCompositionBehavior selectionBehavior) { return false; }
140 // Deletes the current selection plus the specified number of characters
141 // before and after the selection or caret.
142 virtual void extendSelectionAndDelete(int before, int after) { }
143 // If the given position is over a link, returns the absolute url.
144 // Otherwise an empty url is returned.
145 virtual WebURL linkAtPosition(const WebPoint& position) const { return WebURL(); }
147 // Used for zooming of full page plugins.
148 virtual void setZoomLevel(double level, bool textOnly) { }
151 // Start a new search. The plugin should search for a little bit at a time so that it
152 // doesn't block the thread in case of a large document. The results, along with the
153 // find's identifier, should be sent asynchronously to WebFrameClient's reportFindInPage* methods.
154 // Returns true if the search started, or false if the plugin doesn't support search.
155 virtual bool startFind(const WebString& searchText, bool caseSensitive, int identifier) { return false; }
156 // Tells the plugin to jump forward or backward in the list of find results.
157 virtual void selectFindResult(bool forward) { }
158 // Tells the plugin that the user has stopped the find operation.
159 virtual void stopFind() { }
161 // View rotation types.
163 RotationType90Clockwise,
164 RotationType90Counterclockwise
166 // Whether the plugin can rotate the view of its content.
167 virtual bool canRotateView() { return false; }
168 // Rotates the plugin's view of its content.
169 virtual void rotateView(RotationType type) { }
171 virtual bool isPlaceholder() { return true; }
172 virtual bool shouldPersist() const { return false; }