webengine/osswebengine/WebKit/s60/plugins/PluginWin.h
changeset 0 dd21522fd290
child 8 7c90e6132015
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Acts as a container of Netscape compatible plugins.
       
    15 *                It provides an adaptor interface between the S60 Browser and
       
    16 *                Netscape compatible plugins.
       
    17 *
       
    18 */
       
    19 
       
    20 #ifndef PLUGINWIN_H
       
    21 #define PlUGINWIN_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32def.h>
       
    25 #include <coecntrl.h>
       
    26 #include <PluginAdapterInterface.h>
       
    27 #include <npapi.h>
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class PluginSkin;
       
    31 class PluginHandler;
       
    32 class PluginStream;
       
    33 class WebView;
       
    34 class MPluginNotifier;
       
    35 class MOptionMenuHandler;
       
    36 struct NPObject;
       
    37 
       
    38 // CLASS DECLARATION
       
    39 
       
    40 // LOCAL CONSTANTS AND MACROS
       
    41 // These are used to designate the handling of incoming content and loading Plugins
       
    42 // during intial construction of the plugin. We could add ELoadModeConstruct.
       
    43 // They are also used when a plugin requests to download additional content, and
       
    44 // the mapping of target (windowType) to content/plugin handling. Currently, the
       
    45 // loadMode is simplistic, and these are sufficent. If we start to support window
       
    46 // target=_Self or others, we can add ELoadModeSelf, etc.
       
    47 enum TPluginEventType
       
    48     {
       
    49     EEventActivate,
       
    50     EEventDeactivate,
       
    51     EEventLoseFocus,
       
    52     EEventGainFocus,
       
    53     };
       
    54 
       
    55 /**
       
    56 * PluginWin
       
    57 * Acts as a container of Netscape compatible plugins. It provides an
       
    58 * adaptor interface between the S60 Browser and Netscape compatible plugins.
       
    59 *
       
    60 * @lib plugin.dll
       
    61 * @since 3.1
       
    62 */
       
    63 class PluginWin :  public CCoeControl,
       
    64                    public MCoeControlObserver,                    
       
    65                    public MCoeForegroundObserver,
       
    66                    public MPluginAdapter,
       
    67                    public MCoeControlHitTest
       
    68     {
       
    69 
       
    70     public:  // Constructors and destructor
       
    71 
       
    72         /**
       
    73         * Two-phased constructor.
       
    74         *
       
    75         * @since 3.1
       
    76         * @param aHandle A unique id that if identifies the corresponding plugin.
       
    77         * @param aPluginSkin The PluginInst's listener.
       
    78         * @param aWebKitView The WebKitView.
       
    79         * @return A pointer to the newly created PluginWin object
       
    80         */
       
    81         static PluginWin* NewL(PluginSkin* pluginskin,
       
    82                                const WebView& view);
       
    83 
       
    84         /**
       
    85         * Destructor.
       
    86         */
       
    87         virtual ~PluginWin();
       
    88 
       
    89         /**
       
    90         * ConstructL
       
    91         * A part of the two phase construction method
       
    92         * @since 3.1
       
    93         * @return void.
       
    94         */
       
    95         void ConstructL(const WebView& view);
       
    96 
       
    97 
       
    98     public: // New functions
       
    99 
       
   100         /**
       
   101         * Refresh the plugin.
       
   102         *
       
   103         * @since 3.1
       
   104         * @return The error code from the plugin
       
   105         */
       
   106         TInt refreshPlugin(CFbsBitGc& bitmapContext);
       
   107 
       
   108         /**
       
   109         * ViewFocusChanged - invoked when WebKitView gains or loses focus
       
   110         *
       
   111         * @since 3.1
       
   112         * @return void
       
   113         */
       
   114         void viewFocusChanged(TBool focused);
       
   115 
       
   116         /**
       
   117         * ResizePluginRect
       
   118         * Resize the plugin rect.
       
   119         *
       
   120         * @since 3.1
       
   121         * @param aRect the new rect
       
   122         * @return void
       
   123         */
       
   124         void resizePluginRect(TRect& rect);
       
   125 
       
   126  
       
   127         /**
       
   128         * pluginSkin
       
   129         * 
       
   130         *
       
   131         * @since 3.1        
       
   132         * @return 
       
   133         */
       
   134         PluginSkin* pluginSkin() { return m_pluginskin; }
       
   135         
       
   136         
       
   137         /**
       
   138         * addPluginOptionsL
       
   139         * 
       
   140         *
       
   141         * @since 3.1        
       
   142         * @return 
       
   143         */
       
   144         void addPluginOptionsL(CEikMenuPane& menuPane, TInt commandBase, TInt after);
       
   145         
       
   146         /**
       
   147         * addPluginOptionsL
       
   148         * 
       
   149         *
       
   150         * @since 3.1        
       
   151         * @return 
       
   152         */
       
   153         void handlePluginCommandL(TInt id);
       
   154         
       
   155         /**
       
   156         * SetPluginFocusL
       
   157         * Give or take focus from the plugin .
       
   158         *
       
   159         * @since 3.1
       
   160         * @param aPluginFocus if true the PluginInst instance takes focus,
       
   161         *                     otherwise it releases it.
       
   162         */
       
   163         void setPluginFocusL(TBool focus);
       
   164 
       
   165         /**
       
   166         * isPluginInFullscreen
       
   167         * returns if plugin in fullscreen
       
   168         *
       
   169         */        
       
   170         bool isPluginInFullscreen() { return m_fullscreen; }
       
   171 
       
   172         /**
       
   173         * isForceScroll
       
   174         * returns true if plugin in forceScroll mode
       
   175         */        
       
   176         bool isForceScroll() { return m_forceScroll; }
       
   177         
       
   178         /**
       
   179         * NotifyPluginVisible
       
   180         * Notify Plugins of their visibility.
       
   181         *
       
   182         */
       
   183         void NotifyPluginVisible(TBool visible);
       
   184  public: // Functions from CCoeControl
       
   185 
       
   186         /**
       
   187         * Returns the number of child controls.
       
   188         *
       
   189         * @since 3.1
       
   190         * @param aIndex index of child control
       
   191         * @return child control
       
   192         */
       
   193         CCoeControl* ComponentControl( TInt index )  const;
       
   194 
       
   195         /**
       
   196         * Returns the number of child controls.
       
   197         *
       
   198         * @since 3.1
       
   199         * @return Always returns 0
       
   200         */
       
   201         TInt CountComponentControls() const;
       
   202 
       
   203         /**
       
   204         * Hides or shows the PluginInst.
       
   205         *
       
   206         * @since 3.1
       
   207         * @param aVisible if true it makes the PluginInst visible otherwise invisible.
       
   208         * @return void.
       
   209         */
       
   210         void makeVisible(TBool visible);
       
   211 
       
   212         /**
       
   213         * Handles an event from an observed control.
       
   214         *
       
   215         * @since 3.1
       
   216         * @param aControl The control that sent the event.
       
   217         * @param aEventType The event type.
       
   218         * @return void.
       
   219         */
       
   220         void HandleControlEventL(CCoeControl *control, TCoeEvent eventType);
       
   221 
       
   222         /**
       
   223         * Updates the size of the control.
       
   224         *
       
   225         * @since 3.1
       
   226         * @return void
       
   227         */
       
   228         void SizeChanged();
       
   229 
       
   230         /**
       
   231         * Updates the size of the control.
       
   232         *
       
   233         * @since 3.1
       
   234         * @return void
       
   235         */
       
   236         void PositionChanged();
       
   237 
       
   238         /**
       
   239         * Updates the size or position of the control.
       
   240         *
       
   241         * @since 5.0
       
   242         * @return void
       
   243         */
       
   244         void windowChanged();
       
   245 
       
   246         /**
       
   247         * Updates the size or position of the control.
       
   248         *
       
   249         * @since 5.0
       
   250         * @return void
       
   251         */
       
   252         void windowChangedL();
       
   253 
       
   254         /**
       
   255         * Hands a key event to the control.
       
   256         *
       
   257         * @since 3.1
       
   258         * @param aKeyEvent The key event.
       
   259         * @param aKeyEvent The type of the key event.
       
   260         * @return EKeyWasNotConsumed.
       
   261         */
       
   262         TKeyResponse OfferKeyEventL(const TKeyEvent& keyevent,TEventCode type);
       
   263         
       
   264         /**
       
   265         * 
       
   266         *
       
   267         * @since 3.1
       
   268         * @param 
       
   269         * @param 
       
   270         * @return 
       
   271         */
       
   272         void processEventL( TPluginEventType eventType, TBool& consumed );
       
   273         TBool HitRegionContains(const TPoint &aPoint, const CCoeControl &/*aControl*/) const;
       
   274 
       
   275         /**
       
   276         * HandlePointerEventL
       
   277         * From CCoeControl
       
   278         *
       
   279         */
       
   280         void HandlePointerEventL(const TPointerEvent& aPointerEvent);
       
   281 
       
   282  
       
   283         /**
       
   284         * Draw
       
   285         * From CCoeControl
       
   286         *
       
   287         */        
       
   288         void Draw(const TRect& rect) const;
       
   289  
       
   290         /**
       
   291         * FocusChanged
       
   292         * From CCoeControl
       
   293         *
       
   294         */        
       
   295         void FocusChanged(TDrawNow aDrawNow);
       
   296 
       
   297   public: //From MCoeForegroundObserver
       
   298 
       
   299     /**
       
   300         * HandleGainingForeground 
       
   301         * @since 3.1
       
   302         * @return none
       
   303         */
       
   304     void HandleGainingForeground();
       
   305     
       
   306     
       
   307     /**
       
   308         * HandleLosingForeground 
       
   309         * @since 3.1
       
   310         * @return none
       
   311         */
       
   312     void HandleLosingForeground();
       
   313 
       
   314 
       
   315         /**
       
   316         * Return window object usable from scriptable plugins
       
   317         * @since 3.1
       
   318         * @return none
       
   319         */
       
   320         NPObject* windowScriptNPObject();
       
   321 
       
   322         /**
       
   323         * Sets the plugin's behaviour as windowed or windowless
       
   324         * @since 3.2
       
   325         * @return
       
   326         */
       
   327         void setWindowedPlugin(bool windowedPlugin) { m_windowedPlugin = windowedPlugin; }
       
   328 
       
   329         /**
       
   330         * Sets the plugin's behaviour as windowed or windowless
       
   331         * @since 3.2
       
   332         * @return
       
   333         */
       
   334         void setTransparentPlugin(bool transparentPlugin) { m_transparentPlugin = transparentPlugin; }
       
   335 
       
   336         /**
       
   337         * Forces a redraw of the screen
       
   338         * @since 3.2
       
   339         * @return
       
   340         */
       
   341         void forceRedraw(bool drawNow);
       
   342         
       
   343         /**
       
   344         * Move/scroll window by aOffset
       
   345         * Sets the cursor poistion
       
   346         * @since 3.1
       
   347         * @return
       
   348         */
       
   349         void moveWindow(const TPoint& aOffset);
       
   350 
       
   351         /**
       
   352         * Deactivate plugin on plugin request
       
   353         * @since 3.1
       
   354         * @return
       
   355         */
       
   356         void pluginDeactivate();        
       
   357         
       
   358 
       
   359 public: // Functions from MPluginAdapter
       
   360 
       
   361     /**
       
   362     * Gets the pointer to the minor version number of the plug-in version
       
   363     * number of the Browser Plug-in API.
       
   364     * @since 3.1
       
   365     * @return Series 60 returns 1. Series 80 and the Nokia 7710 smartphone return 101.
       
   366     */
       
   367     TUint16 GetVersion() {return 1;};
       
   368 
       
   369     /**
       
   370     * Called when the plug-in has completed its creation.
       
   371     * This function is called from the constructL function of the plug-in.
       
   372     * @since 3.1
       
   373     * @param aPluginControl A pointer to the plug-in control window
       
   374     * @return void
       
   375     */
       
   376     void PluginConstructedL(CCoeControl* aControl);
       
   377 
       
   378     /**
       
   379     * Called after the plug-in has been deleted.
       
   380     * This function is called from the destructor of the plug-in.
       
   381     * @since 3.1
       
   382     * @return void
       
   383     */
       
   384     void PluginFinishedL() {m_control = NULL;}
       
   385 
       
   386     /**
       
   387     * Called by the plug-in to open a URL in the parent frame.
       
   388     * This function is not implemented in Series 60. It is supported in Series 80 and in the Nokia 7710 smartphone.
       
   389     * @since 3.1
       
   390     * @param aUrl Name of the URL to open
       
   391     * @return void
       
   392     */
       
   393     void OpenUrlL(const TDesC& /*aUrl*/) {}
       
   394 
       
   395     /**
       
   396     * Called by the plug-in to open a URL in a named window or frame.
       
   397     * This function is not implemented in Series 60. It is supported in
       
   398     * Series 80 and in the Nokia 7710 smartphone.
       
   399     * @since 3.1
       
   400     * @param aUrl Name of the URL to open
       
   401     * @param aNewTargetWindowName The name of the target window or frame
       
   402     * @return void
       
   403     */
       
   404     void OpenUrlInTargetWindowL(const TDesC& /*aUrl*/,
       
   405                                 const TDesC& /*aNewTargetWindowName*/) {}
       
   406 
       
   407     /**
       
   408     * Specifies whether or not the frame has a previous navigation history item.
       
   409     * This function is not implemented in Series 60. It is supported in Series 80
       
   410     * and in the Nokia 7710 smartphone.
       
   411     * @since 3.1
       
   412     * @return ETrue if the frame has a previous navigation history item false otherwise
       
   413     */
       
   414     TBool HasNavigationHistoryPrevious() const{return EFalse;}
       
   415 
       
   416     /**
       
   417     * Informs the browser to load the next navigation history URL in its parent frame.
       
   418     * This function is not implemented in Series 60. It is supported in Series 80
       
   419     * and in the Nokia 7710 smartphone.
       
   420     * @since 3.1
       
   421     * @return void
       
   422     */
       
   423     void LoadNavigationHistoryPreviousL(){}
       
   424 
       
   425     /**
       
   426     * Returns whether the frame has a next navigation history item.
       
   427     * This function is not implemented in Series 60. It is supported
       
   428     * in Series 80 and in the Nokia 7710 smartphone.
       
   429     * @since 3.1
       
   430     * @return Returns whether the frame has a next navigation history item.
       
   431     */
       
   432     TBool HasNavigationHistoryNext() const{return EFalse;}
       
   433 
       
   434     /**
       
   435     * Informs the browser to load the next navigation history URL in its
       
   436     * parent frame. This function is not implemented in Series 60. It is
       
   437     * supported in Series 80 and in the Nokia 7710 smartphone.
       
   438     * @since 3.1
       
   439     * @return void
       
   440     */
       
   441     void LoadNavigationHistoryNextL(){}
       
   442 
       
   443     /**
       
   444     * Returns the window system level control object for the plug-in.
       
   445     * @since 3.1
       
   446     * @return A pointer to the parent control window.
       
   447     */
       
   448     CCoeControl* GetParentControl(){return this;};
       
   449 
       
   450     /**
       
   451     * Returns the observer for the plug-in control.
       
   452     * @since 3.1
       
   453     * @return Observer that the plug-in can use to send events to the browser.
       
   454     */
       
   455     MCoeControlObserver* GetParentControlObserver(){return this;};
       
   456 
       
   457     /**
       
   458     * Sets the plug-in notifier allowing the plug-in to control portions of the browser.
       
   459     * @since 3.1
       
   460     * @param aNotifier Pointer to an interface that the browser can use to send events to the plug-in.
       
   461     * @return void
       
   462     */
       
   463     void SetPluginNotifier(MPluginNotifier* notifier) { m_notifier = notifier; }
       
   464 
       
   465     /**
       
   466     * Sets the plug-in option menu handler, allowing the plug-in to handle the custom
       
   467     * menu commands from the browser.
       
   468     * @since 3.1
       
   469     * @param aOptionMenuHandler Pointer to an interface that the browser can use to send
       
   470     * option menu commands to the plug-in.
       
   471     * @return void
       
   472     */
       
   473     void SetOptionMenuHandler(MOptionMenuHandler* optionmenuhandler){ m_optionmenuhandler = optionmenuhandler; }
       
   474 
       
   475 
       
   476     /**
       
   477     * PluginDataUrl  
       
   478     * @since 3.1
       
   479     * @param       
       
   480     * @return void
       
   481     */
       
   482     HBufC8* PluginDataUrl();
       
   483     
       
   484     
       
   485     void TogleScreenMode(bool aFullScreen);
       
   486     protected: // New functions
       
   487 
       
   488         /**
       
   489         * C++ default constructor.
       
   490         *
       
   491         * @since 3.1
       
   492         * @param 
       
   493         * @param 
       
   494         */
       
   495         PluginWin(PluginSkin* pluginskin);
       
   496                                
       
   497     private:    // Data
       
   498         
       
   499         CCoeControl*                        m_control;
       
   500         MPluginNotifier*                    m_notifier;
       
   501         MOptionMenuHandler*                 m_optionmenuhandler;
       
   502                         
       
   503         PluginSkin*                         m_pluginskin;      //not owned               
       
   504         TBool                               m_pluginfocus;
       
   505         bool                                m_windowedPlugin;
       
   506         bool                                m_transparentPlugin;
       
   507         CFbsBitmap*                         m_bitmap;       //The bitmap for windowless plugin
       
   508         CFbsBitmap*                         m_mask;         //The mask for transparent windowless plugin
       
   509         CFbsBitmapDevice*                   m_bitmapDeviceMask;
       
   510         CFbsBitGc*                          m_bitmapContextMask; 
       
   511         bool                                m_fullscreen;
       
   512         bool                                m_windowCreated;
       
   513         bool                                m_forceScroll;
       
   514     };
       
   515 
       
   516 
       
   517 #endif      // PluginWin_H
       
   518 
       
   519 // End of File