webengine/osswebengine/WebKit/s60/plugins/PluginSkin.h
changeset 0 dd21522fd290
child 5 10e98eab6f85
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:  Represents the Object Widget From Webcore
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __PLUGINSKIN_H__
       
    20 #define __PLUGINSKIN_H__
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <badesca.h>
       
    25 #include <wtf/Vector.h>
       
    26 #include <wtf/HashSet.h>
       
    27 #include <npupp.h>
       
    28 #include "WebCoreWidget.h"
       
    29 #include "WebCannedImages.h"
       
    30 #include "PluginPlayer.h"
       
    31 #include "WebFrame.h"
       
    32 #include "WebFrameView.h"
       
    33 #include "WebView.h"
       
    34 #include "MemoryManager.h"
       
    35 //#include <Element.h>
       
    36 
       
    37 // FORWARD DECLARATIONS
       
    38 class PluginWin;
       
    39 class PluginStream;
       
    40 class WebFrame;
       
    41 
       
    42 namespace WebCore {
       
    43     class String;
       
    44     class Element;
       
    45 }
       
    46 
       
    47 // LOCAL CONSTANTS AND MACROS
       
    48 // These are used to designate the handling of incoming content and loading Plugins
       
    49 // during intial construction of the plugin. We could add ELoadModeConstruct.
       
    50 // They are also used when a plugin requests to download additional content, and
       
    51 // the mapping of target (windowType) to content/plugin handling. 
       
    52 enum TPluginLoadMode
       
    53     {
       
    54     ELoadModeTop,
       
    55     ELoadModeSaveAsFile,
       
    56     ELoadModePlugin,
       
    57     ELoadModeNew,
       
    58     ELoadModeParent,
       
    59     ELoadModeSelf,
       
    60     ELoadModeNone
       
    61     };
       
    62  
       
    63  enum TWindowType
       
    64     {
       
    65     EWindowTypePlugin = 0,
       
    66     EWindowTypeBlank,
       
    67     EWindowTypeNew,
       
    68     EWindowTypeSelf,
       
    69     EWindowTypeCurrent,
       
    70     EWindowTypeParent,
       
    71     EWindowTypeTop,
       
    72     EWindowTypeUnknown
       
    73     };
       
    74 
       
    75 _LIT(KBlank, "_blank");
       
    76 _LIT(KNew, "_new");
       
    77 _LIT(KSelf, "_self");
       
    78 _LIT(KCurrent, "_current");
       
    79 _LIT(KParent, "_parent");
       
    80 _LIT(KTop, "_top");
       
    81     
       
    82 /**
       
    83 *  PluginSkin
       
    84 *  Represents the Object Widget
       
    85 *  This class acts as an Adapter between the webcore and the plugin engines.
       
    86 *
       
    87 *  @lib plugin.dll
       
    88 *  @since 3.1
       
    89 */
       
    90 
       
    91 class PluginSkin : public CBase,
       
    92                    public MWebCoreObjectWidget,
       
    93                    public MMemoryCollector
       
    94 
       
    95   {
       
    96     public: //  Constructors and destructor
       
    97 
       
    98         /**
       
    99         * Two-phased constructor.
       
   100         */
       
   101         static PluginSkin* NewL( WebFrame& frame,
       
   102                                  const TPtrC8& url,
       
   103                                  const Vector<WebCore::String>& attributesNames,
       
   104                                  const Vector<WebCore::String>& attributeValues,
       
   105                                  const TPtrC8& baseUrl,
       
   106                                  const WebCore::String& mimeType,
       
   107                                  TBool canInteract);
       
   108 
       
   109         /**
       
   110         * destructor.
       
   111         */
       
   112         virtual ~PluginSkin();
       
   113 
       
   114     private:    // Constructors
       
   115 
       
   116         /**
       
   117         * C++ default constructor.
       
   118         */
       
   119         PluginSkin( WebFrame& webFrame );
       
   120 
       
   121         /**
       
   122         * By default Symbian 2nd phase constructor is private.
       
   123         */
       
   124         void ConstructL( const WebCore::String& mimeType,
       
   125                          const Vector<WebCore::String>& attributesNames,
       
   126                          const Vector<WebCore::String>& attributeValues,
       
   127                          const TPtrC8& url,
       
   128                          const TPtrC8& baseUrl,
       
   129                          TBool canInteract);
       
   130 
       
   131 
       
   132     public:
       
   133 
       
   134 
       
   135         /**
       
   136         * PluginWin
       
   137         * Returns a pointer to the CPluginWin object.
       
   138         * @since 3.1
       
   139         * @return The CPluginWin object
       
   140         */
       
   141         PluginWin* pluginWin() { return m_pluginwin;}
       
   142 
       
   143 
       
   144         /**
       
   145         * Frame
       
   146         * Returns a pointer to WebKitFrame object.
       
   147         * @since 3.1
       
   148         * @return The WebKitControl object
       
   149         */
       
   150         WebFrame* frame() const { return m_frame; } 
       
   151         
       
   152         
       
   153         /**
       
   154         * 
       
   155         * 
       
   156         * @since 3.1
       
   157         * @return 
       
   158         */
       
   159         void createPluginWinL(TDesC8& url, TDesC& mimetype);
       
   160 
       
   161 
       
   162         /**
       
   163         * 
       
   164         * 
       
   165         * @since 3.1
       
   166         * @return 
       
   167         */
       
   168         void loadPluginL( const TDesC8& mimetype );
       
   169 
       
   170         /**
       
   171         * 
       
   172         * 
       
   173         * @since 3.1
       
   174         * @return 
       
   175         */
       
   176         NPP getNPP(){return m_instance;}
       
   177 
       
   178         /**
       
   179         * 
       
   180         * 
       
   181         * @since 3.1
       
   182         * @return 
       
   183         */
       
   184         NPPluginFuncs* getNPPluginFucs() {return m_pluginfuncs;}
       
   185 
       
   186         /**
       
   187         * 
       
   188         * 
       
   189         * @since 3.1
       
   190         * @return 
       
   191         */
       
   192         void forceRedraw(bool drawNow = true);
       
   193 
       
   194         /**
       
   195         * 
       
   196         * 
       
   197         * @since 3.1
       
   198         * @return 
       
   199         */        
       
   200         TBool isBrowserScheme(const TPtrC8& url);
       
   201         
       
   202         /**
       
   203         *
       
   204         * GetLoadMode
       
   205         * Returns the load mode associated with the "window-type".
       
   206         */
       
   207         TPluginLoadMode GetLoadMode(const TDesC* aWindowType);
       
   208         
       
   209         /**
       
   210         *
       
   211         * GetWindowType
       
   212         * Resolves the "window-type" string into a TWindowType.
       
   213         */
       
   214         TWindowType GetWindowType(const TDesC* aWindowType);
       
   215 
       
   216     public: // Methods From MWebCoreObjectWidget
       
   217 
       
   218         void setNeedsDisplay( TBool ) {}
       
   219         
       
   220         void setCursor( CursorTypes ) {}
       
   221         /**
       
   222         * Draw
       
   223         * From MWebCoreObjectWidget
       
   224         * Repaints the frame.
       
   225         * @since 3.1
       
   226         * @param TRect& aRect
       
   227         * @return void
       
   228         */
       
   229         void draw( WebCoreGraphicsContext& gc,
       
   230                    const TRect& rect );
       
   231 
       
   232 
       
   233         /**
       
   234         * IsVisible
       
   235         * From MWebCoreObjectWidget
       
   236         * Purpose:
       
   237         * @since 3.1
       
   238         * @return void
       
   239         */
       
   240         TBool isVisible() const;
       
   241 
       
   242         /**
       
   243         * SizeHint
       
   244         * From MWebCoreObjectWidget
       
   245         * Purpose
       
   246         * @since 3.1
       
   247         * @return TSize
       
   248         */
       
   249         TSize sizeHint() const;
       
   250 
       
   251         /**
       
   252         * IsFocused
       
   253         * From MWebCoreObjectWidget
       
   254         * Purpose
       
   255         * @since 3.1
       
   256         * @return TBool
       
   257         */
       
   258         TBool isFocused() const { return ETrue; }
       
   259 
       
   260         /**
       
   261         * MakeVisible
       
   262         * From MWebCoreObjectWidget
       
   263         * Purpose
       
   264         * @since 3.0
       
   265         * @param TBool aVisible
       
   266         * @return void
       
   267         */
       
   268         void makeVisible(TBool visible) ;
       
   269 
       
   270         /**
       
   271         * SetFocus
       
   272         * From MWebCoreObjectWidget
       
   273         * Purpose
       
   274         * @since 3.1
       
   275         * @param TBool aFoucs
       
   276         * @return void
       
   277         */
       
   278         void setFocus(TBool focus) ;
       
   279 
       
   280         /**
       
   281         * Activate
       
   282         * From MWebCoreObjectWidget
       
   283         * Purpose Activated the plugin
       
   284         * @since 3.1
       
   285         * @param TBool aFoucs
       
   286         * @return void
       
   287         */
       
   288         void activate();
       
   289 
       
   290         /**
       
   291         * Rect
       
   292         * From MWebCoreObjectWidget
       
   293         * Purpose
       
   294         * @since 3.1
       
   295         * @return TRect
       
   296         */
       
   297         TRect rect() const;
       
   298 
       
   299         /**
       
   300         * SetRect
       
   301         * From MWebCoreObjectWidget
       
   302         * Purpose Sets the Rect
       
   303         * @since 3.1
       
   304         * @param TRect aRect
       
   305         * @return void
       
   306         */
       
   307         void setRect(const TRect& rect);
       
   308 
       
   309 
       
   310         /**
       
   311         * IsFocusable
       
   312         * From MWebCoreObjectWidget
       
   313         * Purpose Check if the plugin is focusable
       
   314         * @since 3.2
       
   315         * @param TRect aRect
       
   316         * @return void
       
   317         */
       
   318         TBool isFocusable() const;
       
   319 
       
   320        /**
       
   321         * SetParent
       
   322         * From MWebCoreObjectWidget
       
   323         * Set the CCoeControl parent for this WebKitBridge
       
   324         * @since 3.0
       
   325         * @return void
       
   326         */
       
   327         void setParent( MScrollView* /*aParent*/){/*iParent = aBrCtlInterface*/};
       
   328 
       
   329        /**
       
   330         * IsActive
       
   331         * From MWebCoreObjectWidget
       
   332         * Returns ETrue is plugin is active and receiving events
       
   333         * @since 3.1
       
   334         * @return void
       
   335         */
       
   336         TBool isActive() const { return m_active; }
       
   337 
       
   338         /**
       
   339         * Deactivate
       
   340         * From MWebCoreObjectWidget
       
   341         * Removes the plugin from control stack
       
   342         * @since 3.1
       
   343         * @return void
       
   344         */
       
   345         void deActivate();
       
   346 
       
   347         /**
       
   348         * SetFont
       
   349         * From MWebCoreObjectWidget
       
   350         * Sets the font
       
   351         * @since 3.1
       
   352         * @return void
       
   353         */
       
   354         void setFont(CFont* font);
       
   355         
       
   356         /**
       
   357         * CanInteract
       
   358         * Returns the m_canInteract flag
       
   359         * @since 5.0
       
   360         * @return TBool
       
   361         */
       
   362         TBool CanInteract() const 
       
   363         {
       
   364             return m_canInteract;
       
   365         }
       
   366         
       
   367         /**
       
   368         * pluginPlayer
       
   369         * Returns the plugin player
       
   370         * @since 5.0
       
   371         * @return PluginPlayer*
       
   372         */
       
   373         PluginPlayer* pluginPlayer() const {
       
   374             return m_frame->frameView()->topView()->pluginPlayer();
       
   375         }
       
   376         
       
   377         
       
   378         HBufC8* url() { return m_url; }
       
   379         
       
   380         void playPluginContent(const TDesC8& aRequestUrl) {};
       
   381 
       
   382         void viewFocusChanged(TBool focused);
       
   383         
       
   384         void positionChanged();
       
   385 
       
   386         void stopPluginContent(const TDesC8& aRequestUrl) {};
       
   387 
       
   388         void *pluginScriptableObject(); 
       
   389         
       
   390         void pluginFocusChanged(TBool focus);
       
   391         
       
   392         TBool hasResized () {return m_resized; }
       
   393 
       
   394         void resized();
       
   395         
       
   396         void ref() {++m_ref;};
       
   397         
       
   398         void deref() {if (--m_ref <= 0) delete this;};
       
   399 
       
   400         TBool loadPluginL( const TDesC& mimetype);
       
   401         
       
   402         void openInViewerL();
       
   403         
       
   404         // stream manipulation
       
   405         void addPluginStream(PluginStream*);
       
   406         void removePluginStream(PluginStream*);      
       
   407         
       
   408   public:
       
   409         //callbacks from NpnImplementation  
       
   410         int getRequestL(const TDesC8& url, bool notify, void* notifydata,const TDesC* aWindowType);                          
       
   411         int postRequestL(const TDesC8& url, const TDesC& buffer, bool fromfile, bool notify, void* notifydata,const TDesC* aWindowType);
       
   412         bool isInteractive();
       
   413         TRect getClipRect() const;
       
   414         TRect getPluginWinRect() const;
       
   415         void setClipRect(TRect rect);
       
   416         TInt handleNetworkAccess() const;
       
   417         WebCore::Element* getElement() {return m_element;}
       
   418         void setElement(WebCore::Element* aElement) {m_element = aElement;}
       
   419 
       
   420   public:  // from MMemoryCollector
       
   421         TUint Collect(unsigned int aRequired);
       
   422         void Restore()                          {}
       
   423         TOOMPriority Priority()                 { return EOOM_PriorityLow; }
       
   424         
       
   425 
       
   426         /**
       
   427         * Run javascript, possibly asynchronously.
       
   428         *
       
   429         * @since 3.2
       
   430         * @return Bool.
       
   431         */
       
   432         TBool RunScript(); 
       
   433         void handlePluginForeground(TBool focus);       
       
   434   private:  // private member data
       
   435         void setPluginWinClipedRect();
       
   436         TRect frameVisibleRect() const;
       
   437         void Close();
       
   438         
       
   439         // Window-owning CoeControl which wraps the CoeControl created by the plugin
       
   440         PluginWin* m_pluginwin;
       
   441         WebFrame* m_frame; // not owned
       
   442         CFont* m_font;
       
   443         HBufC8* m_url;
       
   444         WebCore::Element* m_element;
       
   445         
       
   446         TBool m_visible;
       
   447         TBool m_pluginSupported;
       
   448         TBool m_pluginClosed;
       
   449         TBool m_canInteract;
       
   450         TBool m_focused;
       
   451         TBool m_active;
       
   452         TBool m_flashContent;
       
   453         
       
   454         TRect m_rect;
       
   455         TRect m_pluginWinClipRect;        
       
   456         int m_ref;
       
   457 
       
   458         TCannedImageData m_cannedimg;
       
   459         // Attribute lists - The plugin API expects a separate array for
       
   460         // attribute names and values
       
   461         CDesCArrayFlat *m_attributeNames;
       
   462         CDesCArrayFlat *m_attributeValues;
       
   463         //Active Object to run script
       
   464         CIdle* iJavascriptTimer;
       
   465         
       
   466         //Javascript: url 
       
   467         RPointerArray<HBufC> m_JSUrls;
       
   468 
       
   469         WTF::HashSet<PluginStream*>  m_streams;
       
   470 
       
   471 public:
       
   472         TInt m_handle;
       
   473         NPP m_instance;    
       
   474         NPPluginFuncs* m_pluginfuncs;
       
   475         bool m_resized;
       
   476         RPointerArray<HBufC> m_tempFilesArray;
       
   477 };
       
   478 
       
   479 #endif //  __PLUGINSKIN_H__