|
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 "WebPluginContainer.h" |
|
35 |
|
36 #include "Widget.h" |
|
37 #include <wtf/PassRefPtr.h> |
|
38 #include <wtf/Vector.h> |
|
39 |
|
40 struct NPObject; |
|
41 |
|
42 namespace WebCore { |
|
43 class HTMLPlugInElement; |
|
44 class IntRect; |
|
45 class KeyboardEvent; |
|
46 class MouseEvent; |
|
47 class ResourceError; |
|
48 class ResourceResponse; |
|
49 class WheelEvent; |
|
50 } |
|
51 |
|
52 namespace WebKit { |
|
53 |
|
54 class WebPlugin; |
|
55 class WebPluginLoadObserver; |
|
56 |
|
57 class WebPluginContainerImpl : public WebCore::Widget, public WebPluginContainer { |
|
58 public: |
|
59 static PassRefPtr<WebPluginContainerImpl> create(WebCore::HTMLPlugInElement* element, WebPlugin* webPlugin) |
|
60 { |
|
61 return adoptRef(new WebPluginContainerImpl(element, webPlugin)); |
|
62 } |
|
63 |
|
64 // Widget methods |
|
65 virtual void setFrameRect(const WebCore::IntRect&); |
|
66 virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect&); |
|
67 virtual void invalidateRect(const WebCore::IntRect&); |
|
68 virtual void setFocus(bool); |
|
69 virtual void show(); |
|
70 virtual void hide(); |
|
71 virtual void handleEvent(WebCore::Event*); |
|
72 virtual void frameRectsChanged(); |
|
73 virtual void setParentVisible(bool); |
|
74 virtual void setParent(WebCore::ScrollView*); |
|
75 virtual void widgetPositionsUpdated(); |
|
76 |
|
77 // WebPluginContainer methods |
|
78 virtual WebElement element(); |
|
79 virtual void invalidate(); |
|
80 virtual void invalidateRect(const WebRect&); |
|
81 virtual void reportGeometry(); |
|
82 virtual void clearScriptObjects(); |
|
83 virtual NPObject* scriptableObjectForElement(); |
|
84 virtual WebString executeScriptURL(const WebURL&, bool popupsAllowed); |
|
85 virtual void loadFrameRequest(const WebURLRequest&, const WebString& target, bool notifyNeeded, void* notifyData); |
|
86 |
|
87 // This cannot be null. |
|
88 WebPlugin* plugin() { return m_webPlugin; } |
|
89 void setPlugin(WebPlugin* plugin) { m_webPlugin = plugin; } |
|
90 |
|
91 // Printing interface. The plugin can support custom printing |
|
92 // (which means it controls the layout, number of pages etc). |
|
93 // Whether the plugin supports its own paginated print. The other print |
|
94 // interface methods are called only if this method returns true. |
|
95 bool supportsPaginatedPrint() const; |
|
96 // Sets up printing at the given print rect and printer DPI. printableArea |
|
97 // is in points (a point is 1/72 of an inch).Returns the number of pages to |
|
98 // be printed at these settings. |
|
99 int printBegin(const WebCore::IntRect& printableArea, int printerDPI) const; |
|
100 // Prints the page specified by pageNumber (0-based index) into the supplied canvas. |
|
101 bool printPage(int pageNumber, WebCore::GraphicsContext* gc); |
|
102 // Ends the print operation. |
|
103 void printEnd(); |
|
104 |
|
105 // Copy the selected text. |
|
106 void copy(); |
|
107 |
|
108 // Resource load events for the plugin's source data: |
|
109 void didReceiveResponse(const WebCore::ResourceResponse&); |
|
110 void didReceiveData(const char *data, int dataLength); |
|
111 void didFinishLoading(); |
|
112 void didFailLoading(const WebCore::ResourceError&); |
|
113 |
|
114 NPObject* scriptableObject(); |
|
115 |
|
116 void willDestroyPluginLoadObserver(WebPluginLoadObserver*); |
|
117 |
|
118 private: |
|
119 WebPluginContainerImpl(WebCore::HTMLPlugInElement* element, WebPlugin* webPlugin) |
|
120 : m_element(element) |
|
121 , m_webPlugin(webPlugin) { } |
|
122 ~WebPluginContainerImpl(); |
|
123 |
|
124 void handleMouseEvent(WebCore::MouseEvent*); |
|
125 void handleWheelEvent(WebCore::WheelEvent*); |
|
126 void handleKeyboardEvent(WebCore::KeyboardEvent*); |
|
127 |
|
128 void calculateGeometry(const WebCore::IntRect& frameRect, |
|
129 WebCore::IntRect& windowRect, |
|
130 WebCore::IntRect& clipRect, |
|
131 Vector<WebCore::IntRect>& cutOutRects); |
|
132 WebCore::IntRect windowClipRect() const; |
|
133 void windowCutOutRects(const WebCore::IntRect& frameRect, |
|
134 Vector<WebCore::IntRect>& cutOutRects); |
|
135 |
|
136 WebCore::HTMLPlugInElement* m_element; |
|
137 WebPlugin* m_webPlugin; |
|
138 Vector<WebPluginLoadObserver*> m_pluginLoadObservers; |
|
139 }; |
|
140 |
|
141 } // namespace WebKit |
|
142 |
|
143 #endif |