NS_IMETHODIMP nsPluginArray::NamedItem(const nsAString& aName, nsIDOMPlugin** aReturn) { NS_PRECONDITION(nsnull != aReturn, "null arg"); *aReturn = nsnull; if (!AllowPlugins()) return NS_OK; if (mPluginArray == nsnull) { nsresult rv = GetPlugins(); if (rv != NS_OK) return rv; } for (PRUint32 i = 0; i < mPluginCount; i++) { nsAutoString pluginName; nsIDOMPlugin* plugin = mPluginArray[i]; if (plugin->GetName(pluginName) == NS_OK) { if (pluginName.Equals(aName)) { *aReturn = plugin; NS_IF_ADDREF(plugin); break; } } } return NS_OK; }
NS_IMETHODIMP nsPluginArray::GetLength(PRUint32* aLength) { if (AllowPlugins() && mPluginHost) return mPluginHost->GetPluginCount(aLength); *aLength = 0; return NS_OK; }
NS_IMETHODIMP nsPluginArray::GetLength(PRUint32* aLength) { nsPluginHost *pluginHost = static_cast<nsPluginHost*>(mPluginHost.get()); if (AllowPlugins() && pluginHost) return pluginHost->GetPluginCount(aLength); *aLength = 0; return NS_OK; }
NS_IMETHODIMP nsPluginArray::Refresh(PRBool aReloadDocuments) { nsresult res = NS_OK; if (!AllowPlugins()) return NS_SUCCESS_LOSS_OF_INSIGNIFICANT_DATA; // refresh the component registry first, see bug 87913 nsCOMPtr<nsIServiceManager> servManager; NS_GetServiceManager(getter_AddRefs(servManager)); nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servManager); if (registrar) registrar->AutoRegister(nsnull); if (!mPluginHost) { mPluginHost = do_GetService(kPluginManagerCID, &res); } if(NS_FAILED(res)) { return res; } nsCOMPtr<nsIPluginManager> pm(do_QueryInterface(mPluginHost)); // NS_ERROR_PLUGINS_PLUGINSNOTCHANGED on reloading plugins indicates // that plugins did not change and was not reloaded PRBool pluginsNotChanged = PR_FALSE; if(pm) pluginsNotChanged = (NS_ERROR_PLUGINS_PLUGINSNOTCHANGED == pm->ReloadPlugins(aReloadDocuments)); // no need to reload the page if plugins have not been changed // in fact, if we do reload we can hit recursive load problem, see bug 93351 if(pluginsNotChanged) return res; nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(mDocShell); if (mPluginArray != nsnull) { for (PRUint32 i = 0; i < mPluginCount; i++) NS_IF_RELEASE(mPluginArray[i]); delete[] mPluginArray; } mPluginCount = 0; mPluginArray = nsnull; if (mNavigator) mNavigator->RefreshMIMEArray(); if (aReloadDocuments && webNav) webNav->Reload(nsIWebNavigation::LOAD_FLAGS_NONE); return res; }
nsIDOMPlugin* nsPluginArray::GetItemAt(PRUint32 aIndex, nsresult* aResult) { *aResult = NS_OK; if (!AllowPlugins()) return nsnull; if (mPluginArray == nsnull) { *aResult = GetPlugins(); if (*aResult != NS_OK) return nsnull; } return aIndex < mPluginCount ? mPluginArray[aIndex] : nsnull; }
NS_IMETHODIMP nsPluginArray::Refresh(bool aReloadDocuments) { nsresult res = NS_OK; if (!AllowPlugins()) return NS_SUCCESS_LOSS_OF_INSIGNIFICANT_DATA; if (!mPluginHost) { mPluginHost = do_GetService(MOZ_PLUGIN_HOST_CONTRACTID, &res); } if(NS_FAILED(res)) { return res; } // NS_ERROR_PLUGINS_PLUGINSNOTCHANGED on reloading plugins indicates // that plugins did not change and was not reloaded bool pluginsNotChanged = false; if(mPluginHost) pluginsNotChanged = (NS_ERROR_PLUGINS_PLUGINSNOTCHANGED == mPluginHost->ReloadPlugins(aReloadDocuments)); // no need to reload the page if plugins have not been changed // in fact, if we do reload we can hit recursive load problem, see bug 93351 if(pluginsNotChanged) return res; nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(mDocShell); if (mPluginArray != nsnull) { for (PRUint32 i = 0; i < mPluginCount; i++) NS_IF_RELEASE(mPluginArray[i]); delete[] mPluginArray; } mPluginCount = 0; mPluginArray = nsnull; if (mNavigator) mNavigator->RefreshMIMEArray(); if (aReloadDocuments && webNav) webNav->Reload(nsIWebNavigation::LOAD_FLAGS_NONE); return res; }
NS_IMETHODIMP nsPluginArray::Item(PRUint32 aIndex, nsIDOMPlugin** aReturn) { NS_PRECONDITION(nsnull != aReturn, "null arg"); *aReturn = nsnull; if (!AllowPlugins()) return NS_OK; if (mPluginArray == nsnull) { nsresult rv = GetPlugins(); if (rv != NS_OK) return rv; } if (aIndex < mPluginCount) { *aReturn = mPluginArray[aIndex]; NS_IF_ADDREF(*aReturn); } return NS_OK; }
nsIDOMPlugin* nsPluginArray::GetNamedItem(const nsAString& aName, nsresult* aResult) { *aResult = NS_OK; if (!AllowPlugins()) return nsnull; if (mPluginArray == nsnull) { *aResult = GetPlugins(); if (*aResult != NS_OK) return nsnull; } for (PRUint32 i = 0; i < mPluginCount; i++) { nsAutoString pluginName; nsIDOMPlugin* plugin = mPluginArray[i]; if (plugin->GetName(pluginName) == NS_OK && pluginName.Equals(aName)) { return plugin; } } return nsnull; }