2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2014 Opera Software ASA. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #ifndef WebPluginContainer_h
33 #define WebPluginContainer_h
35 #include "../platform/WebCommon.h"
51 class WebPluginContainer
{
53 enum TouchEventRequestType
{
54 TouchEventRequestTypeNone
,
55 TouchEventRequestTypeRaw
,
56 TouchEventRequestTypeSynthesizedMouse
,
59 // Returns the element containing this plugin.
60 virtual WebElement
element() = 0;
62 virtual void invalidate() = 0;
63 virtual void invalidateRect(const WebRect
&) = 0;
64 virtual void scrollRect(const WebRect
&) = 0;
66 // Causes the container to be marked as needing layout, which in turn will cause
67 // layoutIfNeeded() to be called on any contained WebPlugin during the container's
68 // web view's lifecycle update, and in particular before calling paint() on the
70 virtual void setNeedsLayout() = 0;
72 // Causes the container to report its current geometry via
73 // WebPlugin::updateGeometry.
74 virtual void reportGeometry() = 0;
76 // Allow the plugin to pass script objects to the browser. The container
77 // tracks ownership of script objects in order to allow browser references
78 // to them to be dropped when clearScriptObjects is called.
79 virtual void allowScriptObjects() = 0;
81 // Drop any references to script objects allocated by the plugin.
82 // These are objects derived from WebPlugin::scriptableObject. This is
83 // called when the plugin is being destroyed or if it needs to be
85 virtual void clearScriptObjects() = 0;
87 // Returns the scriptable object associated with the DOM element
88 // containing the plugin.
89 virtual NPObject
* scriptableObjectForElement() = 0;
91 // Returns the scriptable object associated with the DOM element
92 // containing the plugin as a native v8 object.
93 virtual v8::Local
<v8::Object
> v8ObjectForElement() = 0;
95 // Executes a "javascript:" URL on behalf of the plugin in the context
96 // of the frame containing the plugin. Returns the result of script
98 virtual WebString
executeScriptURL(const WebURL
&, bool popupsAllowed
) = 0;
100 // Loads an URL in the specified frame (or the frame containing this
101 // plugin if target is empty). If notifyNeeded is true, then upon
102 // completion, WebPlugin::didFinishLoadingFrameRequest is called if the
103 // load was successful or WebPlugin::didFailLoadingFrameRequest is
104 // called if the load failed. The given notifyData is passed along to
106 virtual void loadFrameRequest(
107 const WebURLRequest
&, const WebString
& target
, bool notifyNeeded
, void* notifyData
) = 0;
109 // Determines whether the given rectangle in this plugin is above all other
110 // content. The rectangle is in the plugin's coordinate system.
111 virtual bool isRectTopmost(const WebRect
&) = 0;
113 // Notifies when the plugin changes the kind of touch-events it accepts.
114 virtual void requestTouchEventType(TouchEventRequestType
) = 0;
116 // Notifies when the plugin starts/stops accepting wheel events. Without
117 // calling the function with true, the container might not always able to
118 // receive wheel events in some cases (such as when threaded compositing
119 // is in use but a scroll bar is not in use).
120 virtual void setWantsWheelEvents(bool) = 0;
122 // Converts root frame's coordinates to plugin's local coordinates.
123 virtual WebPoint
rootFrameToLocalPoint(const WebPoint
&) = 0;
125 // Converts plugin's local coordinate to root frame's coordinates.
126 virtual WebPoint
localToRootFramePoint(const WebPoint
&) = 0;
128 virtual WebPlugin
* plugin() = 0;
129 virtual void setPlugin(WebPlugin
*) = 0;
131 virtual float deviceScaleFactor() = 0;
132 virtual float pageScaleFactor() = 0;
133 virtual float pageZoomFactor() = 0;
135 // Sets the layer representing the plugin for compositing. The
136 // WebPluginContainer does *not* take ownership.
137 virtual void setWebLayer(WebLayer
*) = 0;
140 ~WebPluginContainer() { }