PluginController.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. #ifndef PluginController_h
  26. #define PluginController_h
  27. #include <wtf/Forward.h>
  28. #if PLATFORM(MAC)
  29. #include "PluginComplexTextInputState.h"
  30. #endif
  31. struct NPObject;
  32. typedef struct _NPVariant NPVariant;
  33. typedef void* NPIdentifier;
  34. namespace WebCore {
  35. class HTTPHeaderMap;
  36. class IntRect;
  37. class KURL;
  38. class ProtectionSpace;
  39. }
  40. namespace WebKit {
  41. class PluginController {
  42. public:
  43. // Returns false if the plugin has explicitly been hidden. Returns true otherwise (even if the plugin is currently obscured from view on screen.)
  44. virtual bool isPluginVisible() = 0;
  45. // Tells the controller that the plug-in wants the given rect to be repainted. The rect is in the plug-in's coordinate system.
  46. virtual void invalidate(const WebCore::IntRect&) = 0;
  47. // Returns the user agent string.
  48. virtual String userAgent() = 0;
  49. // Loads the given URL and associates it with the request ID.
  50. //
  51. // If a target is specified, then the URL will be loaded in the window or frame that the target refers to.
  52. // Once the URL finishes loading, Plugin::frameDidFinishLoading will be called with the given requestID. If the URL
  53. // fails to load, Plugin::frameDidFailToLoad will be called.
  54. //
  55. // If the URL is a JavaScript URL, the JavaScript code will be evaluated and the result sent back using Plugin::didEvaluateJavaScript.
  56. virtual void loadURL(uint64_t requestID, const String& method, const String& urlString, const String& target,
  57. const WebCore::HTTPHeaderMap& headerFields, const Vector<uint8_t>& httpBody, bool allowPopups) = 0;
  58. /// Cancels the load of a stream that was requested by loadURL.
  59. virtual void cancelStreamLoad(uint64_t streamID) = 0;
  60. // Cancels the load of the manual stream.
  61. virtual void cancelManualStreamLoad() = 0;
  62. #if ENABLE(NETSCAPE_PLUGIN_API)
  63. // Get the NPObject that corresponds to the window JavaScript object. Returns a retained object.
  64. virtual NPObject* windowScriptNPObject() = 0;
  65. // Get the NPObject that corresponds to the plug-in's element. Returns a retained object.
  66. virtual NPObject* pluginElementNPObject() = 0;
  67. // Evaluates the given script string in the context of the given NPObject.
  68. virtual bool evaluate(NPObject*, const String& scriptString, NPVariant* result, bool allowPopups) = 0;
  69. #endif
  70. // Set the statusbar text.
  71. virtual void setStatusbarText(const String&) = 0;
  72. #if USE(ACCELERATED_COMPOSITING)
  73. // Return whether accelerated compositing is enabled.
  74. virtual bool isAcceleratedCompositingEnabled() = 0;
  75. #endif
  76. // Tells the controller that the plug-in process has crashed.
  77. virtual void pluginProcessCrashed() = 0;
  78. // Tells the controller that we're about to dispatch an event to the plug-in.
  79. virtual void willSendEventToPlugin() = 0;
  80. #if PLATFORM(MAC)
  81. // Tells the controller that the plug-in focus or window focus did change.
  82. virtual void pluginFocusOrWindowFocusChanged(bool) = 0;
  83. // Tells the controller that complex text input be enabled or disabled for the plug-in.
  84. virtual void setComplexTextInputState(PluginComplexTextInputState) = 0;
  85. // Returns the mach port of the compositing render server.
  86. virtual mach_port_t compositingRenderServerPort() = 0;
  87. // Open the preference pane for this plug-in (as stated in the plug-in's Info.plist).
  88. virtual void openPluginPreferencePane() = 0;
  89. #endif
  90. // Returns the contents scale factor.
  91. virtual float contentsScaleFactor() = 0;
  92. // Returns the proxies for the given URL or null on failure.
  93. virtual String proxiesForURL(const String&) = 0;
  94. // Returns the cookies for the given URL or null on failure.
  95. virtual String cookiesForURL(const String&) = 0;
  96. // Sets the cookies for the given URL.
  97. virtual void setCookiesForURL(const String& urlString, const String& cookieString) = 0;
  98. // Get authentication credentials for the given protection space.
  99. virtual bool getAuthenticationInfo(const WebCore::ProtectionSpace&, String& username, String& password) = 0;
  100. // Returns whether private browsing is enabled.
  101. virtual bool isPrivateBrowsingEnabled() = 0;
  102. // Returns whether or not asynchronous plugin initialization is enabled.
  103. virtual bool asynchronousPluginInitializationEnabled() const { return false; }
  104. // Returns whether or not asynchronous plugin initialization should be attempted for all plugins.
  105. virtual bool asynchronousPluginInitializationEnabledForAllPlugins() const { return false; }
  106. // Returns the articifical plugin delay to use for testing of asynchronous plugin initialization.
  107. virtual bool artificialPluginInitializationDelayEnabled() const { return false; }
  108. // Increments a counter that prevents the plug-in from being destroyed.
  109. virtual void protectPluginFromDestruction() = 0;
  110. // Decrements a counter that, when it reaches 0, stops preventing the plug-in from being destroyed.
  111. virtual void unprotectPluginFromDestruction() = 0;
  112. #if PLUGIN_ARCHITECTURE(X11)
  113. // Create a plugin container for windowed plugins
  114. virtual uint64_t createPluginContainer() = 0;
  115. virtual void windowedPluginGeometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect, uint64_t windowID) = 0;
  116. #endif
  117. // Called when the a plug-in instance is successfully initialized, either synchronously or asynchronously.
  118. virtual void didInitializePlugin() = 0;
  119. // Called when the a plug-in instance fails to initialized, either synchronously or asynchronously.
  120. virtual void didFailToInitializePlugin() = 0;
  121. // Helper class for delaying destruction of a plug-in.
  122. class PluginDestructionProtector {
  123. public:
  124. explicit PluginDestructionProtector(PluginController* pluginController)
  125. : m_pluginController(pluginController)
  126. {
  127. m_pluginController->protectPluginFromDestruction();
  128. }
  129. ~PluginDestructionProtector()
  130. {
  131. m_pluginController->unprotectPluginFromDestruction();
  132. }
  133. private:
  134. PluginController* m_pluginController;
  135. };
  136. protected:
  137. virtual ~PluginController() { }
  138. };
  139. } // namespace WebKit
  140. #endif // PluginController_h