1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
|
/*
* Copyright (C) 2010, 2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#if ENABLE(NETSCAPE_PLUGIN_API)
#include "Connection.h"
#include "Plugin.h"
#include "PluginProcess.h"
#include <WebCore/AffineTransform.h>
#include <WebCore/IntRect.h>
#include <WebCore/SecurityOrigin.h>
#include <memory>
#if PLATFORM(COCOA)
#include <wtf/RetainPtr.h>
OBJC_CLASS CALayer;
#endif
namespace WebCore {
class HTTPHeaderMap;
class ProtectionSpace;
}
namespace WebKit {
class ShareableBitmap;
class NPVariantData;
class PluginProcessConnection;
struct PluginCreationParameters;
class PluginProxy : public Plugin {
public:
static Ref<PluginProxy> create(uint64_t pluginProcessToken);
~PluginProxy();
uint64_t pluginInstanceID() const { return m_pluginInstanceID; }
void pluginProcessCrashed();
void didReceivePluginProxyMessage(IPC::Connection&, IPC::Decoder&);
bool didReceiveSyncPluginProxyMessage(IPC::Connection&, IPC::Decoder&, UniqueRef<IPC::Encoder>&);
private:
explicit PluginProxy(uint64_t pluginProcessToken);
// Plugin
bool initialize(const Parameters&) override;
bool initializeSynchronously();
void destroy() override;
void paint(WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect) override;
bool supportsSnapshotting() const override;
RefPtr<ShareableBitmap> snapshot() override;
#if PLATFORM(COCOA)
PlatformLayer* pluginLayer() override;
#endif
bool isTransparent() override;
bool wantsWheelEvents() override;
void geometryDidChange(const WebCore::IntSize& pluginSize, const WebCore::IntRect& clipRect, const WebCore::AffineTransform& pluginToRootViewTransform) override;
void visibilityDidChange(bool isVisible) override;
void frameDidFinishLoading(uint64_t requestID) override;
void frameDidFail(uint64_t requestID, bool wasCancelled) override;
void didEvaluateJavaScript(uint64_t requestID, const String& result) override;
void streamWillSendRequest(uint64_t streamID, const URL& requestURL, const URL& responseURL, int responseStatus) override;
void streamDidReceiveResponse(uint64_t streamID, const URL& responseURL, uint32_t streamLength, uint32_t lastModifiedTime, const String& mimeType, const String& headers, const String& suggestedFileName) override;
void streamDidReceiveData(uint64_t streamID, const uint8_t* bytes, int length) override;
void streamDidFinishLoading(uint64_t streamID) override;
void streamDidFail(uint64_t streamID, bool wasCancelled) override;
void manualStreamDidReceiveResponse(const URL& responseURL, uint32_t streamLength, uint32_t lastModifiedTime, const WTF::String& mimeType, const WTF::String& headers, const String& suggestedFileName) override;
void manualStreamDidReceiveData(const uint8_t* bytes, int length) override;
void manualStreamDidFinishLoading() override;
void manualStreamDidFail(bool wasCancelled) override;
bool handleMouseEvent(const WebMouseEvent&) override;
bool handleWheelEvent(const WebWheelEvent&) override;
bool handleMouseEnterEvent(const WebMouseEvent&) override;
bool handleMouseLeaveEvent(const WebMouseEvent&) override;
bool handleContextMenuEvent(const WebMouseEvent&) override;
bool handleKeyboardEvent(const WebKeyboardEvent&) override;
void setFocus(bool) override;
bool handleEditingCommand(const String& commandName, const String& argument) override;
bool isEditingCommandEnabled(const String& commandName) override;
bool shouldAllowScripting() override { return true; }
bool shouldAllowNavigationFromDrags() override { return false; }
bool handlesPageScaleFactor() const override;
bool requiresUnifiedScaleFactor() const override;
NPObject* pluginScriptableNPObject() override;
void windowFocusChanged(bool) override;
void windowVisibilityChanged(bool) override;
#if PLATFORM(COCOA)
void windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates) override;
uint64_t pluginComplexTextInputIdentifier() const override;
void sendComplexTextInput(const String& textInput) override;
void setLayerHostingMode(LayerHostingMode) override;
#endif
void contentsScaleFactorChanged(float) override;
void storageBlockingStateChanged(bool) override;
void privateBrowsingStateChanged(bool) override;
void mutedStateChanged(bool) override;
bool getFormValue(String& formValue) override;
bool handleScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity) override;
WebCore::Scrollbar* horizontalScrollbar() override;
WebCore::Scrollbar* verticalScrollbar() override;
unsigned countFindMatches(const String&, WebCore::FindOptions, unsigned) override { return 0; }
bool findString(const String&, WebCore::FindOptions, unsigned) override { return false; }
WebCore::IntPoint convertToRootView(const WebCore::IntPoint&) const override;
RefPtr<WebCore::SharedBuffer> liveResourceData() const override;
bool performDictionaryLookupAtLocation(const WebCore::FloatPoint&) override { return false; }
String getSelectionString() const override { return String(); }
String getSelectionForWordAtPoint(const WebCore::FloatPoint&) const override { return String(); }
bool existingSelectionContainsPoint(const WebCore::FloatPoint&) const override { return false; }
float contentsScaleFactor();
bool needsBackingStore() const;
bool updateBackingStore();
uint64_t windowNPObjectID();
WebCore::IntRect pluginBounds();
void geometryDidChange();
// Message handlers.
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);
void update(const WebCore::IntRect& paintedRect);
void proxiesForURL(const String& urlString, CompletionHandler<void(String)>&&);
void cookiesForURL(const String& urlString, CompletionHandler<void(String)>&&);
void setCookiesForURL(const String& urlString, const String& cookieString);
void getAuthenticationInfo(const WebCore::ProtectionSpace&, CompletionHandler<void(bool returnValue, String username, String password)>&&);
void getPluginElementNPObject(CompletionHandler<void(uint64_t)>&&);
void evaluate(const NPVariantData& npObjectAsVariantData, const String& scriptString, bool allowPopups, CompletionHandler<void(bool returnValue, NPVariantData&& resultData)>&&);
void setPluginIsPlayingAudio(bool);
void continueStreamLoad(uint64_t streamID);
void cancelStreamLoad(uint64_t streamID);
void cancelManualStreamLoad();
void setStatusbarText(const String& statusbarText);
#if PLATFORM(COCOA)
void pluginFocusOrWindowFocusChanged(bool);
void setComplexTextInputState(uint64_t);
void setLayerHostingContextID(uint32_t);
#endif
#if PLATFORM(X11)
void createPluginContainer(CompletionHandler<void(uint64_t windowID)>&&);
void windowedPluginGeometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect, uint64_t windowID);
void windowedPluginVisibilityDidChange(bool isVisible, uint64_t windowID);
#endif
bool canInitializeAsynchronously() const;
void didCreatePlugin(bool wantsWheelEvents, uint32_t remoteLayerClientID, CompletionHandler<void()>&&);
void didFailToCreatePlugin(CompletionHandler<void()>&&);
void didCreatePluginInternal(bool wantsWheelEvents, uint32_t remoteLayerClientID);
void didFailToCreatePluginInternal();
uint64_t m_pluginProcessToken { 0 };
RefPtr<PluginProcessConnection> m_connection;
uint64_t m_pluginInstanceID { 0 };
WebCore::IntSize m_pluginSize;
// The clip rect in plug-in coordinates.
WebCore::IntRect m_clipRect;
// A transform that can be used to convert from root view coordinates to plug-in coordinates.
WebCore::AffineTransform m_pluginToRootViewTransform;
// This is the backing store that we paint when we're told to paint.
RefPtr<ShareableBitmap> m_backingStore;
// This is the shared memory backing store that the plug-in paints into. When the plug-in tells us
// that it's painted something in it, we'll blit from it to our own backing store.
RefPtr<ShareableBitmap> m_pluginBackingStore;
// Whether all of the plug-in backing store contains valid data.
bool m_pluginBackingStoreContainsValidData { false };
bool m_isStarted { false };
// Whether we're called invalidate in response to an update call, and are now waiting for a paint call.
bool m_waitingForPaintInResponseToUpdate { false };
// Whether we should send wheel events to this plug-in or not.
bool m_wantsWheelEvents { false };
// 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.
uint32_t m_remoteLayerClientID { 0 };
std::unique_ptr<PluginCreationParameters> m_pendingPluginCreationParameters;
bool m_waitingOnAsynchronousInitialization { false };
#if PLATFORM(COCOA)
RetainPtr<CALayer> m_pluginLayer;
#endif
};
} // namespace WebKit
SPECIALIZE_TYPE_TRAITS_PLUGIN(PluginProxy, isPluginProxy())
#endif // ENABLE(NETSCAPE_PLUGIN_API)
|