webengine/osswebengine/WebKit/Plugins/WebBaseNetscapePluginView.h
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     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 
       
    29 #ifndef __LP64__
       
    30 #import <Cocoa/Cocoa.h>
       
    31 
       
    32 #import <AGL/agl.h>
       
    33 #import <WebKit/npfunctions.h>
       
    34 #import <WebKit/npapi.h>
       
    35 #import <WebKit/WebBasePluginPackage.h>
       
    36 
       
    37 @class DOMElement;
       
    38 @class WebDataSource;
       
    39 @class WebFrame;
       
    40 @class WebNetscapePluginPackage;
       
    41 @class WebNetscapePluginNullEventSender;
       
    42 @class WebBaseNetscapePluginStream;
       
    43 @class WebNetscapePluginStream;
       
    44 @class WebView;
       
    45 
       
    46 typedef union PluginPort {
       
    47 #ifndef NP_NO_QUICKDRAW
       
    48     NP_Port qdPort;
       
    49 #endif        
       
    50     NP_CGContext cgPort;
       
    51     NP_GLContext aglPort;
       
    52 } PluginPort;
       
    53 
       
    54 @interface WebBaseNetscapePluginView : NSView <WebPluginManualLoader>
       
    55 {
       
    56     WebNetscapePluginPackage *pluginPackage;
       
    57     
       
    58     NSURL *sourceURL;
       
    59     WebFrame *_webFrame;
       
    60     
       
    61     BOOL _loadManually;
       
    62     WebNetscapePluginStream *_manualStream;
       
    63     unsigned _dataLengthReceived;
       
    64     NSError *_error;
       
    65     
       
    66     int mode;
       
    67     
       
    68     unsigned argsCount;
       
    69     char **cAttributes;
       
    70     char **cValues;
       
    71         
       
    72     NPP plugin;
       
    73     NPWindow window;
       
    74     NPWindow lastSetWindow;
       
    75     PluginPort nPort;
       
    76     PluginPort lastSetPort;
       
    77     NPDrawingModel drawingModel;
       
    78     
       
    79     // These are only valid when drawingModel is NPDrawingModelOpenGL
       
    80     AGLContext aglContext;
       
    81     NSWindow *aglWindow;
       
    82 
       
    83 #ifndef NP_NO_QUICKDRAW
       
    84     // This is only valid when drawingModel is NPDrawingModelQuickDraw
       
    85     GWorldPtr offscreenGWorld;
       
    86 #endif
       
    87 
       
    88     BOOL isStarted;
       
    89     BOOL inSetWindow;
       
    90     BOOL suspendKeyUpEvents;
       
    91     BOOL hasFocus;
       
    92     BOOL currentEventIsUserGesture;
       
    93     BOOL isTransparent;
       
    94     BOOL isCompletelyObscured;
       
    95     BOOL shouldStopSoon;
       
    96 
       
    97     unsigned pluginFunctionCallDepth;
       
    98     
       
    99     DOMElement *element;
       
   100     
       
   101     int32 specifiedHeight;
       
   102     int32 specifiedWidth;
       
   103             
       
   104     NSString *MIMEType;
       
   105     NSURL *baseURL;
       
   106     NSTrackingRectTag trackingTag;
       
   107     NSMutableArray *streams;
       
   108     NSMutableDictionary *pendingFrameLoads;
       
   109     NSTimer *nullEventTimer;
       
   110     
       
   111     NPP_NewProcPtr NPP_New;
       
   112     NPP_DestroyProcPtr NPP_Destroy;
       
   113     NPP_SetWindowProcPtr NPP_SetWindow;
       
   114     NPP_NewStreamProcPtr NPP_NewStream;
       
   115     NPP_DestroyStreamProcPtr NPP_DestroyStream;
       
   116     NPP_StreamAsFileProcPtr NPP_StreamAsFile;
       
   117     NPP_WriteReadyProcPtr NPP_WriteReady;
       
   118     NPP_WriteProcPtr NPP_Write;
       
   119     NPP_PrintProcPtr NPP_Print;
       
   120     NPP_HandleEventProcPtr NPP_HandleEvent;
       
   121     NPP_URLNotifyProcPtr NPP_URLNotify;
       
   122     NPP_GetValueProcPtr NPP_GetValue;
       
   123     NPP_SetValueProcPtr NPP_SetValue;
       
   124     
       
   125     EventHandlerRef keyEventHandler;
       
   126 }
       
   127 
       
   128 + (WebBaseNetscapePluginView *)currentPluginView;
       
   129 
       
   130 
       
   131 - (id)initWithFrame:(NSRect)r
       
   132       pluginPackage:(WebNetscapePluginPackage *)thePluginPackage
       
   133                 URL:(NSURL *)URL
       
   134             baseURL:(NSURL *)baseURL
       
   135            MIMEType:(NSString *)MIME
       
   136       attributeKeys:(NSArray *)keys
       
   137     attributeValues:(NSArray *)values
       
   138        loadManually:(BOOL)loadManually
       
   139          DOMElement:(DOMElement *)anElement;
       
   140 
       
   141 
       
   142 - (BOOL)start;
       
   143 - (BOOL)isStarted;
       
   144 - (void)stop;
       
   145 
       
   146 - (WebFrame *)webFrame;
       
   147 - (WebDataSource *)dataSource;
       
   148 - (WebView *)webView;
       
   149 - (NSWindow *)currentWindow;
       
   150 
       
   151 - (NPP)plugin;
       
   152 
       
   153 - (WebNetscapePluginPackage *)pluginPackage;
       
   154 - (void)setPluginPackage:(WebNetscapePluginPackage *)thePluginPackage;
       
   155 - (void)setMIMEType:(NSString *)theMIMEType;
       
   156 - (void)setBaseURL:(NSURL *)theBaseURL;
       
   157 - (void)setAttributeKeys:(NSArray *)keys andValues:(NSArray *)values;
       
   158 - (void)setMode:(int)theMode;
       
   159 - (void)viewWillMoveToHostWindow:(NSWindow *)hostWindow;
       
   160 - (void)viewDidMoveToHostWindow;
       
   161 - (void)disconnectStream:(WebBaseNetscapePluginStream*)stream;
       
   162 
       
   163 // Returns the NPObject that represents the plugin interface.
       
   164 // The return value is expected to be retained.
       
   165 - (NPObject *)createPluginScriptableObject;
       
   166 
       
   167 // -willCallPlugInFunction must be called before calling any of the NPP_* functions for this view's plugin.
       
   168 // This is necessary to ensure that plug-ins are not destroyed while WebKit calls into them.  Some plug-ins (Flash
       
   169 // at least) are written with the assumption that nothing they do in their plug-in functions can cause NPP_Destroy()
       
   170 // to be called.  Unfortunately, this is not true, especially if the plug-in uses NPN_Invoke() to execute a
       
   171 // document.write(), which clears the document and destroys the plug-in.
       
   172 // See <rdar://problem/4480737>.
       
   173 - (void)willCallPlugInFunction;
       
   174 
       
   175 // -didCallPlugInFunction should be called after returning from a plug-in function.  It should be called exactly
       
   176 // once for every call to -willCallPlugInFunction.
       
   177 // See <rdar://problem/4480737>.
       
   178 - (void)didCallPlugInFunction;
       
   179 
       
   180 @end
       
   181 #endif
       
   182