• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 Apple 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
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef PluginProxy_h
27 #define PluginProxy_h
28 
29 #if ENABLE(PLUGIN_PROCESS)
30 
31 #include "Connection.h"
32 #include "Plugin.h"
33 
34 #if PLATFORM(MAC)
35 #include <wtf/RetainPtr.h>
36 OBJC_CLASS CALayer;
37 #endif
38 
39 namespace WebCore {
40     class HTTPHeaderMap;
41 }
42 
43 namespace WebKit {
44 
45 class ShareableBitmap;
46 class NPVariantData;
47 class PluginProcessConnection;
48 
49 class PluginProxy : public Plugin {
50 public:
51     static PassRefPtr<PluginProxy> create(const String& pluginPath);
52     ~PluginProxy();
53 
pluginInstanceID()54     uint64_t pluginInstanceID() const { return m_pluginInstanceID; }
55     void pluginProcessCrashed();
56 
57     void didReceivePluginProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments);
58     CoreIPC::SyncReplyMode didReceiveSyncPluginProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*);
59 
60 private:
61     explicit PluginProxy(const String& pluginPath);
62 
63     // Plugin
64     virtual bool initialize(PluginController*, const Parameters&);
65     virtual void destroy();
66     virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect& dirtyRect);
67     virtual PassRefPtr<ShareableBitmap> snapshot();
68 #if PLATFORM(MAC)
69     virtual PlatformLayer* pluginLayer();
70 #endif
71     virtual bool isTransparent();
72     virtual void geometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect);
73     virtual void frameDidFinishLoading(uint64_t requestID);
74     virtual void frameDidFail(uint64_t requestID, bool wasCancelled);
75     virtual void didEvaluateJavaScript(uint64_t requestID, const WTF::String& requestURLString, const WTF::String& result);
76     virtual void streamDidReceiveResponse(uint64_t streamID, const WebCore::KURL& responseURL, uint32_t streamLength, uint32_t lastModifiedTime, const WTF::String& mimeType, const WTF::String& headers);
77     virtual void streamDidReceiveData(uint64_t streamID, const char* bytes, int length);
78     virtual void streamDidFinishLoading(uint64_t streamID);
79     virtual void streamDidFail(uint64_t streamID, bool wasCancelled);
80     virtual void manualStreamDidReceiveResponse(const WebCore::KURL& responseURL, uint32_t streamLength, uint32_t lastModifiedTime, const WTF::String& mimeType, const WTF::String& headers);
81     virtual void manualStreamDidReceiveData(const char* bytes, int length);
82     virtual void manualStreamDidFinishLoading();
83     virtual void manualStreamDidFail(bool wasCancelled);
84 
85     virtual bool handleMouseEvent(const WebMouseEvent&);
86     virtual bool handleWheelEvent(const WebWheelEvent&);
87     virtual bool handleMouseEnterEvent(const WebMouseEvent&);
88     virtual bool handleMouseLeaveEvent(const WebMouseEvent&);
89     virtual bool handleKeyboardEvent(const WebKeyboardEvent&);
90     virtual void setFocus(bool);
91     virtual NPObject* pluginScriptableNPObject();
92 #if PLATFORM(MAC)
93     virtual void windowFocusChanged(bool);
94     virtual void windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates);
95     virtual void windowVisibilityChanged(bool);
96     virtual uint64_t pluginComplexTextInputIdentifier() const;
97     virtual void sendComplexTextInput(const String& textInput);
98 #endif
99 
100     virtual void privateBrowsingStateChanged(bool);
101 
102     virtual PluginController* controller();
103 
104     bool needsBackingStore() const;
105 
106     // Message handlers.
107     void loadURL(uint64_t requestID, const String& method, const String& urlString, const String& target, const WebCore::HTTPHeaderMap& headerFields, const Vector<uint8_t>& httpBody, bool allowPopups);
108     void update(const WebCore::IntRect& paintedRect);
109     void proxiesForURL(const String& urlString, String& proxyString);
110     void cookiesForURL(const String& urlString, String& cookieString);
111     void setCookiesForURL(const String& urlString, const String& cookieString);
112     void getWindowScriptNPObject(uint64_t& windowScriptNPObjectID);
113     void getPluginElementNPObject(uint64_t& pluginElementNPObjectID);
114     void evaluate(const NPVariantData& npObjectAsVariantData, const String& scriptString, bool allowPopups, bool& returnValue, NPVariantData& resultData);
115     void cancelStreamLoad(uint64_t streamID);
116     void cancelManualStreamLoad();
117     void setStatusbarText(const String& statusbarText);
118 #if PLATFORM(MAC)
119     void setComplexTextInputEnabled(bool);
120 #endif
121 
122     String m_pluginPath;
123 
124     RefPtr<PluginProcessConnection> m_connection;
125     uint64_t m_pluginInstanceID;
126 
127     PluginController* m_pluginController;
128 
129     // The plug-in rect in window coordinates.
130     WebCore::IntRect m_frameRect;
131 
132     // This is the backing store that we paint when we're told to paint.
133     RefPtr<ShareableBitmap> m_backingStore;
134 
135     // This is the shared memory backing store that the plug-in paints into. When the plug-in tells us
136     // that it's painted something in it, we'll blit from it to our own backing store.
137     RefPtr<ShareableBitmap> m_pluginBackingStore;
138 
139     // Whether all of the plug-in backing store contains valid data.
140     bool m_pluginBackingStoreContainsValidData;
141 
142     bool m_isStarted;
143 
144     // Whether we're called invalidate in response to an update call, and are now waiting for a paint call.
145     bool m_waitingForPaintInResponseToUpdate;
146 
147     // The client ID for the CA layer in the plug-in process. Will be 0 if the plug-in is not a CA plug-in.
148     uint32_t m_remoteLayerClientID;
149 
150 #if PLATFORM(MAC)
151     RetainPtr<CALayer> m_pluginLayer;
152 #endif
153 };
154 
155 } // namespace WebKit
156 
157 #endif // ENABLE(PLUGIN_PROCESS)
158 
159 #endif // PluginProxy_h
160