Bug 657952: Minimize methods in nsIPluginHost. r=jst

This commit is contained in:
Josh Aas 2011-05-21 09:28:54 -04:00
parent 3841353728
commit 896e34b1ed
15 changed files with 153 additions and 264 deletions

View File

@ -423,11 +423,12 @@ IsSupportedImage(const nsCString& aMimeType)
static PRBool
IsSupportedPlugin(const nsCString& aMIMEType)
{
nsCOMPtr<nsIPluginHost> host(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
if (!host) {
nsCOMPtr<nsIPluginHost> pluginHostCOM(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
nsPluginHost *pluginHost = static_cast<nsPluginHost*>(pluginHostCOM.get());
if (!pluginHost) {
return PR_FALSE;
}
nsresult rv = host->IsPluginEnabledForType(aMIMEType.get());
nsresult rv = pluginHost->IsPluginEnabledForType(aMIMEType.get());
return NS_SUCCEEDED(rv);
}
@ -458,13 +459,18 @@ IsPluginEnabledByExtension(nsIURI* uri, nsCString& mimeType)
nsCAutoString ext;
GetExtensionFromURI(uri, ext);
if (ext.IsEmpty())
if (ext.IsEmpty()) {
return PR_FALSE;
}
nsCOMPtr<nsIPluginHost> pluginHostCOM(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
nsPluginHost *pluginHost = static_cast<nsPluginHost*>(pluginHostCOM.get());
if (!pluginHost) {
return PR_FALSE;
}
nsCOMPtr<nsIPluginHost> host(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
const char* typeFromExt;
if (host &&
NS_SUCCEEDED(host->IsPluginEnabledForExtension(ext.get(), typeFromExt))) {
if (NS_SUCCEEDED(pluginHost->IsPluginEnabledForExtension(ext.get(), typeFromExt))) {
mimeType = typeFromExt;
return PR_TRUE;
}
@ -1722,8 +1728,8 @@ nsresult
nsObjectLoadingContent::TypeForClassID(const nsAString& aClassID,
nsACString& aType)
{
// Need a plugin host for any class id support
nsCOMPtr<nsIPluginHost> pluginHost(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
nsCOMPtr<nsIPluginHost> pluginHostCOM(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
nsPluginHost *pluginHost = static_cast<nsPluginHost*>(pluginHostCOM.get());
if (!pluginHost) {
return NS_ERROR_NOT_AVAILABLE;
}
@ -1962,11 +1968,13 @@ nsObjectLoadingContent::GetPluginSupportState(nsIContent* aContent,
/* static */ PluginSupportState
nsObjectLoadingContent::GetPluginDisabledState(const nsCString& aContentType)
{
nsCOMPtr<nsIPluginHost> host(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
if (!host) {
nsCOMPtr<nsIPluginHost> pluginHostCOM(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
nsPluginHost *pluginHost = static_cast<nsPluginHost*>(pluginHostCOM.get());
if (!pluginHost) {
return ePluginUnsupported;
}
nsresult rv = host->IsPluginEnabledForType(aContentType.get());
nsresult rv = pluginHost->IsPluginEnabledForType(aContentType.get());
if (rv == NS_ERROR_PLUGIN_DISABLED)
return ePluginDisabled;
if (rv == NS_ERROR_PLUGIN_BLOCKLISTED)

View File

@ -79,6 +79,8 @@
#include "nsICachingChannel.h"
#include "nsPluginArray.h"
#include "nsIPluginHost.h"
#include "nsPluginHost.h"
#include "nsIPluginInstanceOwner.h"
#include "nsGeolocation.h"
#include "nsDesktopNotification.h"
#include "nsContentCID.h"
@ -6548,20 +6550,17 @@ nsGlobalWindow::InitJavaProperties()
// can fail. If it fails, we won't try again...
mDidInitJavaProperties = PR_TRUE;
// Check whether the plugin supports NPRuntime, if so, init through
// it.
nsCOMPtr<nsIPluginHost> host(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
if (!host) {
return;
}
mDummyJavaPluginOwner = new nsDummyJavaPluginOwner(mDoc);
if (!mDummyJavaPluginOwner) {
return;
}
host->InstantiateDummyJavaPlugin(mDummyJavaPluginOwner);
nsCOMPtr<nsIPluginHost> pluginHostCOM(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
nsPluginHost *pluginHost = static_cast<nsPluginHost*>(pluginHostCOM.get());
if (!pluginHost) {
return;
}
pluginHost->InstantiateDummyJavaPlugin(mDummyJavaPluginOwner);
// It's possible for us (or the Java plugin, rather) to process
// events during the above call, which can lead to this window being

View File

@ -48,6 +48,7 @@
#include "nsDOMClassInfo.h"
#include "nsPluginError.h"
#include "nsContentUtils.h"
#include "nsPluginHost.h"
nsPluginArray::nsPluginArray(nsNavigator* navigator,
nsIDocShell *aDocShell)
@ -85,8 +86,9 @@ NS_IMPL_RELEASE(nsPluginArray)
NS_IMETHODIMP
nsPluginArray::GetLength(PRUint32* aLength)
{
if (AllowPlugins() && mPluginHost)
return mPluginHost->GetPluginCount(aLength);
nsPluginHost *pluginHost = static_cast<nsPluginHost*>(mPluginHost.get());
if (AllowPlugins() && pluginHost)
return pluginHost->GetPluginCount(aLength);
*aLength = 0;
return NS_OK;
@ -260,7 +262,8 @@ nsPluginArray::GetPlugins()
if (!mPluginCount)
return NS_OK;
rv = mPluginHost->GetPlugins(mPluginCount, mPluginArray);
nsPluginHost *pluginHost = static_cast<nsPluginHost*>(mPluginHost.get());
rv = pluginHost->GetPlugins(mPluginCount, mPluginArray);
if (NS_SUCCEEDED(rv)) {
// need to wrap each of these with a nsPluginElement, which
// is scriptable.

View File

@ -38,6 +38,7 @@
#ifndef nsPluginArray_h___
#define nsPluginArray_h___
#include "nsCOMPtr.h"
#include "nsIDOMPluginArray.h"
#include "nsIDOMPlugin.h"
#include "nsIPluginHost.h"
@ -45,7 +46,6 @@
class nsNavigator;
class nsIDocShell;
class nsIPluginHost;
// NB: Due to weak references, nsNavigator has intimate knowledge of our
// internals.

View File

@ -37,41 +37,16 @@
#include "nspluginroot.idl"
#include "nsISupports.idl"
#include "nsIPluginInstanceOwner.idl"
#include "nsIStreamListener.idl"
#include "nsIStringStream.idl"
#include "nsIPluginTag.idl"
#include "nsIFile.idl"
%{C++
#include "nsPluginNativeWindow.h"
#ifdef MOZILLA_INTERNAL_API
#include "nsString.h"
#include "nsNetUtil.h"
#endif
#include "prlink.h" // for PRLibrary
#define MOZ_PLUGIN_HOST_CONTRACTID \
"@mozilla.org/plugin/host;1"
%}
interface nsIURI;
interface nsIDOMPlugin;
interface nsIChannel;
interface nsIPluginStreamListener;
[ptr] native PRLibraryPtr(PRLibrary);
[ptr] native nsPluginNativeWindowPtr(nsPluginNativeWindow);
[scriptable, uuid(17523504-EC17-4B6A-B803-2B465D26DB44)]
[scriptable, uuid(28F1F9E1-CD23-4FE2-BCC8-BBB0B2D49A4A)]
interface nsIPluginHost : nsISupports
{
[noscript] void init();
[noscript] void destroy();
[noscript] void loadPlugins();
/**
* Causes the plugins directory to be searched again for new plugin
* libraries.
@ -81,175 +56,8 @@ interface nsIPluginHost : nsISupports
*/
void reloadPlugins(in boolean reloadPages);
/**
* Instantiate an embedded plugin for an existing channel. The caller is
* responsible for opening the channel. It may or may not be already opened
* when this function is called.
*/
[noscript] nsIStreamListener instantiatePluginForChannel(in nsIChannel aChannel, in nsIPluginInstanceOwner aOwner);
[noscript] void setUpPluginInstance(in string aMimeType, in nsIURI aURL, in nsIPluginInstanceOwner aOwner);
// The return code is NS_OK if the plugin is enabled,
// NS_ERROR_PLUGIN_DISABLED if the plugin is explicitly disabled, and
// NS_ERROR_FAILURE if there is no plugin for this type.
[noscript] void isPluginEnabledForType(in string aMimeType);
// The return code is NS_OK if the plugin is enabled and NS_ERROR_FAILURE if
// the plugin is explicitly disabled or there is no plugin.
[noscript] void isPluginEnabledForExtension(in string aExtension, in constCharStarRef aMimeType);
[noscript] readonly attribute unsigned long pluginCount;
[noscript] void getPlugins(in unsigned long aPluginCount, out /*array*/ nsIDOMPlugin aPluginArray);
void getPluginTags([optional] out unsigned long aPluginCount,
[retval, array, size_is(aPluginCount)] out nsIPluginTag aResults);
/**
* Fetches a URL.
*
* (Corresponds to NPN_GetURL and NPN_GetURLNotify.)
*
* @param pluginInst - the plugin making the request. If NULL, the URL
* is fetched in the background.
* @param url - the URL to fetch
* @param target - the target window into which to load the URL, or NULL if
* the data should be returned to the plugin via streamListener.
* @param streamListener - a stream listener to be used to return data to
* the plugin. May be NULL if target is not NULL.
* @param altHost - an IP-address string that will be used instead of the
* host specified in the URL. This is used to prevent DNS-spoofing
* attacks. Can be defaulted to NULL meaning use the host in the URL.
* @param referrer - the referring URL (may be NULL)
* @param forceJSEnabled - forces JavaScript to be enabled for 'javascript:'
* URLs, even if the user currently has JavaScript disabled (usually
* specify PR_FALSE)
* @result - NS_OK if this operation was successful
*/
[noscript] void getURL(in nsISupports pluginInt,
in string url,
in string target,
in nsIPluginStreamListener streamListener,
in string altHost,
in string referrer,
in boolean forceJSEnabled);
/**
* Posts to a URL with post data and/or post headers.
*
* (Corresponds to NPN_PostURL and NPN_PostURLNotify.)
*
* @param pluginInst - the plugin making the request. If NULL, the URL
* is fetched in the background.
* @param url - the URL to fetch
* @param postDataLength - the length of postData (if non-NULL)
* @param postData - the data to POST. NULL specifies that there is not post
* data
* @param isFile - whether the postData specifies the name of a file to
* post instead of data. The file will be deleted afterwards.
* @param target - the target window into which to load the URL, or NULL if
* the data should be returned to the plugin via streamListener.
* @param streamListener - a stream listener to be used to return data to
* the plugin. May be NULL if target is not NULL.
* @param altHost - an IP-address string that will be used instead of the
* host specified in the URL. This is used to prevent DNS-spoofing
* attacks. Can be defaulted to NULL meaning use the host in the URL.
* @param referrer - the referring URL (may be NULL)
* @param forceJSEnabled - forces JavaScript to be enabled for 'javascript:'
* URLs, even if the user currently has JavaScript disabled (usually
* specify PR_FALSE)
* @param postHeadersLength - the length of postHeaders (if non-NULL)
* @param postHeaders - the headers to POST. Must be in the form of
* "HeaderName: HeaderValue\r\n". Each header, including the last,
* must be followed by "\r\n". NULL specifies that there are no
* post headers
* @result - NS_OK if this operation was successful
*/
[noscript] void postURL(in nsISupports pluginInst,
in string url,
in PRUint32 postDataLen,
in string postData,
in boolean isFile,
in string target,
in nsIPluginStreamListener streamListener,
in string altHost,
in string referrer,
in boolean forceJSEnabled,
in PRUint32 postHeadersLength,
in string postHeaders);
/**
* Returns the proxy info for a given URL. The caller is required to
* free the resulting memory with nsIMalloc::Free. The result will be in the
* following format
*
* i) "DIRECT" -- no proxy
* ii) "PROXY xxx.xxx.xxx.xxx" -- use proxy
* iii) "SOCKS xxx.xxx.xxx.xxx" -- use SOCKS
* iv) Mixed. e.g. "PROXY 111.111.111.111;PROXY 112.112.112.112",
* "PROXY 111.111.111.111;SOCKS 112.112.112.112"....
*
* Which proxy/SOCKS to use is determined by the plugin.
*/
[noscript] void findProxyForURL(in string aURL, out string aResult);
[noscript] void UserAgent(in nativeChar resultingAgentString);
/**
* This method parses post buffer to find out case insensitive "Content-length" string
* and CR or LF some where after that, then it assumes there is http headers in
* the input buffer and continue to search for end of headers (CRLFCRLF or LFLF).
* It will *always malloc()* output buffer (caller is responsible to free it)
* if input buffer starts with LF, which comes from 4.x spec
* http://developer.netscape.com/docs/manuals/communicator/plugin/pgfn2.htm#1007754
* "If no custom headers are required, simply add a blank
* line ('\n') to the beginning of the file or buffer.",
* it skips that '\n' and considers rest of the input buffer as data.
* If "Content-length" string and end of headers is found
* it substitutes single LF with CRLF in the headers, so the end of headers
* always will be CRLFCRLF (single CR in headers, if any, remain untouched)
* else
* it puts "Content-length: "+size_of_data+CRLFCRLF at the beginning of the output buffer
* and memcpy data to the output buffer
*
* On failure outPostData and outPostDataLen will be set in 0.
* @param aInPostData - the post data
* @param aInPostDataLen - the length aInPostData
* @param aOutPostData - the buffer
* @param aOutPostDataLen - the length of aOutPostData
*/
[noscript] void parsePostBufferToFixHeaders(in string aInPostData,
in unsigned long aInPostDataLen,
out string aOutPostData,
out unsigned long aOutPostDataLen);
/**
* To create temp file with Content len header in, it will use by http POST
*/
[noscript] nsIFile createTempFileToPost(in string aPostDataURL);
/**
* Creates a new plugin native window object
*/
[noscript] void newPluginNativeWindow(out nsPluginNativeWindowPtr aPluginNativeWindow);
/**
* Deletes plugin native window object created by NewPluginNativeWindow
*/
[noscript] void deletePluginNativeWindow(in nsPluginNativeWindowPtr aPluginNativeWindow);
/**
* Instantiate a "dummy" java plugin if a java plugin that supports
* NPRuntime is installed. This plugin is used for exposing
* window.java and window.Packages. If the java plugin supports
* NPRuntime and instantiation was successful, aOwners instance will
* be non-null, if not, it will be null.
*/
[noscript] void instantiateDummyJavaPlugin(in nsIPluginInstanceOwner aOwner);
[noscript, notxpcom] void addIdleTimeTarget(in nsIPluginInstanceOwner objectFrame, in boolean isVisible);
[noscript, notxpcom] void removeIdleTimeTarget(in nsIPluginInstanceOwner objectFrame);
/*
* Flags for use with clearSiteData.

View File

@ -41,6 +41,7 @@
// FIXME(bug 332648): Give me a real API please!
#include "jscntxt.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsJSNPRuntime.h"
#include "nsNPAPIPlugin.h"
#include "nsNPAPIPluginInstance.h"
@ -54,6 +55,7 @@
#include "nsIDOMElement.h"
#include "prmem.h"
#include "nsIContent.h"
#include "nsIPluginInstanceOwner.h"
#define NPRUNTIME_JSCLASS_NAME "NPObject JS wrapper class"

View File

@ -49,6 +49,7 @@
#include "jscntxt.h"
#include "nsPluginHost.h"
#include "nsNPAPIPlugin.h"
#include "nsNPAPIPluginInstance.h"
#include "nsNPAPIPluginStreamListener.h"
@ -581,9 +582,11 @@ MakeNewNPAPIStreamInternal(NPP npp, const char *relativeURL, const char *target,
if (!inst || !inst->IsRunning())
return NPERR_INVALID_INSTANCE_ERROR;
nsCOMPtr<nsIPluginHost> pluginHost = do_GetService(MOZ_PLUGIN_HOST_CONTRACTID);
NS_ASSERTION(pluginHost, "failed to get plugin host");
if (!pluginHost) return NPERR_GENERIC_ERROR;
nsCOMPtr<nsIPluginHost> pluginHostCOM = do_GetService(MOZ_PLUGIN_HOST_CONTRACTID);
nsPluginHost *pluginHost = static_cast<nsPluginHost*>(pluginHostCOM.get());
if (!pluginHost) {
return NPERR_GENERIC_ERROR;
}
nsCOMPtr<nsIPluginStreamListener> listener;
// Set aCallNotify here to false. If pluginHost->GetURL or PostURL fail,
@ -2410,9 +2413,11 @@ _useragent(NPP npp)
}
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPN_UserAgent: npp=%p\n", (void*)npp));
nsCOMPtr<nsIPluginHost> pluginHost(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
if (!pluginHost)
nsCOMPtr<nsIPluginHost> pluginHostCOM(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
nsPluginHost *pluginHost = static_cast<nsPluginHost*>(pluginHostCOM.get());
if (!pluginHost) {
return nsnull;
}
const char *retstr;
nsresult rv = pluginHost->UserAgent(&retstr);
@ -2501,8 +2506,8 @@ _getvalueforurl(NPP instance, NPNURLVariable variable, const char *url,
switch (variable) {
case NPNURLVProxy:
{
nsCOMPtr<nsIPluginHost> pluginHost(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
nsCOMPtr<nsIPluginHost> pluginHostCOM(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
nsPluginHost *pluginHost = static_cast<nsPluginHost*>(pluginHostCOM.get());
if (pluginHost && NS_SUCCEEDED(pluginHost->FindProxyForURL(url, value))) {
*len = *value ? PL_strlen(*value) : 0;
return NPERR_NO_ERROR;

View File

@ -57,6 +57,8 @@
#include "nsDirectoryServiceDefs.h"
#include "nsJSNPRuntime.h"
#include "nsPluginStreamListenerPeer.h"
#include "nsSize.h"
#include "nsNetCID.h"
using namespace mozilla;
using namespace mozilla::plugins::parent;

View File

@ -625,13 +625,13 @@ nsresult nsPluginHost::GetPrompt(nsIPluginInstanceOwner *aOwner, nsIPrompt **aPr
return rv;
}
NS_IMETHODIMP nsPluginHost::GetURL(nsISupports* pluginInst,
const char* url,
const char* target,
nsIPluginStreamListener* streamListener,
const char* altHost,
const char* referrer,
PRBool forceJSEnabled)
nsresult nsPluginHost::GetURL(nsISupports* pluginInst,
const char* url,
const char* target,
nsIPluginStreamListener* streamListener,
const char* altHost,
const char* referrer,
PRBool forceJSEnabled)
{
return GetURLWithHeaders(static_cast<nsNPAPIPluginInstance*>(pluginInst),
url, target, streamListener, altHost, referrer,
@ -681,7 +681,7 @@ nsresult nsPluginHost::GetURLWithHeaders(nsNPAPIPluginInstance* pluginInst,
return rv;
}
NS_IMETHODIMP nsPluginHost::PostURL(nsISupports* pluginInst,
nsresult nsPluginHost::PostURL(nsISupports* pluginInst,
const char* url,
PRUint32 postDataLen,
const char* postData,
@ -785,7 +785,7 @@ NS_IMETHODIMP nsPluginHost::PostURL(nsISupports* pluginInst,
* with the exception that multiple values are not implemented.
*/
NS_IMETHODIMP nsPluginHost::FindProxyForURL(const char* url, char* *result)
nsresult nsPluginHost::FindProxyForURL(const char* url, char* *result)
{
if (!url || !result) {
return NS_ERROR_INVALID_ARG;
@ -849,12 +849,12 @@ NS_IMETHODIMP nsPluginHost::FindProxyForURL(const char* url, char* *result)
return res;
}
NS_IMETHODIMP nsPluginHost::Init()
nsresult nsPluginHost::Init()
{
return NS_OK;
}
NS_IMETHODIMP nsPluginHost::Destroy()
nsresult nsPluginHost::Destroy()
{
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsPluginHost::Destroy Called\n"));
@ -933,9 +933,9 @@ nsPluginHost::GetPluginTempDir(nsIFile **aDir)
return sPluginTempDir->Clone(aDir);
}
NS_IMETHODIMP nsPluginHost::InstantiatePluginForChannel(nsIChannel* aChannel,
nsIPluginInstanceOwner* aOwner,
nsIStreamListener** aListener)
nsresult nsPluginHost::InstantiatePluginForChannel(nsIChannel* aChannel,
nsIPluginInstanceOwner* aOwner,
nsIStreamListener** aListener)
{
NS_PRECONDITION(aChannel && aOwner,
"Invalid arguments to InstantiatePluginForChannel");
@ -1236,9 +1236,9 @@ nsresult nsPluginHost::FindStoppedPluginForURL(nsIURI* aURL,
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsPluginHost::SetUpPluginInstance(const char *aMimeType,
nsIURI *aURL,
nsIPluginInstanceOwner *aOwner)
nsresult nsPluginHost::SetUpPluginInstance(const char *aMimeType,
nsIURI *aURL,
nsIPluginInstanceOwner *aOwner)
{
NS_ENSURE_ARG_POINTER(aOwner);
@ -1387,7 +1387,7 @@ nsPluginHost::TrySetUpPluginInstance(const char *aMimeType,
return rv;
}
NS_IMETHODIMP
nsresult
nsPluginHost::IsPluginEnabledForType(const char* aMimeType)
{
nsPluginTag *plugin = FindPluginForType(aMimeType, PR_TRUE);
@ -1435,7 +1435,7 @@ static int CompareExtensions(const char *aExtensionList, const char *aExtension)
return PL_strcasecmp(pExt, aExtension);
}
NS_IMETHODIMP
nsresult
nsPluginHost::IsPluginEnabledForExtension(const char* aExtension,
const char* &aMimeType)
{
@ -1565,7 +1565,7 @@ private:
NS_IMPL_ISUPPORTS1(DOMPluginImpl, nsIDOMPlugin)
NS_IMETHODIMP
nsresult
nsPluginHost::GetPluginCount(PRUint32* aPluginCount)
{
LoadPlugins();
@ -1585,7 +1585,7 @@ nsPluginHost::GetPluginCount(PRUint32* aPluginCount)
return NS_OK;
}
NS_IMETHODIMP
nsresult
nsPluginHost::GetPlugins(PRUint32 aPluginCount, nsIDOMPlugin** aPluginArray)
{
LoadPlugins();
@ -2341,7 +2341,7 @@ nsresult nsPluginHost::ScanPluginsDirectoryList(nsISimpleEnumerator *dirEnum,
return NS_OK;
}
NS_IMETHODIMP nsPluginHost::LoadPlugins()
nsresult nsPluginHost::LoadPlugins()
{
// do not do anything if it is already done
// use ReloadPlugins() to enforce loading
@ -3535,7 +3535,7 @@ nsPluginHost::HandleBadPlugin(PRLibrary* aLibrary, nsNPAPIPluginInstance *aInsta
return rv;
}
NS_IMETHODIMP
nsresult
nsPluginHost::ParsePostBufferToFixHeaders(const char *inPostData, PRUint32 inPostDataLen,
char **outPostData, PRUint32 *outPostDataLen)
{
@ -3687,7 +3687,7 @@ nsPluginHost::ParsePostBufferToFixHeaders(const char *inPostData, PRUint32 inPos
return NS_OK;
}
NS_IMETHODIMP
nsresult
nsPluginHost::CreateTempFileToPost(const char *aPostDataURL, nsIFile **aTmpFile)
{
nsresult rv;
@ -3788,19 +3788,19 @@ nsPluginHost::CreateTempFileToPost(const char *aPostDataURL, nsIFile **aTmpFile)
return rv;
}
NS_IMETHODIMP
nsresult
nsPluginHost::NewPluginNativeWindow(nsPluginNativeWindow ** aPluginNativeWindow)
{
return PLUG_NewPluginNativeWindow(aPluginNativeWindow);
}
NS_IMETHODIMP
nsresult
nsPluginHost::DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow)
{
return PLUG_DeletePluginNativeWindow(aPluginNativeWindow);
}
NS_IMETHODIMP
nsresult
nsPluginHost::InstantiateDummyJavaPlugin(nsIPluginInstanceOwner *aOwner)
{
// Pass PR_FALSE as the second arg, we want the answer to be the

View File

@ -62,11 +62,13 @@
#include "nsPluginTags.h"
#include "nsIEffectiveTLDService.h"
#include "nsIIDNService.h"
#include "nsCRT.h"
class nsNPAPIPlugin;
class nsIComponentManager;
class nsIFile;
class nsIChannel;
class nsPluginNativeWindow;
#if defined(XP_MACOSX) && !defined(NP_NO_CARBON)
#define MAC_CARBON_PLUGINS
@ -106,6 +108,52 @@ public:
NS_DECL_NSIOBSERVER
NS_DECL_NSITIMERCALLBACK
nsresult Init();
nsresult Destroy();
nsresult LoadPlugins();
nsresult InstantiatePluginForChannel(nsIChannel* aChannel,
nsIPluginInstanceOwner* aOwner,
nsIStreamListener** aListener);
nsresult SetUpPluginInstance(const char *aMimeType,
nsIURI *aURL,
nsIPluginInstanceOwner *aOwner);
nsresult IsPluginEnabledForType(const char* aMimeType);
nsresult IsPluginEnabledForExtension(const char* aExtension, const char* &aMimeType);
nsresult GetPluginCount(PRUint32* aPluginCount);
nsresult GetPlugins(PRUint32 aPluginCount, nsIDOMPlugin** aPluginArray);
nsresult GetURL(nsISupports* pluginInst,
const char* url,
const char* target,
nsIPluginStreamListener* streamListener,
const char* altHost,
const char* referrer,
PRBool forceJSEnabled);
nsresult PostURL(nsISupports* pluginInst,
const char* url,
PRUint32 postDataLen,
const char* postData,
PRBool isFile,
const char* target,
nsIPluginStreamListener* streamListener,
const char* altHost,
const char* referrer,
PRBool forceJSEnabled,
PRUint32 postHeadersLength,
const char* postHeaders);
nsresult FindProxyForURL(const char* url, char* *result);
nsresult UserAgent(const char **retstring);
nsresult ParsePostBufferToFixHeaders(const char *inPostData, PRUint32 inPostDataLen,
char **outPostData, PRUint32 *outPostDataLen);
nsresult CreateTempFileToPost(const char *aPostDataURL, nsIFile **aTmpFile);
nsresult NewPluginNativeWindow(nsPluginNativeWindow ** aPluginNativeWindow);
nsresult DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow);
nsresult InstantiateDummyJavaPlugin(nsIPluginInstanceOwner *aOwner);
void AddIdleTimeTarget(nsIPluginInstanceOwner* objectFrame, PRBool isVisible);
void RemoveIdleTimeTarget(nsIPluginInstanceOwner* objectFrame);
nsresult GetPluginName(nsNPAPIPluginInstance *aPluginInstance, const char** aPluginName);
nsresult StopPluginInstance(nsNPAPIPluginInstance* aInstance);
nsresult HandleBadPlugin(PRLibrary* aLibrary, nsNPAPIPluginInstance *aInstance);

View File

@ -49,6 +49,7 @@
#include "nsNetCID.h"
#include "nsPluginLogging.h"
#include "nsIURI.h"
#include "nsIURL.h"
#include "nsPluginHost.h"
#include "nsIByteRangeRequest.h"
#include "nsIMultiPartChannel.h"
@ -58,6 +59,8 @@
#include "nsIDocument.h"
#include "nsIWebNavigation.h"
#include "nsContentUtils.h"
#include "nsNetUtil.h"
#include "nsPluginNativeWindow.h"
#define MAGIC_REQUEST_CONTEXT 0x01020304

View File

@ -62,6 +62,7 @@
#include "nsExceptionHandler.h"
#endif
#include "nsNPAPIPlugin.h"
#include "nsILocalFile.h"
using base::KillProcess;

View File

@ -67,6 +67,7 @@
// plugins
#include "nsIPluginHost.h"
#include "nsPluginHost.h"
static NS_DEFINE_CID(kPluginDocumentCID, NS_PLUGINDOCUMENT_CID);
// Factory code for creating variations on html documents
@ -306,8 +307,10 @@ nsContentDLF::CreateInstance(const char* aCommand,
aDocListener, aDocViewer);
}
nsCOMPtr<nsIPluginHost> ph (do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
if(ph && NS_SUCCEEDED(ph->IsPluginEnabledForType(aContentType))) {
nsCOMPtr<nsIPluginHost> pluginHostCOM(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
nsPluginHost *pluginHost = static_cast<nsPluginHost*>(pluginHostCOM.get());
if(pluginHost &&
NS_SUCCEEDED(pluginHost->IsPluginEnabledForType(aContentType))) {
return CreateDocument(aCommand,
aChannel, aLoadGroup,
aContainer, kPluginDocumentCID,

View File

@ -2635,10 +2635,13 @@ nsObjectFrame::Instantiate(nsIChannel* aChannel, nsIStreamListener** aStreamList
nsresult rv = PrepareInstanceOwner();
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPluginHost> pluginHost(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID, &rv));
if (NS_FAILED(rv))
nsCOMPtr<nsIPluginHost> pluginHostCOM(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID, &rv));
nsPluginHost *pluginHost = static_cast<nsPluginHost*>(pluginHostCOM.get());
if (NS_FAILED(rv)) {
return rv;
mInstanceOwner->SetPluginHost(pluginHost);
}
mInstanceOwner->SetPluginHost(pluginHostCOM);
// This must be done before instantiating the plugin
FixupWindow(GetContentRectRelativeToSelf().Size());
@ -3174,9 +3177,10 @@ nsPluginInstanceOwner::nsPluginInstanceOwner()
{
// create nsPluginNativeWindow object, it is derived from NPWindow
// struct and allows to manipulate native window procedure
nsCOMPtr<nsIPluginHost> ph = do_GetService(MOZ_PLUGIN_HOST_CONTRACTID);
if (ph)
ph->NewPluginNativeWindow(&mPluginWindow);
nsCOMPtr<nsIPluginHost> pluginHostCOM = do_GetService(MOZ_PLUGIN_HOST_CONTRACTID);
nsPluginHost *pluginHost = static_cast<nsPluginHost*>(pluginHostCOM.get());
if (pluginHost)
pluginHost->NewPluginNativeWindow(&mPluginWindow);
else
mPluginWindow = nsnull;
@ -3276,9 +3280,10 @@ nsPluginInstanceOwner::~nsPluginInstanceOwner()
}
// clean up plugin native window object
nsCOMPtr<nsIPluginHost> ph = do_GetService(MOZ_PLUGIN_HOST_CONTRACTID);
if (ph) {
ph->DeletePluginNativeWindow(mPluginWindow);
nsCOMPtr<nsIPluginHost> pluginHostCOM = do_GetService(MOZ_PLUGIN_HOST_CONTRACTID);
nsPluginHost *pluginHost = static_cast<nsPluginHost*>(pluginHostCOM.get());
if (pluginHost) {
pluginHost->DeletePluginNativeWindow(mPluginWindow);
mPluginWindow = nsnull;
}

View File

@ -109,6 +109,7 @@
#endif
#include "nsIPluginHost.h" // XXX needed for ext->type mapping (bug 233289)
#include "nsPluginHost.h"
#include "nsEscape.h"
#include "nsIStringBundle.h" // XXX needed to localize error msgs
@ -2758,7 +2759,8 @@ NS_IMETHODIMP nsExternalHelperAppService::GetTypeFromExtension(const nsACString&
const nsCString& flatExt = PromiseFlatCString(aFileExt);
// Try the plugins
const char* mimeType;
nsCOMPtr<nsIPluginHost> pluginHost (do_GetService(MOZ_PLUGIN_HOST_CONTRACTID, &rv));
nsCOMPtr<nsIPluginHost> pluginHostCOM(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID, &rv));
nsPluginHost* pluginHost = static_cast<nsPluginHost*>(pluginHostCOM.get());
if (NS_SUCCEEDED(rv)) {
if (NS_SUCCEEDED(pluginHost->IsPluginEnabledForExtension(flatExt.get(), mimeType))) {
aContentType = mimeType;