webengine/osswebengine/WebKit/s60/plugins/PluginSkin.cpp
branchRCL_3
changeset 92 e1bea15f9a39
parent 91 30342f40acbf
child 93 79859ed3eea9
--- a/webengine/osswebengine/WebKit/s60/plugins/PluginSkin.cpp	Thu Jul 15 19:53:20 2010 +0300
+++ b/webengine/osswebengine/WebKit/s60/plugins/PluginSkin.cpp	Thu Aug 19 10:58:56 2010 +0300
@@ -164,7 +164,6 @@
       m_ref(1),
       m_oldRect(TRect(0,0,0,0)),
       m_oldViewport(TRect(0,0,0,0)),
-      m_loadmode(ELoadModeNone),
       m_NPObject(0),
       m_handle(-1),
       m_instance(0),    
@@ -421,6 +420,25 @@
     
  }
 
+// ----------------------------------------------------------------------------
+// PluginSkin::HandleLosingForeground()
+// PluginSkin function to handle Losing foreground event
+// ----------------------------------------------------------------------------
+void PluginSkin::HandleLosingForeground()
+{
+    if(m_pluginwin) 
+        m_pluginwin->HandleLosingForeground();
+}
+ 
+// ----------------------------------------------------------------------------
+// PluginSkin::HandleGainingForeground()
+// PluginSkin function to handle Gaining foreground event
+// ----------------------------------------------------------------------------
+void PluginSkin::HandleGainingForeground()
+{
+    if(m_pluginwin)
+        m_pluginwin->HandleGainingForeground();
+}
 
 // ----------------------------------------------------------------------------
 // PluginSkin::pluginFocusChanged()
@@ -724,11 +742,9 @@
         NPError error( NPERR_NO_ERROR );
         
         m_instance = (NPP) User::AllocL(sizeof(NPP_t));
-        m_instance->ndata = pluginWin();
-        m_instance->pdata = NULL;
-
         if (m_instance) {
-            
+            m_instance->ndata = pluginWin();
+            m_instance->pdata = NULL;            
             PluginHandler* pluginhandler = WebCore::StaticObjectsContainer::instance()->pluginHandler();
             if ( pluginhandler ) {
                 pluginhandler->loadPluginL( m_handle, &m_pluginfuncs );
@@ -745,9 +761,9 @@
                 }
                 if (m_pluginwin) {
                     m_pluginwin->ConstructL(*(control(m_frame)->webView()));
+                }
             }
         }
-        }
 
         switch ( error ) {
             case NPERR_OUT_OF_MEMORY_ERROR: {
@@ -758,13 +774,11 @@
                 User::Leave( KErrNotSupported );
                 break;
             }
-        }    
+        }
         
         if (m_pluginwin)
-        m_pluginwin->SetExtent( TPoint(0,0), TSize(0,0) );
-            
+            m_pluginwin->SetExtent( TPoint(0,0), TSize(0,0) );
     }
-
 }
 
 // -----------------------------------------------------------------------------
@@ -874,7 +888,6 @@
 int PluginSkin::getRequestL(const TDesC8& url, bool notify, void* notifydata,const TDesC* aWindowType)
 {
     TPluginLoadMode loadmode = GetLoadMode(aWindowType);
-    setLoadMode(loadmode);
     
     if (url.Ptr() == NULL ) {                        
         return KErrArgument;
@@ -1275,37 +1288,46 @@
 
 void PluginSkin::reCreatePlugin()
 {
-    //destroy the plugin
+    TBuf16<4> apId;
+    apId.Format( _L("%d"), m_frame->frameView()->topView()->accessPointId() );
     
-    Vector<PluginStream*> streams;
-    for (HashSet<PluginStream*>::iterator it = m_streams.begin(); it != m_streams.end(); ++it) {
-        streams.append(*it);
-    }    
-    for (int i=0; i<streams.size(); ++i) {
-        streams[i]->close();
-    }
-    m_streams.clear();
-
-    if (m_instance && m_pluginfuncs && m_pluginfuncs->destroy) {        
-        m_pluginfuncs->destroy(m_instance, NULL);
+    if (m_pluginwin ) {
+        m_pluginwin->notifyAPChange((void*)&apId);
     }
-    User::Free(m_instance); m_instance = 0;
-    delete m_pluginwin; m_pluginwin = 0;
-    delete iJavascriptTimer; iJavascriptTimer = 0;
+    
+    if (m_streams.size() > 0) {
+        
+        //destroy the plugin
     
-    RFs& rfs = StaticObjectsContainer::instance()->fsSession();
-    for(TInt i=0; i < m_tempFilesArray.Count(); i++)
-        {
-          rfs.Delete(m_tempFilesArray[i]->Des());
+        Vector<PluginStream*> streams;
+        for (HashSet<PluginStream*>::iterator it = m_streams.begin(); it != m_streams.end(); ++it) {
+            streams.append(*it);
+        }    
+        for (int i=0; i<streams.size(); ++i) {
+            streams[i]->close();
+        }
+        m_streams.clear();
+    
+        if (m_instance && m_pluginfuncs && m_pluginfuncs->destroy) {        
+            m_pluginfuncs->destroy(m_instance, NULL);
         }
-    m_tempFilesArray.ResetAndDestroy();
-       
-    //create/load the destroyed plugin again
-    
-    NetscapePlugInStreamLoaderClient* pluginloader = NetscapePlugInStreamLoaderClient::NewL(m_url->Des(), this, core(m_frame));
-    if (pluginloader) {
-        pluginloader->start();                            
-    }    
+        User::Free(m_instance); m_instance = 0;
+        delete m_pluginwin; m_pluginwin = 0;
+        delete iJavascriptTimer; iJavascriptTimer = 0;
+        
+        RFs& rfs = StaticObjectsContainer::instance()->fsSession();
+        for(TInt i=0; i < m_tempFilesArray.Count(); i++) {
+            rfs.Delete(m_tempFilesArray[i]->Des());
+        }
+        m_tempFilesArray.ResetAndDestroy();
+           
+        //create/load the destroyed plugin again
+                    
+        NetscapePlugInStreamLoaderClient* pluginloader = NetscapePlugInStreamLoaderClient::NewL(m_url->Des(), this, core(m_frame));
+        if (pluginloader) {
+            pluginloader->start();                            
+        }                                                
+    }
 }
 
 // -----------------------------------------------------------------------------