NS_IMETHODIMP nsWebNavigationInfo::IsTypeSupported(const nsACString& aType, nsIWebNavigation* aWebNav, uint32_t* aIsTypeSupported) { NS_PRECONDITION(aIsTypeSupported, "null out param?"); // Note to self: aWebNav could be an nsWebBrowser or an nsDocShell here (or // an nsSHistory, but not much we can do with that). So if we start using // it here, we need to be careful to get to the docshell correctly. // For now just report what the Gecko-Content-Viewers category has // to say for itself. *aIsTypeSupported = nsIWebNavigationInfo::UNSUPPORTED; // We want to claim that the type for PDF documents is unsupported, // so that the internal PDF viewer's stream converted will get used. if (aType.LowerCaseEqualsLiteral("application/pdf") && nsContentUtils::IsPDFJSEnabled()) { return NS_OK; } const nsCString& flatType = PromiseFlatCString(aType); nsresult rv = IsTypeSupportedInternal(flatType, aIsTypeSupported); NS_ENSURE_SUCCESS(rv, rv); if (*aIsTypeSupported) { return rv; } // If this request is for a docShell that isn't going to allow plugins, // there's no need to try and find a plugin to handle it. nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aWebNav)); bool allowed; if (docShell && NS_SUCCEEDED(docShell->GetAllowPlugins(&allowed)) && !allowed) { return NS_OK; } // Try reloading plugins in case they've changed. nsCOMPtr<nsIPluginHost> pluginHost = do_GetService(MOZ_PLUGIN_HOST_CONTRACTID); if (pluginHost) { // false will ensure that currently running plugins will not // be shut down rv = pluginHost->ReloadPlugins(); 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 IsTypeSupportedInternal(flatType, aIsTypeSupported); } } return NS_OK; }
/* static */ bool MediaSource::IsTypeSupported(const GlobalObject& aGlobal, const nsAString& aType) { ErrorResult unused; return IsTypeSupportedInternal(aType, unused); }
NS_IMETHODIMP nsWebNavigationInfo::IsTypeSupported(const nsACString& aType, nsIWebNavigation* aWebNav, PRUint32* aIsTypeSupported) { NS_PRECONDITION(aIsTypeSupported, "null out param?"); // Note to self: aWebNav could be an nsWebBrowser or an nsDocShell here (or // an nsSHistory, but not much we can do with that). So if we start using // it here, we need to be careful to get to the docshell correctly. // For now just report what the Gecko-Content-Viewers category has // to say for itself. *aIsTypeSupported = nsIWebNavigationInfo::UNSUPPORTED; const nsCString& flatType = PromiseFlatCString(aType); nsresult rv = IsTypeSupportedInternal(flatType, aIsTypeSupported); NS_ENSURE_SUCCESS(rv, rv); if (*aIsTypeSupported) { return rv; } // Try reloading plugins in case they've changed. nsCOMPtr<nsIPluginHost> pluginHost = do_GetService(MOZ_PLUGIN_HOST_CONTRACTID); if (pluginHost) { // PR_FALSE will ensure that currently running plugins will not // be shut down rv = pluginHost->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 IsTypeSupportedInternal(flatType, aIsTypeSupported); } } return NS_OK; }