WebNetscapePluginView.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*
  2. * Copyright (C) 2005, 2007 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. *
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
  14. * its contributors may be used to endorse or promote products derived
  15. * from this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
  18. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
  21. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  26. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. */
  28. #if ENABLE(NETSCAPE_PLUGIN_API)
  29. #import "WebBaseNetscapePluginView.h"
  30. #import "WebNetscapeContainerCheckPrivate.h"
  31. #import <WebKit/npfunctions.h>
  32. #import <WebKit/npapi.h>
  33. #import <wtf/HashMap.h>
  34. #import <wtf/HashSet.h>
  35. #import <wtf/OwnPtr.h>
  36. @class WebDataSource;
  37. @class WebFrame;
  38. @class WebNetscapePluginPackage;
  39. @class WebView;
  40. class PluginTimer;
  41. class WebNetscapePluginStream;
  42. class WebNetscapePluginEventHandler;
  43. typedef union PluginPort {
  44. #ifndef NP_NO_QUICKDRAW
  45. NP_Port qdPort;
  46. #endif
  47. NP_CGContext cgPort;
  48. } PluginPort;
  49. // Because the Adobe 7.x Acrobat plug-in has a hard coded check for a view named
  50. // "WebNetscapePluginDocumentView", this class must retain the old name in order
  51. // for the plug-in to function correctly. (rdar://problem/4699455)
  52. #define WebNetscapePluginView WebNetscapePluginDocumentView
  53. @interface WebNetscapePluginView : WebBaseNetscapePluginView<WebPluginManualLoader, WebPluginContainerCheckController>
  54. {
  55. RefPtr<WebNetscapePluginStream> _manualStream;
  56. RetainPtr<CALayer> _pluginLayer;
  57. unsigned _dataLengthReceived;
  58. RetainPtr<NSError> _error;
  59. unsigned argsCount;
  60. char **cAttributes;
  61. char **cValues;
  62. NPP plugin;
  63. NPWindow window;
  64. NPWindow lastSetWindow;
  65. PluginPort nPort;
  66. PluginPort lastSetPort;
  67. NPDrawingModel drawingModel;
  68. NPEventModel eventModel;
  69. #ifndef NP_NO_QUICKDRAW
  70. // This is only valid when drawingModel is NPDrawingModelQuickDraw
  71. GWorldPtr offscreenGWorld;
  72. #endif
  73. OwnPtr<WebNetscapePluginEventHandler> _eventHandler;
  74. BOOL inSetWindow;
  75. BOOL shouldStopSoon;
  76. uint32_t currentTimerID;
  77. HashMap<uint32_t, PluginTimer*>* timers;
  78. unsigned pluginFunctionCallDepth;
  79. int32_t specifiedHeight;
  80. int32_t specifiedWidth;
  81. HashSet<RefPtr<WebNetscapePluginStream> > streams;
  82. RetainPtr<NSMapTable> _pendingFrameLoads;
  83. BOOL _isFlash;
  84. BOOL _isSilverlight;
  85. NSMutableDictionary *_containerChecksInProgress;
  86. uint32_t _currentContainerCheckRequestID;
  87. }
  88. + (WebNetscapePluginView *)currentPluginView;
  89. - (id)initWithFrame:(NSRect)r
  90. pluginPackage:(WebNetscapePluginPackage *)thePluginPackage
  91. URL:(NSURL *)URL
  92. baseURL:(NSURL *)baseURL
  93. MIMEType:(NSString *)MIME
  94. attributeKeys:(NSArray *)keys
  95. attributeValues:(NSArray *)values
  96. loadManually:(BOOL)loadManually
  97. element:(PassRefPtr<WebCore::HTMLPlugInElement>)element;
  98. - (NPP)plugin;
  99. - (void)disconnectStream:(WebNetscapePluginStream*)stream;
  100. // Returns the NPObject that represents the plugin interface.
  101. // The return value is expected to be retained.
  102. - (NPObject *)createPluginScriptableObject;
  103. // Returns the form value associated with the plugin instance.
  104. - (BOOL)getFormValue:(NSString **)value;
  105. // -willCallPlugInFunction must be called before calling any of the NPP_* functions for this view's plugin.
  106. // This is necessary to ensure that plug-ins are not destroyed while WebKit calls into them. Some plug-ins (Flash
  107. // at least) are written with the assumption that nothing they do in their plug-in functions can cause NPP_Destroy()
  108. // to be called. Unfortunately, this is not true, especially if the plug-in uses NPN_Invoke() to execute a
  109. // document.write(), which clears the document and destroys the plug-in.
  110. // See <rdar://problem/4480737>.
  111. - (void)willCallPlugInFunction;
  112. // -didCallPlugInFunction should be called after returning from a plug-in function. It should be called exactly
  113. // once for every call to -willCallPlugInFunction.
  114. // See <rdar://problem/4480737>.
  115. - (void)didCallPlugInFunction;
  116. - (void)handleMouseMoved:(NSEvent *)event;
  117. - (void)handleMouseEntered:(NSEvent *)event;
  118. - (void)handleMouseExited:(NSEvent *)event;
  119. - (uint32_t)checkIfAllowedToLoadURL:(const char*)urlCString frame:(const char*)frameNameCString callbackFunc:(void (*)(NPP npp, uint32_t checkID, NPBool allowed, void* context))callbackFunc context:(void*)context;
  120. - (void)cancelCheckIfAllowedToLoadURL:(uint32_t)checkID;
  121. @end
  122. @interface WebNetscapePluginView (WebInternal)
  123. - (BOOL)sendEvent:(void*)event isDrawRect:(BOOL)eventIsDrawRect;
  124. - (NPEventModel)eventModel;
  125. - (CALayer *)pluginLayer;
  126. - (NPError)loadRequest:(NSURLRequest *)request inTarget:(NSString *)target withNotifyData:(void *)notifyData sendNotification:(BOOL)sendNotification;
  127. - (NPError)getURLNotify:(const char *)URL target:(const char *)target notifyData:(void *)notifyData;
  128. - (NPError)getURL:(const char *)URL target:(const char *)target;
  129. - (NPError)postURLNotify:(const char *)URL target:(const char *)target len:(UInt32)len buf:(const char *)buf file:(NPBool)file notifyData:(void *)notifyData;
  130. - (NPError)postURL:(const char *)URL target:(const char *)target len:(UInt32)len buf:(const char *)buf file:(NPBool)file;
  131. - (NPError)newStream:(NPMIMEType)type target:(const char *)target stream:(NPStream**)stream;
  132. - (NPError)write:(NPStream*)stream len:(SInt32)len buffer:(void *)buffer;
  133. - (NPError)destroyStream:(NPStream*)stream reason:(NPReason)reason;
  134. - (void)status:(const char *)message;
  135. - (const char *)userAgent;
  136. - (void)invalidateRect:(NPRect *)invalidRect;
  137. - (void)invalidateRegion:(NPRegion)invalidateRegion;
  138. - (void)forceRedraw;
  139. - (NPError)getVariable:(NPNVariable)variable value:(void *)value;
  140. - (NPError)setVariable:(NPPVariable)variable value:(void *)value;
  141. - (uint32_t)scheduleTimerWithInterval:(uint32_t)interval repeat:(NPBool)repeat timerFunc:(void (*)(NPP npp, uint32_t timerID))timerFunc;
  142. - (void)unscheduleTimer:(uint32_t)timerID;
  143. - (NPError)popUpContextMenu:(NPMenu *)menu;
  144. - (NPError)getVariable:(NPNURLVariable)variable forURL:(const char*)url value:(char**)value length:(uint32_t*)length;
  145. - (NPError)setVariable:(NPNURLVariable)variable forURL:(const char*)url value:(const char*)value length:(uint32_t)length;
  146. - (NPError)getAuthenticationInfoWithProtocol:(const char*) protocol host:(const char*)host port:(int32_t)port scheme:(const char*)scheme realm:(const char*)realm
  147. username:(char**)username usernameLength:(uint32_t*)usernameLength
  148. password:(char**)password passwordLength:(uint32_t*)passwordLength;
  149. - (char*)resolveURL:(const char*)url forTarget:(const char*)target;
  150. @end
  151. WKNBrowserContainerCheckFuncs *browserContainerCheckFuncs();
  152. #endif