| 1 | /* |
| 2 | * Copyright (C) 2010-2018 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 | #pragma once |
| 27 | |
| 28 | #include <wtf/Forward.h> |
| 29 | |
| 30 | #if PLATFORM(COCOA) |
| 31 | #include "PluginComplexTextInputState.h" |
| 32 | #endif |
| 33 | |
| 34 | struct NPObject; |
| 35 | typedef struct _NPVariant NPVariant; |
| 36 | typedef void* NPIdentifier; |
| 37 | |
| 38 | namespace WTF { |
| 39 | class MachSendRight; |
| 40 | } |
| 41 | |
| 42 | namespace WebCore { |
| 43 | class ; |
| 44 | class IntRect; |
| 45 | class ProtectionSpace; |
| 46 | } |
| 47 | |
| 48 | namespace WebKit { |
| 49 | |
| 50 | class PluginController { |
| 51 | public: |
| 52 | // Tells the controller that the plug-in wants the given rect to be repainted. The rect is in the plug-in's coordinate system. |
| 53 | virtual void invalidate(const WebCore::IntRect&) = 0; |
| 54 | |
| 55 | // Returns the user agent string. |
| 56 | virtual String userAgent() = 0; |
| 57 | |
| 58 | // Loads the given URL and associates it with the request ID. |
| 59 | // |
| 60 | // If a target is specified, then the URL will be loaded in the window or frame that the target refers to. |
| 61 | // Once the URL finishes loading, Plugin::frameDidFinishLoading will be called with the given requestID. If the URL |
| 62 | // fails to load, Plugin::frameDidFailToLoad will be called. |
| 63 | // |
| 64 | // If the URL is a JavaScript URL, the JavaScript code will be evaluated and the result sent back using Plugin::didEvaluateJavaScript. |
| 65 | virtual void (uint64_t requestID, const String& method, const String& urlString, const String& target, |
| 66 | const WebCore::HTTPHeaderMap& , const Vector<uint8_t>& httpBody, bool ) = 0; |
| 67 | |
| 68 | // Continues the load of a stream that was requested by loadURL. |
| 69 | virtual void continueStreamLoad(uint64_t streamID) = 0; |
| 70 | |
| 71 | // Cancels the load of a stream that was requested by loadURL. |
| 72 | virtual void cancelStreamLoad(uint64_t streamID) = 0; |
| 73 | |
| 74 | // Cancels the load of the manual stream. |
| 75 | virtual void cancelManualStreamLoad() = 0; |
| 76 | |
| 77 | #if ENABLE(NETSCAPE_PLUGIN_API) |
| 78 | // Get the NPObject that corresponds to the window JavaScript object. Returns a retained object. |
| 79 | virtual NPObject* windowScriptNPObject() = 0; |
| 80 | |
| 81 | // Get the NPObject that corresponds to the plug-in's element. Returns a retained object. |
| 82 | virtual NPObject* pluginElementNPObject() = 0; |
| 83 | |
| 84 | // Evaluates the given script string in the context of the given NPObject. |
| 85 | virtual bool evaluate(NPObject*, const String& scriptString, NPVariant* result, bool ) = 0; |
| 86 | |
| 87 | // Called by the Netscape plug-in when it starts or stops playing audio. |
| 88 | virtual void setPluginIsPlayingAudio(bool) = 0; |
| 89 | |
| 90 | // Returns whether the plugin should be muted. |
| 91 | virtual bool isMuted() const = 0; |
| 92 | #endif |
| 93 | |
| 94 | // Set the statusbar text. |
| 95 | virtual void setStatusbarText(const String&) = 0; |
| 96 | |
| 97 | // Return whether accelerated compositing is enabled. |
| 98 | virtual bool isAcceleratedCompositingEnabled() = 0; |
| 99 | |
| 100 | // Tells the controller that the plug-in process has crashed. |
| 101 | virtual void pluginProcessCrashed() = 0; |
| 102 | |
| 103 | #if PLATFORM(COCOA) |
| 104 | // Tells the controller that the plug-in focus or window focus did change. |
| 105 | virtual void pluginFocusOrWindowFocusChanged(bool) = 0; |
| 106 | |
| 107 | // Tells the controller that complex text input be enabled or disabled for the plug-in. |
| 108 | virtual void setComplexTextInputState(PluginComplexTextInputState) = 0; |
| 109 | |
| 110 | // Returns the mach port of the compositing render server. |
| 111 | virtual const WTF::MachSendRight& compositingRenderServerPort() = 0; |
| 112 | #endif |
| 113 | |
| 114 | // Returns the contents scale factor. |
| 115 | virtual float contentsScaleFactor() = 0; |
| 116 | |
| 117 | // Returns the proxies for the given URL or null on failure. |
| 118 | virtual String proxiesForURL(const String&) = 0; |
| 119 | |
| 120 | // Returns the cookies for the given URL or null on failure. |
| 121 | virtual String cookiesForURL(const String&) = 0; |
| 122 | |
| 123 | // Sets the cookies for the given URL. |
| 124 | virtual void setCookiesForURL(const String& urlString, const String& cookieString) = 0; |
| 125 | |
| 126 | // Get authentication credentials for the given protection space. |
| 127 | virtual bool getAuthenticationInfo(const WebCore::ProtectionSpace&, String& username, String& password) = 0; |
| 128 | |
| 129 | // Returns whether private browsing is enabled. |
| 130 | virtual bool isPrivateBrowsingEnabled() = 0; |
| 131 | |
| 132 | // Returns whether or not asynchronous plugin initialization is enabled. |
| 133 | virtual bool asynchronousPluginInitializationEnabled() const { return false; } |
| 134 | |
| 135 | // Returns whether or not asynchronous plugin initialization should be attempted for all plugins. |
| 136 | virtual bool asynchronousPluginInitializationEnabledForAllPlugins() const { return false; } |
| 137 | |
| 138 | // Returns the articifical plugin delay to use for testing of asynchronous plugin initialization. |
| 139 | virtual bool artificialPluginInitializationDelayEnabled() const { return false; } |
| 140 | |
| 141 | // Increments a counter that prevents the plug-in from being destroyed. |
| 142 | virtual void protectPluginFromDestruction() = 0; |
| 143 | |
| 144 | // Decrements a counter that, when it reaches 0, stops preventing the plug-in from being destroyed. |
| 145 | virtual void unprotectPluginFromDestruction() = 0; |
| 146 | |
| 147 | #if PLATFORM(X11) |
| 148 | // Create a plugin container for windowed plugins |
| 149 | virtual uint64_t createPluginContainer() = 0; |
| 150 | virtual void windowedPluginGeometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect, uint64_t windowID) = 0; |
| 151 | virtual void windowedPluginVisibilityDidChange(bool isVisible, uint64_t windowID) = 0; |
| 152 | #endif |
| 153 | |
| 154 | // Called when the a plug-in instance is successfully initialized, either synchronously or asynchronously. |
| 155 | virtual void didInitializePlugin() = 0; |
| 156 | |
| 157 | // Called when the a plug-in instance fails to initialized, either synchronously or asynchronously. |
| 158 | virtual void didFailToInitializePlugin() = 0; |
| 159 | |
| 160 | // Helper class for delaying destruction of a plug-in. |
| 161 | class PluginDestructionProtector { |
| 162 | public: |
| 163 | explicit PluginDestructionProtector(PluginController* pluginController) |
| 164 | : m_pluginController(pluginController) |
| 165 | { |
| 166 | m_pluginController->protectPluginFromDestruction(); |
| 167 | } |
| 168 | |
| 169 | ~PluginDestructionProtector() |
| 170 | { |
| 171 | m_pluginController->unprotectPluginFromDestruction(); |
| 172 | } |
| 173 | |
| 174 | private: |
| 175 | PluginController* m_pluginController; |
| 176 | }; |
| 177 | |
| 178 | protected: |
| 179 | virtual ~PluginController() { } |
| 180 | }; |
| 181 | |
| 182 | } // namespace WebKit |
| 183 | |