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.
31 #ifndef WebPluginContainerImpl_h
32 #define WebPluginContainerImpl_h
34 #include "PluginViewBase.h"
35 #include "WebPluginContainer.h"
38 #include <wtf/OwnPtr.h>
39 #include <wtf/PassRefPtr.h>
40 #include <wtf/Vector.h>
45 class HTMLPlugInElement;
50 class PluginLayerChromium;
52 class ResourceResponse;
55 #if ENABLE(GESTURE_EVENTS)
56 class PlatformGestureEvent;
64 class WebPluginLoadObserver;
66 class WebPluginContainerImpl : public WebCore::PluginViewBase, public WebPluginContainer {
68 static PassRefPtr<WebPluginContainerImpl> create(WebCore::HTMLPlugInElement* element, WebPlugin* webPlugin)
70 return adoptRef(new WebPluginContainerImpl(element, webPlugin));
74 virtual void setFrameRect(const WebCore::IntRect&);
75 virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect&);
76 virtual void invalidateRect(const WebCore::IntRect&);
77 virtual void setFocus(bool);
80 virtual void handleEvent(WebCore::Event*);
81 virtual void frameRectsChanged();
82 virtual void setParentVisible(bool);
83 virtual void setParent(WebCore::ScrollView*);
84 virtual void widgetPositionsUpdated();
85 virtual bool isPluginContainer() const { return true; }
87 // WebPluginContainer methods
88 virtual WebElement element();
89 virtual void invalidate();
90 virtual void invalidateRect(const WebRect&);
91 virtual void scrollRect(int dx, int dy, const WebRect&);
92 virtual void reportGeometry();
93 virtual void setBackingTextureId(unsigned);
94 virtual void setBackingIOSurfaceId(int width,
96 uint32_t ioSurfaceId);
97 virtual void commitBackingTexture();
98 virtual void clearScriptObjects();
99 virtual NPObject* scriptableObjectForElement();
100 virtual WebString executeScriptURL(const WebURL&, bool popupsAllowed);
101 virtual void loadFrameRequest(const WebURLRequest&, const WebString& target, bool notifyNeeded, void* notifyData);
102 virtual void zoomLevelChanged(double zoomLevel);
104 // This cannot be null.
105 WebPlugin* plugin() { return m_webPlugin; }
106 void setPlugin(WebPlugin* plugin) { m_webPlugin = plugin; }
108 // Printing interface. The plugin can support custom printing
109 // (which means it controls the layout, number of pages etc).
110 // Whether the plugin supports its own paginated print. The other print
111 // interface methods are called only if this method returns true.
112 bool supportsPaginatedPrint() const;
113 // If the plugin content should not be scaled to the printable area of
114 // the page, then this method should return true.
115 bool isPrintScalingDisabled() const;
116 // Sets up printing at the given print rect and printer DPI. printableArea
117 // is in points (a point is 1/72 of an inch).Returns the number of pages to
118 // be printed at these settings.
119 int printBegin(const WebCore::IntRect& printableArea, int printerDPI) const;
120 // Prints the page specified by pageNumber (0-based index) into the supplied canvas.
121 bool printPage(int pageNumber, WebCore::GraphicsContext* gc);
122 // Ends the print operation.
125 // Copy the selected text.
128 // Resource load events for the plugin's source data:
129 void didReceiveResponse(const WebCore::ResourceResponse&);
130 void didReceiveData(const char *data, int dataLength);
131 void didFinishLoading();
132 void didFailLoading(const WebCore::ResourceError&);
134 NPObject* scriptableObject();
136 void willDestroyPluginLoadObserver(WebPluginLoadObserver*);
138 #if USE(ACCELERATED_COMPOSITING)
139 virtual WebCore::LayerChromium* platformLayer() const;
142 ScrollbarGroup* scrollbarGroup();
144 void willStartLiveResize();
145 void willEndLiveResize();
147 bool paintCustomOverhangArea(WebCore::GraphicsContext*, const WebCore::IntRect&, const WebCore::IntRect&, const WebCore::IntRect&);
149 #if ENABLE(GESTURE_EVENTS)
150 bool handleGestureEvent(const WebCore::PlatformGestureEvent&);
154 WebPluginContainerImpl(WebCore::HTMLPlugInElement* element, WebPlugin* webPlugin);
155 ~WebPluginContainerImpl();
157 void handleMouseEvent(WebCore::MouseEvent*);
158 void handleWheelEvent(WebCore::WheelEvent*);
159 void handleKeyboardEvent(WebCore::KeyboardEvent*);
161 void calculateGeometry(const WebCore::IntRect& frameRect,
162 WebCore::IntRect& windowRect,
163 WebCore::IntRect& clipRect,
164 Vector<WebCore::IntRect>& cutOutRects);
165 WebCore::IntRect windowClipRect() const;
166 void windowCutOutRects(const WebCore::IntRect& frameRect,
167 Vector<WebCore::IntRect>& cutOutRects);
169 WebCore::HTMLPlugInElement* m_element;
170 WebPlugin* m_webPlugin;
171 Vector<WebPluginLoadObserver*> m_pluginLoadObservers;
173 #if USE(ACCELERATED_COMPOSITING)
174 RefPtr<WebCore::PluginLayerChromium> m_platformLayer;
177 // The associated scrollbar group object, created lazily. Used for Pepper
179 OwnPtr<ScrollbarGroup> m_scrollbarGroup;
182 } // namespace WebKit