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 commitBackingTexture();
95 virtual void clearScriptObjects();
96 virtual NPObject* scriptableObjectForElement();
97 virtual WebString executeScriptURL(const WebURL&, bool popupsAllowed);
98 virtual void loadFrameRequest(const WebURLRequest&, const WebString& target, bool notifyNeeded, void* notifyData);
99 virtual void zoomLevelChanged(double zoomLevel);
101 // This cannot be null.
102 WebPlugin* plugin() { return m_webPlugin; }
103 void setPlugin(WebPlugin* plugin) { m_webPlugin = plugin; }
105 // Printing interface. The plugin can support custom printing
106 // (which means it controls the layout, number of pages etc).
107 // Whether the plugin supports its own paginated print. The other print
108 // interface methods are called only if this method returns true.
109 bool supportsPaginatedPrint() const;
110 // Sets up printing at the given print rect and printer DPI. printableArea
111 // is in points (a point is 1/72 of an inch).Returns the number of pages to
112 // be printed at these settings.
113 int printBegin(const WebCore::IntRect& printableArea, int printerDPI) const;
114 // Prints the page specified by pageNumber (0-based index) into the supplied canvas.
115 bool printPage(int pageNumber, WebCore::GraphicsContext* gc);
116 // Ends the print operation.
119 // Copy the selected text.
122 // Resource load events for the plugin's source data:
123 void didReceiveResponse(const WebCore::ResourceResponse&);
124 void didReceiveData(const char *data, int dataLength);
125 void didFinishLoading();
126 void didFailLoading(const WebCore::ResourceError&);
128 NPObject* scriptableObject();
130 void willDestroyPluginLoadObserver(WebPluginLoadObserver*);
132 #if USE(ACCELERATED_COMPOSITING)
133 virtual WebCore::LayerChromium* platformLayer() const;
136 ScrollbarGroup* scrollbarGroup();
138 void willStartLiveResize();
139 void willEndLiveResize();
141 bool paintCustomOverhangArea(WebCore::GraphicsContext*, const WebCore::IntRect&, const WebCore::IntRect&, const WebCore::IntRect&);
143 #if ENABLE(GESTURE_EVENTS)
144 bool handleGestureEvent(const WebCore::PlatformGestureEvent&);
148 WebPluginContainerImpl(WebCore::HTMLPlugInElement* element, WebPlugin* webPlugin);
149 ~WebPluginContainerImpl();
151 void handleMouseEvent(WebCore::MouseEvent*);
152 void handleWheelEvent(WebCore::WheelEvent*);
153 void handleKeyboardEvent(WebCore::KeyboardEvent*);
155 void calculateGeometry(const WebCore::IntRect& frameRect,
156 WebCore::IntRect& windowRect,
157 WebCore::IntRect& clipRect,
158 Vector<WebCore::IntRect>& cutOutRects);
159 WebCore::IntRect windowClipRect() const;
160 void windowCutOutRects(const WebCore::IntRect& frameRect,
161 Vector<WebCore::IntRect>& cutOutRects);
163 WebCore::HTMLPlugInElement* m_element;
164 WebPlugin* m_webPlugin;
165 Vector<WebPluginLoadObserver*> m_pluginLoadObservers;
167 #if USE(ACCELERATED_COMPOSITING)
168 RefPtr<WebCore::PluginLayerChromium> m_platformLayer;
171 // The associated scrollbar group object, created lazily. Used for Pepper
173 OwnPtr<ScrollbarGroup> m_scrollbarGroup;
176 } // namespace WebKit