Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Public Attributes
nsPluginTag Class Reference

A linked-list of plugin information that is used for instantiating plugins and reflecting plugin information into JavaScript. More...

#include <nsPluginHostImpl.h>

Collaboration diagram for nsPluginTag:
Collaboration graph
[legend]

List of all members.

Public Types

enum  nsRegisterType { ePluginRegister, ePluginUnregister }

Public Member Functions

 nsPluginTag ()
 nsPluginTag (nsPluginTag *aPluginTag)
 nsPluginTag (nsPluginInfo *aPluginInfo)
 nsPluginTag (const char *aName, const char *aDescription, const char *aFileName, const char *aFullPath, const char *const *aMimeTypes, const char *const *aMimeDescriptions, const char *const *aExtensions, PRInt32 aVariants, PRInt64 aLastModifiedTime=0, PRBool aCanUnload=PR_TRUE)
 ~nsPluginTag ()
void SetHost (nsPluginHostImpl *aHost)
void TryUnloadPlugin (PRBool aForceShutdown=PR_FALSE)
void Mark (PRUint32 mask)
PRBool Equals (nsPluginTag *aPluginTag)
void RegisterWithCategoryManager (PRBool aOverrideInternalTypes, nsRegisterType aType=ePluginRegister)

Public Attributes

nsPluginTagmNext
nsPluginHostImplmPluginHost
char * mName
char * mDescription
PRInt32 mVariants
char ** mMimeTypeArray
char ** mMimeDescriptionArray
char ** mExtensionsArray
PRLibrarymLibrary
nsIPluginmEntryPoint
PRUint32 mFlags
PRPackedBool mCanUnloadLibrary
PRPackedBool mXPConnected
char * mFileName
char * mFullPath
PRInt64 mLastModifiedTime

Detailed Description

A linked-list of plugin information that is used for instantiating plugins and reflecting plugin information into JavaScript.

Definition at line 78 of file nsPluginHostImpl.h.


Member Enumeration Documentation

Enumerator:
ePluginRegister 
ePluginUnregister 

Definition at line 103 of file nsPluginHostImpl.h.


Constructor & Destructor Documentation

Definition at line 775 of file nsPluginHostImpl.cpp.

Here is the call graph for this function:

Definition at line 819 of file nsPluginHostImpl.cpp.

{
  mPluginHost = nsnull;
  mNext = nsnull;
  mName = new_str(aPluginInfo->fName);
  mDescription = new_str(aPluginInfo->fDescription);
  mVariants = aPluginInfo->fVariantCount;

  mMimeTypeArray = nsnull;
  mMimeDescriptionArray = nsnull;
  mExtensionsArray = nsnull;

  if(aPluginInfo->fMimeTypeArray != nsnull)
  {
    mMimeTypeArray = new char*[mVariants];
    for (int i = 0; i < mVariants; i++)
      mMimeTypeArray[i] = new_str(aPluginInfo->fMimeTypeArray[i]);
  }

  if(aPluginInfo->fMimeDescriptionArray != nsnull)
  {
    mMimeDescriptionArray = new char*[mVariants];
    for (int i = 0; i < mVariants; i++) {
      // we should cut off the list of suffixes which the mime
      // description string may have, see bug 53895
      // it is usually in form "some description (*.sf1, *.sf2)"
      // so we can search for the opening round bracket
      char cur = '\0';
      char pre = '\0';
      char * p = PL_strrchr(aPluginInfo->fMimeDescriptionArray[i], '(');
      if (p && (p != aPluginInfo->fMimeDescriptionArray[i])) {
        if ((p - 1) && *(p - 1) == ' ') {
          pre = *(p - 1);
          *(p - 1) = '\0';
        } else {
          cur = *p;
          *p = '\0';
        }

      }
      mMimeDescriptionArray[i] = new_str(aPluginInfo->fMimeDescriptionArray[i]);
      // restore the original string
      if (cur != '\0')
        *p = cur;
      if (pre != '\0')
        *(p - 1) = pre;
    }
  }

  if(aPluginInfo->fExtensionArray != nsnull)
  {
    mExtensionsArray = new char*[mVariants];
    for (int i = 0; i < mVariants; i++)
      mExtensionsArray[i] = new_str(aPluginInfo->fExtensionArray[i]);
  }

  mFileName = new_str(aPluginInfo->fFileName);
  mFullPath = new_str(aPluginInfo->fFullPath);

  mLibrary = nsnull;
  mCanUnloadLibrary = PR_TRUE;
  mEntryPoint = nsnull;
#ifdef XP_MACOSX
  mCanUnloadLibrary = !aPluginInfo->fBundle;
#endif
  mFlags = NS_PLUGIN_FLAG_ENABLED;
  mXPConnected = PR_FALSE;
}

Here is the call graph for this function:

nsPluginTag::nsPluginTag ( const char *  aName,
const char *  aDescription,
const char *  aFileName,
const char *  aFullPath,
const char *const aMimeTypes,
const char *const aMimeDescriptions,
const char *const aExtensions,
PRInt32  aVariants,
PRInt64  aLastModifiedTime = 0,
PRBool  aCanUnload = PR_TRUE 
)

Definition at line 891 of file nsPluginHostImpl.cpp.

  : mNext(nsnull),
    mVariants(aVariants),
    mMimeTypeArray(nsnull),
    mMimeDescriptionArray(nsnull),
    mExtensionsArray(nsnull),
    mLibrary(nsnull),
    mEntryPoint(nsnull),
    mFlags(0),
    mCanUnloadLibrary(aCanUnload),
    mXPConnected(PR_FALSE),
    mLastModifiedTime(aLastModifiedTime)
{
  mPluginHost = nsnull;
  mName            = new_str(aName);
  mDescription     = new_str(aDescription);
  mFileName        = new_str(aFileName);
  mFullPath        = new_str(aFullPath);

  if (mVariants) {
    mMimeTypeArray        = new char*[mVariants];
    mMimeDescriptionArray = new char*[mVariants];
    mExtensionsArray      = new char*[mVariants];

    for (PRInt32 i = 0; i < aVariants; ++i) {
      mMimeTypeArray[i]        = new_str(aMimeTypes[i]);
      mMimeDescriptionArray[i] = new_str(aMimeDescriptions[i]);
      mExtensionsArray[i]      = new_str(aExtensions[i]);
    }
  }
}

Here is the call graph for this function:

Definition at line 932 of file nsPluginHostImpl.cpp.

{
  TryUnloadPlugin(PR_TRUE);

  // Remove mime types added to the catagory manager
  // only if we were made 'active' by setting the host
  if (mPluginHost) {
    RegisterWithCategoryManager(PR_FALSE, nsPluginTag::ePluginUnregister);
  }

  if (nsnull != mName) {
    delete[] (mName);
    mName = nsnull;
  }

  if (nsnull != mDescription) {
    delete[] (mDescription);
    mDescription = nsnull;
  }

  if (nsnull != mMimeTypeArray) {
    for (int i = 0; i < mVariants; i++)
      delete[] mMimeTypeArray[i];

    delete[] (mMimeTypeArray);
    mMimeTypeArray = nsnull;
  }

  if (nsnull != mMimeDescriptionArray) {
    for (int i = 0; i < mVariants; i++)
      delete[] mMimeDescriptionArray[i];

    delete[] (mMimeDescriptionArray);
    mMimeDescriptionArray = nsnull;
  }

  if (nsnull != mExtensionsArray) {
    for (int i = 0; i < mVariants; i++)
      delete[] mExtensionsArray[i];

    delete[] (mExtensionsArray);
    mExtensionsArray = nsnull;
  }

  if(nsnull != mFileName)
  {
    delete [] mFileName;
    mFileName = nsnull;
  }

  if(nsnull != mFullPath)
  {
    delete [] mFullPath;
    mFullPath = nsnull;
  }

}

Here is the call graph for this function:


Member Function Documentation

Definition at line 1089 of file nsPluginHostImpl.cpp.

{
  NS_ENSURE_TRUE(aPluginTag, PR_FALSE);

  if ( (PL_strcmp(mName, aPluginTag->mName) != 0) ||
       (PL_strcmp(mDescription, aPluginTag->mDescription) != 0) ||
       (mVariants != aPluginTag->mVariants) )
    return PR_FALSE;

  if (mVariants && mMimeTypeArray && aPluginTag->mMimeTypeArray) {
    for (PRInt32 i = 0; i < mVariants; i++) {
      if (PL_strcmp(mMimeTypeArray[i], aPluginTag->mMimeTypeArray[i]) != 0)
        return PR_FALSE;
    }
  }
  return PR_TRUE;
}
void nsPluginTag::Mark ( PRUint32  mask) [inline]

Definition at line 100 of file nsPluginHostImpl.h.

{ mFlags |= mask; }

Here is the caller graph for this function:

Definition at line 3738 of file nsPluginHostImpl.cpp.

{
  if (!mMimeTypeArray)
    return;

  PLUGIN_LOG(PLUGIN_LOG_NORMAL,
  ("nsPluginTag::RegisterWithCategoryManager plugin=%s, removing = %s\n",
  mFileName, aType == ePluginUnregister ? "yes" : "no"));

  nsCOMPtr<nsICategoryManager> catMan = do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
  if (!catMan)
    return;

  const char *contractId = "@mozilla.org/content/plugin/document-loader-factory;1";

  nsCOMPtr<nsIPrefBranch> psvc(do_GetService(NS_PREFSERVICE_CONTRACTID));
  if (!psvc)
    return; // NS_ERROR_OUT_OF_MEMORY

  // A preference controls whether or not the full page plugin is disabled for
  // a particular type. The string must be in the form:
  //   type1,type2,type3,type4
  // Note: need an actual interface to control this and subsequent disabling 
  // (and other plugin host settings) so applications can reliably disable 
  // plugins - without relying on implementation details such as prefs/category
  // manager entries.
  nsXPIDLCString overrideTypes;
  psvc->GetCharPref("plugin.disable_full_page_plugin_for_types", getter_Copies(overrideTypes));
  nsCAutoString overrideTypesFormatted;
  overrideTypesFormatted.Assign(',');
  overrideTypesFormatted += overrideTypes;
  overrideTypesFormatted.Append(',');

  nsACString::const_iterator start, end;
  for(int i = 0; i < mVariants; i++) {
    if (aType == ePluginUnregister) {
      nsXPIDLCString value;
      if (NS_SUCCEEDED(catMan->GetCategoryEntry("Gecko-Content-Viewers",
                                                mMimeTypeArray[i],
                                                getter_Copies(value)))) {
        // Only delete the entry if a plugin registered for it
        if (strcmp(value, contractId) == 0) {
          catMan->DeleteCategoryEntry("Gecko-Content-Viewers",
                                      mMimeTypeArray[i],
                                      PR_TRUE);
        }
      }
    } else {
      overrideTypesFormatted.BeginReading(start);
      overrideTypesFormatted.EndReading(end);
      
      nsDependentCString mimeType(mMimeTypeArray[i]);
      nsCAutoString commaSeparated; 
      commaSeparated.Assign(',');
      commaSeparated += mimeType;
      commaSeparated.Append(',');
      if (!FindInReadable(commaSeparated, start, end)) {
        catMan->AddCategoryEntry("Gecko-Content-Viewers",
                                 mMimeTypeArray[i],
                                 contractId,
                                 PR_FALSE, /* persist: broken by bug 193031 */
                                 aOverrideInternalTypes, /* replace if we're told to */
                                 nsnull);
      }
    }

    PLUGIN_LOG(PLUGIN_LOG_NOISY,
    ("nsPluginTag::RegisterWithCategoryManager mime=%s, plugin=%s\n",
    mMimeTypeArray[i], mFileName));
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 990 of file nsPluginHostImpl.cpp.

{
  mPluginHost = aHost;
}

Here is the caller graph for this function:

Definition at line 1052 of file nsPluginHostImpl.cpp.

{
  PRBool isXPCOM = PR_FALSE;
  if (!(mFlags & NS_PLUGIN_FLAG_OLDSCHOOL))
    isXPCOM = PR_TRUE;

  if (isXPCOM && !aForceShutdown) return;

  if (mEntryPoint)
  {
    mEntryPoint->Shutdown();
    mEntryPoint->Release();
    mEntryPoint = nsnull;
  }

  // before we unload check if we are allowed to, see bug #61388
  // also, never unload an XPCOM plugin library
  if (mLibrary && mCanUnloadLibrary && !isXPCOM) {
    // NPAPI plugins can be unloaded now if they don't use XPConnect
    if (!mXPConnected)
      // unload the plugin asynchronously by posting a PLEvent
      PostPluginUnloadEvent(mLibrary);
    else {
      // add library to the unused library list to handle it later
      if (mPluginHost)
        mPluginHost->AddUnusedLibrary(mLibrary);
    }
  }

  // we should zero it anyway, it is going to be unloaded by
  // CleanUnsedLibraries before we need to call the library
  // again so the calling code should not be fooled and reload
  // the library fresh
  mLibrary = nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 121 of file nsPluginHostImpl.h.

Definition at line 113 of file nsPluginHostImpl.h.

Definition at line 119 of file nsPluginHostImpl.h.

Definition at line 117 of file nsPluginHostImpl.h.

Definition at line 123 of file nsPluginHostImpl.h.

Definition at line 120 of file nsPluginHostImpl.h.

Definition at line 124 of file nsPluginHostImpl.h.

Definition at line 125 of file nsPluginHostImpl.h.

Definition at line 118 of file nsPluginHostImpl.h.

Definition at line 116 of file nsPluginHostImpl.h.

Definition at line 115 of file nsPluginHostImpl.h.

Definition at line 112 of file nsPluginHostImpl.h.

Definition at line 110 of file nsPluginHostImpl.h.

Definition at line 111 of file nsPluginHostImpl.h.

Definition at line 114 of file nsPluginHostImpl.h.

Definition at line 122 of file nsPluginHostImpl.h.


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