webengine/osswebengine/WebKit/s60/plugins/PluginSkin.cpp
branchRCL_3
changeset 92 e1bea15f9a39
parent 91 30342f40acbf
child 93 79859ed3eea9
equal deleted inserted replaced
91:30342f40acbf 92:e1bea15f9a39
   162       m_canInteract( EFalse ),
   162       m_canInteract( EFalse ),
   163       m_rect(TRect(0,0,0,0)),
   163       m_rect(TRect(0,0,0,0)),
   164       m_ref(1),
   164       m_ref(1),
   165       m_oldRect(TRect(0,0,0,0)),
   165       m_oldRect(TRect(0,0,0,0)),
   166       m_oldViewport(TRect(0,0,0,0)),
   166       m_oldViewport(TRect(0,0,0,0)),
   167       m_loadmode(ELoadModeNone),
       
   168       m_NPObject(0),
   167       m_NPObject(0),
   169       m_handle(-1),
   168       m_handle(-1),
   170       m_instance(0),    
   169       m_instance(0),    
   171       m_pluginfuncs(0),
   170       m_pluginfuncs(0),
   172       m_resized(false)
   171       m_resized(false)
   419     m_pluginSupported = EFalse;
   418     m_pluginSupported = EFalse;
   420     m_pluginClosed = true;
   419     m_pluginClosed = true;
   421     
   420     
   422  }
   421  }
   423 
   422 
       
   423 // ----------------------------------------------------------------------------
       
   424 // PluginSkin::HandleLosingForeground()
       
   425 // PluginSkin function to handle Losing foreground event
       
   426 // ----------------------------------------------------------------------------
       
   427 void PluginSkin::HandleLosingForeground()
       
   428 {
       
   429     if(m_pluginwin) 
       
   430         m_pluginwin->HandleLosingForeground();
       
   431 }
       
   432  
       
   433 // ----------------------------------------------------------------------------
       
   434 // PluginSkin::HandleGainingForeground()
       
   435 // PluginSkin function to handle Gaining foreground event
       
   436 // ----------------------------------------------------------------------------
       
   437 void PluginSkin::HandleGainingForeground()
       
   438 {
       
   439     if(m_pluginwin)
       
   440         m_pluginwin->HandleGainingForeground();
       
   441 }
   424 
   442 
   425 // ----------------------------------------------------------------------------
   443 // ----------------------------------------------------------------------------
   426 // PluginSkin::pluginFocusChanged()
   444 // PluginSkin::pluginFocusChanged()
   427 // PluginSkin function to show/hide fullscreen sprite
   445 // PluginSkin function to show/hide fullscreen sprite
   428 // ----------------------------------------------------------------------------
   446 // ----------------------------------------------------------------------------
   722     if (!m_instance) {
   740     if (!m_instance) {
   723         
   741         
   724         NPError error( NPERR_NO_ERROR );
   742         NPError error( NPERR_NO_ERROR );
   725         
   743         
   726         m_instance = (NPP) User::AllocL(sizeof(NPP_t));
   744         m_instance = (NPP) User::AllocL(sizeof(NPP_t));
   727         m_instance->ndata = pluginWin();
       
   728         m_instance->pdata = NULL;
       
   729 
       
   730         if (m_instance) {
   745         if (m_instance) {
   731             
   746             m_instance->ndata = pluginWin();
       
   747             m_instance->pdata = NULL;            
   732             PluginHandler* pluginhandler = WebCore::StaticObjectsContainer::instance()->pluginHandler();
   748             PluginHandler* pluginhandler = WebCore::StaticObjectsContainer::instance()->pluginHandler();
   733             if ( pluginhandler ) {
   749             if ( pluginhandler ) {
   734                 pluginhandler->loadPluginL( m_handle, &m_pluginfuncs );
   750                 pluginhandler->loadPluginL( m_handle, &m_pluginfuncs );
   735         
   751         
   736                 if (m_pluginfuncs && m_pluginfuncs->newp) {        
   752                 if (m_pluginfuncs && m_pluginfuncs->newp) {        
   743                                                     NULL );
   759                                                     NULL );
   744                                                                       
   760                                                                       
   745                 }
   761                 }
   746                 if (m_pluginwin) {
   762                 if (m_pluginwin) {
   747                     m_pluginwin->ConstructL(*(control(m_frame)->webView()));
   763                     m_pluginwin->ConstructL(*(control(m_frame)->webView()));
       
   764                 }
   748             }
   765             }
   749         }
       
   750         }
   766         }
   751 
   767 
   752         switch ( error ) {
   768         switch ( error ) {
   753             case NPERR_OUT_OF_MEMORY_ERROR: {
   769             case NPERR_OUT_OF_MEMORY_ERROR: {
   754                 User::Leave( KErrNoMemory );
   770                 User::Leave( KErrNoMemory );
   756             }
   772             }
   757             case NPERR_GENERIC_ERROR: {
   773             case NPERR_GENERIC_ERROR: {
   758                 User::Leave( KErrNotSupported );
   774                 User::Leave( KErrNotSupported );
   759                 break;
   775                 break;
   760             }
   776             }
   761         }    
   777         }
   762         
   778         
   763         if (m_pluginwin)
   779         if (m_pluginwin)
   764         m_pluginwin->SetExtent( TPoint(0,0), TSize(0,0) );
   780             m_pluginwin->SetExtent( TPoint(0,0), TSize(0,0) );
   765             
   781     }
   766     }
       
   767 
       
   768 }
   782 }
   769 
   783 
   770 // -----------------------------------------------------------------------------
   784 // -----------------------------------------------------------------------------
   771 // PluginSkin::CreatePluginWinL
   785 // PluginSkin::CreatePluginWinL
   772 //
   786 //
   872 
   886 
   873 //callbacks from NpnImplementation  
   887 //callbacks from NpnImplementation  
   874 int PluginSkin::getRequestL(const TDesC8& url, bool notify, void* notifydata,const TDesC* aWindowType)
   888 int PluginSkin::getRequestL(const TDesC8& url, bool notify, void* notifydata,const TDesC* aWindowType)
   875 {
   889 {
   876     TPluginLoadMode loadmode = GetLoadMode(aWindowType);
   890     TPluginLoadMode loadmode = GetLoadMode(aWindowType);
   877     setLoadMode(loadmode);
       
   878     
   891     
   879     if (url.Ptr() == NULL ) {                        
   892     if (url.Ptr() == NULL ) {                        
   880         return KErrArgument;
   893         return KErrArgument;
   881     }
   894     }
   882     
   895     
  1273     return EWindowTypeUnknown;
  1286     return EWindowTypeUnknown;
  1274 }
  1287 }
  1275 
  1288 
  1276 void PluginSkin::reCreatePlugin()
  1289 void PluginSkin::reCreatePlugin()
  1277 {
  1290 {
  1278     //destroy the plugin
  1291     TBuf16<4> apId;
  1279     
  1292     apId.Format( _L("%d"), m_frame->frameView()->topView()->accessPointId() );
  1280     Vector<PluginStream*> streams;
  1293     
  1281     for (HashSet<PluginStream*>::iterator it = m_streams.begin(); it != m_streams.end(); ++it) {
  1294     if (m_pluginwin ) {
  1282         streams.append(*it);
  1295         m_pluginwin->notifyAPChange((void*)&apId);
  1283     }    
  1296     }
  1284     for (int i=0; i<streams.size(); ++i) {
  1297     
  1285         streams[i]->close();
  1298     if (m_streams.size() > 0) {
  1286     }
  1299         
  1287     m_streams.clear();
  1300         //destroy the plugin
  1288 
  1301     
  1289     if (m_instance && m_pluginfuncs && m_pluginfuncs->destroy) {        
  1302         Vector<PluginStream*> streams;
  1290         m_pluginfuncs->destroy(m_instance, NULL);
  1303         for (HashSet<PluginStream*>::iterator it = m_streams.begin(); it != m_streams.end(); ++it) {
  1291     }
  1304             streams.append(*it);
  1292     User::Free(m_instance); m_instance = 0;
  1305         }    
  1293     delete m_pluginwin; m_pluginwin = 0;
  1306         for (int i=0; i<streams.size(); ++i) {
  1294     delete iJavascriptTimer; iJavascriptTimer = 0;
  1307             streams[i]->close();
  1295     
  1308         }
  1296     RFs& rfs = StaticObjectsContainer::instance()->fsSession();
  1309         m_streams.clear();
  1297     for(TInt i=0; i < m_tempFilesArray.Count(); i++)
  1310     
  1298         {
  1311         if (m_instance && m_pluginfuncs && m_pluginfuncs->destroy) {        
  1299           rfs.Delete(m_tempFilesArray[i]->Des());
  1312             m_pluginfuncs->destroy(m_instance, NULL);
  1300         }
  1313         }
  1301     m_tempFilesArray.ResetAndDestroy();
  1314         User::Free(m_instance); m_instance = 0;
  1302        
  1315         delete m_pluginwin; m_pluginwin = 0;
  1303     //create/load the destroyed plugin again
  1316         delete iJavascriptTimer; iJavascriptTimer = 0;
  1304     
  1317         
  1305     NetscapePlugInStreamLoaderClient* pluginloader = NetscapePlugInStreamLoaderClient::NewL(m_url->Des(), this, core(m_frame));
  1318         RFs& rfs = StaticObjectsContainer::instance()->fsSession();
  1306     if (pluginloader) {
  1319         for(TInt i=0; i < m_tempFilesArray.Count(); i++) {
  1307         pluginloader->start();                            
  1320             rfs.Delete(m_tempFilesArray[i]->Des());
  1308     }    
  1321         }
       
  1322         m_tempFilesArray.ResetAndDestroy();
       
  1323            
       
  1324         //create/load the destroyed plugin again
       
  1325                     
       
  1326         NetscapePlugInStreamLoaderClient* pluginloader = NetscapePlugInStreamLoaderClient::NewL(m_url->Des(), this, core(m_frame));
       
  1327         if (pluginloader) {
       
  1328             pluginloader->start();                            
       
  1329         }                                                
       
  1330     }
  1309 }
  1331 }
  1310 
  1332 
  1311 // -----------------------------------------------------------------------------
  1333 // -----------------------------------------------------------------------------
  1312 // PluginWin::NotifyPluginsForScrollOrPinch
  1334 // PluginWin::NotifyPluginsForScrollOrPinch
  1313 // When ever there is Scroll or Pinch zoom is in progress, the webframe will
  1335 // When ever there is Scroll or Pinch zoom is in progress, the webframe will