if(mOwner != nsnull) {  mOwner->CancelTimer();  nsCOMPtr<nsIPluginInstance> inst; if(NS_SUCCEEDED(mOwner->GetInstance(*getter_AddRefs(inst)))) { nsPluginWindow *win; mOwner->GetWindow(win); nsPluginNativeWindow *window = (nsPluginNativeWindow *)win; nsCOMPtr<nsIPluginInstance> nullinst;  PRBool doCache = PR_TRUE; PRBool doCallSetWindowAfterDestroy = PR_FALSE;   inst->GetValue(nsPluginInstanceVariable_DoCacheBool, (void *) &doCache); if (!doCache) {   inst->GetValue(nsPluginInstanceVariable_CallSetWindowAfterDestroyBool, (void *) &doCallSetWindowAfterDestroy); if (!doCallSetWindowAfterDestroy) { if (window) window->CallSetWindow(nullinst); else inst->SetWindow(nsnull); } inst->Stop(); inst->Destroy(); if (doCallSetWindowAfterDestroy) { if (window) window->CallSetWindow(nullinst); else inst->SetWindow(nsnull); } } else { window ? window->CallSetWindow(nullinst) : inst->SetWindow(nsnull); inst->Stop(); } } } return NS_OK;
return NS_ERROR_FAILURE;
PluginViewerImpl::Destroy(void){  // XXX ripped off from nsObjectFrame::Destroy()    // we need to finish with the plugin before native window is destroyed  // doing this in the destructor is too late.  if(mOwner != nsnull)  {    // stop the timer explicitly to reduce reference count.    mOwner->CancelTimer();    nsCOMPtr<nsIPluginInstance> inst;    if(NS_SUCCEEDED(mOwner->GetInstance(*getter_AddRefs(inst))))    {      nsPluginWindow *win;      mOwner->GetWindow(win);      nsPluginNativeWindow *window = (nsPluginNativeWindow *)win;      nsCOMPtr<nsIPluginInstance> nullinst;      PRBool doCache = PR_TRUE;      PRBool doCallSetWindowAfterDestroy = PR_FALSE;      // first, determine if the plugin wants to be cached      inst->GetValue(nsPluginInstanceVariable_DoCacheBool,                      (void *) &doCache);      if (!doCache) {        // then determine if the plugin wants Destroy to be called after        // Set Window. This is for bug 50547.        inst->GetValue(nsPluginInstanceVariable_CallSetWindowAfterDestroyBool,                        (void *) &doCallSetWindowAfterDestroy);        if (!doCallSetWindowAfterDestroy) {          if (window)             window->CallSetWindow(nullinst);          else             inst->SetWindow(nsnull);        }        inst->Stop();        inst->Destroy();        if (doCallSetWindowAfterDestroy) {          if (window)             window->CallSetWindow(nullinst);          else             inst->SetWindow(nsnull);        }      } else {        window ? window->CallSetWindow(nullinst) : inst->SetWindow(nsnull);        inst->Stop();      }    }  }  return NS_OK;}