Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes
nsPluginHostImpl Class Reference

#include <nsPluginHostImpl.h>

Inheritance diagram for nsPluginHostImpl:
Inheritance graph
[legend]
Collaboration diagram for nsPluginHostImpl:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsPluginHostImpl ()
virtual ~nsPluginHostImpl ()
NS_IMETHOD GetValue (nsPluginManagerVariable variable, void *value)
NS_IMETHOD ReloadPlugins (PRBool reloadPages)
NS_IMETHOD UserAgent (const char **resultingAgentString)
NS_IMETHOD GetURL (nsISupports *pluginInst, const char *url, const char *target=NULL, nsIPluginStreamListener *streamListener=NULL, const char *altHost=NULL, const char *referrer=NULL, PRBool forceJSEnabled=PR_FALSE)
 Fetches a URL.
NS_IMETHOD GetURLWithHeaders (nsISupports *pluginInst, const char *url, const char *target=NULL, nsIPluginStreamListener *streamListener=NULL, const char *altHost=NULL, const char *referrer=NULL, PRBool forceJSEnabled=PR_FALSE, PRUint32 getHeadersLength=0, const char *getHeaders=NULL)
 Fetches a URL, with Headers.
NS_IMETHOD PostURL (nsISupports *pluginInst, const char *url, PRUint32 postDataLen, const char *postData, PRBool isFile=PR_FALSE, const char *target=NULL, nsIPluginStreamListener *streamListener=NULL, const char *altHost=NULL, const char *referrer=NULL, PRBool forceJSEnabled=PR_FALSE, PRUint32 postHeadersLength=0, const char *postHeaders=NULL)
 Posts to a URL with post data and/or post headers.
NS_IMETHOD RegisterPlugin (REFNSIID aCID, const char *aPluginName, const char *aDescription, const char **aMimeTypes, const char **aMimeDescriptions, const char **aFileExtensions, PRInt32 aCount)
NS_IMETHOD UnregisterPlugin (REFNSIID aCID)
NS_IMETHOD Init (void)
NS_IMETHOD Destroy (void)
NS_IMETHOD LoadPlugins (void)
NS_IMETHOD GetPluginFactory (const char *aMimeType, nsIPlugin **aPlugin)
NS_IMETHOD InstantiateEmbeddedPlugin (const char *aMimeType, nsIURI *aURL, nsIPluginInstanceOwner *aOwner)
NS_IMETHOD InstantiateFullPagePlugin (const char *aMimeType, nsIURI *aURI, nsIStreamListener *&aStreamListener, nsIPluginInstanceOwner *aOwner)
NS_IMETHOD SetUpPluginInstance (const char *aMimeType, nsIURI *aURL, nsIPluginInstanceOwner *aOwner)
NS_IMETHOD IsPluginEnabledForType (const char *aMimeType)
NS_IMETHOD IsPluginEnabledForExtension (const char *aExtension, const char *&aMimeType)
NS_IMETHOD GetPluginCount (PRUint32 *aPluginCount)
NS_IMETHOD GetPlugins (PRUint32 aPluginCount, nsIDOMPlugin **aPluginArray)
NS_IMETHOD HandleBadPlugin (PRLibrary *aLibrary, nsIPluginInstance *instance)
NS_IMETHOD BeginWaitCursor (void)
NS_IMETHOD EndWaitCursor (void)
NS_IMETHOD SupportsURLProtocol (const char *protocol, PRBool *result)
NS_IMETHOD NotifyStatusChange (nsIPlugin *plugin, nsresult errorStatus)
NS_IMETHOD FindProxyForURL (const char *url, char **result)
NS_IMETHOD RegisterWindow (nsIEventHandler *handler, nsPluginPlatformWindowRef window)
NS_IMETHOD UnregisterWindow (nsIEventHandler *handler, nsPluginPlatformWindowRef window)
NS_IMETHOD AllocateMenuID (nsIEventHandler *handler, PRBool isSubmenu, PRInt16 *result)
NS_IMETHOD DeallocateMenuID (nsIEventHandler *handler, PRInt16 menuID)
NS_IMETHOD HasAllocatedMenuID (nsIEventHandler *handler, PRInt16 menuID, PRBool *result)
NS_IMETHOD ProcessNextEvent (PRBool *bEventHandled)
NS_IMETHOD CreateInstance (nsISupports *aOuter, REFNSIID aIID, void **aResult)
NS_IMETHOD LockFactory (PRBool aLock)
NS_IMETHOD GetProgramPath (const char **result)
NS_IMETHOD GetTempDirPath (const char **result)
NS_IMETHOD NewTempFileName (const char *prefix, PRUint32 bufLen, char *resultBuf)
NS_IMETHOD GetCookie (const char *inCookieURL, void *inOutCookieBuffer, PRUint32 &inOutCookieSize)
 Retrieves a cookie from the browser's persistent cookie store.
NS_IMETHOD SetCookie (const char *inCookieURL, const void *inCookieBuffer, PRUint32 inCookieSize)
 Stores a cookie in the browser's persistent cookie store.
NS_IMETHOD Observe (nsISupports *aSubject, const char *aTopic, const PRUnichar *someData)
NS_IMETHOD SetIsScriptableInstance (nsIPluginInstance *aPluginInstance, PRBool aScriptable)
 nsPIPluginHost interface
NS_IMETHOD ParsePostBufferToFixHeaders (const char *inPostData, PRUint32 inPostDataLen, char **outPostData, PRUint32 *outPostDataLen)
NS_IMETHOD CreateTmpFileToPost (const char *postDataURL, char **pTmpFileName)
NS_IMETHOD NewPluginNativeWindow (nsPluginNativeWindow **aPluginNativeWindow)
NS_IMETHOD DeletePluginNativeWindow (nsPluginNativeWindow *aPluginNativeWindow)
NS_IMETHOD NewPluginURLStream (const nsString &aURL, nsIPluginInstance *aInstance, nsIPluginStreamListener *aListener, const char *aPostData=nsnull, PRBool isFile=PR_FALSE, PRUint32 aPostDataLen=0, const char *aHeadersData=nsnull, PRUint32 aHeadersDataLen=0)
nsresult DoURLLoadSecurityCheck (nsIPluginInstance *aInstance, const char *aURL)
NS_IMETHOD AddHeadersToChannel (const char *aHeadersData, PRUint32 aHeadersDataLen, nsIChannel *aGenericChannel)
NS_IMETHOD StopPluginInstance (nsIPluginInstance *aInstance)
NS_IMETHOD AddUnusedLibrary (PRLibrary *aLibrary)
void beginWaitCursor ()
 Puts up a wait cursor.
void endWaitCursor ()
 Restores the previous (non-wait) cursor.
void supportsURLProtocol (in string aProtocol, out boolean aResult)
 Returns true if a URL protocol (e.g.
void notifyStatusChange (in nsIPlugin aPlugin, in nsresult aStatus)
 This method may be called by the plugin to indicate that an error has occurred, e.g.
void findProxyForURL (in string aURL, out string aResult)
 Returns the proxy info for a given URL.
void registerWindow (in nsIEventHandler aHandler, in nsPluginPlatformWindowRef aWindow)
 Registers a top-level window with the browser.
void unregisterWindow (in nsIEventHandler aHandler, in nsPluginPlatformWindowRef aWindow)
 Unregisters a top-level window with the browser.
void allocateMenuID (in nsIEventHandler aHandler, in boolean aIsSubmenu, out short aResult)
 Allocates a new menu ID (for the Mac).
void deallocateMenuID (in nsIEventHandler aHandler, in short aMenuID)
 Deallocates a menu ID (for the Mac).
void hasAllocatedMenuID (in nsIEventHandler aHandler, in short aMenuID, out boolean aResult)
 Indicates whether this event handler has allocated the given menu ID.
void GetValue (in nsPluginManagerVariable variable, in nativeVoid value)
 Returns the value of a variable associated with the plugin manager.
void reloadPlugins (in boolean reloadPages)
 Causes the plugins directory to be searched again for new plugin libraries.
void UserAgent (in nativeChar resultingAgentString)
 Returns the user agent string for the browser.
void RegisterPlugin (in REFNSIID aCID, in string aPluginName, in string aDescription, in nativeChar aMimeTypes, in nativeChar aMimeDescriptions, in nativeChar aFileExtensions, in long aCount)
 Persistently register a plugin with the plugin manager.
void UnregisterPlugin (in REFNSIID aCID)
 Unregister a plugin from the plugin manager.
void init ()
void destroy ()
void loadPlugins ()
void getPluginFactory (in string aMimeType, out nsIPlugin aPlugin)
void instantiateEmbeddedPlugin (in string aMimeType, in nsIURI aURL, in nsIPluginInstanceOwner aOwner)
void instantiateFullPagePlugin (in string aMimeType, in nsIURI aURI, in nsIStreamListenerRef aStreamListener, in nsIPluginInstanceOwner aOwner)
void setUpPluginInstance (in string aMimeType, in nsIURI aURL, in nsIPluginInstanceOwner aOwner)
void isPluginEnabledForType (in string aMimeType)
void isPluginEnabledForExtension (in string aExtension, in constCharStarRef aMimeType)
void getPlugins (in unsigned long aPluginCount, outnsIDOMPlugin aPluginArray)
void stopPluginInstance (in nsIPluginInstance aInstance)
void handleBadPlugin (in PRLibraryPtr aLibrary, in nsIPluginInstance instance)
void createInstance (in nsISupports aOuter, in nsIIDRef iid,[retval, iid_is(iid)] out nsQIResult result)
 Creates an instance of a component.
void lockFactory (in PRBool lock)
 LockFactory provides the client a way to keep the component in memory until it is finished with it.
void getProgramPath (out constCharPtr aProgramPath)
 Returns the name of the browser executable program.
void getTempDirPath (out constCharPtr aTempDirPath)
 Returns the name of the temporary directory.
void newTempFileName (in string aPrefix, in unsigned long aLength, in charPtr aBuffer)
 Returns a unique temporary file name.
void getCookie (in string aCookieURL, in voidPtr aCookieBuffer, in PRUint32Ref aCookieSize)
 Retrieves a cookie from the browser's persistent cookie store.
void setCookie (in string aCookieURL, in constVoidPtr aCookieBuffer, in unsigned long aCookieSize)
 Stores a cookie in the browser's persistent cookie store.
void observe (in nsISupports aSubject, in string aTopic, in wstring aData)
 Observe will be called when there is a notification for the topic |aTopic|.
void setIsScriptableInstance (in nsIPluginInstance aInstance, in boolean aScriptable)
 To notify the plugin manager that the plugin created a script object.
void parsePostBufferToFixHeaders (in string aInPostData, in unsigned long aInPostDataLen, out string aOutPostData, out unsigned long aOutPostDataLen)
 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).
void createTmpFileToPost (in string aPostDataURL, out string aTmpFileName)
 To create tmp file with Content len header in, it will use by http POST.
void newPluginNativeWindow (out nsPluginNativeWindowPtr aPluginNativeWindow)
 Creates a new plugin native window object.
void deletePluginNativeWindow (in nsPluginNativeWindowPtr aPluginNativeWindow)
 Deletes plugin native window object created by NewPluginNativeWindow.

Static Public Member Functions

static NS_METHOD Create (nsISupports *aOuter, REFNSIID aIID, void **aResult)
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
static NS_DECL_ISUPPORTS const
char * 
GetPluginName (nsIPluginInstance *aPluginInstance)
static nsresult GetPluginTempDir (nsIFile **aDir)

Public Attributes

readonly attribute unsigned long pluginCount

Private Member Functions

NS_IMETHOD TrySetUpPluginInstance (const char *aMimeType, nsIURI *aURL, nsIPluginInstanceOwner *aOwner)
nsresult LoadXPCOMPlugins (nsIComponentManager *aComponentManager)
nsresult NewEmbeddedPluginStream (nsIURI *aURL, nsIPluginInstanceOwner *aOwner, nsIPluginInstance *aInstance)
nsresult NewFullPagePluginStream (nsIStreamListener *&aStreamListener, nsIPluginInstance *aInstance)
nsresult FindPluginEnabledForType (const char *aMimeType, nsPluginTag *&aPlugin)
nsresult FindStoppedPluginForURL (nsIURI *aURL, nsIPluginInstanceOwner *aOwner)
nsresult SetUpDefaultPluginInstance (const char *aMimeType, nsIURI *aURL, nsIPluginInstanceOwner *aOwner)
nsresult AddInstanceToActiveList (nsCOMPtr< nsIPlugin > aPlugin, nsIPluginInstance *aInstance, nsIURI *aURL, PRBool aDefaultPlugin, nsIPluginInstancePeer *peer)
nsresult FindPlugins (PRBool aCreatePluginList, PRBool *aPluginsChanged)
nsresult ScanPluginsDirectory (nsIFile *pluginsDir, nsIComponentManager *compManager, PRBool aCreatePluginList, PRBool *aPluginsChanged, PRBool checkForUnwantedPlugins=PR_FALSE)
nsresult ScanPluginsDirectoryList (nsISimpleEnumerator *dirEnum, nsIComponentManager *compManager, PRBool aCreatePluginList, PRBool *aPluginsChanged, PRBool checkForUnwantedPlugins=PR_FALSE)
PRBool IsRunningPlugin (nsPluginTag *plugin)
nsresult WritePluginInfo ()
nsresult ReadPluginInfo ()
nsPluginTagRemoveCachedPluginsInfo (const char *filename)
nsPluginTagHaveSamePlugin (nsPluginTag *aPluginTag)
PRBool IsDuplicatePlugin (nsPluginTag *aPluginTag)
void ClearCachedPluginInfoList ()
nsresult EnsurePrivateDirServiceProvider ()
nsresult GetPrompt (nsIPluginInstanceOwner *aOwner, nsIPrompt **aPrompt)
nsresult ScanForRealInComponentsFolder (nsIComponentManager *aCompManager)
void UnloadUnusedLibraries ()

Private Attributes

char * mPluginPath
nsPluginTagmPlugins
nsPluginTagmCachedPlugins
PRPackedBool mPluginsLoaded
PRPackedBool mDontShowBadPluginMessage
PRPackedBool mIsDestroyed
PRPackedBool mOverrideInternalTypes
PRPackedBool mAllowAlienStarHandler
PRPackedBool mDefaultPluginDisabled
nsActivePluginList mActivePluginList
nsVoidArray mUnusedLibraries
nsCOMPtr< nsIFilemPluginRegFile
nsCOMPtr< nsIPrefBranchmPrefService
nsRefPtr
< nsPluginDirServiceProvider
mPrivateDirServiceProvider
nsWeakPtr mCurrentDocument

Static Private Attributes

static nsIFilesPluginTempDir

Detailed Description

Definition at line 180 of file nsPluginHostImpl.h.


Constructor & Destructor Documentation

Definition at line 2561 of file nsPluginHostImpl.cpp.

{
  mPluginsLoaded = PR_FALSE;
  mDontShowBadPluginMessage = PR_FALSE;
  mIsDestroyed = PR_FALSE;
  mOverrideInternalTypes = PR_FALSE;
  mAllowAlienStarHandler = PR_FALSE;
  mUnusedLibraries.Clear();
  mDefaultPluginDisabled = PR_FALSE;

  gActivePluginList = &mActivePluginList;

  // check to see if pref is set at startup to let plugins take over in
  // full page mode for certain image mime types that we handle internally
  mPrefService = do_GetService(NS_PREFSERVICE_CONTRACTID);
  if (mPrefService) {
    PRBool tmp;
    mPrefService->GetBoolPref("plugin.override_internal_types", &tmp);
    mOverrideInternalTypes = tmp;

    mPrefService->GetBoolPref("plugin.allow_alien_star_handler", &tmp);
    mAllowAlienStarHandler = tmp;

    mPrefService->GetBoolPref("plugin.default_plugin_disabled", &tmp);
    mDefaultPluginDisabled = tmp;

#ifdef WINCE
    mDefaultPluginDisabled = PR_TRUE;
#endif
  }

  nsCOMPtr<nsIObserverService> obsService = do_GetService("@mozilla.org/observer-service;1");
  if (obsService)
  {
    obsService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
  }

#ifdef PLUGIN_LOGGING
  nsPluginLogging::gNPNLog = PR_NewLogModule(NPN_LOG_NAME);
  nsPluginLogging::gNPPLog = PR_NewLogModule(NPP_LOG_NAME);
  nsPluginLogging::gPluginLog = PR_NewLogModule(PLUGIN_LOG_NAME);

  PR_LOG(nsPluginLogging::gNPNLog, PLUGIN_LOG_ALWAYS,("NPN Logging Active!\n"));
  PR_LOG(nsPluginLogging::gPluginLog, PLUGIN_LOG_ALWAYS,("General Plugin Logging Active! (nsPluginHostImpl::ctor)\n"));
  PR_LOG(nsPluginLogging::gNPPLog, PLUGIN_LOG_ALWAYS,("NPP Logging Active!\n"));

  PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("nsPluginHostImpl::ctor\n"));
  PR_LogFlush();
#endif
  mCachedPlugins = nsnull;
}

Here is the call graph for this function:

Definition at line 2629 of file nsPluginHostImpl.cpp.

{
  PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("nsPluginHostImpl::dtor\n"));

#ifdef NS_DEBUG
  printf("nsPluginHostImpl dtor\n");
#endif
  Destroy();
}

Here is the call graph for this function:


Member Function Documentation

NS_IMETHODIMP nsPluginHostImpl::AddHeadersToChannel ( const char *  aHeadersData,
PRUint32  aHeadersDataLen,
nsIChannel aGenericChannel 
)

Definition at line 5885 of file nsPluginHostImpl.cpp.

{
  nsresult rv = NS_OK;

  nsCOMPtr<nsIHttpChannel> aChannel = do_QueryInterface(aGenericChannel);
  if (!aChannel) {
    return NS_ERROR_NULL_POINTER;
  }

  // used during the manipulation of the String from the aHeadersData
  nsCAutoString headersString;
  nsCAutoString oneHeader;
  nsCAutoString headerName;
  nsCAutoString headerValue;
  PRInt32 crlf = 0;
  PRInt32 colon = 0;

  //
  // Turn the char * buffer into an nsString.
  //
  headersString = aHeadersData;

  //
  // Iterate over the nsString: for each "\r\n" delimited chunk,
  // add the value as a header to the nsIHTTPChannel
  //

  while (PR_TRUE) {
    crlf = headersString.Find("\r\n", PR_TRUE);
    if (-1 == crlf) {
      rv = NS_OK;
      return rv;
    }
    headersString.Mid(oneHeader, 0, crlf);
    headersString.Cut(0, crlf + 2);
    oneHeader.StripWhitespace();
    colon = oneHeader.Find(":");
    if (-1 == colon) {
      rv = NS_ERROR_NULL_POINTER;
      return rv;
    }
    oneHeader.Left(headerName, colon);
    colon++;
    oneHeader.Mid(headerValue, colon, oneHeader.Length() - colon);

    //
    // FINALLY: we can set the header!
    //

    rv = aChannel->SetRequestHeader(headerName, headerValue, PR_TRUE);
    if (NS_FAILED(rv)) {
      rv = NS_ERROR_NULL_POINTER;
      return rv;
    }
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsPluginHostImpl::AddInstanceToActiveList ( nsCOMPtr< nsIPlugin aPlugin,
nsIPluginInstance aInstance,
nsIURI aURL,
PRBool  aDefaultPlugin,
nsIPluginInstancePeer peer 
) [private]

Definition at line 3700 of file nsPluginHostImpl.cpp.

{
  NS_ENSURE_ARG_POINTER(aURL);

  nsCAutoString url;
  (void)aURL->GetSpec(url);

  // let's find the corresponding plugin tag by matching nsIPlugin pointer
  // it's legal for XPCOM plugins not to have nsIPlugin implemented but
  // this is OK, we don't need the plugin tag for XPCOM plugins. It is going
  // to be used later when we decide whether or not we should delay unloading
  // NPAPI dll from memory, and XPCOM dlls will stay in memory anyway.
  nsPluginTag * pluginTag = nsnull;
  if(aPlugin) {
    for(pluginTag = mPlugins; pluginTag != nsnull; pluginTag = pluginTag->mNext) {
      if(pluginTag->mEntryPoint == aPlugin)
        break;
    }
    NS_ASSERTION(pluginTag, "Plugin tag not found");
  }

  nsActivePlugin * plugin = new nsActivePlugin(pluginTag, aInstance, url.get(), aDefaultPlugin, peer);

  if(!plugin)
    return NS_ERROR_OUT_OF_MEMORY;

  mActivePluginList.add(plugin);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 6692 of file nsPluginHostImpl.cpp.

{
  if (mUnusedLibraries.IndexOf(aLibrary) == -1) // don't add duplicates
    mUnusedLibraries.AppendElement(aLibrary);

  return NS_OK;
}

Here is the caller graph for this function:

void nsIPluginManager2::allocateMenuID ( in nsIEventHandler  aHandler,
in boolean  aIsSubmenu,
out short  aResult 
) [inherited]

Allocates a new menu ID (for the Mac).

Parameters:
aHandler- the event handler for the window
aIsSubmenu- whether this is a sub-menu ID or not
aResult- the resulting menu ID
Returns:
- NS_OK if this operation was successful
NS_IMETHODIMP nsPluginHostImpl::AllocateMenuID ( nsIEventHandler handler,
PRBool  isSubmenu,
PRInt16 result 
)

Definition at line 3200 of file nsPluginHostImpl.cpp.

Puts up a wait cursor.

Returns:
- NS_OK if this operation was successful

Definition at line 3077 of file nsPluginHostImpl.cpp.

Definition at line 5340 of file nsPluginHostImpl.cpp.

Here is the caller graph for this function:

static NS_METHOD nsPluginHostImpl::Create ( nsISupports *  aOuter,
REFNSIID  aIID,
void **  aResult 
) [static]
void nsIFactory::createInstance ( in nsISupports  aOuter,
in nsIIDRef  iid,
[retval, iid_is(iid)] out nsQIResult  result 
) [inherited]

Creates an instance of a component.

Parameters:
aOuterPointer to a component that wishes to be aggregated in the resulting instance. This will be nsnull if no aggregation is requested.
iidThe IID of the interface being requested in the component which is being currently created.
result[out] Pointer to the newly created instance, if successful.
Returns:
NS_OK - Component successfully created and the interface being requested was successfully returned in result. NS_NOINTERFACE - Interface not accessible. NS_ERROR_NO_AGGREGATION - if an 'outer' object is supplied, but the component is not aggregatable. NS_ERROR* - Method failure.
NS_IMETHODIMP nsPluginHostImpl::CreateInstance ( nsISupports *  aOuter,
REFNSIID  aIID,
void **  aResult 
)

Definition at line 3228 of file nsPluginHostImpl.cpp.

{
  NS_NOTREACHED("how'd I get here?");
  return NS_ERROR_UNEXPECTED;
}
void nsPIPluginHost::createTmpFileToPost ( in string  aPostDataURL,
out string  aTmpFileName 
) [inherited]

To create tmp file with Content len header in, it will use by http POST.

NS_IMETHODIMP nsPluginHostImpl::CreateTmpFileToPost ( const char *  postDataURL,
char **  pTmpFileName 
)

Definition at line 6502 of file nsPluginHostImpl.cpp.

{
  *pTmpFileName = 0;
  nsresult rv;
  PRInt64 fileSize;
  nsCAutoString filename;

  // stat file == get size & convert file:///c:/ to c: if needed
  nsCOMPtr<nsIFile> inFile;
  rv = NS_GetFileFromURLSpec(nsDependentCString(postDataURL),
                             getter_AddRefs(inFile));
  if (NS_FAILED(rv)) {
    nsCOMPtr<nsILocalFile> localFile;
    rv = NS_NewNativeLocalFile(nsDependentCString(postDataURL), PR_FALSE,
                               getter_AddRefs(localFile));
    if (NS_FAILED(rv)) return rv;
    inFile = localFile;
  }
  rv = inFile->GetFileSize(&fileSize);
  if (NS_FAILED(rv)) return rv;
  rv = inFile->GetNativePath(filename);
  if (NS_FAILED(rv)) return rv;

  if (!LL_IS_ZERO(fileSize)) {
    nsCOMPtr<nsIInputStream> inStream;
    rv = NS_NewLocalFileInputStream(getter_AddRefs(inStream), inFile);
    if (NS_FAILED(rv)) return rv;

    // Create a temporary file to write the http Content-length:
    // %ld\r\n\" header and "\r\n" == end of headers for post data to

    nsCOMPtr<nsIFile> tempFile;
    rv = GetPluginTempDir(getter_AddRefs(tempFile));
    if (NS_FAILED(rv))
      return rv;

    nsCAutoString inFileName;
    inFile->GetNativeLeafName(inFileName);
    // XXX hack around bug 70083
    inFileName.Insert(NS_LITERAL_CSTRING("post-"), 0);
    rv = tempFile->AppendNative(inFileName);

    if (NS_FAILED(rv))
      return rv;

    // make it unique, and mode == 0600, not world-readable
    rv = tempFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0600);
    if (NS_FAILED(rv))
      return rv;

    nsCOMPtr<nsIOutputStream> outStream;
    if (NS_SUCCEEDED(rv)) {
      rv = NS_NewLocalFileOutputStream(getter_AddRefs(outStream),
        tempFile,
        (PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE),
        0600); // 600 so others can't read our form data
    }
    NS_ASSERTION(NS_SUCCEEDED(rv), "Post data file couldn't be created!");
    if (NS_FAILED(rv))
      return rv;

    char buf[1024];
    PRUint32 br, bw;
    PRBool firstRead = PR_TRUE;
    while (1) {
      // Read() mallocs if buffer is null
      rv = inStream->Read(buf, 1024, &br);
      if (NS_FAILED(rv) || (PRInt32)br <= 0)
        break;
      if (firstRead) {
        // according to the 4.x spec
        // http://developer.netscape.com/docs/manuals/communicator/plugin/pgfn2.htm#1007707
        //"For protocols in which the headers must be distinguished from the body,
        // such as HTTP, the buffer or file should contain the headers, followed by
        // a blank line, then the body. If no custom headers are required, simply
        // add a blank line ('\n') to the beginning of the file or buffer.

        char *parsedBuf;
        // assuming first 1K (or what we got) has all headers in,
        // lets parse it through nsPluginHostImpl::ParsePostBufferToFixHeaders()
        ParsePostBufferToFixHeaders((const char *)buf, br, &parsedBuf, &bw);
        rv = outStream->Write(parsedBuf, bw, &br);
        nsMemory::Free(parsedBuf);
        if (NS_FAILED(rv) || (bw != br))
          break;

        firstRead = PR_FALSE;
        continue;
      }
      bw = br;
      rv = outStream->Write(buf, bw, &br);
      if (NS_FAILED(rv) || (bw != br))
        break;
    }

    inStream->Close();
    outStream->Close();
    if (NS_SUCCEEDED(rv)) {
      nsCAutoString path;
      if (NS_SUCCEEDED(tempFile->GetNativePath(path)))
        *pTmpFileName = ToNewCString(path);
    }
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIPluginManager2::deallocateMenuID ( in nsIEventHandler  aHandler,
in short  aMenuID 
) [inherited]

Deallocates a menu ID (for the Mac).

Parameters:
aHandler- the event handler for the window
aMenuID- the menu ID
Returns:
- NS_OK if this operation was successful

Definition at line 3207 of file nsPluginHostImpl.cpp.

Deletes plugin native window object created by NewPluginNativeWindow.

Definition at line 6615 of file nsPluginHostImpl.cpp.

{
  return PLUG_DeletePluginNativeWindow(aPluginNativeWindow);
}

Here is the call graph for this function:

void nsIPluginHost::destroy ( ) [inherited]

Definition at line 3253 of file nsPluginHostImpl.cpp.

{
  PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsPluginHostImpl::Destroy Called\n"));

  if (mIsDestroyed)
    return NS_OK;

  mIsDestroyed = PR_TRUE;

  // we should call nsIPluginInstance::Stop and nsIPluginInstance::SetWindow
  // for those plugins who want it
  mActivePluginList.stopRunning(nsnull);

  // at this point nsIPlugin::Shutdown calls will be performed if needed
  mActivePluginList.shut();

  if (nsnull != mPluginPath)
  {
    PR_Free(mPluginPath);
    mPluginPath = nsnull;
  }

  while (nsnull != mPlugins)
  {
    nsPluginTag *temp = mPlugins->mNext;

    // while walking through the list of the plugins see if we still have anything
    // to shutdown some plugins may have never created an instance but still expect
    // the shutdown call see bugzilla bug 73071
    // with current logic, no need to do anything special as nsIPlugin::Shutdown
    // will be performed in the destructor

    delete mPlugins;
    mPlugins = temp;
  }

  // Delete any remaining cached plugins list
  while (mCachedPlugins)
  {
    nsPluginTag *next = mCachedPlugins->mNext;
    delete mCachedPlugins;
    mCachedPlugins = next;
  }

  // Lets remove any of the temporary files that we created.
  if (sPluginTempDir) {
    sPluginTempDir->Remove(PR_TRUE);

    NS_RELEASE(sPluginTempDir);
  }

  if (mPrivateDirServiceProvider)
  {
    nsCOMPtr<nsIDirectoryService> dirService =
      do_GetService(kDirectoryServiceContractID);
    if (dirService)
      dirService->UnregisterProvider(mPrivateDirServiceProvider);
    mPrivateDirServiceProvider = nsnull;
  }

  mPrefService = nsnull; // release prefs service to avoid leaks!

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 5840 of file nsPluginHostImpl.cpp.

{
  nsresult rv;

  if (!aURL || *aURL == '\0')
    return NS_OK;

  // get the URL of the document that loaded the plugin
  nsCOMPtr<nsIDocument> doc;
  nsCOMPtr<nsIPluginInstancePeer> peer;
  rv = aInstance->GetPeer(getter_AddRefs(peer));
  if (NS_FAILED(rv) || !peer)
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsPIPluginInstancePeer> privpeer(do_QueryInterface(peer));
  nsCOMPtr<nsIPluginInstanceOwner> owner;
  rv = privpeer->GetOwner(getter_AddRefs(owner));
  if (!owner)
    return NS_ERROR_FAILURE;

  rv = owner->GetDocument(getter_AddRefs(doc));
  if (!doc)
    return NS_ERROR_FAILURE;

  // Create an absolute URL for the target in case the target is relative
  nsCOMPtr<nsIURI> targetURL;
  rv = NS_NewURI(getter_AddRefs(targetURL), aURL, doc->GetBaseURI());

  if (!targetURL)
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsIScriptSecurityManager> secMan(
    do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv));
  if (NS_FAILED(rv))
    return rv;

  return secMan->CheckLoadURIWithPrincipal(doc->GetPrincipal(), targetURL,
                                           nsIScriptSecurityManager::STANDARD);

}

Here is the call graph for this function:

Here is the caller graph for this function:

Restores the previous (non-wait) cursor.

Returns:
- NS_OK if this operation was successful

Definition at line 3084 of file nsPluginHostImpl.cpp.

Definition at line 5677 of file nsPluginHostImpl.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsPluginHostImpl::FindPluginEnabledForType ( const char *  aMimeType,
nsPluginTag *&  aPlugin 
) [private]

Definition at line 4461 of file nsPluginHostImpl.cpp.

{
  nsPluginTag *plugins = nsnull;
  PRInt32     variants, cnt;

  aPlugin = nsnull;

  LoadPlugins();

  // if we have a mimetype passed in, search the mPlugins
  // linked list for a match
  if (nsnull != aMimeType) {
    plugins = mPlugins;

    while (nsnull != plugins) {
      variants = plugins->mVariants;

      for (cnt = 0; cnt < variants; cnt++) {
        if (plugins->mMimeTypeArray[cnt] && (0 == PL_strcasecmp(plugins->mMimeTypeArray[cnt], aMimeType))) {
          aPlugin = plugins;
          return NS_OK;
        }
      }

      if (cnt < variants)
        break;

      plugins = plugins->mNext;
    }
  }

  return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsPluginHostImpl::FindPlugins ( PRBool  aCreatePluginList,
PRBool aPluginsChanged 
) [private]

Definition at line 5149 of file nsPluginHostImpl.cpp.

{
  // let's start timing if we are only really creating the plugin list
  if (aCreatePluginList) {
    NS_TIMELINE_START_TIMER("LoadPlugins");
  }

#ifdef CALL_SAFETY_ON
  // check preferences on whether or not we want to try safe calls to plugins
  NS_INIT_PLUGIN_SAFE_CALLS;
#endif

  NS_ENSURE_ARG_POINTER(aPluginsChanged);

  *aPluginsChanged = PR_FALSE;
  nsresult rv;

  // Read cached plugins info
  ReadPluginInfo();

  nsCOMPtr<nsIComponentManager> compManager;
  NS_GetComponentManager(getter_AddRefs(compManager));
  if (compManager)
    LoadXPCOMPlugins(compManager);

  // Failure here is not a show-stopper so just warn.
  rv = EnsurePrivateDirServiceProvider();
  NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to register dir service provider.");

  nsCOMPtr<nsIProperties> dirService(do_GetService(kDirectoryServiceContractID, &rv));
  if (NS_FAILED(rv))
    return rv;

  nsCOMPtr<nsISimpleEnumerator> dirList;

  // Scan plugins directories;
  // don't pass aPluginsChanged directly, to prevent its
  // possible reset in subsequent ScanPluginsDirectory calls
  PRBool pluginschanged = PR_FALSE;

  // Scan the app-defined list of plugin dirs.
  rv = dirService->Get(NS_APP_PLUGINS_DIR_LIST, NS_GET_IID(nsISimpleEnumerator), getter_AddRefs(dirList));
  if (NS_SUCCEEDED(rv)) {
    ScanPluginsDirectoryList(dirList, compManager, aCreatePluginList, &pluginschanged);

    if (pluginschanged)
      *aPluginsChanged = PR_TRUE;

    // if we are just looking for possible changes,
    // no need to proceed if changes are detected
    if (!aCreatePluginList && *aPluginsChanged) {
      ClearCachedPluginInfoList();
      return NS_OK;
    }
  }

  mPluginsLoaded = PR_TRUE; // at this point 'some' plugins have been loaded,
                            // the rest is optional

#if defined (XP_WIN)

  PRBool bScanPLIDs = PR_FALSE;

  if (mPrefService)
    mPrefService->GetBoolPref("plugin.scan.plid.all", &bScanPLIDs);

    // Now lets scan any PLID directories
  if (bScanPLIDs && mPrivateDirServiceProvider) {
    rv = mPrivateDirServiceProvider->GetPLIDDirectories(getter_AddRefs(dirList));
    if (NS_SUCCEEDED(rv)) {
      ScanPluginsDirectoryList(dirList, compManager, aCreatePluginList, &pluginschanged);

      if (pluginschanged)
        *aPluginsChanged = PR_TRUE;

      // if we are just looking for possible changes,
      // no need to proceed if changes are detected
      if (!aCreatePluginList && *aPluginsChanged) {
        ClearCachedPluginInfoList();
        return NS_OK;
      }
    }
  }


  // Scan the installation paths of our popular plugins if the prefs are enabled

  // This table controls the order of scanning
  const char* const prefs[] = {NS_WIN_JRE_SCAN_KEY,         nsnull,
                               NS_WIN_ACROBAT_SCAN_KEY,     nsnull,
                               NS_WIN_QUICKTIME_SCAN_KEY,   nsnull,
                               NS_WIN_WMP_SCAN_KEY,         nsnull,
                               NS_WIN_4DOTX_SCAN_KEY,       "1"  /*  second column is flag for 4.x folder */ };

  PRUint32 size = sizeof(prefs) / sizeof(prefs[0]);

  for (PRUint32 i = 0; i < size; i+=2) {
    nsCOMPtr<nsIFile> dirToScan;
    PRBool bExists;
    if (NS_SUCCEEDED(dirService->Get(prefs[i], NS_GET_IID(nsIFile), getter_AddRefs(dirToScan))) &&
        dirToScan &&
        NS_SUCCEEDED(dirToScan->Exists(&bExists)) &&
        bExists) {

      PRBool bFilterUnwanted = PR_FALSE;

      // 4.x plugins folder stuff:
      // Normally we "filter" the 4.x folder through |IsUnwantedPlugin|
      // Check for a pref to see if we want to scan the entire 4.x plugins folder
      if (prefs[i+1]) {
        PRBool bScanEverything;
        bFilterUnwanted = PR_TRUE;  // default to filter 4.x folder
        if (mPrefService &&
            NS_SUCCEEDED(mPrefService->GetBoolPref(prefs[i], &bScanEverything)) &&
            bScanEverything)
          bFilterUnwanted = PR_FALSE;

      }
      ScanPluginsDirectory(dirToScan, compManager, aCreatePluginList, &pluginschanged, bFilterUnwanted);

      if (pluginschanged)
        *aPluginsChanged = PR_TRUE;

      // if we are just looking for possible changes,
      // no need to proceed if changes are detected
      if (!aCreatePluginList && *aPluginsChanged) {
        ClearCachedPluginInfoList();
        return NS_OK;
      }
    }
  }

#endif

  // if get to this point and did not detect changes in plugins
  // that means no plugins got updated or added
  // let's see if plugins have been removed
  if (!*aPluginsChanged) {
    // count plugins remained in cache, if there are some, that means some plugins were removed;
    // while counting, we should ignore unwanted plugins which are also present in cache
    PRUint32 cachecount = 0;
    for (nsPluginTag * cachetag = mCachedPlugins; cachetag; cachetag = cachetag->mNext) {
      if (!(cachetag->mFlags & NS_PLUGIN_FLAG_UNWANTED))
        cachecount++;
    }
    // if there is something left in cache, some plugins got removed from the directory
    // and therefor their info did not get removed from the cache info list during directory scan;
    // flag this fact
    if (cachecount > 0)
      *aPluginsChanged = PR_TRUE;
  }

  // if we are not creating the list, there is no need to proceed
  if (!aCreatePluginList) {
    ClearCachedPluginInfoList();
    return NS_OK;
  }

  // if we are creating the list, it is already done;
  // update the plugins info cache if changes are detected
  if (*aPluginsChanged)
    WritePluginInfo();

  // No more need for cached plugins. Clear it up.
  ClearCachedPluginInfoList();

  /*
   * XXX Big time hack alert!!!!
   *     Because Real Player 8 installs in the components folder, we must have this one off
   *     scan for nppl3260.dll because XPCOM has shut off nsGetFactory type plugins.
   *     When we stop supporting Real 8 or they fix their installer, this can go away.
   */
  if (aCreatePluginList)
    ScanForRealInComponentsFolder(compManager);

  // reverse our list of plugins
  nsPluginTag *next,*prev = nsnull;
  for (nsPluginTag *cur = mPlugins; cur; cur = next) {
    next = cur->mNext;
    cur->mNext = prev;
    prev = cur;
  }

  mPlugins = prev;

  NS_TIMELINE_STOP_TIMER("LoadPlugins");
  NS_TIMELINE_MARK_TIMER("LoadPlugins");

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIPluginManager2::findProxyForURL ( in string  aURL,
out string  aResult 
) [inherited]

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.

NS_IMETHODIMP nsPluginHostImpl::FindProxyForURL ( const char *  url,
char **  result 
)

Definition at line 3115 of file nsPluginHostImpl.cpp.

{
  if (!url || !result) {
    return NS_ERROR_INVALID_ARG;
  }
  nsresult res;

  nsCOMPtr<nsIURI> uriIn;
  nsCOMPtr<nsIProtocolProxyService> proxyService;
  nsCOMPtr<nsIIOService> ioService;

  proxyService = do_GetService(kProtocolProxyServiceCID, &res);
  if (NS_FAILED(res) || !proxyService) {
    return res;
  }

  ioService = do_GetService(kIOServiceCID, &res);
  if (NS_FAILED(res) || !ioService) {
    return res;
  }

  // make an nsURI from the argument url
  res = ioService->NewURI(nsDependentCString(url), nsnull, nsnull, getter_AddRefs(uriIn));
  if (NS_FAILED(res)) {
    return res;
  }

  nsCOMPtr<nsIProxyInfo> pi;

  res = proxyService->Resolve(uriIn, 0, getter_AddRefs(pi));
  if (NS_FAILED(res)) {
    return res;
  }

  nsCAutoString host, type;
  PRInt32 port = -1;

  // These won't fail, and even if they do... we'll be ok.
  if (pi) {
    pi->GetType(type);
    pi->GetHost(host);
    pi->GetPort(&port);
  }

  if (!pi || host.IsEmpty() || port <= 0 || host.EqualsLiteral("direct")) {
    *result = PL_strdup("DIRECT");
  } else if (type.EqualsLiteral("http")) {
    *result = PR_smprintf("PROXY %s:%d", host.get(), port);
  } else if (type.EqualsLiteral("socks4")) {
    *result = PR_smprintf("SOCKS %s:%d", host.get(), port);
  } else if (type.EqualsLiteral("socks")) {
    // XXX - this is socks5, but there is no API for us to tell the
    // plugin that fact. SOCKS for now, in case the proxy server
    // speaks SOCKS4 as well. See bug 78176
    // For a long time this was returning an http proxy type, so
    // very little is probably broken by this
    *result = PR_smprintf("SOCKS %s:%d", host.get(), port);
  } else {
    NS_ASSERTION(PR_FALSE, "Unknown proxy type!");
    *result = PL_strdup("DIRECT");
  }

  if (nsnull == *result) {
    res = NS_ERROR_OUT_OF_MEMORY;
  }

  return res;
}

Here is the call graph for this function:

Definition at line 3659 of file nsPluginHostImpl.cpp.

{
  nsCAutoString url;
  if(!aURL)
    return NS_ERROR_FAILURE;

  (void)aURL->GetAsciiSpec(url);

  nsActivePlugin * plugin = mActivePluginList.findStopped(url.get());

  if((plugin != nsnull) && (plugin->mStopped))
  {
    nsIPluginInstance* instance = plugin->mInstance;
    nsPluginWindow    *window = nsnull;
    aOwner->GetWindow(window);

    aOwner->SetInstance(instance);

    // we have to reset the owner and instance in the plugin instance peer
    //instance->GetPeer(&peer);
    ((nsPluginInstancePeerImpl*)plugin->mPeer)->SetOwner(aOwner);

    instance->Start();
    aOwner->CreateWidget();

    // If we've got a native window, the let the plugin know about it.
    if (window->window)
    {
      nsCOMPtr<nsIPluginInstance> inst = instance;
      ((nsPluginNativeWindow*)window)->CallSetWindow(inst);
    }

    plugin->setStopped(PR_FALSE);
    return NS_OK;
  }
  return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsICookieStorage::getCookie ( in string  aCookieURL,
in voidPtr  aCookieBuffer,
in PRUint32Ref  aCookieSize 
) [inherited]

Retrieves a cookie from the browser's persistent cookie store.

Parameters:
aCookieURL- URL string to look up cookie with.
aCookieBuffer- buffer large enough to accomodate cookie data.
aCookieSize- on input, size of the cookie buffer, on output cookie's size.
NS_IMETHODIMP nsPluginHostImpl::GetCookie ( const char *  inCookieURL,
void inOutCookieBuffer,
PRUint32 inOutCookieSize 
)

Retrieves a cookie from the browser's persistent cookie store.

Parameters:
inCookieURLURL string to look up cookie with.
inOutCookieBufferbuffer large enough to accomodate cookie data.
inOutCookieSizeon input, size of the cookie buffer, on output cookie's size.

Definition at line 6131 of file nsPluginHostImpl.cpp.

{
  nsresult rv = NS_ERROR_NOT_IMPLEMENTED;
  nsXPIDLCString cookieString;
  PRUint32 cookieStringLen = 0;
  nsCOMPtr<nsIURI> uriIn;

  if ((nsnull == inCookieURL) || (0 >= inOutCookieSize)) {
    return NS_ERROR_INVALID_ARG;
  }

  nsCOMPtr<nsIIOService> ioService(do_GetService(kIOServiceCID, &rv));

  if (NS_FAILED(rv) || (nsnull == ioService)) {
    return rv;
  }

  nsCOMPtr<nsICookieService> cookieService =
           do_GetService(kCookieServiceCID, &rv);

  if (NS_FAILED(rv) || (nsnull == cookieService)) {
    return NS_ERROR_INVALID_ARG;
  }

  // make an nsURI from the argument url
  rv = ioService->NewURI(nsDependentCString(inCookieURL), nsnull, nsnull, getter_AddRefs(uriIn));
  if (NS_FAILED(rv)) {
    return rv;
  }

  rv = cookieService->GetCookieString(uriIn, nsnull, getter_Copies(cookieString));

  if (NS_FAILED(rv) || (!cookieString) ||
      (inOutCookieSize <= (cookieStringLen = PL_strlen(cookieString.get())))) {
    return NS_ERROR_FAILURE;
  }

  PL_strcpy((char *) inOutCookieBuffer, cookieString.get());
  inOutCookieSize = cookieStringLen;
  rv = NS_OK;

  return rv;
}

Here is the call graph for this function:

Definition at line 4423 of file nsPluginHostImpl.cpp.

{
  LoadPlugins();

  PRUint32 count = 0;

  nsPluginTag* plugin = mPlugins;
  while (plugin != nsnull) {
    ++count;
    plugin = plugin->mNext;
  }

  *aPluginCount = count;

  return NS_OK;
}
void nsIPluginHost::getPluginFactory ( in string  aMimeType,
out nsIPlugin  aPlugin 
) [inherited]
NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory ( const char *  aMimeType,
nsIPlugin **  aPlugin 
)

Definition at line 4595 of file nsPluginHostImpl.cpp.

{
  nsresult rv = NS_ERROR_FAILURE;
  *aPlugin = NULL;

  if(!aMimeType)
    return NS_ERROR_ILLEGAL_VALUE;

  // If plugins haven't been scanned yet, do so now
  LoadPlugins();

  nsPluginTag* pluginTag;
  if((rv = FindPluginEnabledForType(aMimeType, pluginTag)) == NS_OK)
  {
    PLUGIN_LOG(PLUGIN_LOG_BASIC,
    ("nsPluginHostImpl::GetPluginFactory Begin mime=%s, plugin=%s\n",
    aMimeType, pluginTag->mFileName));

#ifdef NS_DEBUG
    if(aMimeType && pluginTag->mFileName)
      printf("For %s found plugin %s\n", aMimeType, pluginTag->mFileName);
#endif

    if (nsnull == pluginTag->mLibrary)  // if we haven't done this yet
    {

     nsCOMPtr<nsILocalFile> file = do_CreateInstance("@mozilla.org/file/local;1");
#if !defined(XP_MACOSX)
      file->InitWithNativePath(nsDependentCString(pluginTag->mFileName));
#else
      if (nsnull == pluginTag->mFullPath)
        return NS_ERROR_FAILURE;
      file->InitWithNativePath(nsDependentCString(pluginTag->mFullPath));
#endif
      nsPluginFile pluginFile(file);
      PRLibrary* pluginLibrary = NULL;

      if (pluginFile.LoadPlugin(pluginLibrary) != NS_OK || pluginLibrary == NULL)
        return NS_ERROR_FAILURE;

      // remove from unused lib list, if it is there
      if (mUnusedLibraries.IndexOf(pluginLibrary) > -1)
        mUnusedLibraries.RemoveElement(pluginLibrary);

      pluginTag->mLibrary = pluginLibrary;
    }

    nsIPlugin* plugin = pluginTag->mEntryPoint;
    if(plugin == NULL)
    {
      // nsIPlugin* of xpcom plugins can be found thru a call to
      // nsIComponentManager::GetClassObjectByContractID()
      nsCAutoString contractID(
              NS_LITERAL_CSTRING(NS_INLINE_PLUGIN_CONTRACTID_PREFIX) +
              nsDependentCString(aMimeType));
      nsresult rv = CallGetClassObject(contractID.get(), &plugin);
      if (NS_SUCCEEDED(rv) && plugin)
      {
        // plugin is already addref'd
        pluginTag->mEntryPoint = plugin;
        plugin->Initialize();
      }
    }

    if (plugin == NULL)
    {
      // No, this is not a leak. GetGlobalServiceManager() doesn't
      // addref the pointer on the way out. It probably should.
      nsIServiceManagerObsolete* serviceManager;
      nsServiceManager::GetGlobalServiceManager((nsIServiceManager**)&serviceManager);

      // need to get the plugin factory from this plugin.
      nsFactoryProc nsGetFactory = nsnull;
#ifdef XP_OS2
      nsGetFactory = (nsFactoryProc) PR_FindSymbol(pluginTag->mLibrary, "_NSGetFactory");
#else
      nsGetFactory = (nsFactoryProc) PR_FindSymbol(pluginTag->mLibrary, "NSGetFactory");
#endif
      if(nsGetFactory != nsnull && IsCompatibleExecutable(pluginTag->mFullPath))
      {
// XPCOM-style plugins (or at least the OJI one) cause crashes on
// on windows GCC builds, so we're just turning them off for now.
#if !defined(XP_WIN) || !defined(__GNUC__)
        rv = nsGetFactory(serviceManager, kPluginCID, nsnull, nsnull,    // XXX fix ClassName/ContractID
                          (nsIFactory**)&pluginTag->mEntryPoint);
        plugin = pluginTag->mEntryPoint;
        if (plugin != NULL)
          plugin->Initialize();
#endif
      }
#ifdef XP_OS2
      // on OS2, first check if this might be legacy XPCOM module.
      else if (PR_FindSymbol(pluginTag->mLibrary, "NSGetFactory") &&
               IsCompatibleExecutable(pluginTag->mFullPath))
      {
        // Possibly a legacy XPCOM module. We'll need to create a calling
        // vtable/calling convention wrapper for it.
        nsCOMPtr<nsILegacyPluginWrapperOS2> wrapper =
                       do_GetService(NS_LEGACY_PLUGIN_WRAPPER_CONTRACTID, &rv);
        if (NS_SUCCEEDED(rv))
        {
          rv = wrapper->GetFactory(serviceManager, kPluginCID, nsnull, nsnull,
                                   pluginTag->mLibrary, &pluginTag->mEntryPoint);
          plugin = pluginTag->mEntryPoint;
          if (plugin != NULL)
            plugin->Initialize();
        }
      }
#endif
      else
      {
       // Now lets try to get the entry point from a 4.x plugin
       rv = NS_ERROR_FAILURE;
       if (NS_FAILED(rv))
         rv = ns4xPlugin::CreatePlugin(serviceManager,
                                       pluginTag->mFileName,
                                       pluginTag->mFullPath,
                                       pluginTag->mLibrary,
                                       &pluginTag->mEntryPoint);

        plugin = pluginTag->mEntryPoint;
        pluginTag->mFlags |= NS_PLUGIN_FLAG_OLDSCHOOL;
        // no need to initialize, already done by CreatePlugin()
      }
    }

#if defined (XP_MACOSX)
   /* Flash 6.0 r50 and older on Mac has a bug which calls ::UseInputWindow(NULL, true)
      which turn off all our inline IME. Turn it back after the plugin
      initializtion and hope that future versions will be fixed. See bug 159016
   */
    if (pluginTag->mDescription &&
       !PL_strncasecmp(pluginTag->mDescription, "Shockwave Flash 6.0", 19)) {
       int ver = atoi(pluginTag->mDescription + 21);
       if  (ver && ver <= 50) {
         ::UseInputWindow(NULL, false);
       }
    }
#endif

    if (plugin != nsnull)
    {
      *aPlugin = plugin;
      plugin->AddRef();
      return NS_OK;
    }
  }

  PLUGIN_LOG(PLUGIN_LOG_NORMAL,
  ("nsPluginHostImpl::GetPluginFactory End mime=%s, rv=%d, plugin=%p name=%s\n",
  aMimeType, rv, *aPlugin, (pluginTag ? pluginTag->mFileName : "(not found)")));

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char * nsPluginHostImpl::GetPluginName ( nsIPluginInstance aPluginInstance) [static]

Definition at line 2615 of file nsPluginHostImpl.cpp.

{
  nsActivePlugin *plugin =
    gActivePluginList ? gActivePluginList->find(aPluginInstance) : nsnull;

  if (plugin && plugin->mPluginTag) {
    return plugin->mPluginTag->mName;
  }

  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIPluginHost::getPlugins ( in unsigned long  aPluginCount,
outnsIDOMPlugin  aPluginArray 
) [inherited]
NS_IMETHODIMP nsPluginHostImpl::GetPlugins ( PRUint32  aPluginCount,
nsIDOMPlugin **  aPluginArray 
)

Definition at line 4443 of file nsPluginHostImpl.cpp.

{
  LoadPlugins();

  nsPluginTag* plugin = mPlugins;
  for (PRUint32 i = 0; i < aPluginCount && plugin != nsnull;
       i++, plugin = plugin->mNext) {
    nsIDOMPlugin* domPlugin = new DOMPluginImpl(plugin);
    NS_IF_ADDREF(domPlugin);
    aPluginArray[i] = domPlugin;
  }

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 3330 of file nsPluginHostImpl.cpp.

{
  if (!sPluginTempDir) {
    nsCOMPtr<nsIFile> tmpDir;
    nsresult rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR,
                                         getter_AddRefs(tmpDir));
    NS_ENSURE_SUCCESS(rv, rv);

    rv = tmpDir->AppendNative(kPluginTmpDirName);

    // make it unique, and mode == 0700, not world-readable
    rv = tmpDir->CreateUnique(nsIFile::DIRECTORY_TYPE, 0700);
    NS_ENSURE_SUCCESS(rv, rv);

    tmpDir.swap(sPluginTempDir);
  }

  return sPluginTempDir->Clone(aDir);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIFileUtilities::getProgramPath ( out constCharPtr  aProgramPath) [inherited]

Returns the name of the browser executable program.

Parameters:
aProgramPath- the returned path to the program
Returns:
- NS_OK if this operation was successful

Definition at line 6078 of file nsPluginHostImpl.cpp.

{
  nsresult rv;
  NS_ENSURE_ARG_POINTER(result);
  *result = nsnull;

  nsCOMPtr<nsIProperties> dirService(do_GetService(kDirectoryServiceContractID, &rv));
  if (NS_FAILED(rv))
    return rv;
  nsCOMPtr<nsILocalFile> programDir;
  rv = dirService->Get(NS_XPCOM_CURRENT_PROCESS_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(programDir));
  if (NS_FAILED(rv))
    return rv;

  nsCAutoString temp;
  rv = programDir->GetNativePath(temp);
  *result = ToNewCString(temp);
  return rv;
}

Here is the call graph for this function:

nsresult nsPluginHostImpl::GetPrompt ( nsIPluginInstanceOwner aOwner,
nsIPrompt **  aPrompt 
) [private]

Definition at line 2863 of file nsPluginHostImpl.cpp.

{
  nsresult rv;
  nsCOMPtr<nsIPrompt> prompt;
  nsCOMPtr<nsIWindowWatcher> wwatch = do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);

  if (wwatch) {
    nsCOMPtr<nsIDOMWindow> domWindow;
    if (aOwner) {
      nsCOMPtr<nsIDocument> document;
      aOwner->GetDocument(getter_AddRefs(document));
      if (document) {
        domWindow = document->GetWindow();
      }
    }

    if (!domWindow) {
      wwatch->GetWindowByName(NS_LITERAL_STRING("_content").get(), nsnull, getter_AddRefs(domWindow));
    }
    rv = wwatch->GetNewPrompter(domWindow, getter_AddRefs(prompt));
  }

  NS_IF_ADDREF(*aPrompt = prompt);
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIFileUtilities::getTempDirPath ( out constCharPtr  aTempDirPath) [inherited]

Returns the name of the temporary directory.

Parameters:
aTempDirPath- the returned path to the temp directory
Returns:
- NS_OK if this operation was successful

Definition at line 6100 of file nsPluginHostImpl.cpp.

{
  nsresult rv;
  NS_ENSURE_ARG_POINTER(result);
  *result = nsnull;

  nsCOMPtr<nsIProperties> dirService(do_GetService(kDirectoryServiceContractID, &rv));
  if (NS_FAILED(rv))
    return rv;
  nsCOMPtr<nsILocalFile> tempDir;
  rv = dirService->Get(NS_OS_TEMP_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(tempDir));
  if (NS_FAILED(rv))
    return rv;

  nsCAutoString temp;
  rv = tempDir->GetNativePath(temp);
  *result = ToNewCString(temp);
  return rv;
}

Here is the call graph for this function:

NS_IMETHODIMP nsPluginHostImpl::GetURL ( nsISupports *  pluginInst,
const char *  url,
const char *  target = NULL,
nsIPluginStreamListener streamListener = NULL,
const char *  altHost = NULL,
const char *  referrer = NULL,
PRBool  forceJSEnabled = PR_FALSE 
) [virtual]

Fetches a URL.

(Corresponds to NPN_GetURL and NPN_GetURLNotify.)

Parameters:
pluginInst- the plugin making the request. If NULL, the URL is fetched in the background.
url- the URL to fetch
target- the target window into which to load the URL, or NULL if the data should be returned to the plugin via streamListener.
streamListener- a stream listener to be used to return data to the plugin. May be NULL if target is not NULL.
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.
referrer- the referring URL (may be NULL)
forceJSEnabled- forces JavaScript to be enabled for 'javascript:' URLs, even if the user currently has JavaScript disabled (usually specify PR_FALSE)
Returns:
- NS_OK if this operation was successful

Implements nsIPluginManager.

Definition at line 2890 of file nsPluginHostImpl.cpp.

{
  return GetURLWithHeaders(pluginInst, url, target, streamListener,
                           altHost, referrer, forceJSEnabled, nsnull, nsnull);
}

Here is the call graph for this function:

NS_IMETHODIMP nsPluginHostImpl::GetURLWithHeaders ( nsISupports *  pluginInst,
const char *  url,
const char *  target = NULL,
nsIPluginStreamListener streamListener = NULL,
const char *  altHost = NULL,
const char *  referrer = NULL,
PRBool  forceJSEnabled = PR_FALSE,
PRUint32  getHeadersLength = 0,
const char *  getHeaders = NULL 
) [virtual]

Fetches a URL, with Headers.

See also:
GetURL. Identical except for additional params headers and headersLen
Parameters:
getHeadersLength- the length of getHeaders (if non-NULL)
getHeaders- the headers to GET. 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 get headers
Returns:
- NS_OK if this operation was successful

Implements nsIPluginManager.

Definition at line 2904 of file nsPluginHostImpl.cpp.

{
  nsAutoString      string; string.AssignWithConversion(url);
  nsresult          rv;

  // we can only send a stream back to the plugin (as specified by a
  // null target) if we also have a nsIPluginStreamListener to talk to
  if(target == nsnull && streamListener == nsnull)
   return NS_ERROR_ILLEGAL_VALUE;

  nsCOMPtr<nsIPluginInstance> instance = do_QueryInterface(pluginInst, &rv);

  if (NS_SUCCEEDED(rv))
  {
    rv = DoURLLoadSecurityCheck(instance, url);
  }

  if (NS_SUCCEEDED(rv))
  {
    if (nsnull != target)
    {
      nsCOMPtr<nsIPluginInstancePeer> peer;
      rv = instance->GetPeer(getter_AddRefs(peer));
      if (NS_SUCCEEDED(rv) && peer)
      {
        nsCOMPtr<nsPIPluginInstancePeer> privpeer(do_QueryInterface(peer));
        nsCOMPtr<nsIPluginInstanceOwner> owner;
        rv = privpeer->GetOwner(getter_AddRefs(owner));
        if (owner)
        {
          if ((0 == PL_strcmp(target, "newwindow")) ||
              (0 == PL_strcmp(target, "_new")))
            target = "_blank";
          else if (0 == PL_strcmp(target, "_current"))
            target = "_self";

          rv = owner->GetURL(url, target, nsnull, 0, (void *) getHeaders, getHeadersLength);
        }
      }
    }

    if (nsnull != streamListener)
      rv = NewPluginURLStream(string, instance, streamListener, nsnull,
                              PR_FALSE, nsnull, getHeaders, getHeadersLength);
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIPluginManager::GetValue ( in nsPluginManagerVariable  variable,
in nativeVoid  value 
) [inherited]

Returns the value of a variable associated with the plugin manager.

(Corresponds to NPN_GetValue.)

Parameters:
variable- the plugin manager variable to get
value- the address of where to store the resulting value
Returns:
- NS_OK if this operation was successful

Definition at line 2669 of file nsPluginHostImpl.cpp.

{
  nsresult rv = NS_OK;

  NS_ENSURE_ARG_POINTER(aValue);

#if defined(XP_UNIX) && !defined(XP_MACOSX) && defined(MOZ_X11)
  if (nsPluginManagerVariable_XDisplay == aVariable) {
    Display** value = NS_REINTERPRET_CAST(Display**, aValue);
#if defined(MOZ_WIDGET_GTK) || defined (MOZ_WIDGET_GTK2)
    *value = GDK_DISPLAY();
#elif defined(MOZ_WIDGET_QT)
    *value = qt_xdisplay();
#elif defined(MOZ_WIDGET_XLIB)
    *value = xxlib_rgb_get_display(xxlib_find_handle(XXLIBRGB_DEFAULT_HANDLE));
#endif
    if (!(*value)) {
      return NS_ERROR_FAILURE;
    }
  }
#endif
  if (nsPluginManagerVariable_SupportsXEmbed == aVariable) {
#ifdef MOZ_WIDGET_GTK2
    *(NPBool*)aValue = PR_TRUE;
#else
    *(NPBool*)aValue = PR_FALSE;
#endif
  }
  return rv;
}

Here is the call graph for this function:

void nsIPluginHost::handleBadPlugin ( in PRLibraryPtr  aLibrary,
in nsIPluginInstance  instance 
) [inherited]

Definition at line 6237 of file nsPluginHostImpl.cpp.

{
  // the |aLibrary| parameter is not needed anymore, after we added |aInstance| which
  // can also be used to look up the plugin name, but we cannot get rid of it because
  // the |nsIPluginHost| interface is deprecated which in fact means 'frozen'

  nsresult rv = NS_OK;

  NS_ASSERTION(PR_FALSE, "Plugin performed illegal operation");

  if(mDontShowBadPluginMessage)
    return rv;

  nsCOMPtr<nsIPluginInstanceOwner> owner;

  if (aInstance) {
    nsCOMPtr<nsIPluginInstancePeer> peer;
    rv = aInstance->GetPeer(getter_AddRefs(peer));
    if (NS_SUCCEEDED(rv) && peer) {
      nsCOMPtr<nsPIPluginInstancePeer> privpeer(do_QueryInterface(peer));
      privpeer->GetOwner(getter_AddRefs(owner));
    }
  }

  nsCOMPtr<nsIPrompt> prompt;
  GetPrompt(owner, getter_AddRefs(prompt));
  if (prompt) {
    nsCOMPtr<nsIStringBundleService> strings(do_GetService(kStringBundleServiceCID, &rv));
    if (NS_FAILED(rv))
      return rv;

    nsCOMPtr<nsIStringBundle> bundle;
    rv = strings->CreateBundle(BRAND_PROPERTIES_URL, getter_AddRefs(bundle));
    if (NS_FAILED(rv))
      return rv;

    nsXPIDLString brandName;
    if (NS_FAILED(rv = bundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
                                 getter_Copies(brandName))))
      return rv;

    rv = strings->CreateBundle(PLUGIN_PROPERTIES_URL, getter_AddRefs(bundle));
    if (NS_FAILED(rv))
      return rv;

    nsXPIDLString title, message, checkboxMessage;
    if (NS_FAILED(rv = bundle->GetStringFromName(NS_LITERAL_STRING("BadPluginTitle").get(),
                                 getter_Copies(title))))
      return rv;

    const PRUnichar *formatStrings[] = { brandName.get() };
    if (NS_FAILED(rv = bundle->FormatStringFromName(NS_LITERAL_STRING("BadPluginMessage").get(),
                                 formatStrings, 1, getter_Copies(message))))
      return rv;

    if (NS_FAILED(rv = bundle->GetStringFromName(NS_LITERAL_STRING("BadPluginCheckboxMessage").get(),
                                 getter_Copies(checkboxMessage))))
      return rv;

    // add plugin name to the message
    char * pluginname = nsnull;
    nsActivePlugin * p = mActivePluginList.find(aInstance);
    if (p) {
      nsPluginTag * tag = p->mPluginTag;
      if (tag) {
        if (tag->mName)
          pluginname = tag->mName;
        else
          pluginname = tag->mFileName;
      }
    }

    nsAutoString msg;
    msg.AssignWithConversion(pluginname);
    msg.AppendLiteral("\n\n");
    msg.Append(message);

    PRInt32 buttonPressed;
    PRBool checkboxState = PR_FALSE;
    rv = prompt->ConfirmEx(title, msg.get(),
                         nsIPrompt::BUTTON_TITLE_OK * nsIPrompt::BUTTON_POS_0,
                         nsnull, nsnull, nsnull,
                         checkboxMessage, &checkboxState, &buttonPressed);


    if (NS_SUCCEEDED(rv) && checkboxState)
      mDontShowBadPluginMessage = PR_TRUE;
  }

  return rv;
}

Here is the call graph for this function:

void nsIPluginManager2::hasAllocatedMenuID ( in nsIEventHandler  aHandler,
in short  aMenuID,
out boolean  aResult 
) [inherited]

Indicates whether this event handler has allocated the given menu ID.

Parameters:
aHandler- the event handler for the window
aMenuID- the menu ID
aResult- returns PR_TRUE if the menu ID is allocated
Returns:
- NS_OK if this operation was successful

Definition at line 3214 of file nsPluginHostImpl.cpp.

Definition at line 4793 of file nsPluginHostImpl.cpp.

{
  for(nsPluginTag* tag = mPlugins; tag; tag = tag->mNext) {
    if(tag->Equals(aPluginTag))
      return tag;
  }
  return nsnull;
}

Here is the caller graph for this function:

void nsIPluginHost::init ( ) [inherited]

Definition at line 3246 of file nsPluginHostImpl.cpp.

{
  return NS_OK;
}
void nsIPluginHost::instantiateEmbeddedPlugin ( in string  aMimeType,
in nsIURI  aURL,
in nsIPluginInstanceOwner  aOwner 
) [inherited]

Definition at line 3353 of file nsPluginHostImpl.cpp.

{
#ifdef PLUGIN_LOGGING
  nsCAutoString urlSpec;
  if(aURL != nsnull) (void)aURL->GetAsciiSpec(urlSpec);

  PR_LOG(nsPluginLogging::gPluginLog, PLUGIN_LOG_NORMAL,
        ("nsPluginHostImpl::InstatiateEmbeddedPlugin Begin mime=%s, owner=%p, url=%s\n",
        aMimeType, aOwner, urlSpec.get()));

  PR_LogFlush();
#endif

  nsresult  rv;
  nsIPluginInstance *instance = nsnull;
  nsCOMPtr<nsIPluginTagInfo2> pti2;
  nsPluginTagType tagType;
  PRBool isJavaEnabled = PR_TRUE;
  PRBool isJava = PR_FALSE;

  rv = aOwner->QueryInterface(kIPluginTagInfo2IID, getter_AddRefs(pti2));

  if(rv != NS_OK) {
    return rv;
  }

  rv = pti2->GetTagType(&tagType);

  if((rv != NS_OK) || !((tagType == nsPluginTagType_Embed)
                        || (tagType == nsPluginTagType_Applet)
                        || (tagType == nsPluginTagType_Object)))
  {
    return rv;
  }

  // Security checks
  // Can't do security checks without a URI - hopefully the plugin will take
  // care of that
  if (aURL) {
    nsCOMPtr<nsIScriptSecurityManager> secMan =
                    do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
    if (NS_FAILED(rv))
      return rv; // Better fail if we can't do security checks

    nsCOMPtr<nsIDocument> doc;
    if (aOwner)
      aOwner->GetDocument(getter_AddRefs(doc));
    if (!doc)
      return NS_ERROR_NULL_POINTER;

    rv = secMan->CheckLoadURIWithPrincipal(doc->GetPrincipal(), aURL, 0);
    if (NS_FAILED(rv))
      return rv;

    nsCOMPtr<nsIDOMElement> elem;
    pti2->GetDOMElement(getter_AddRefs(elem));

    PRInt16 shouldLoad = nsIContentPolicy::ACCEPT; // default permit
    nsresult rv =
      NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_OBJECT,
                                aURL,
                                doc->GetDocumentURI(),
                                elem,
                                nsDependentCString(aMimeType ? aMimeType : ""),
                                nsnull, //extra
                                &shouldLoad);
    if (NS_FAILED(rv) || NS_CP_REJECTED(shouldLoad))
      return NS_ERROR_CONTENT_BLOCKED_SHOW_ALT;
  }



  if (tagType == nsPluginTagType_Applet ||
      PL_strncasecmp(aMimeType, "application/x-java-vm", 21) == 0 ||
      PL_strncasecmp(aMimeType, "application/x-java-applet", 25) == 0) {
#ifdef OJI
    isJava = PR_TRUE;
    // see if java is enabled
    if (mPrefService) {
      rv = mPrefService->GetBoolPref("security.enable_java", &isJavaEnabled);
      if (NS_SUCCEEDED(rv)) {
        // if not, don't show this plugin
        if (!isJavaEnabled) {
          return NS_ERROR_FAILURE;
        }
      }
      else {
        // if we were unable to get the pref, assume java is enabled
        // and rely on the "find the plugin or not" logic.

        // make sure the value wasn't modified in GetBoolPref
        isJavaEnabled = PR_TRUE;
      }
    }
#else
    isJavaEnabled = PR_FALSE;
    return NS_ERROR_FAILURE;
#endif
  }

  // Determine if the scheme of this URL is one we can handle internaly because we should
  // only open the initial stream if it's one that we can handle internally. Otherwise
  // |NS_OpenURI| in |InstantiateEmbeddedPlugin| may open up a OS protocal registered helper app
  PRBool bCanHandleInternally = PR_FALSE;
  nsCAutoString scheme;
  if (aURL && NS_SUCCEEDED(aURL->GetScheme(scheme))) {
      nsCAutoString contractID(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX);
      contractID += scheme;
      ToLowerCase(contractID);
      nsCOMPtr<nsIProtocolHandler> handler = do_GetService(contractID.get());
      if (handler)
        bCanHandleInternally = PR_TRUE;
  }

  if(FindStoppedPluginForURL(aURL, aOwner) == NS_OK) {

    PLUGIN_LOG(PLUGIN_LOG_NOISY,
    ("nsPluginHostImpl::InstatiateEmbeddedPlugin FoundStopped mime=%s\n", aMimeType));

    aOwner->GetInstance(instance);
    if((!aMimeType || !isJava) && bCanHandleInternally)
      rv = NewEmbeddedPluginStream(aURL, aOwner, instance);

    // notify Java DOM component
    nsresult res;
    nsCOMPtr<nsIPluginInstanceOwner> javaDOM =
             do_GetService("@mozilla.org/blackwood/java-dom;1", &res);
    if (NS_SUCCEEDED(res) && javaDOM)
      javaDOM->SetInstance(instance);

    NS_IF_RELEASE(instance);
    return NS_OK;
  }

  // if we don't have a MIME type at this point, we still have one more chance by
  // opening the stream and seeing if the server hands one back
  if (!aMimeType)
    return bCanHandleInternally ? NewEmbeddedPluginStream(aURL, aOwner, nsnull) : NS_ERROR_FAILURE;

  rv = SetUpPluginInstance(aMimeType, aURL, aOwner);

  if(rv == NS_OK)
    rv = aOwner->GetInstance(instance);
  else
  {
   /*
    * If we are here, it's time to either show the default plugin
    * or return failure so layout will replace us.
    *
    * Currently, the default plugin is shown for all EMBED and APPLET
    * tags and also any OBJECT tag that has a PLUGINURL PARAM tag name.
    */

    PRBool bHasPluginURL = PR_FALSE;
    nsCOMPtr<nsIPluginTagInfo2> pti2(do_QueryInterface(aOwner));

    if(pti2) {
      const char *value;
      bHasPluginURL = NS_SUCCEEDED(pti2->GetParameter("PLUGINURL", &value));
    }

    // if we didn't find a pluginURL param on the object tag,
    // there's nothing more to do here
    if(nsPluginTagType_Object == tagType && !bHasPluginURL)
      return rv;

    if(NS_FAILED(SetUpDefaultPluginInstance(aMimeType, aURL, aOwner)))
      return NS_ERROR_FAILURE;

    if(NS_FAILED(aOwner->GetInstance(instance)))
      return NS_ERROR_FAILURE;

    rv = NS_OK;
  }

  // if we have a failure error, it means we found a plugin for the mimetype,
  // but we had a problem with the entry point
  if(rv == NS_ERROR_FAILURE)
    return rv;

  // if we are here then we have loaded a plugin for this mimetype
  // and it could be the Default plugin

  nsPluginWindow    *window = nsnull;

  //we got a plugin built, now stream
  aOwner->GetWindow(window);

  if (nsnull != instance)
  {
    instance->Start();
    aOwner->CreateWidget();

    // If we've got a native window, the let the plugin know about it.
    if (window->window)
    {
      nsCOMPtr<nsIPluginInstance> inst = instance;
      ((nsPluginNativeWindow*)window)->CallSetWindow(inst);
    }

    // create an initial stream with data
    // don't make the stream if it's a java applet or we don't have SRC or DATA attribute
    PRBool havedata = PR_FALSE;

    nsCOMPtr<nsIPluginTagInfo> pti(do_QueryInterface(aOwner, &rv));

    if(pti) {
      const char *value;
      havedata = NS_SUCCEEDED(pti->GetAttribute("SRC", &value));
      // no need to check for "data" as it would have been converted to "src"
    }

    if(havedata && !isJava && bCanHandleInternally)
      rv = NewEmbeddedPluginStream(aURL, aOwner, instance);

    // notify Java DOM component
    nsresult res;
    nsCOMPtr<nsIPluginInstanceOwner> javaDOM =
             do_GetService("@mozilla.org/blackwood/java-dom;1", &res);
    if (NS_SUCCEEDED(res) && javaDOM)
      javaDOM->SetInstance(instance);

    NS_RELEASE(instance);
  }

#ifdef PLUGIN_LOGGING
  nsCAutoString urlSpec2;
  if(aURL != nsnull) (void)aURL->GetAsciiSpec(urlSpec2);

  PR_LOG(nsPluginLogging::gPluginLog, PLUGIN_LOG_NORMAL,
        ("nsPluginHostImpl::InstatiateEmbeddedPlugin Finished mime=%s, rv=%d, owner=%p, url=%s\n",
        aMimeType, rv, aOwner, urlSpec2.get()));

  PR_LogFlush();
#endif

  return rv;
}

Here is the call graph for this function:

void nsIPluginHost::instantiateFullPagePlugin ( in string  aMimeType,
in nsIURI  aURI,
in nsIStreamListenerRef  aStreamListener,
in nsIPluginInstanceOwner  aOwner 
) [inherited]
NS_IMETHODIMP nsPluginHostImpl::InstantiateFullPagePlugin ( const char *  aMimeType,
nsIURI aURI,
nsIStreamListener *&  aStreamListener,
nsIPluginInstanceOwner aOwner 
)

Definition at line 3597 of file nsPluginHostImpl.cpp.

{
#ifdef PLUGIN_LOGGING
  nsCAutoString urlSpec;
  aURI->GetSpec(urlSpec);
  PLUGIN_LOG(PLUGIN_LOG_NORMAL,
  ("nsPluginHostImpl::InstatiateFullPagePlugin Begin mime=%s, owner=%p, url=%s\n",
  aMimeType, aOwner, urlSpec.get()));
#endif

  if(FindStoppedPluginForURL(aURI, aOwner) == NS_OK) {
    PLUGIN_LOG(PLUGIN_LOG_NOISY,
    ("nsPluginHostImpl::InstatiateFullPagePlugin FoundStopped mime=%s\n",aMimeType));

    nsIPluginInstance* instance;
    aOwner->GetInstance(instance);
    if(!aMimeType || PL_strncasecmp(aMimeType, "application/x-java-vm", 21))
      NewFullPagePluginStream(aStreamListener, instance);
    NS_IF_RELEASE(instance);
    return NS_OK;
  }

  nsresult rv = SetUpPluginInstance(aMimeType, aURI, aOwner);

  if (NS_OK == rv)
  {
    nsCOMPtr<nsIPluginInstance> instance;
    nsPluginWindow * win = nsnull;

    aOwner->GetInstance(*getter_AddRefs(instance));
    aOwner->GetWindow(win);

    if (win && instance)
    {
      instance->Start();
      aOwner->CreateWidget();

      // If we've got a native window, the let the plugin know about it.
      nsPluginNativeWindow * window = (nsPluginNativeWindow *)win;
      if (window->window)
        window->CallSetWindow(instance);

      rv = NewFullPagePluginStream(aStreamListener, instance);

      // If we've got a native window, the let the plugin know about it.
      if (window->window)
        window->CallSetWindow(instance);
    }
  }

  PLUGIN_LOG(PLUGIN_LOG_NORMAL,
  ("nsPluginHostImpl::InstatiateFullPagePlugin End mime=%s, rv=%d, owner=%p, url=%s\n",
  aMimeType, rv, aOwner, urlSpec.get()));

  return rv;
}

Here is the call graph for this function:

Definition at line 4802 of file nsPluginHostImpl.cpp.

{
  nsPluginTag * tag = HaveSamePlugin(aPluginTag);
  if (tag) {
    // if we got the same plugin, check the full path to see if this is a dup;

    // mFileName contains full path on Windows and Unix and leaf name on Mac
    // if those are not equal, we have the same plugin with  different path,
    // i.e. duplicate, return true
    if (PL_strcmp(tag->mFileName, aPluginTag->mFileName))
      return PR_TRUE;

    // if they are equal, compare mFullPath fields just in case
    // mFileName contained leaf name only, and if not equal, return true
    if (tag->mFullPath && aPluginTag->mFullPath && PL_strcmp(tag->mFullPath, aPluginTag->mFullPath))
      return PR_TRUE;
  }

  // we do not have it at all, return false
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIPluginHost::isPluginEnabledForExtension ( in string  aExtension,
in constCharStarRef  aMimeType 
) [inherited]
NS_IMETHODIMP nsPluginHostImpl::IsPluginEnabledForExtension ( const char *  aExtension,
const char *&  aMimeType 
)

Definition at line 4177 of file nsPluginHostImpl.cpp.

{
  nsPluginTag *plugins = nsnull;
  PRInt32     variants, cnt;

  LoadPlugins();

  // if we have a mimetype passed in, search the mPlugins linked
  // list for a match
  if (nsnull != aExtension)
  {
    plugins = mPlugins;

    while (nsnull != plugins)
    {
      variants = plugins->mVariants;

      if (plugins->mExtensionsArray)
      {
        for (cnt = 0; cnt < variants; cnt++)
        {
          // mExtensionsArray[cnt] is a list of extensions separated
          // by commas
          if (0 == CompareExtensions(plugins->mExtensionsArray[cnt], aExtension))
          {
            aMimeType = plugins->mMimeTypeArray[cnt];
            return NS_OK;
          }
        }

        if (cnt < variants)
          break;
      }

      plugins = plugins->mNext;
    }
  }

  return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4113 of file nsPluginHostImpl.cpp.

{
  nsPluginTag *plugins = nsnull;
  PRInt32     variants, cnt;

  LoadPlugins();

  // if we have a mimetype passed in, search the mPlugins linked
  // list for a match
  if (nsnull != aMimeType)
  {
    plugins = mPlugins;

    while (nsnull != plugins)
    {
      variants = plugins->mVariants;

      for (cnt = 0; cnt < variants; cnt++)
        if (plugins->mMimeTypeArray[cnt] && (0 == PL_strcasecmp(plugins->mMimeTypeArray[cnt], aMimeType)))
          return NS_OK;

      if (cnt < variants)
        break;

      plugins = plugins->mNext;
    }
  }

  return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2702 of file nsPluginHostImpl.cpp.

{
  if(!plugin)
    return PR_FALSE;

  // we can check for mLibrary to be non-zero and then querry nsIPluginInstancePeer
  // in nsActivePluginList to see if plugin with matching mime type is not stopped
  if(!plugin->mLibrary)
    return PR_FALSE;

  for(int i = 0; i < plugin->mVariants; i++) {
    nsActivePlugin * p = mActivePluginList.find(plugin->mMimeTypeArray[i]);
    if(p && !p->mStopped)
      return PR_TRUE;
  }

  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 5121 of file nsPluginHostImpl.cpp.

{
  // do not do anything if it is already done
  // use ReloadPlugins() to enforce loading
  if(mPluginsLoaded)
    return NS_OK;

  PRBool pluginschanged;
  nsresult rv = FindPlugins(PR_TRUE, &pluginschanged);
  if (NS_FAILED(rv))
    return rv;

  // only if plugins have changed will we ask XPTI to refresh
  if (pluginschanged) {
    // rescan XPTI to catch any newly installed interfaces
    nsCOMPtr<nsIInterfaceInfoManager> iim (dont_AddRef(XPTI_GetInterfaceInfoManager()));
    if (iim)
      iim->AutoRegisterInterfaces();
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 5351 of file nsPluginHostImpl.cpp.

{
  // the component reg is a flat file now see 48888
  // we have to reimplement this method if we need it

  // The "new style" XPCOM plugins have their information stored in
  // the component registry, under the key
  //
  //   nsIRegistry::Common/software/plugins
  //
  // Enumerate through that list now, creating an nsPluginTag for
  // each.

  return NS_OK;
}

Here is the caller graph for this function:

void nsIFactory::lockFactory ( in PRBool  lock) [inherited]

LockFactory provides the client a way to keep the component in memory until it is finished with it.

The client can call LockFactory(PR_TRUE) to lock the factory and LockFactory(PR_FALSE) to release the factory.

Parameters:
lock- Must be PR_TRUE or PR_FALSE
Returns:
NS_OK - If the lock operation was successful. NS_ERROR* - Method failure.

Definition at line 3238 of file nsPluginHostImpl.cpp.

{
  NS_NOTREACHED("how'd I get here?");
  return NS_ERROR_UNEXPECTED;
}

Definition at line 5993 of file nsPluginHostImpl.cpp.

{
  if (!aURL)
    return NS_OK;

  nsPluginStreamListenerPeer  *listener = new nsPluginStreamListenerPeer();
  if (listener == nsnull)
    return NS_ERROR_OUT_OF_MEMORY;

  nsresult rv;

  // if we have an instance, everything has been set up
  // if we only have an owner, then we need to pass it in
  // so the listener can set up the instance later after
  // we've determined the mimetype of the stream
  if(aInstance != nsnull)
    rv = listener->InitializeEmbedded(aURL, aInstance);
  else if(aOwner != nsnull)
    rv = listener->InitializeEmbedded(aURL, nsnull, aOwner, this);
  else
    rv = NS_ERROR_ILLEGAL_VALUE;

  if (NS_SUCCEEDED(rv)) {
    nsCOMPtr<nsIDocument> doc;
    nsCOMPtr<nsILoadGroup> loadGroup;

    if (aOwner) {
      rv = aOwner->GetDocument(getter_AddRefs(doc));
      if (NS_SUCCEEDED(rv) && doc) {
        loadGroup = doc->GetDocumentLoadGroup();
      }
    }

    nsCOMPtr<nsIChannel> channel;

    rv = NS_NewChannel(getter_AddRefs(channel), aURL, nsnull, loadGroup, nsnull);
    if (NS_SUCCEEDED(rv)) {
      // if this is http channel, set referrer, some servers are configured
      // to reject requests without referrer set, see bug 157796
      nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
      if (httpChannel && doc)
        httpChannel->SetReferrer(doc->GetDocumentURI());

      rv = channel->AsyncOpen(listener, nsnull);
      if (NS_SUCCEEDED(rv))
        return NS_OK;
    }
  }

  delete listener;
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsPluginHostImpl::NewFullPagePluginStream ( nsIStreamListener *&  aStreamListener,
nsIPluginInstance aInstance 
) [private]

Definition at line 6050 of file nsPluginHostImpl.cpp.

{
  nsPluginStreamListenerPeer  *listener = new nsPluginStreamListenerPeer();
  if (listener == nsnull)
    return NS_ERROR_OUT_OF_MEMORY;

  nsresult rv;

  rv = listener->InitializeFullPage(aInstance);

  aStreamListener = listener;
  NS_ADDREF(listener);

  // add peer to list of stream peers for this instance
  nsActivePlugin * p = mActivePluginList.find(aInstance);
  if (p) {
    if (!p->mStreams && (NS_FAILED(rv = NS_NewISupportsArray(getter_AddRefs(p->mStreams)))))
      return rv;
    p->mStreams->AppendElement(aStreamListener);
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Creates a new plugin native window object.

Definition at line 6609 of file nsPluginHostImpl.cpp.

{
  return PLUG_NewPluginNativeWindow(aPluginNativeWindow);
}

Here is the call graph for this function:

NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream ( const nsString aURL,
nsIPluginInstance aInstance,
nsIPluginStreamListener aListener,
const char *  aPostData = nsnull,
PRBool  isFile = PR_FALSE,
PRUint32  aPostDataLen = 0,
const char *  aHeadersData = nsnull,
PRUint32  aHeadersDataLen = 0 
)

Definition at line 5697 of file nsPluginHostImpl.cpp.

{
  nsCOMPtr<nsIURI> url;
  nsAutoString absUrl;
  nsresult rv;

  if (aURL.Length() <= 0)
    return NS_OK;

  // get the full URL of the document that the plugin is embedded
  //   in to create an absolute url in case aURL is relative
  nsCOMPtr<nsIDocument> doc;
  nsCOMPtr<nsIPluginInstancePeer> peer;
  nsCOMPtr<nsIPluginInstanceOwner> owner;
  rv = aInstance->GetPeer(getter_AddRefs(peer));
  if (NS_SUCCEEDED(rv) && peer)
  {
    nsCOMPtr<nsPIPluginInstancePeer> privpeer(do_QueryInterface(peer));
    rv = privpeer->GetOwner(getter_AddRefs(owner));
    if (owner)
    {
      rv = owner->GetDocument(getter_AddRefs(doc));
      if (NS_SUCCEEDED(rv) && doc)
      {
        // Create an absolute URL
        rv = NS_MakeAbsoluteURI(absUrl, aURL, doc->GetBaseURI());
      }
    }
  }

  if (absUrl.IsEmpty())
    absUrl.Assign(aURL);

  rv = NS_NewURI(getter_AddRefs(url), absUrl);

  if (NS_SUCCEEDED(rv))
  {
    nsCOMPtr<nsIPluginTagInfo2> pti2 = do_QueryInterface(owner);
    nsCOMPtr<nsIDOMElement> element;
    if (pti2)
      pti2->GetDOMElement(getter_AddRefs(element));

    PRInt16 shouldLoad = nsIContentPolicy::ACCEPT;
    rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_OTHER,
                                   url,
                                   (doc ? doc->GetDocumentURI() : nsnull),
                                   element,
                                   EmptyCString(), //mime guess
                                   nsnull,         //extra
                                   &shouldLoad);
    if (NS_FAILED(rv)) return rv;
    if (NS_CP_REJECTED(shouldLoad)) {
      // Disallowed by content policy
      return NS_ERROR_CONTENT_BLOCKED;
    }

    nsPluginStreamListenerPeer *listenerPeer = new nsPluginStreamListenerPeer;
    if (listenerPeer == NULL)
      return NS_ERROR_OUT_OF_MEMORY;

    NS_ADDREF(listenerPeer);
    rv = listenerPeer->Initialize(url, aInstance, aListener);

    if (NS_SUCCEEDED(rv))
    {
      nsCOMPtr<nsIInterfaceRequestor> callbacks;

      if (doc)
      {
        // Get the script global object owner and use that as the notification callback
        nsIScriptGlobalObject* global = doc->GetScriptGlobalObject();

        if (global)
        {
          callbacks = do_QueryInterface(global->GetGlobalObjectOwner());
        }
      }

      nsCOMPtr<nsIChannel> channel;

      rv = NS_NewChannel(getter_AddRefs(channel), url, nsnull,
        nsnull, /* do not add this internal plugin's channel
                on the load group otherwise this channel could be canceled
                form |nsWebShell::OnLinkClickSync| bug 166613 */
        callbacks);
      if (NS_FAILED(rv))
        return rv;

      if (doc)
      {
        // Set the owner of channel to the document principal...
        channel->SetOwner(doc->GetPrincipal());
      }

      // deal with headers and post data
      nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
      if(httpChannel) {
        if (aPostData) {

          nsCOMPtr<nsIInputStream> postDataStream;
          rv = NS_NewPluginPostDataStream(getter_AddRefs(postDataStream), (const char*)aPostData,
                                          aPostDataLen, aIsFile);

          if (!postDataStream)
          {
            NS_RELEASE(aInstance);
            return NS_ERROR_UNEXPECTED;
          }

          // XXX it's a bit of a hack to rewind the postdata stream
          // here but it has to be done in case the post data is
          // being reused multiple times.
          nsCOMPtr<nsISeekableStream>
          postDataSeekable(do_QueryInterface(postDataStream));
          if (postDataSeekable)
            postDataSeekable->Seek(nsISeekableStream::NS_SEEK_SET, 0);

          nsCOMPtr<nsIUploadChannel> uploadChannel(do_QueryInterface(httpChannel));
          NS_ASSERTION(uploadChannel, "http must support nsIUploadChannel");

          uploadChannel->SetUploadStream(postDataStream, EmptyCString(), -1);
        }

        if (aHeadersData)
          rv = AddHeadersToChannel(aHeadersData, aHeadersDataLen, httpChannel);
      }
      rv = channel->AsyncOpen(listenerPeer, nsnull);
    }
    NS_RELEASE(listenerPeer);
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIFileUtilities::newTempFileName ( in string  aPrefix,
in unsigned long  aLength,
in charPtr  aBuffer 
) [inherited]

Returns a unique temporary file name.

Parameters:
aPrefix- a string to prefix to the temporary file name
aLength- the length of the resulting buffer to receive the data
aBuffer- the returned temp file name
Returns:
- NS_OK if this operation was successful
NS_IMETHODIMP nsPluginHostImpl::NewTempFileName ( const char *  prefix,
PRUint32  bufLen,
char *  resultBuf 
)

Definition at line 6122 of file nsPluginHostImpl.cpp.

void nsIPluginManager2::notifyStatusChange ( in nsIPlugin  aPlugin,
in nsresult  aStatus 
) [inherited]

This method may be called by the plugin to indicate that an error has occurred, e.g.

that the plugin has failed or is shutting down spontaneously. This allows the browser to clean up any plugin-specific state.

Parameters:
aPlugin- the plugin whose status is changing
aStatus- the error status value
Returns:
- NS_OK if this operation was successful

Definition at line 3098 of file nsPluginHostImpl.cpp.

void nsIObserver::observe ( in nsISupports  aSubject,
in string  aTopic,
in wstring  aData 
) [inherited]

Observe will be called when there is a notification for the topic |aTopic|.

This assumes that the object implementing this interface has been registered with an observer service such as the nsIObserverService.

If you expect multiple topics/subjects, the impl is responsible for filtering.

You should not modify, add, remove, or enumerate notifications in the implemention of observe.

Parameters:
aSubject: Notification specific interface pointer.
aTopic: The notification topic or subject.
aData: Notification specific wide string. subject event.
NS_IMETHODIMP nsPluginHostImpl::Observe ( nsISupports *  aSubject,
const char *  aTopic,
const PRUnichar someData 
)

Definition at line 6220 of file nsPluginHostImpl.cpp.

{
#ifdef NS_DEBUG
  printf("nsPluginHostImpl::Observe \"%s\"\n", aTopic ? aTopic : "");
#endif
  if (!nsCRT::strcmp(NS_XPCOM_SHUTDOWN_OBSERVER_ID, aTopic))
  {
    Destroy();
    UnloadUnusedLibraries();
  }
  return NS_OK;
}

Here is the call graph for this function:

void nsPIPluginHost::parsePostBufferToFixHeaders ( in string  aInPostData,
in unsigned long  aInPostDataLen,
out string  aOutPostData,
out unsigned long  aOutPostDataLen 
) [inherited]

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 '
' 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.

Parameters:
aInPostData- the post data
aInPostDataLen- the length aInPostData
aOutPostData- the buffer
aOutPostDataLen- the length of aOutPostData
NS_IMETHODIMP nsPluginHostImpl::ParsePostBufferToFixHeaders ( const char *  inPostData,
PRUint32  inPostDataLen,
char **  outPostData,
PRUint32 outPostDataLen 
)

Definition at line 6348 of file nsPluginHostImpl.cpp.

{
  if (!inPostData || !outPostData || !outPostDataLen)
    return NS_ERROR_NULL_POINTER;

  *outPostData = 0;
  *outPostDataLen = 0;

  const char CR = '\r';
  const char LF = '\n';
  const char CRLFCRLF[] = {CR,LF,CR,LF,'\0'}; // C string"\r\n\r\n"
  const char ContentLenHeader[] = "Content-length";

  nsAutoVoidArray singleLF;
  const char *pSCntlh = 0;// pointer to start of ContentLenHeader in inPostData
  const char *pSod = 0;   // pointer to start of data in inPostData
  const char *pEoh = 0;   // pointer to end of headers in inPostData
  const char *pEod = inPostData + inPostDataLen; // pointer to end of inPostData
  if (*inPostData == LF) {
    // 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.
    // so *inPostData == '\n' is valid
    pSod = inPostData + 1;
  } else {
    const char *s = inPostData; //tmp pointer to sourse inPostData
    while (s < pEod) {
      if (!pSCntlh &&
          (*s == 'C' || *s == 'c') &&
          (s + sizeof(ContentLenHeader) - 1 < pEod) &&
          (!PL_strncasecmp(s, ContentLenHeader, sizeof(ContentLenHeader) - 1)))
      {
        // lets assume this is ContentLenHeader for now
        const char *p = pSCntlh = s;
        p += sizeof(ContentLenHeader) - 1;
        // search for first CR or LF == end of ContentLenHeader
        for (; p < pEod; p++) {
          if (*p == CR || *p == LF) {
            // got delimiter,
            // one more check; if previous char is a digit
            // most likely pSCntlh points to the start of ContentLenHeader
            if (*(p-1) >= '0' && *(p-1) <= '9') {
              s = p;
            }
            break; //for loop
          }
        }
        if (pSCntlh == s) { // curret ptr is the same
          pSCntlh = 0; // that was not ContentLenHeader
          break; // there is nothing to parse, break *WHILE LOOP* here
        }
      }

      if (*s == CR) {
        if (pSCntlh && // only if ContentLenHeader is found we are looking for end of headers
            ((s + sizeof(CRLFCRLF)-1) <= pEod) &&
            !memcmp(s, CRLFCRLF, sizeof(CRLFCRLF)-1))
        {
          s += sizeof(CRLFCRLF)-1;
          pEoh = pSod = s; // data stars here
          break;
        }
      } else if (*s == LF) {
        if (*(s-1) != CR) {
          singleLF.AppendElement((void*)s);
        }
        if (pSCntlh && (s+1 < pEod) && (*(s+1) == LF)) {
          s++;
          singleLF.AppendElement((void*)s);
          s++;
          pEoh = pSod = s; // data stars here
          break;
        }
      }
      s++;
    }
  }

  // deal with output buffer
  if (!pSod) { // lets assume whole buffer is a data
    pSod = inPostData;
  }

  PRUint32 newBufferLen = 0;
  PRUint32 dataLen = pEod - pSod;
  PRUint32 headersLen = pEoh ? pSod - inPostData : 0;

  char *p; // tmp ptr into new output buf
  if (headersLen) { // we got a headers
    // this function does not make any assumption on correctness
    // of ContentLenHeader value in this case.

    newBufferLen = dataLen + headersLen;
    // in case there were single LFs in headers
    // reserve an extra space for CR will be added before each single LF
    int cntSingleLF = singleLF.Count();
    newBufferLen += cntSingleLF;

    if (!(*outPostData = p = (char*)nsMemory::Alloc(newBufferLen)))
      return NS_ERROR_OUT_OF_MEMORY;

    // deal with single LF
    const char *s = inPostData;
    if (cntSingleLF) {
      for (int i=0; i<cntSingleLF; i++) {
        const char *plf = (const char*) singleLF.ElementAt(i); // ptr to single LF in headers
        int n = plf - s; // bytes to copy
        if (n) { // for '\n\n' there is nothing to memcpy
          memcpy(p, s, n);
          p += n;
        }
        *p++ = CR;
        s = plf;
        *p++ = *s++;
      }
    }
    // are we done with headers?
    headersLen = pEoh - s;
    if (headersLen) { // not yet
      memcpy(p, s, headersLen); // copy the rest
      p += headersLen;
    }
  } else  if (dataLen) { // no ContentLenHeader is found but there is a data
    // make new output buffer big enough
    // to keep ContentLenHeader+value followed by data
    PRUint32 l = sizeof(ContentLenHeader) + sizeof(CRLFCRLF) + 32;
    newBufferLen = dataLen + l;
    if (!(*outPostData = p = (char*)nsMemory::Alloc(newBufferLen)))
      return NS_ERROR_OUT_OF_MEMORY;
    headersLen = PR_snprintf(p, l,"%s: %ld%s", ContentLenHeader, dataLen, CRLFCRLF);
    if (headersLen == l) { // if PR_snprintf has ate all extra space consider this as an error
      nsMemory::Free(p);
      *outPostData = 0;
      return NS_ERROR_FAILURE;
    }
    p += headersLen;
    newBufferLen = headersLen + dataLen;
  }
  // at this point we've done with headers.
  // there is a possibility that input buffer has only headers info in it
  // which already parsed and copied into output buffer.
  // copy the data
  if (dataLen) {
    memcpy(p, pSod, dataLen);
  }

  *outPostDataLen = newBufferLen;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsPluginHostImpl::PostURL ( nsISupports *  pluginInst,
const char *  url,
PRUint32  postDataLen,
const char *  postData,
PRBool  isFile = PR_FALSE,
const char *  target = NULL,
nsIPluginStreamListener streamListener = NULL,
const char *  altHost = NULL,
const char *  referrer = NULL,
PRBool  forceJSEnabled = PR_FALSE,
PRUint32  postHeadersLength = 0,
const char *  postHeaders = NULL 
) [virtual]

Posts to a URL with post data and/or post headers.

(Corresponds to NPN_PostURL and NPN_PostURLNotify.)

Parameters:
pluginInst- the plugin making the request. If NULL, the URL is fetched in the background.
url- the URL to fetch
postDataLength- the length of postData (if non-NULL)
postData- the data to POST. NULL specifies that there is not post data
isFile- whether the postData specifies the name of a file to post instead of data. The file will be deleted afterwards.
target- the target window into which to load the URL, or NULL if the data should be returned to the plugin via streamListener.
streamListener- a stream listener to be used to return data to the plugin. May be NULL if target is not NULL.
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.
referrer- the referring URL (may be NULL)
forceJSEnabled- forces JavaScript to be enabled for 'javascript:' URLs, even if the user currently has JavaScript disabled (usually specify PR_FALSE)
postHeadersLength- the length of postHeaders (if non-NULL)
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
Returns:
- NS_OK if this operation was successful

Implements nsIPluginManager.

Definition at line 2963 of file nsPluginHostImpl.cpp.

{
  nsAutoString      string; string.AssignWithConversion(url);
  nsresult          rv;

  // we can only send a stream back to the plugin (as specified
  // by a null target) if we also have a nsIPluginStreamListener
  // to talk to also
  if(target == nsnull && streamListener == nsnull)
   return NS_ERROR_ILLEGAL_VALUE;

  nsCOMPtr<nsIPluginInstance> instance = do_QueryInterface(pluginInst, &rv);

  if (NS_SUCCEEDED(rv))
  {
    rv = DoURLLoadSecurityCheck(instance, url);
  }

  if (NS_SUCCEEDED(rv))
  {
      char *dataToPost;
      if (isFile) {
        rv = CreateTmpFileToPost(postData, &dataToPost);
        if (NS_FAILED(rv) || !dataToPost) return rv;

      } else {
        PRUint32 newDataToPostLen;
        ParsePostBufferToFixHeaders(postData, postDataLen, &dataToPost, &newDataToPostLen);
        if (!dataToPost)
          return NS_ERROR_UNEXPECTED;

        // we use nsIStringInputStream::adoptDataa()
        // in NS_NewPluginPostDataStream to set the stream
        // all new data alloced in  ParsePostBufferToFixHeaders()
        // well be nsMemory::Free()d on destroy the stream
        postDataLen = newDataToPostLen;
      }

      if (nsnull != target)
        {
          nsCOMPtr<nsIPluginInstancePeer> peer;
          rv = instance->GetPeer(getter_AddRefs(peer));

          if (NS_SUCCEEDED(rv) && peer)
            {
              nsCOMPtr<nsPIPluginInstancePeer> privpeer(do_QueryInterface(peer));
              nsCOMPtr<nsIPluginInstanceOwner> owner;
              rv = privpeer->GetOwner(getter_AddRefs(owner));
              if (owner)
                {
                  if (!target) {
                    target = "_self";
                  }
                  else {
                    if ((0 == PL_strcmp(target, "newwindow")) ||
                        (0 == PL_strcmp(target, "_new")))
                      target = "_blank";
                    else if (0 == PL_strcmp(target, "_current"))
                      target = "_self";
                  }

                  rv = owner->GetURL(url, target, (void*)dataToPost, postDataLen,
                                     (void*) postHeaders, postHeadersLength, isFile);
                }
            }
        }

      // if we don't have a target, just create a stream.  This does
      // NS_OpenURI()!
      if (streamListener != nsnull)
        rv = NewPluginURLStream(string, instance, streamListener,
                                (const char*)dataToPost, isFile, postDataLen,
                                postHeaders, postHeadersLength);
      if (isFile) {
        NS_Free(dataToPost);
      }
  }

  return rv;
}

Here is the call graph for this function:

Definition at line 3221 of file nsPluginHostImpl.cpp.

Definition at line 5472 of file nsPluginHostImpl.cpp.

{
  nsresult rv;

  nsCOMPtr<nsIProperties> directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID,&rv));
  if (NS_FAILED(rv))
    return rv;

  directoryService->Get(NS_APP_APPLICATION_REGISTRY_DIR, NS_GET_IID(nsIFile),
                        getter_AddRefs(mPluginRegFile));

  if (!mPluginRegFile)
    return NS_ERROR_FAILURE;

  PRFileDesc* fd = nsnull;

  nsCOMPtr<nsIFile> pluginReg;

  rv = mPluginRegFile->Clone(getter_AddRefs(pluginReg));
  if (NS_FAILED(rv))
    return rv;

  rv = pluginReg->AppendNative(kPluginRegistryFilename);
  if (NS_FAILED(rv))
    return rv;

  nsCOMPtr<nsILocalFile> localFile = do_QueryInterface(pluginReg, &rv);
  if (NS_FAILED(rv))
    return rv;

  PRInt64 fileSize;
  rv = localFile->GetFileSize(&fileSize);
  if (NS_FAILED(rv)) {
    return rv;
  }

  PRInt32 flen = nsInt64(fileSize);
  if (flen == 0) {
    NS_WARNING("Plugins Registry Empty!");
    return NS_OK; // ERROR CONDITION
  }

  nsPluginManifestLineReader reader;
  char* registry = reader.Init(flen);
  if (!registry) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  rv = localFile->OpenNSPRFileDesc(PR_RDONLY, 0444, &fd);
  if (NS_FAILED(rv))
    return rv;

  // set rv to return an error on goto out
  rv = NS_ERROR_FAILURE;

  PRInt32 bread = PR_Read(fd, registry, flen);
  PR_Close(fd);

  if (flen > bread)
    return rv;

  if (!ReadSectionHeader(reader, "HEADER")) {
    return rv;;
  }

  if (!reader.NextLine()) {
    return rv;
  }

  char* values[6];

  // VersionLiteral, kPluginRegistryVersion
  if (2 != reader.ParseLine(values, 2)) {
    return rv;
  }

  // VersionLiteral
  if (PL_strcmp(values[0], "Version")) {
    return rv;
  }

  // kPluginRegistryVersion
  if (PL_strcmp(values[1], kPluginRegistryVersion)) {
    return rv;
  }

  if (!ReadSectionHeader(reader, "PLUGINS")) {
    return rv;
  }

  while (reader.NextLine()) {
    char *filename = reader.LinePtr();
    if (!reader.NextLine())
      return rv;

    char *fullpath = reader.LinePtr();
    if (!reader.NextLine())
      return rv;

    // lastModifiedTimeStamp|canUnload|tag.mFlag
    if (3 != reader.ParseLine(values, 3))
      return rv;

    PRInt64 lastmod = nsCRT::atoll(values[0]);
    PRBool canunload = atoi(values[1]);
    PRUint32 tagflag = atoi(values[2]);
    if (!reader.NextLine())
      return rv;

    char *description = reader.LinePtr();
    if (!reader.NextLine())
      return rv;

    char *name = reader.LinePtr();
    if (!reader.NextLine())
      return rv;

    int mimetypecount = atoi(reader.LinePtr());

    char *stackalloced[PLUGIN_REG_MIMETYPES_ARRAY_SIZE * 3];
    char **mimetypes;
    char **mimedescriptions;
    char **extensions;
    char **heapalloced = 0;
    if (mimetypecount > PLUGIN_REG_MIMETYPES_ARRAY_SIZE - 1) {
      heapalloced = new char *[mimetypecount * 3];
      mimetypes = heapalloced;
    } else {
      mimetypes = stackalloced;
    }
    mimedescriptions = mimetypes + mimetypecount;
    extensions = mimedescriptions + mimetypecount;

    int mtr = 0; //mimetype read
    for (; mtr < mimetypecount; mtr++) {
      if (!reader.NextLine())
        break;

      //line number|mimetype|description|extension
      if (4 != reader.ParseLine(values, 4))
        break;
      int line = atoi(values[0]);
      if (line != mtr)
        break;
      mimetypes[mtr] = values[1];
      mimedescriptions[mtr] = values[2];
      extensions[mtr] = values[3];
    }

    if (mtr != mimetypecount) {
      if (heapalloced) {
        delete [] heapalloced;
      }
      return rv;
    }

    nsPluginTag* tag = new nsPluginTag(name,
      description,
      filename,
      (*fullpath ? fullpath : 0), // we have to pass 0 prt if it's empty str
      (const char* const*)mimetypes,
      (const char* const*)mimedescriptions,
      (const char* const*)extensions,
      mimetypecount, lastmod, canunload);
    if (heapalloced) {
      delete [] heapalloced;
    }

    if (!tag) {
      continue;
    }

    // Mark plugin as loaded from cache
    tag->Mark(tagflag | NS_PLUGIN_FLAG_FROMCACHE);
    PR_LOG(nsPluginLogging::gPluginLog, PLUGIN_LOG_BASIC,
      ("LoadCachedPluginsInfo : Loading Cached plugininfo for %s\n", tag->mFileName));
    tag->mNext = mCachedPlugins;
    mCachedPlugins = tag;

  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIPluginManager::RegisterPlugin ( in REFNSIID  aCID,
in string  aPluginName,
in string  aDescription,
in nativeChar  aMimeTypes,
in nativeChar  aMimeDescriptions,
in nativeChar  aFileExtensions,
in long  aCount 
) [inherited]

Persistently register a plugin with the plugin manager.

aMimeTypes, aMimeDescriptions, and aFileExtensions are parallel arrays that contain information about the MIME types that the plugin supports.

Parameters:
aCID- the plugin's CID
aPluginName- the plugin's name
aDescription- a description of the plugin
aMimeTypes- an array of MIME types that the plugin is prepared to handle
aMimeDescriptions- an array of descriptions for the MIME types that the plugin can handle.
aFileExtensions- an array of file extensions for the MIME types that the plugin can handle.
aCount- the number of elements in the aMimeTypes, aMimeDescriptions, and aFileExtensions arrays.
Returns:
- NS_OK if the operation was successful.

Here is the caller graph for this function:

NS_IMETHODIMP nsPluginHostImpl::RegisterPlugin ( REFNSIID  aCID,
const char *  aPluginName,
const char *  aDescription,
const char **  aMimeTypes,
const char **  aMimeDescriptions,
const char **  aFileExtensions,
PRInt32  aCount 
)

Definition at line 3057 of file nsPluginHostImpl.cpp.

Registers a top-level window with the browser.

Events received by that window will be dispatched to the event handler specified.

Parameters:
aHandler- the event handler for the window
aWindow- the platform window reference
Returns:
- NS_OK if this operation was successful

Definition at line 3186 of file nsPluginHostImpl.cpp.

void nsIPluginManager::reloadPlugins ( in boolean  reloadPages) [inherited]

Causes the plugins directory to be searched again for new plugin libraries.

(Corresponds to NPN_ReloadPlugins.)

Parameters:
reloadPages- indicates whether currently visible pages should also be reloaded

Definition at line 2722 of file nsPluginHostImpl.cpp.

{
  PLUGIN_LOG(PLUGIN_LOG_NORMAL,
  ("nsPluginHostImpl::ReloadPlugins Begin reloadPages=%d, active_instance_count=%d\n",
  reloadPages, mActivePluginList.mCount));

  nsresult rv = NS_OK;

  // this will create the initial plugin list out of cache
  // if it was not created yet
  if (!mPluginsLoaded)
    return LoadPlugins();

  // we are re-scanning plugins. New plugins may have been added, also some
  // plugins may have been removed, so we should probably shut everything down
  // but don't touch running (active and  not stopped) plugins

  // check if plugins changed, no need to do anything else
  // if no changes to plugins have been made
  // PR_FALSE instructs not to touch the plugin list, just to
  // look for possible changes
  PRBool pluginschanged = PR_TRUE;
  FindPlugins(PR_FALSE, &pluginschanged);

  // if no changed detected, return an appropriate error code
  if (!pluginschanged)
    return NS_ERROR_PLUGINS_PLUGINSNOTCHANGED;

  nsCOMPtr<nsISupportsArray> instsToReload;

  if(reloadPages) {
    NS_NewISupportsArray(getter_AddRefs(instsToReload));

    // Then stop any running plugin instances but hold on to the documents in the array
    // We are going to need to restart the instances in these documents later
    mActivePluginList.stopRunning(instsToReload);
  }

  // clean active plugin list
  mActivePluginList.removeAllStopped();

  // shutdown plugins and kill the list if there are no running plugins
  nsPluginTag * prev = nsnull;
  nsPluginTag * next = nsnull;

  for(nsPluginTag * p = mPlugins; p != nsnull;) {
    next = p->mNext;

    // XXX only remove our plugin from the list if it's not running and not
    // an XPCOM plugin. XPCOM plugins do not get a call to nsIPlugin::Shutdown
    // if plugins are reloaded. This also fixes a crash on UNIX where the call
    // to shutdown would break the ProxyJNI connection to the JRE after a reload.
    // see bug 86591
    if(!IsRunningPlugin(p) && (!p->mEntryPoint || (p->mFlags & NS_PLUGIN_FLAG_OLDSCHOOL))) {
      if(p == mPlugins)
        mPlugins = next;
      else
        prev->mNext = next;

      delete p;
      p = next;
      continue;
    }

    prev = p;
    p = next;
  }

  // set flags
  mPluginsLoaded = PR_FALSE;

  // load them again
  rv = LoadPlugins();

  // If we have shut down any plugin instances, we've now got to restart them.
  // Post an event to do the rest as we are going to be destroying the frame tree and we also want
  // any posted unload events to finish
  PRUint32 c;
  if (reloadPages &&
      instsToReload &&
      NS_SUCCEEDED(instsToReload->Count(&c)) &&
      c > 0) {
    nsCOMPtr<nsIEventQueueService> eventService(do_GetService(kEventQueueServiceCID));
    if (eventService) {
      nsCOMPtr<nsIEventQueue> eventQueue;
      eventService->GetThreadEventQueue(PR_GetCurrentThread(), getter_AddRefs(eventQueue));
      if (eventQueue) {
        nsPluginDocReframeEvent * ev = new nsPluginDocReframeEvent(instsToReload);
        if (ev) {
          PL_InitEvent(ev, nsnull, HandlePluginDocReframePLEvent, DestroyPluginDocReframePLEvent);
          eventQueue->PostEvent(ev);
        }
      }
    }

  }

  PLUGIN_LOG(PLUGIN_LOG_NORMAL,
  ("nsPluginHostImpl::ReloadPlugins End active_instance_count=%d\n",
  mActivePluginList.mCount));

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 5656 of file nsPluginHostImpl.cpp.

{
  nsPluginTag **link = &mCachedPlugins;
  for (nsPluginTag *tag = *link; tag; link = &tag->mNext, tag = *link)
  {
    // compare filename or else the mFullPath if it exists. Mac seems to use
    // mFullPath for fullpath and mFileName for just the leafname of fullpath.
    // On win and unix, mFullPath is never used and mFileName is contains the
    // full pathname. All this should move to using nsIFile.
    if (!PL_strcmp(tag->mFileName, filename) ||
        (tag->mFullPath && !PL_strcmp(tag->mFullPath, filename)))
    {
      // Found it. Remove it from our list
      *link = tag->mNext;
      return tag;
    }
  }
  return nsnull;
}

Here is the caller graph for this function:

Definition at line 6623 of file nsPluginHostImpl.cpp.

{
  nsresult rv = NS_OK;

#ifdef XP_WIN

  // First, lets check if we already have Real. No point in doing this if it's installed correctly
  if (NS_SUCCEEDED(IsPluginEnabledForType("audio/x-pn-realaudio-plugin")))
    return rv;

  // Next, maybe the pref wants to override
  PRBool bSkipRealPlayerHack = PR_FALSE;
  if (!mPrefService ||
     (NS_SUCCEEDED(mPrefService->GetBoolPref("plugin.skip_real_player_hack", &bSkipRealPlayerHack)) &&
     bSkipRealPlayerHack))
  return rv;

  // now we need the XPCOM components folder
  nsCOMPtr<nsIFile> RealPlugin;
  if (NS_FAILED(NS_GetSpecialDirectory(NS_XPCOM_COMPONENT_DIR, getter_AddRefs(RealPlugin))) || !RealPlugin)
    return rv;

  // make sure the file is actually there
  RealPlugin->AppendNative(nsDependentCString("nppl3260.dll"));
  PRBool exists;
  nsCAutoString filePath;
  RealPlugin->Exists(&exists);
  if (!exists || NS_FAILED(RealPlugin->GetNativePath(filePath)))
    return rv;

  // now make sure it's a plugin
  nsCOMPtr<nsILocalFile> localfile;
  NS_NewNativeLocalFile(filePath,
                        PR_TRUE,
                        getter_AddRefs(localfile));

  if (!nsPluginsDir::IsPluginFile(localfile))
    return rv;

  // try to get the mime info and descriptions out of the plugin
  nsPluginFile pluginFile(localfile);
  nsPluginInfo info = { sizeof(info) };
  if (NS_FAILED(pluginFile.GetPluginInfo(info)))
    return rv;

  nsCOMPtr<nsIComponentManager> compManager;
  NS_GetComponentManager(getter_AddRefs(compManager));

  // finally, create our "plugin tag" and add it to the list
  if (info.fMimeTypeArray) {
    nsPluginTag *pluginTag = new nsPluginTag(&info);
    if (pluginTag) {
      pluginTag->SetHost(this);
      pluginTag->mNext = mPlugins;
      mPlugins = pluginTag;

      // last thing we need is to register this plugin with layout so it can be used in full-page mode
      pluginTag->RegisterWithCategoryManager(mOverrideInternalTypes);
    }
  }

  // free allocated strings in GetPluginInfo
  pluginFile.FreePluginInfo(info);

#endif

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsPluginHostImpl::ScanPluginsDirectory ( nsIFile pluginsDir,
nsIComponentManager compManager,
PRBool  aCreatePluginList,
PRBool aPluginsChanged,
PRBool  checkForUnwantedPlugins = PR_FALSE 
) [private]

Definition at line 4895 of file nsPluginHostImpl.cpp.

{
  NS_ENSURE_ARG_POINTER(aPluginsChanged);
  nsresult rv;

  *aPluginsChanged = PR_FALSE;

#ifdef PLUGIN_LOGGING
  nsCAutoString dirPath;
  pluginsDir->GetNativePath(dirPath);
  PLUGIN_LOG(PLUGIN_LOG_BASIC,
  ("nsPluginHostImpl::ScanPluginsDirectory dir=%s\n", dirPath.get()));
#endif

  nsCOMPtr<nsISimpleEnumerator> iter;
  rv = pluginsDir->GetDirectoryEntries(getter_AddRefs(iter));
  if (NS_FAILED(rv))
    return rv;

  // Collect all the files in this directory in a void array we can sort later
  nsAutoVoidArray pluginFilesArray;  // array for sorting files in this directory
  PRBool hasMore;
  while (NS_SUCCEEDED(iter->HasMoreElements(&hasMore)) && hasMore) {
    nsCOMPtr<nsISupports> supports;
    rv = iter->GetNext(getter_AddRefs(supports));
    if (NS_FAILED(rv))
      continue;
    nsCOMPtr<nsILocalFile> dirEntry(do_QueryInterface(supports, &rv));
    if (NS_FAILED(rv))
      continue;

    // Sun's JRE 1.3.1 plugin must have symbolic links resolved or else it'll crash.
    // See bug 197855.
    dirEntry->Normalize();

    nsAutoString filePath;
    rv = dirEntry->GetPath(filePath);
    if (NS_FAILED(rv))
      continue;

    if (nsPluginsDir::IsPluginFile(dirEntry)) {
      pluginFileinDirectory * item = new pluginFileinDirectory();
      if (!item)
        return NS_ERROR_OUT_OF_MEMORY;
      
      // Get file mod time
      PRInt64 fileModTime = LL_ZERO;
      dirEntry->GetLastModifiedTime(&fileModTime);
      
      item->mModTime = fileModTime;
      item->mFilename = filePath;
      pluginFilesArray.AppendElement(item);
    }
  } // end round of up of plugin files

  // now sort the array by file modification time or by filename, if equal
  // put newer plugins first to weed out dups and catch upgrades, see bug 119966
  pluginFilesArray.Sort(ComparePluginFileInDirectory, nsnull);

  // finally, go through the array, looking at each entry and continue processing it
  for (PRInt32 i = 0; i < pluginFilesArray.Count(); i++) {
    pluginFileinDirectory* pfd = NS_STATIC_CAST(pluginFileinDirectory*, pluginFilesArray[i]);
    nsCOMPtr <nsIFile> file = do_CreateInstance("@mozilla.org/file/local;1");
    nsCOMPtr <nsILocalFile> localfile = do_QueryInterface(file);
    localfile->InitWithPath(pfd->mFilename);
    PRInt64 fileModTime = pfd->mModTime;

    // Look for it in our cache
    nsPluginTag *pluginTag = RemoveCachedPluginsInfo(NS_ConvertUCS2toUTF8(pfd->mFilename).get());

    delete pfd;
    if (pluginTag) {
      // If plugin changed, delete cachedPluginTag and dont use cache
      if (LL_NE(fileModTime, pluginTag->mLastModifiedTime)) {
        // Plugins has changed. Dont use cached plugin info.
        delete pluginTag;
        pluginTag = nsnull;

        // plugin file changed, flag this fact
        *aPluginsChanged = PR_TRUE;
      }
      else {
        // if it is unwanted plugin we are checking for, get it back to the cache info list
        // if this is a duplicate plugin, too place it back in the cache info list marking unwantedness
        if((checkForUnwantedPlugins && isUnwantedPlugin(pluginTag)) || IsDuplicatePlugin(pluginTag) || isUnwantedJavaPlugin(pluginTag)) {
          pluginTag->Mark(NS_PLUGIN_FLAG_UNWANTED);
          pluginTag->mNext = mCachedPlugins;
          mCachedPlugins = pluginTag;
        }
      }
    }
    else {
      // plugin file was added, flag this fact
      *aPluginsChanged = PR_TRUE;
    }

    // if we are not creating the list, just continue the loop
    // no need to proceed if changes are detected
    if (!aCreatePluginList) {
      if (*aPluginsChanged)
        return NS_OK;
      else
        continue;
    }

    // if it is not found in cache info list or has been changed, create a new one
    if (!pluginTag) {
      nsPluginFile pluginFile(file);
      PRLibrary* pluginLibrary = nsnull;

      // load the plugin's library so we can ask it some questions, but not for Windows
#ifndef XP_WIN
      if (pluginFile.LoadPlugin(pluginLibrary) != NS_OK || pluginLibrary == nsnull)
        continue;
#endif

      // create a tag describing this plugin.
      nsPluginInfo info = { sizeof(info) };
      nsresult res = pluginFile.GetPluginInfo(info);
      if(NS_FAILED(res))
        continue;

      // if we don't have mime type -- don't proceed, this is not a plugin
      if(!info.fMimeTypeArray) {
        pluginFile.FreePluginInfo(info);
        continue;
      }

      // Check for any potential '*' mime type handlers which are not our
      // own default plugin and disable them as they will break the plugin
      // finder service, see Bugzilla bug 132430
      if (!mAllowAlienStarHandler)
        FixUpPluginInfo(info, pluginFile);

      pluginTag = new nsPluginTag(&info);
      pluginFile.FreePluginInfo(info);

      if(pluginTag == nsnull)
        return NS_ERROR_OUT_OF_MEMORY;

      pluginTag->mLibrary = pluginLibrary;
      pluginTag->mLastModifiedTime = fileModTime;

      // if this is unwanted plugin we are checkin for, or this is a duplicate plugin,
      // add it to our cache info list so we can cache the unwantedness of this plugin
      // when we sync cached plugins to registry
      if((checkForUnwantedPlugins && isUnwantedPlugin(pluginTag)) || IsDuplicatePlugin(pluginTag) || isUnwantedJavaPlugin(pluginTag)) {
        pluginTag->Mark(NS_PLUGIN_FLAG_UNWANTED);
        pluginTag->mNext = mCachedPlugins;
        mCachedPlugins = pluginTag;
      }
    }

    // set the flag that we want to add this plugin to the list for now
    // and see if it remains after we check several reasons not to do so
    PRBool bAddIt = PR_TRUE;

    // check if this is a specific plugin we don't want
    if((checkForUnwantedPlugins && isUnwantedPlugin(pluginTag)) ||
       isUnwantedJavaPlugin(pluginTag))
      bAddIt = PR_FALSE;

    // check if we already have this plugin in the list which
    // is possible if we do refresh
    if(bAddIt) {
      if (HaveSamePlugin(pluginTag)) {
        // we cannot get here if the plugin has just been added
        // and thus |pluginTag| is not from cache, because otherwise
        // it would not be present in the list;
        // so there is no need to delete |pluginTag| -- it _is_ from the cache info list.
        bAddIt = PR_FALSE;
      }
    }

    // so if we still want it -- do it
    if(bAddIt) {
      pluginTag->SetHost(this);
      pluginTag->mNext = mPlugins;
      mPlugins = pluginTag;

      pluginTag->RegisterWithCategoryManager(mOverrideInternalTypes);
    }
    else if (!(pluginTag->mFlags & NS_PLUGIN_FLAG_UNWANTED)) {
      // we don't need it, delete it;
      // but don't delete unwanted plugins since they are cached
      // in the cache info list and will be deleted later
      delete pluginTag;
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsPluginHostImpl::ScanPluginsDirectoryList ( nsISimpleEnumerator dirEnum,
nsIComponentManager compManager,
PRBool  aCreatePluginList,
PRBool aPluginsChanged,
PRBool  checkForUnwantedPlugins = PR_FALSE 
) [private]

Definition at line 5091 of file nsPluginHostImpl.cpp.

{
    PRBool hasMore;
    while (NS_SUCCEEDED(dirEnum->HasMoreElements(&hasMore)) && hasMore) {
      nsCOMPtr<nsISupports> supports;
      nsresult rv = dirEnum->GetNext(getter_AddRefs(supports));
      if (NS_FAILED(rv))
        continue;
      nsCOMPtr<nsIFile> nextDir(do_QueryInterface(supports, &rv));
      if (NS_FAILED(rv))
        continue;

      // don't pass aPluginsChanged directly to prevent it from been reset
      PRBool pluginschanged = PR_FALSE;
      ScanPluginsDirectory(nextDir, compManager, aCreatePluginList, &pluginschanged, checkForUnwantedPlugins);

      if (pluginschanged)
        *aPluginsChanged = PR_TRUE;

      // if changes are detected and we are not creating the list, do not proceed
      if (!aCreatePluginList && *aPluginsChanged)
        break;
    }
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsICookieStorage::setCookie ( in string  aCookieURL,
in constVoidPtr  aCookieBuffer,
in unsigned long  aCookieSize 
) [inherited]

Stores a cookie in the browser's persistent cookie store.

Parameters:
aCookieURL- URL string store cookie with.
aCookieBuffer- buffer containing cookie data.
aCookieSize- specifies size of cookie data.
NS_IMETHODIMP nsPluginHostImpl::SetCookie ( const char *  inCookieURL,
const void inCookieBuffer,
PRUint32  inCookieSize 
)

Stores a cookie in the browser's persistent cookie store.

Parameters:
inCookieURLURL string store cookie with.
inCookieBufferbuffer containing cookie data.
inCookieSizespecifies size of cookie data.

Definition at line 6177 of file nsPluginHostImpl.cpp.

{
  nsresult rv = NS_ERROR_NOT_IMPLEMENTED;
  nsCOMPtr<nsIURI> uriIn;

  if ((nsnull == inCookieURL) || (nsnull == inCookieBuffer) ||
      (0 >= inCookieSize)) {
    return NS_ERROR_INVALID_ARG;
  }

  nsCOMPtr<nsIIOService> ioService(do_GetService(kIOServiceCID, &rv));

  if (NS_FAILED(rv) || (nsnull == ioService)) {
    return rv;
  }

  nsCOMPtr<nsICookieService> cookieService =
           do_GetService(kCookieServiceCID, &rv);

  if (NS_FAILED(rv) || (nsnull == cookieService)) {
    return NS_ERROR_FAILURE;
  }

  // make an nsURI from the argument url
  rv = ioService->NewURI(nsDependentCString(inCookieURL), nsnull, nsnull, getter_AddRefs(uriIn));
  if (NS_FAILED(rv)) {
    return NS_ERROR_FAILURE;
  }

  nsCOMPtr<nsIPrompt> prompt;
  GetPrompt(nsnull, getter_AddRefs(prompt));

  char * cookie = (char *)inCookieBuffer;
  char c = cookie[inCookieSize];
  cookie[inCookieSize] = '\0';
  rv = cookieService->SetCookieString(uriIn, prompt, cookie, nsnull);
  cookie[inCookieSize] = c;

  return rv;
}

Here is the call graph for this function:

void nsPIPluginHost::setIsScriptableInstance ( in nsIPluginInstance  aInstance,
in boolean  aScriptable 
) [inherited]

To notify the plugin manager that the plugin created a script object.

nsPIPluginHost interface

Definition at line 6334 of file nsPluginHostImpl.cpp.

{
  nsActivePlugin * p = mActivePluginList.find(aPluginInstance);
  if(p == nsnull)
    return NS_ERROR_FAILURE;

  p->mXPConnected = aScriptable;
  if(p->mPluginTag)
    p->mPluginTag->mXPConnected = aScriptable;

  return NS_OK;
}

Here is the call graph for this function:

nsresult nsPluginHostImpl::SetUpDefaultPluginInstance ( const char *  aMimeType,
nsIURI aURL,
nsIPluginInstanceOwner aOwner 
) [private]

Definition at line 4036 of file nsPluginHostImpl.cpp.

{
  if (mDefaultPluginDisabled) {
    // The default plugin is disabled, don't load it.

    return NS_OK;
  }

  nsCOMPtr<nsIPluginInstance> instance;
  nsCOMPtr<nsIPlugin> plugin = NULL;
  const char* mimetype = aMimeType;

  if(!aURL)
    return NS_ERROR_FAILURE;

  GetPluginFactory("*", getter_AddRefs(plugin));

  nsresult result;
  instance = do_CreateInstance(NS_INLINE_PLUGIN_CONTRACTID_PREFIX "*",
                               &result);

  // couldn't create an XPCOM plugin, try to create wrapper for a
  // legacy plugin
  if (NS_FAILED(result))
  {
    if(plugin)
      result = plugin->CreateInstance(NULL, kIPluginInstanceIID,
                                      getter_AddRefs(instance));
  }

  // neither an XPCOM or legacy plugin could be instantiated, so
  // return the failure
  if(NS_FAILED(result))
    return result;

  // it is adreffed here
  aOwner->SetInstance(instance);

  nsRefPtr<nsPluginInstancePeerImpl> peer = new nsPluginInstancePeerImpl();
  if (!peer)
    return NS_ERROR_OUT_OF_MEMORY;

  // if we don't have a mimetype, check by file extension
  nsXPIDLCString mt;
  if (!mimetype || !*mimetype)
  {
    nsresult res = NS_OK;
    nsCOMPtr<nsIMIMEService> ms (do_GetService(NS_MIMESERVICE_CONTRACTID, &res));
    if(NS_SUCCEEDED(res))
    {
      res = ms->GetTypeFromURI(aURL, mt);
      if(NS_SUCCEEDED(res))
        mimetype = mt.get();
    }
  }

  // set up the peer for the instance
  peer->Initialize(aOwner, mimetype);

  // this should addref the peer but not the instance or owner except
  // in some cases not Java, see bug 140931 our COM pointer will free
  // the peer
  result = instance->Initialize(peer);
  if (NS_FAILED(result))
    return result;

  // instance and peer will be addreffed here
  result = AddInstanceToActiveList(plugin, instance, aURL, PR_TRUE, peer);

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIPluginHost::setUpPluginInstance ( in string  aMimeType,
in nsIURI  aURL,
in nsIPluginInstanceOwner  aOwner 
) [inherited]

Definition at line 3813 of file nsPluginHostImpl.cpp.

{
  nsresult rv = NS_OK;

  rv = TrySetUpPluginInstance(aMimeType, aURL, aOwner);

  // if we fail, refresh plugin list just in case the plugin has been
  // just added and try to instantiate plugin instance again, see bug 143178
  if (NS_FAILED(rv)) {
    // we should also make sure not to do this more than once per page
    // so if there are a few embed tags with unknown plugins,
    // we don't get unnecessary overhead
    // let's cache document to decide whether this is the same page or not
    nsCOMPtr<nsIDocument> document;
    if (aOwner)
      aOwner->GetDocument(getter_AddRefs(document));

    nsCOMPtr<nsIDocument> currentdocument = do_QueryReferent(mCurrentDocument);
    if (document == currentdocument)
      return rv;

    mCurrentDocument = do_GetWeakReference(document);

    // ReloadPlugins will do the job smartly: nothing will be done
    // if no changes detected, in such a case just return
    if (NS_ERROR_PLUGINS_PLUGINSNOTCHANGED == ReloadPlugins(PR_FALSE))
      return rv;

    // other failure return codes may be not fatal, so we can still try
    rv = TrySetUpPluginInstance(aMimeType, aURL, aOwner);
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 5948 of file nsPluginHostImpl.cpp.

{
  PLUGIN_LOG(PLUGIN_LOG_NORMAL,
  ("nsPluginHostImpl::StopPluginInstance called instance=%p\n",aInstance));

  nsActivePlugin * plugin = mActivePluginList.find(aInstance);

  if(plugin != nsnull) {
    plugin->setStopped(PR_TRUE);  // be sure we set the "stop" bit

    // if the plugin does not want to be 'cached' just remove it
    PRBool doCache = PR_TRUE;
    aInstance->GetValue(nsPluginInstanceVariable_DoCacheBool, (void *) &doCache);

    if (!doCache) {
      PRLibrary * library = nsnull;
      if(plugin->mPluginTag)
        library = plugin->mPluginTag->mLibrary;

      mActivePluginList.remove(plugin);
    }
    else {
      // if it is allowed to be cached simply stop it, but first we should check
      // if we haven't exceeded the maximum allowed number of cached instances

      // try to get the max cached plugins from a pref or use default
      PRUint32 max_num;
      nsresult rv = NS_ERROR_FAILURE;
      if (mPrefService) {
        rv = mPrefService->GetIntPref(NS_PREF_MAX_NUM_CACHED_PLUGINS, (int*)&max_num);
      }
      if (NS_FAILED(rv)) max_num = DEFAULT_NUMBER_OF_STOPPED_PLUGINS;

      if(mActivePluginList.getStoppedCount() >= max_num) {
        nsActivePlugin * oldest = mActivePluginList.findOldestStopped();
        if(oldest != nsnull)
          mActivePluginList.remove(oldest);
      }
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

void nsIPluginManager2::supportsURLProtocol ( in string  aProtocol,
out boolean  aResult 
) [inherited]

Returns true if a URL protocol (e.g.

"http") is supported.

Parameters:
aProtocol- the protocol name
aResult- true if the protocol is supported
Returns:
- NS_OK if this operation was successful
NS_IMETHODIMP nsPluginHostImpl::SupportsURLProtocol ( const char *  protocol,
PRBool result 
)

Definition at line 3091 of file nsPluginHostImpl.cpp.

NS_IMETHODIMP nsPluginHostImpl::TrySetUpPluginInstance ( const char *  aMimeType,
nsIURI aURL,
nsIPluginInstanceOwner aOwner 
) [private]

Definition at line 3850 of file nsPluginHostImpl.cpp.

{
#ifdef PLUGIN_LOGGING
  nsCAutoString urlSpec;
  if(aURL != nsnull) (void)aURL->GetSpec(urlSpec);

  PR_LOG(nsPluginLogging::gPluginLog, PLUGIN_LOG_NORMAL,
        ("nsPluginHostImpl::TrySetupPluginInstance Begin mime=%s, owner=%p, url=%s\n",
        aMimeType, aOwner, urlSpec.get()));

  PR_LogFlush();
#endif


  nsresult result = NS_ERROR_FAILURE;
  nsCOMPtr<nsIPluginInstance> instance;
  nsCOMPtr<nsIPlugin> plugin;
  const char* mimetype = nsnull;

  if(!aURL)
    return NS_ERROR_FAILURE;

  // if don't have a mimetype or no plugin can handle this mimetype
  // check by file extension
  if(!aMimeType || NS_FAILED(IsPluginEnabledForType(aMimeType))) {
    nsCOMPtr<nsIURL> url = do_QueryInterface(aURL);
    if (!url) return NS_ERROR_FAILURE;

    nsCAutoString fileExtension;
    url->GetFileExtension(fileExtension);

    // if we don't have an extension or no plugin for this extension,
    // return failure as there is nothing more we can do
    if (fileExtension.IsEmpty() ||
        NS_FAILED(IsPluginEnabledForExtension(fileExtension.get(),
                                              mimetype))) {

      if (mDefaultPluginDisabled) {
        aOwner->PluginNotAvailable(aMimeType ? aMimeType : mimetype);
      }

      return NS_ERROR_FAILURE;
    }
  }
  else
    mimetype = aMimeType;

  PRBool isJavaPlugin = PR_FALSE;
  if (aMimeType &&
      (PL_strncasecmp(aMimeType, "application/x-java-vm", 21) == 0 ||
         PL_strncasecmp(aMimeType, "application/x-java-applet", 25) == 0))
  {
    isJavaPlugin = PR_TRUE;
  }

#if defined(OJI) && ((defined(XP_UNIX) && !defined(XP_MACOSX)) || defined(XP_OS2))
  // This is a work-around on Unix for a LiveConnect problem (bug 83698).
  // The problem:
  // The proxy JNI needs to be created by the browser. If it is created by
  // someone else (e.g., a plugin) on a different thread, the proxy JNI will
  // not work, and break LiveConnect.
  // Currently, on Unix, when instantiating a Java plugin instance (by calling
  // InstantiateEmbeddedPlugin() next), Java plugin will create the proxy JNI
  // if it is not created yet. If that happens, LiveConnect will be broken.
  // Before lazy start JVM was implemented, since at this point the browser
  // already created the proxy JNI buring startup, the problem did not happen.
  // But after the lazy start was implemented, at this point the proxy JNI was
  // not created yet, so the Java plugin created the proxy JNI, and broke
  // liveConnect.
  // On Windows and Mac, Java plugin does not create the proxy JNI, but lets
  // the browser to create it. Hence this is a Unix-only problem.
  //
  // The work-around:
  // The root cause of the problem is in Java plugin's Unix implementation,
  // which should not create the proxy JNI.
  // As a work-around, here we make sure the proxy JNI has been created by the
  // browser, before plugin gets a chance.
  //

  if (isJavaPlugin) {
    // If Java is installed, get proxy JNI.
    nsCOMPtr<nsIJVMManager> jvmManager = do_GetService(nsIJVMManager::GetCID(),
                                                     &result);
    if (NS_SUCCEEDED(result)) {
      JNIEnv* proxyEnv;
      // Get proxy JNI, if not created yet, create it.
      jvmManager->GetProxyJNI(&proxyEnv);
    }
  }
#endif

  nsCAutoString contractID(
          NS_LITERAL_CSTRING(NS_INLINE_PLUGIN_CONTRACTID_PREFIX) +
          nsDependentCString(mimetype));

  GetPluginFactory(mimetype, getter_AddRefs(plugin));

  instance = do_CreateInstance(contractID.get(), &result);

  // couldn't create an XPCOM plugin, try to create wrapper for a
  // legacy plugin
  if (NS_FAILED(result)) {
    if(plugin) {
#ifdef XP_WIN
      static BOOL firstJavaPlugin = FALSE;
      BOOL restoreOrigDir = FALSE;
      char origDir[_MAX_PATH];
      if (isJavaPlugin && !firstJavaPlugin) {
        DWORD dw = ::GetCurrentDirectory(_MAX_PATH, origDir);
        NS_ASSERTION(dw <= _MAX_PATH, "Falied to obtain the current directory, which may leads to incorrect class laoding");
        nsCOMPtr<nsIFile> binDirectory;
        result = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR,
                                        getter_AddRefs(binDirectory));

        if (NS_SUCCEEDED(result)) {
          nsCAutoString path;
          binDirectory->GetNativePath(path);
          restoreOrigDir = ::SetCurrentDirectory(path.get());
        }
      }
#endif
      result = plugin->CreateInstance(NULL, kIPluginInstanceIID, (void **)getter_AddRefs(instance));

#ifdef XP_WIN
      if (!firstJavaPlugin && restoreOrigDir) {
        BOOL bCheck = :: SetCurrentDirectory(origDir);
        NS_ASSERTION(bCheck, " Error restoring driectoy");
        firstJavaPlugin = TRUE;
      }
#endif
    }

    if (NS_FAILED(result)) {
      nsCOMPtr<nsIPlugin> bwPlugin =
        do_GetService("@mozilla.org/blackwood/pluglet-engine;1", &result);
      if (NS_SUCCEEDED(result)) {
        result = bwPlugin->CreatePluginInstance(NULL,
                                                kIPluginInstanceIID,
                                                aMimeType,
                                                (void **)getter_AddRefs(instance));
      }
    }
  }

  // neither an XPCOM or legacy plugin could be instantiated,
  // so return the failure
  if (NS_FAILED(result))
    return result;

  // it is adreffed here
  aOwner->SetInstance(instance);

  nsRefPtr<nsPluginInstancePeerImpl> peer = new nsPluginInstancePeerImpl();
  if (!peer)
    return NS_ERROR_OUT_OF_MEMORY;

  // set up the peer for the instance
  peer->Initialize(aOwner, mimetype);

  result = instance->Initialize(peer);  // this should addref the peer but not the instance or owner
  if (NS_FAILED(result))                 // except in some cases not Java, see bug 140931
    return result;       // our COM pointer will free the peer

  // instance and peer will be addreffed here
  result = AddInstanceToActiveList(plugin, instance, aURL, PR_FALSE, peer);

#ifdef PLUGIN_LOGGING
  nsCAutoString urlSpec2;
  if (aURL)
    aURL->GetSpec(urlSpec2);

  PR_LOG(nsPluginLogging::gPluginLog, PLUGIN_LOG_BASIC,
        ("nsPluginHostImpl::TrySetupPluginInstance Finished mime=%s, rv=%d, owner=%p, url=%s\n",
        aMimeType, result, aOwner, urlSpec2.get()));

  PR_LogFlush();
#endif

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3318 of file nsPluginHostImpl.cpp.

{
  // unload any remaining plugin libraries from memory
  for (PRInt32 i = 0; i < mUnusedLibraries.Count(); i++) {
    PRLibrary * library = (PRLibrary *)mUnusedLibraries[i];
    if (library)
      PostPluginUnloadEvent(library);
  }
  mUnusedLibraries.Clear();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Unregister a plugin from the plugin manager.

Parameters:
aCIDthe CID of the plugin to unregister.
Returns:
- NS_OK if the operation was successful.

Here is the caller graph for this function:

Definition at line 3070 of file nsPluginHostImpl.cpp.

Unregisters a top-level window with the browser.

The handler and window pair should be the same as that specified to RegisterWindow.

Parameters:
aHandler- the event handler for the window
aWindow- the platform window reference
Returns:
- NS_OK if this operation was successful

Definition at line 3193 of file nsPluginHostImpl.cpp.

void nsIPluginManager::UserAgent ( in nativeChar  resultingAgentString) [inherited]

Returns the user agent string for the browser.

(Corresponds to NPN_UserAgent.)

Parameters:
resultingAgentString- the resulting user agent string
nsresult nsPluginHostImpl::UserAgent ( const char **  resultingAgentString)

Definition at line 2830 of file nsPluginHostImpl.cpp.

{
  static char resultString[NS_RETURN_UASTRING_SIZE];
  nsresult res;

  nsCOMPtr<nsIHttpProtocolHandler> http = do_GetService(kHttpHandlerCID, &res);
  if (NS_FAILED(res))
    return res;

  nsCAutoString uaString;
  res = http->GetUserAgent(uaString);

  if (NS_SUCCEEDED(res))
  {
    if(NS_RETURN_UASTRING_SIZE > uaString.Length())
    {
      PL_strcpy(resultString, uaString.get());
      *retstring = resultString;
    }
    else
    {
      *retstring = nsnull;
      res = NS_ERROR_OUT_OF_MEMORY;
    }
  }
  else
    *retstring = nsnull;

  PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsPluginHostImpl::UserAgent return=%s\n", *retstring));

  return res;
}

Here is the call graph for this function:

Definition at line 5368 of file nsPluginHostImpl.cpp.

{

  nsresult rv = NS_OK;
  nsCOMPtr<nsIProperties> directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID,&rv));
  if (NS_FAILED(rv))
    return rv;

  directoryService->Get(NS_APP_APPLICATION_REGISTRY_DIR, NS_GET_IID(nsIFile),
                        getter_AddRefs(mPluginRegFile));

  if (!mPluginRegFile)
    return NS_ERROR_FAILURE;

  PRFileDesc* fd = nsnull;

  nsCOMPtr<nsIFile> pluginReg;

  rv = mPluginRegFile->Clone(getter_AddRefs(pluginReg));
  if (NS_FAILED(rv))
    return rv;

  rv = pluginReg->AppendNative(kPluginRegistryFilename);
  if (NS_FAILED(rv))
    return rv;

  nsCOMPtr<nsILocalFile> localFile = do_QueryInterface(pluginReg, &rv);
  if (NS_FAILED(rv))
    return rv;

  rv = localFile->OpenNSPRFileDesc(PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, 0600, &fd);
  if (NS_FAILED(rv))
    return rv;

  PR_fprintf(fd, "Generated File. Do not edit.\n");

  PR_fprintf(fd, "\n[HEADER]\nVersion%c%s%c%c\n",
             PLUGIN_REGISTRY_FIELD_DELIMITER,
             kPluginRegistryVersion,
             PLUGIN_REGISTRY_FIELD_DELIMITER,
             PLUGIN_REGISTRY_END_OF_LINE_MARKER);

  // Store all plugins in the mPlugins list - all plugins currently in use.
  PR_fprintf(fd, "\n[PLUGINS]\n");

  nsPluginTag *taglist[] = {mPlugins, mCachedPlugins};
  for (int i=0; i<(int)(sizeof(taglist)/sizeof(nsPluginTag *)); i++) {
    for (nsPluginTag *tag = taglist[i]; tag; tag=tag->mNext) {
      // from mCachedPlugins list write down only unwanted plugins
      if ((taglist[i] == mCachedPlugins) && !(tag->mFlags & NS_PLUGIN_FLAG_UNWANTED))
        continue;
      // store each plugin info into the registry
      // filename & fullpath are on separate line
      // because they can contain field delimiter char
      PR_fprintf(fd, "%s%c%c\n%s%c%c\n",
        (tag->mFileName ? tag->mFileName : ""),
        PLUGIN_REGISTRY_FIELD_DELIMITER,
        PLUGIN_REGISTRY_END_OF_LINE_MARKER,
        (tag->mFullPath ? tag->mFullPath : ""),
        PLUGIN_REGISTRY_FIELD_DELIMITER,
        PLUGIN_REGISTRY_END_OF_LINE_MARKER);

      // lastModifiedTimeStamp|canUnload|tag->mFlags
      PR_fprintf(fd, "%lld%c%d%c%lu%c%c\n",
        tag->mLastModifiedTime,
        PLUGIN_REGISTRY_FIELD_DELIMITER,
        tag->mCanUnloadLibrary,
        PLUGIN_REGISTRY_FIELD_DELIMITER,
        tag->mFlags,
        PLUGIN_REGISTRY_FIELD_DELIMITER,
        PLUGIN_REGISTRY_END_OF_LINE_MARKER);

      //description, name & mtypecount are on separate line
      PR_fprintf(fd, "%s%c%c\n%s%c%c\n%d\n",
        (tag->mDescription ? tag->mDescription : ""),
        PLUGIN_REGISTRY_FIELD_DELIMITER,
        PLUGIN_REGISTRY_END_OF_LINE_MARKER,
        (tag->mName ? tag->mName : ""),
        PLUGIN_REGISTRY_FIELD_DELIMITER,
        PLUGIN_REGISTRY_END_OF_LINE_MARKER,
        tag->mVariants);

      // Add in each mimetype this plugin supports
      for (int i=0; i<tag->mVariants; i++) {
        PR_fprintf(fd, "%d%c%s%c%s%c%s%c%c\n",
          i,PLUGIN_REGISTRY_FIELD_DELIMITER,
          (tag->mMimeTypeArray && tag->mMimeTypeArray[i] ? tag->mMimeTypeArray[i] : ""),
          PLUGIN_REGISTRY_FIELD_DELIMITER,
          (tag->mMimeDescriptionArray && tag->mMimeDescriptionArray[i] ? tag->mMimeDescriptionArray[i] : ""),
          PLUGIN_REGISTRY_FIELD_DELIMITER,
          (tag->mExtensionsArray && tag->mExtensionsArray[i] ? tag->mExtensionsArray[i] : ""),
          PLUGIN_REGISTRY_FIELD_DELIMITER,
          PLUGIN_REGISTRY_END_OF_LINE_MARKER);
      }
    }
  }

  if (fd)
    PR_Close(fd);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 508 of file nsPluginHostImpl.h.

Definition at line 503 of file nsPluginHostImpl.h.

Definition at line 494 of file nsPluginHostImpl.h.

Definition at line 515 of file nsPluginHostImpl.h.

Definition at line 506 of file nsPluginHostImpl.h.

Definition at line 496 of file nsPluginHostImpl.h.

Definition at line 497 of file nsPluginHostImpl.h.

Definition at line 500 of file nsPluginHostImpl.h.

Definition at line 492 of file nsPluginHostImpl.h.

Definition at line 511 of file nsPluginHostImpl.h.

Definition at line 493 of file nsPluginHostImpl.h.

Definition at line 495 of file nsPluginHostImpl.h.

Definition at line 512 of file nsPluginHostImpl.h.

Definition at line 513 of file nsPluginHostImpl.h.

Definition at line 509 of file nsPluginHostImpl.h.

readonly attribute unsigned long nsIPluginHost::pluginCount [inherited]

Definition at line 81 of file nsIPluginHost.idl.

Definition at line 517 of file nsPluginHostImpl.h.


The documentation for this class was generated from the following files: