Scan for plugins when we're asked whether we can handle a type, not when we

actually go to handle it.  Bug 273785, r=biesi, sr=darin


git-svn-id: svn://10.0.0.236/trunk@169468 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzbarsky%mit.edu 2005-02-19 02:43:03 +00:00
parent 0797983c27
commit 921bb06afc
2 changed files with 26 additions and 25 deletions

View File

@ -42,6 +42,7 @@
#include "nsIChannel.h"
#include "nsXPIDLString.h"
#include "nsIServiceManager.h"
#include "nsIPluginManager.h"
#include "nsIDOMWindowInternal.h"
#include "nsAutoPtr.h"
@ -201,8 +202,30 @@ nsDSURIContentListener::CanHandleContent(const char* aContentType,
if (NS_FAILED(rv) && rv != NS_ERROR_NOT_AVAILABLE)
return rv;
if (value && *value)
*aCanHandleContent = PR_TRUE;
*aCanHandleContent = value && *value;
// XXXbz should we check that this service actually exists? May be a
// good idea...
if (!*aCanHandleContent) {
// Try loading plugins to see whether someone neglected to do so
nsCOMPtr<nsIPluginManager> pluginManager =
do_GetService("@mozilla.org/plugin/manager;1");
if (pluginManager) {
// PR_FALSE will ensure that currently running plugins will not
// be shut down
rv = pluginManager->ReloadPlugins(PR_FALSE);
if (NS_SUCCEEDED(rv)) {
// OK, we reloaded plugins and there were new ones
// (otherwise NS_ERROR_PLUGINS_PLUGINSNOTCHANGED would have
// been returned). Try checking whether we can handle the
// content now.
return CanHandleContent(aContentType,
aIsContentPreferred,
aDesiredContentType,
aCanHandleContent);
}
}
}
}
return NS_OK;

View File

@ -49,7 +49,6 @@
#include "nsIDOMElement.h"
#include "nsIDocumentViewer.h"
#include "nsIDocumentLoaderFactory.h"
#include "nsIPluginHost.h"
#include "nsCURILoader.h"
#include "nsDocShellCID.h"
#include "nsLayoutCID.h"
@ -165,7 +164,6 @@
static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID);
static NS_DEFINE_CID(kDocumentCharsetInfoCID, NS_DOCUMENTCHARSETINFO_CID);
static NS_DEFINE_CID(kPluginManagerCID, NS_PLUGINMANAGER_CID);
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID,
NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
@ -4832,7 +4830,6 @@ nsDocShell::NewContentViewerObj(const char *aContentType,
nsIStreamListener ** aContentHandler,
nsIContentViewer ** aViewer)
{
nsCOMPtr<nsIPluginHost> pluginHost (do_GetService(kPluginManagerCID));
nsCOMPtr<nsIChannel> aOpenedChannel = do_QueryInterface(request);
nsresult rv;
@ -4849,26 +4846,7 @@ nsDocShell::NewContentViewerObj(const char *aContentType,
docLoaderFactory = do_GetService(contractId.get());
if (!docLoaderFactory) {
// try again after loading plugins
nsCOMPtr<nsIPluginManager> pluginManager = do_QueryInterface(pluginHost);
if (!pluginManager)
return NS_ERROR_FAILURE;
// no need to do anything if plugins have not been changed
// PR_FALSE will ensure that currently running plugins will not be shut down
// but the plugin list will still be updated with newly installed plugins
if (NS_ERROR_PLUGINS_PLUGINSNOTCHANGED == pluginManager->ReloadPlugins(PR_FALSE))
return NS_ERROR_FAILURE;
rv = catMan->GetCategoryEntry("Gecko-Content-Viewers", aContentType,
getter_Copies(contractId));
if (NS_FAILED(rv))
return rv;
docLoaderFactory = do_GetService(contractId.get());
if (!docLoaderFactory)
return NS_ERROR_FAILURE;
return NS_ERROR_FAILURE;
}
// Now create an instance of the content viewer