tizen beta release
[profile/ivi/webkit-efl.git] / Source / WebKit / chromium / src / WebPluginContainerImpl.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 WebPluginContainerImpl_h
32 #define WebPluginContainerImpl_h
33
34 #include "PluginViewBase.h"
35 #include "WebPluginContainer.h"
36 #include "Widget.h"
37
38 #include <wtf/OwnPtr.h>
39 #include <wtf/PassRefPtr.h>
40 #include <wtf/Vector.h>
41
42 struct NPObject;
43
44 namespace WebCore {
45 class HTMLPlugInElement;
46 class IntRect;
47 class KeyboardEvent;
48 class LayerChromium;
49 class MouseEvent;
50 class PluginLayerChromium;
51 class ResourceError;
52 class ResourceResponse;
53 class WheelEvent;
54
55 #if ENABLE(GESTURE_EVENTS)
56 class PlatformGestureEvent;
57 #endif
58 }
59
60 namespace WebKit {
61
62 class ScrollbarGroup;
63 class WebPlugin;
64 class WebPluginLoadObserver;
65
66 class WebPluginContainerImpl : public WebCore::PluginViewBase, public WebPluginContainer {
67 public:
68     static PassRefPtr<WebPluginContainerImpl> create(WebCore::HTMLPlugInElement* element, WebPlugin* webPlugin)
69     {
70         return adoptRef(new WebPluginContainerImpl(element, webPlugin));
71     }
72
73     // Widget methods
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);
78     virtual void show();
79     virtual void hide();
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; }
86
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,
95                                        int height,
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);    
103
104     // This cannot be null.
105     WebPlugin* plugin() { return m_webPlugin; }
106     void setPlugin(WebPlugin* plugin) { m_webPlugin = plugin; }
107
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.
123     void printEnd();
124
125     // Copy the selected text.
126     void copy();
127
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&);
133
134     NPObject* scriptableObject();
135
136     void willDestroyPluginLoadObserver(WebPluginLoadObserver*);
137
138 #if USE(ACCELERATED_COMPOSITING)
139     virtual WebCore::LayerChromium* platformLayer() const;
140 #endif
141
142     ScrollbarGroup* scrollbarGroup();
143
144     void willStartLiveResize();
145     void willEndLiveResize();
146
147     bool paintCustomOverhangArea(WebCore::GraphicsContext*, const WebCore::IntRect&, const WebCore::IntRect&, const WebCore::IntRect&);
148
149 #if ENABLE(GESTURE_EVENTS)
150     bool handleGestureEvent(const WebCore::PlatformGestureEvent&);
151 #endif
152
153 private:
154     WebPluginContainerImpl(WebCore::HTMLPlugInElement* element, WebPlugin* webPlugin);
155     ~WebPluginContainerImpl();
156
157     void handleMouseEvent(WebCore::MouseEvent*);
158     void handleWheelEvent(WebCore::WheelEvent*);
159     void handleKeyboardEvent(WebCore::KeyboardEvent*);
160
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);
168
169     WebCore::HTMLPlugInElement* m_element;
170     WebPlugin* m_webPlugin;
171     Vector<WebPluginLoadObserver*> m_pluginLoadObservers;
172
173 #if USE(ACCELERATED_COMPOSITING)
174     RefPtr<WebCore::PluginLayerChromium> m_platformLayer;
175 #endif
176
177     // The associated scrollbar group object, created lazily. Used for Pepper
178     // scrollbars.
179     OwnPtr<ScrollbarGroup> m_scrollbarGroup;
180 };
181
182 } // namespace WebKit
183
184 #endif