mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 18:08:58 +00:00
Bug 420285 Internationalize plugin tag and plugin host r=jst, sr=bzbarsky, b1.9=jst
This commit is contained in:
parent
a4bea78921
commit
ac80174534
@ -38,12 +38,12 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(e8b85cb4-6281-40b1-b54d-da825487b73a)]
|
||||
[scriptable, uuid(af36bf4d-5652-413f-a78c-745b702f2381)]
|
||||
interface nsIPluginTag : nsISupports
|
||||
{
|
||||
readonly attribute ACString description;
|
||||
readonly attribute ACString filename;
|
||||
readonly attribute ACString name;
|
||||
readonly attribute AUTF8String description;
|
||||
readonly attribute AUTF8String filename;
|
||||
readonly attribute AUTF8String name;
|
||||
attribute boolean disabled;
|
||||
attribute boolean blocklisted;
|
||||
};
|
||||
|
@ -21,7 +21,7 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Sean Echevarria <sean@beatnik.com>
|
||||
* Håkan Waara <hwaara@chello.se>
|
||||
* Håkan Waara <hwaara@chello.se>
|
||||
* Josh Aas <josh@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
@ -201,7 +201,8 @@
|
||||
// 0.06 strip off suffixes in mime description strings, bug 53895
|
||||
// 0.07 changed nsIRegistry to flat file support for caching plugins info
|
||||
// 0.08 mime entry point on MachO, bug 137535
|
||||
static const char *kPluginRegistryVersion = "0.08";
|
||||
// 0.09 the file encoding is changed to UTF-8, bug 420285
|
||||
static const char *kPluginRegistryVersion = "0.09";
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// CID's && IID's
|
||||
static NS_DEFINE_IID(kIPluginInstanceIID, NS_IPLUGININSTANCE_IID);
|
||||
@ -729,11 +730,11 @@ inline char* new_str(const char* str)
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
nsPluginTag::nsPluginTag(nsPluginTag* aPluginTag)
|
||||
: mPluginHost(nsnull),
|
||||
mName(new_str(aPluginTag->mName)),
|
||||
mDescription(new_str(aPluginTag->mDescription)),
|
||||
mName(aPluginTag->mName),
|
||||
mDescription(aPluginTag->mDescription),
|
||||
mVariants(aPluginTag->mVariants),
|
||||
mMimeTypeArray(nsnull),
|
||||
mMimeDescriptionArray(nsnull),
|
||||
mMimeDescriptionArray(aPluginTag->mMimeDescriptionArray),
|
||||
mExtensionsArray(nsnull),
|
||||
mLibrary(nsnull),
|
||||
mEntryPoint(nsnull),
|
||||
@ -741,8 +742,8 @@ nsPluginTag::nsPluginTag(nsPluginTag* aPluginTag)
|
||||
mXPConnected(PR_FALSE),
|
||||
mIsJavaPlugin(aPluginTag->mIsJavaPlugin),
|
||||
mIsNPRuntimeEnabledJavaPlugin(aPluginTag->mIsNPRuntimeEnabledJavaPlugin),
|
||||
mFileName(new_str(aPluginTag->mFileName)),
|
||||
mFullPath(new_str(aPluginTag->mFullPath)),
|
||||
mFileName(aPluginTag->mFileName),
|
||||
mFullPath(aPluginTag->mFullPath),
|
||||
mLastModifiedTime(0),
|
||||
mFlags(NS_PLUGIN_FLAG_ENABLED)
|
||||
{
|
||||
@ -753,13 +754,6 @@ nsPluginTag::nsPluginTag(nsPluginTag* aPluginTag)
|
||||
mMimeTypeArray[i] = new_str(aPluginTag->mMimeTypeArray[i]);
|
||||
}
|
||||
|
||||
if(aPluginTag->mMimeDescriptionArray != nsnull)
|
||||
{
|
||||
mMimeDescriptionArray = new char*[mVariants];
|
||||
for (int i = 0; i < mVariants; i++)
|
||||
mMimeDescriptionArray[i] = new_str(aPluginTag->mMimeDescriptionArray[i]);
|
||||
}
|
||||
|
||||
if(aPluginTag->mExtensionsArray != nsnull)
|
||||
{
|
||||
mExtensionsArray = new char*[mVariants];
|
||||
@ -772,11 +766,10 @@ nsPluginTag::nsPluginTag(nsPluginTag* aPluginTag)
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
nsPluginTag::nsPluginTag(nsPluginInfo* aPluginInfo)
|
||||
: mPluginHost(nsnull),
|
||||
mName(new_str(aPluginInfo->fName)),
|
||||
mDescription(new_str(aPluginInfo->fDescription)),
|
||||
mName(aPluginInfo->fName),
|
||||
mDescription(aPluginInfo->fDescription),
|
||||
mVariants(aPluginInfo->fVariantCount),
|
||||
mMimeTypeArray(nsnull),
|
||||
mMimeDescriptionArray(nsnull),
|
||||
mExtensionsArray(nsnull),
|
||||
mLibrary(nsnull),
|
||||
mEntryPoint(nsnull),
|
||||
@ -788,8 +781,8 @@ nsPluginTag::nsPluginTag(nsPluginInfo* aPluginInfo)
|
||||
mXPConnected(PR_FALSE),
|
||||
mIsJavaPlugin(PR_FALSE),
|
||||
mIsNPRuntimeEnabledJavaPlugin(PR_FALSE),
|
||||
mFileName(new_str(aPluginInfo->fFileName)),
|
||||
mFullPath(new_str(aPluginInfo->fFullPath)),
|
||||
mFileName(aPluginInfo->fFileName),
|
||||
mFullPath(aPluginInfo->fFullPath),
|
||||
mLastModifiedTime(0),
|
||||
mFlags(NS_PLUGIN_FLAG_ENABLED)
|
||||
{
|
||||
@ -817,7 +810,6 @@ nsPluginTag::nsPluginTag(nsPluginInfo* aPluginInfo)
|
||||
|
||||
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
|
||||
@ -836,13 +828,16 @@ nsPluginTag::nsPluginTag(nsPluginInfo* aPluginInfo)
|
||||
}
|
||||
|
||||
}
|
||||
mMimeDescriptionArray[i] = new_str(aPluginInfo->fMimeDescriptionArray[i]);
|
||||
mMimeDescriptionArray.AppendElement(
|
||||
aPluginInfo->fMimeDescriptionArray[i]);
|
||||
// restore the original string
|
||||
if (cur != '\0')
|
||||
*p = cur;
|
||||
if (pre != '\0')
|
||||
*(p - 1) = pre;
|
||||
}
|
||||
} else {
|
||||
mMimeDescriptionArray.SetLength(mVariants);
|
||||
}
|
||||
|
||||
if(aPluginInfo->fExtensionArray != nsnull)
|
||||
@ -851,6 +846,8 @@ nsPluginTag::nsPluginTag(nsPluginInfo* aPluginInfo)
|
||||
for (int i = 0; i < mVariants; i++)
|
||||
mExtensionsArray[i] = new_str(aPluginInfo->fExtensionArray[i]);
|
||||
}
|
||||
|
||||
EnsureMembersAreUTF8();
|
||||
}
|
||||
|
||||
|
||||
@ -865,13 +862,13 @@ nsPluginTag::nsPluginTag(const char* aName,
|
||||
const char* const* aExtensions,
|
||||
PRInt32 aVariants,
|
||||
PRInt64 aLastModifiedTime,
|
||||
PRBool aCanUnload)
|
||||
PRBool aCanUnload,
|
||||
PRBool aArgsAreUTF8)
|
||||
: mPluginHost(nsnull),
|
||||
mName(new_str(aName)),
|
||||
mDescription(new_str(aDescription)),
|
||||
mName(aName),
|
||||
mDescription(aDescription),
|
||||
mVariants(aVariants),
|
||||
mMimeTypeArray(nsnull),
|
||||
mMimeDescriptionArray(nsnull),
|
||||
mExtensionsArray(nsnull),
|
||||
mLibrary(nsnull),
|
||||
mEntryPoint(nsnull),
|
||||
@ -879,14 +876,13 @@ nsPluginTag::nsPluginTag(const char* aName,
|
||||
mXPConnected(PR_FALSE),
|
||||
mIsJavaPlugin(PR_FALSE),
|
||||
mIsNPRuntimeEnabledJavaPlugin(PR_FALSE),
|
||||
mFileName(new_str(aFileName)),
|
||||
mFullPath(new_str(aFullPath)),
|
||||
mFileName(aFileName),
|
||||
mFullPath(aFullPath),
|
||||
mLastModifiedTime(aLastModifiedTime),
|
||||
mFlags(0) // Caller will read in our flags from cache
|
||||
{
|
||||
if (aVariants) {
|
||||
mMimeTypeArray = new char*[mVariants];
|
||||
mMimeDescriptionArray = new char*[mVariants];
|
||||
mExtensionsArray = new char*[mVariants];
|
||||
|
||||
for (PRInt32 i = 0; i < aVariants; ++i) {
|
||||
@ -902,12 +898,15 @@ nsPluginTag::nsPluginTag(const char* aName,
|
||||
}
|
||||
|
||||
mMimeTypeArray[i] = new_str(aMimeTypes[i]);
|
||||
mMimeDescriptionArray[i] = new_str(aMimeDescriptions[i]);
|
||||
mMimeDescriptionArray.AppendElement(aMimeDescriptions[i]);
|
||||
mExtensionsArray[i] = new_str(aExtensions[i]);
|
||||
if (nsPluginHostImpl::IsJavaMIMEType(mMimeTypeArray[i]))
|
||||
mIsJavaPlugin = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!aArgsAreUTF8)
|
||||
EnsureMembersAreUTF8();
|
||||
}
|
||||
|
||||
nsPluginTag::~nsPluginTag()
|
||||
@ -920,12 +919,6 @@ nsPluginTag::~nsPluginTag()
|
||||
RegisterWithCategoryManager(PR_FALSE, nsPluginTag::ePluginUnregister);
|
||||
}
|
||||
|
||||
delete[] (mName);
|
||||
mName = nsnull;
|
||||
|
||||
delete[] (mDescription);
|
||||
mDescription = nsnull;
|
||||
|
||||
if (mMimeTypeArray) {
|
||||
for (int i = 0; i < mVariants; i++)
|
||||
delete[] mMimeTypeArray[i];
|
||||
@ -934,14 +927,6 @@ nsPluginTag::~nsPluginTag()
|
||||
mMimeTypeArray = nsnull;
|
||||
}
|
||||
|
||||
if (mMimeDescriptionArray) {
|
||||
for (int i = 0; i < mVariants; i++)
|
||||
delete[] mMimeDescriptionArray[i];
|
||||
|
||||
delete[] (mMimeDescriptionArray);
|
||||
mMimeDescriptionArray = nsnull;
|
||||
}
|
||||
|
||||
if (mExtensionsArray) {
|
||||
for (int i = 0; i < mVariants; i++)
|
||||
delete[] mExtensionsArray[i];
|
||||
@ -949,16 +934,72 @@ nsPluginTag::~nsPluginTag()
|
||||
delete[] (mExtensionsArray);
|
||||
mExtensionsArray = nsnull;
|
||||
}
|
||||
|
||||
delete [] mFileName;
|
||||
mFileName = nsnull;
|
||||
|
||||
delete [] mFullPath;
|
||||
mFullPath = nsnull;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsPluginTag, nsIPluginTag)
|
||||
|
||||
static nsresult ConvertToUTF8(nsIUnicodeDecoder *aUnicodeDecoder,
|
||||
nsAFlatCString& aString)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
PRInt32 numberOfBytes = aString.Length();
|
||||
PRInt32 outUnicodeLen;
|
||||
nsAutoString buffer;
|
||||
rv = aUnicodeDecoder->GetMaxLength(aString.get(), numberOfBytes,
|
||||
&outUnicodeLen);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!EnsureStringLength(buffer, outUnicodeLen))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = aUnicodeDecoder->Convert(aString.get(), &numberOfBytes,
|
||||
buffer.BeginWriting(), &outUnicodeLen);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
buffer.SetLength(outUnicodeLen);
|
||||
CopyUTF16toUTF8(buffer, aString);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPluginTag::EnsureMembersAreUTF8()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIPlatformCharset> pcs =
|
||||
do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIUnicodeDecoder> decoder;
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm =
|
||||
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCAutoString charset;
|
||||
rv = pcs->GetCharset(kPlatformCharsetSel_FileName, charset);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!charset.LowerCaseEqualsLiteral("utf-8")) {
|
||||
rv = ccm->GetUnicodeDecoderRaw(charset.get(), getter_AddRefs(decoder));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
ConvertToUTF8(decoder, mFileName);
|
||||
ConvertToUTF8(decoder, mFullPath);
|
||||
}
|
||||
|
||||
// The description of the plug-in and the various MIME type descriptions
|
||||
// should be encoded in the standard plain text file encoding for this system.
|
||||
// XXX should we add kPlatformCharsetSel_PluginResource?
|
||||
rv = pcs->GetCharset(kPlatformCharsetSel_PlainTextInFile, charset);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!charset.LowerCaseEqualsLiteral("utf-8")) {
|
||||
rv = ccm->GetUnicodeDecoderRaw(charset.get(), getter_AddRefs(decoder));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
ConvertToUTF8(decoder, mDescription);
|
||||
for (PRInt32 i = 0; i < mMimeDescriptionArray.Length(); ++i) {
|
||||
ConvertToUTF8(decoder, mMimeDescriptionArray[i]);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsPluginTag::SetHost(nsPluginHostImpl * aHost)
|
||||
{
|
||||
mPluginHost = aHost;
|
||||
@ -967,27 +1008,21 @@ void nsPluginTag::SetHost(nsPluginHostImpl * aHost)
|
||||
NS_IMETHODIMP
|
||||
nsPluginTag::GetDescription(nsACString& aDescription)
|
||||
{
|
||||
aDescription.Truncate();
|
||||
if (mDescription)
|
||||
aDescription.Assign(nsDependentCString(mDescription));
|
||||
aDescription = mDescription;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPluginTag::GetFilename(nsACString& aFileName)
|
||||
{
|
||||
aFileName.Truncate();
|
||||
if (mFileName)
|
||||
aFileName.Assign(nsDependentCString(mFileName));
|
||||
aFileName = mFileName;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPluginTag::GetName(nsACString& aName)
|
||||
{
|
||||
aName.Truncate();
|
||||
if (mName)
|
||||
aName.Assign(nsDependentCString(mName));
|
||||
aName = mName;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1130,8 +1165,8 @@ PRBool nsPluginTag::Equals(nsPluginTag *aPluginTag)
|
||||
{
|
||||
NS_ENSURE_TRUE(aPluginTag, PR_FALSE);
|
||||
|
||||
if ( (PL_strcmp(mName, aPluginTag->mName) != 0) ||
|
||||
(PL_strcmp(mDescription, aPluginTag->mDescription) != 0) ||
|
||||
if ( (!mName.Equals(aPluginTag->mName)) ||
|
||||
(!mDescription.Equals(aPluginTag->mDescription)) ||
|
||||
(mVariants != aPluginTag->mVariants) )
|
||||
return PR_FALSE;
|
||||
|
||||
@ -2712,7 +2747,7 @@ nsPluginHostImpl::GetPluginName(nsIPluginInstance *aPluginInstance)
|
||||
gActivePluginList ? gActivePluginList->find(aPluginInstance) : nsnull;
|
||||
|
||||
if (plugin && plugin->mPluginTag) {
|
||||
return plugin->mPluginTag->mName;
|
||||
return plugin->mPluginTag->mName.get();
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
@ -3801,7 +3836,7 @@ nsPluginTag::RegisterWithCategoryManager(PRBool aOverrideInternalTypes,
|
||||
|
||||
PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
||||
("nsPluginTag::RegisterWithCategoryManager plugin=%s, removing = %s\n",
|
||||
mFileName, aType == ePluginUnregister ? "yes" : "no"));
|
||||
mFileName.get(), aType == ePluginUnregister ? "yes" : "no"));
|
||||
|
||||
nsCOMPtr<nsICategoryManager> catMan = do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
|
||||
if (!catMan)
|
||||
@ -3862,7 +3897,7 @@ nsPluginTag::RegisterWithCategoryManager(PRBool aOverrideInternalTypes,
|
||||
|
||||
PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
||||
("nsPluginTag::RegisterWithCategoryManager mime=%s, plugin=%s\n",
|
||||
mMimeTypeArray[i], mFileName));
|
||||
mMimeTypeArray[i], mFileName.get()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -4238,69 +4273,21 @@ nsPluginHostImpl::IsPluginEnabledForExtension(const char* aExtension,
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Utility functions for a charset convertor
|
||||
// which converts platform charset to unicode.
|
||||
|
||||
static nsresult CreateUnicodeDecoder(nsIUnicodeDecoder **aUnicodeDecoder)
|
||||
{
|
||||
nsresult rv;
|
||||
// get the charset
|
||||
nsCAutoString platformCharset;
|
||||
nsCOMPtr <nsIPlatformCharset> platformCharsetService = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = platformCharsetService->GetCharset(kPlatformCharsetSel_FileName, platformCharset);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// get the decoder
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = ccm->GetUnicodeDecoderRaw(platformCharset.get(),
|
||||
aUnicodeDecoder);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static nsresult DoCharsetConversion(nsIUnicodeDecoder *aUnicodeDecoder,
|
||||
const char* aANSIString, nsAString& aUnicodeString)
|
||||
{
|
||||
NS_ENSURE_TRUE(aUnicodeDecoder, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(aANSIString, NS_ERROR_FAILURE);
|
||||
nsresult rv;
|
||||
|
||||
PRInt32 numberOfBytes = strlen(aANSIString);
|
||||
PRInt32 outUnicodeLen;
|
||||
nsAutoString buffer;
|
||||
rv = aUnicodeDecoder->GetMaxLength(aANSIString, numberOfBytes, &outUnicodeLen);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!EnsureStringLength(buffer, outUnicodeLen))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = aUnicodeDecoder->Convert(aANSIString, &numberOfBytes, buffer.BeginWriting(), &outUnicodeLen);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
buffer.SetLength(outUnicodeLen);
|
||||
aUnicodeString = buffer;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class DOMMimeTypeImpl : public nsIDOMMimeType {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
DOMMimeTypeImpl(nsPluginTag* aPluginTag, PRUint32 aMimeTypeIndex)
|
||||
DOMMimeTypeImpl(nsPluginTag* aTag, PRUint32 aMimeTypeIndex)
|
||||
{
|
||||
(void) CreateUnicodeDecoder(getter_AddRefs(mUnicodeDecoder));
|
||||
if (aPluginTag) {
|
||||
if (aPluginTag->mMimeDescriptionArray)
|
||||
(void) DoCharsetConversion(mUnicodeDecoder,
|
||||
aPluginTag->mMimeDescriptionArray[aMimeTypeIndex], mDescription);
|
||||
if (aPluginTag->mExtensionsArray)
|
||||
mSuffixes.AssignWithConversion(aPluginTag->mExtensionsArray[aMimeTypeIndex]);
|
||||
if (aPluginTag->mMimeTypeArray)
|
||||
mType.AssignWithConversion(aPluginTag->mMimeTypeArray[aMimeTypeIndex]);
|
||||
}
|
||||
if (!aTag)
|
||||
return;
|
||||
CopyUTF8toUTF16(aTag->mMimeDescriptionArray[aMimeTypeIndex], mDescription);
|
||||
if (aTag->mExtensionsArray)
|
||||
CopyUTF8toUTF16(aTag->mExtensionsArray[aMimeTypeIndex], mSuffixes);
|
||||
if (aTag->mMimeTypeArray)
|
||||
CopyUTF8toUTF16(aTag->mMimeTypeArray[aMimeTypeIndex], mType);
|
||||
}
|
||||
|
||||
virtual ~DOMMimeTypeImpl() {
|
||||
@ -4335,7 +4322,6 @@ private:
|
||||
nsString mDescription;
|
||||
nsString mSuffixes;
|
||||
nsString mType;
|
||||
nsCOMPtr<nsIUnicodeDecoder> mUnicodeDecoder;
|
||||
};
|
||||
|
||||
|
||||
@ -4348,7 +4334,6 @@ public:
|
||||
|
||||
DOMPluginImpl(nsPluginTag* aPluginTag) : mPluginTag(aPluginTag)
|
||||
{
|
||||
(void) CreateUnicodeDecoder(getter_AddRefs(mUnicodeDecoder));
|
||||
}
|
||||
|
||||
virtual ~DOMPluginImpl() {
|
||||
@ -4356,7 +4341,7 @@ public:
|
||||
|
||||
NS_METHOD GetDescription(nsAString& aDescription)
|
||||
{
|
||||
DoCharsetConversion(mUnicodeDecoder, mPluginTag.mDescription, aDescription);
|
||||
CopyUTF8toUTF16(mPluginTag.mDescription, aDescription);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -4371,39 +4356,36 @@ public:
|
||||
// only show the full path if people have set the pref,
|
||||
// the default should not reveal path information (bug 88183)
|
||||
#if defined(XP_MACOSX)
|
||||
return DoCharsetConversion(mUnicodeDecoder, mPluginTag.mFullPath, aFilename);
|
||||
CopyUTF8toUTF16(mPluginTag.mFullPath, aFilename);
|
||||
#else
|
||||
return DoCharsetConversion(mUnicodeDecoder, mPluginTag.mFileName, aFilename);
|
||||
CopyUTF8toUTF16(mPluginTag.mFileName, aFilename);
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
const char* spec;
|
||||
if (mPluginTag.mFullPath)
|
||||
nsAutoString spec;
|
||||
if (!mPluginTag.mFullPath.IsEmpty())
|
||||
{
|
||||
#if !defined(XP_MACOSX)
|
||||
NS_ERROR("Only MAC should be using nsPluginTag::mFullPath!");
|
||||
#endif
|
||||
spec = mPluginTag.mFullPath;
|
||||
CopyUTF8toUTF16(mPluginTag.mFullPath, spec);
|
||||
}
|
||||
else
|
||||
{
|
||||
spec = mPluginTag.mFileName;
|
||||
CopyUTF8toUTF16(mPluginTag.mFileName, spec);
|
||||
}
|
||||
|
||||
nsCString leafName;
|
||||
nsCOMPtr<nsILocalFile> pluginPath;
|
||||
NS_NewNativeLocalFile(nsDependentCString(spec), PR_TRUE,
|
||||
getter_AddRefs(pluginPath));
|
||||
NS_NewLocalFile(spec, PR_TRUE, getter_AddRefs(pluginPath));
|
||||
|
||||
pluginPath->GetNativeLeafName(leafName);
|
||||
|
||||
nsresult rv = DoCharsetConversion(mUnicodeDecoder, leafName.get(), aFilename);
|
||||
return rv;
|
||||
return pluginPath->GetLeafName(aFilename);
|
||||
}
|
||||
|
||||
NS_METHOD GetName(nsAString& aName)
|
||||
{
|
||||
DoCharsetConversion(mUnicodeDecoder, mPluginTag.mName, aName);
|
||||
CopyUTF8toUTF16(mPluginTag.mName, aName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -4423,16 +4405,15 @@ public:
|
||||
|
||||
NS_METHOD NamedItem(const nsAString& aName, nsIDOMMimeType** aReturn)
|
||||
{
|
||||
for (int index = mPluginTag.mVariants - 1; index >= 0; --index) {
|
||||
if (aName.Equals(NS_ConvertASCIItoUTF16(mPluginTag.mMimeTypeArray[index])))
|
||||
return Item(index, aReturn);
|
||||
for (int i = mPluginTag.mVariants - 1; i >= 0; --i) {
|
||||
if (aName.Equals(NS_ConvertUTF8toUTF16(mPluginTag.mMimeTypeArray[i])))
|
||||
return Item(i, aReturn);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
nsPluginTag mPluginTag;
|
||||
nsCOMPtr<nsIUnicodeDecoder> mUnicodeDecoder;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@ -4681,6 +4662,60 @@ inline PRBool IsCompatibleExecutable(const char* path) { return PR_TRUE; }
|
||||
|
||||
#endif
|
||||
|
||||
static nsresult ConvertToNative(nsIUnicodeEncoder *aEncoder,
|
||||
const nsACString& aUTF8String,
|
||||
nsACString& aNativeString)
|
||||
{
|
||||
NS_ConvertUTF8toUTF16 utf16(aUTF8String);
|
||||
PRInt32 len = utf16.Length();
|
||||
PRInt32 outLen;
|
||||
nsresult rv = aEncoder->GetMaxLength(utf16.get(), len, &outLen);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!EnsureStringLength(aNativeString, outLen))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = aEncoder->Convert(utf16.get(), &len,
|
||||
aNativeString.BeginWriting(), &outLen);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
aNativeString.SetLength(outLen);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult Create4xPlugin(nsIServiceManagerObsolete* aServiceManager,
|
||||
const nsPluginTag *aPluginTag,
|
||||
nsIPlugin **aOut4xPlugnin)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr <nsIPlatformCharset> pcs =
|
||||
do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCAutoString charset;
|
||||
rv = pcs->GetCharset(kPlatformCharsetSel_FileName, charset);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCAutoString fileName, fullPath;
|
||||
if (!charset.LowerCaseEqualsLiteral("utf-8")) {
|
||||
nsCOMPtr<nsIUnicodeEncoder> encoder;
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm =
|
||||
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = ccm->GetUnicodeEncoderRaw(charset.get(), getter_AddRefs(encoder));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = ConvertToNative(encoder, aPluginTag->mFileName, fileName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = ConvertToNative(encoder, aPluginTag->mFullPath, fullPath);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else {
|
||||
fileName = aPluginTag->mFileName;
|
||||
fullPath = aPluginTag->mFullPath;
|
||||
}
|
||||
|
||||
return ns4xPlugin::CreatePlugin(aServiceManager,
|
||||
fileName.get(),
|
||||
fullPath.get(),
|
||||
aPluginTag->mLibrary,
|
||||
aOut4xPlugnin);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugin** aPlugin)
|
||||
@ -4700,11 +4735,11 @@ NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugi
|
||||
rv = NS_OK;
|
||||
PLUGIN_LOG(PLUGIN_LOG_BASIC,
|
||||
("nsPluginHostImpl::GetPluginFactory Begin mime=%s, plugin=%s\n",
|
||||
aMimeType, pluginTag->mFileName));
|
||||
aMimeType, pluginTag->mFileName.get()));
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
if(aMimeType && pluginTag->mFileName)
|
||||
printf("For %s found plugin %s\n", aMimeType, pluginTag->mFileName);
|
||||
if(aMimeType && !pluginTag->mFileName.IsEmpty())
|
||||
printf("For %s found plugin %s\n", aMimeType, pluginTag->mFileName.get());
|
||||
#endif
|
||||
|
||||
if (nsnull == pluginTag->mLibrary) // if we haven't done this yet
|
||||
@ -4712,11 +4747,11 @@ NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugi
|
||||
|
||||
nsCOMPtr<nsILocalFile> file = do_CreateInstance("@mozilla.org/file/local;1");
|
||||
#if !defined(XP_MACOSX)
|
||||
file->InitWithNativePath(nsDependentCString(pluginTag->mFileName));
|
||||
file->InitWithPath(NS_ConvertUTF8toUTF16(pluginTag->mFileName));
|
||||
#else
|
||||
if (nsnull == pluginTag->mFullPath)
|
||||
if (pluginTag->mFullPath.IsEmpty())
|
||||
return NS_ERROR_FAILURE;
|
||||
file->InitWithNativePath(nsDependentCString(pluginTag->mFullPath));
|
||||
file->InitWithPath(NS_ConvertUTF8toUTF16(pluginTag->mFullPath));
|
||||
#endif
|
||||
nsPluginFile pluginFile(file);
|
||||
PRLibrary* pluginLibrary = NULL;
|
||||
@ -4762,7 +4797,7 @@ NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugi
|
||||
#else
|
||||
nsGetFactory = (nsFactoryProc) PR_FindFunctionSymbol(pluginTag->mLibrary, "NSGetFactory");
|
||||
#endif
|
||||
if(nsGetFactory != nsnull && IsCompatibleExecutable(pluginTag->mFullPath))
|
||||
if(nsGetFactory && IsCompatibleExecutable(pluginTag->mFullPath.get()))
|
||||
{
|
||||
// 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.
|
||||
@ -4777,7 +4812,7 @@ NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugi
|
||||
#ifdef XP_OS2
|
||||
// on OS2, first check if this might be legacy XPCOM module.
|
||||
else if (PR_FindSymbol(pluginTag->mLibrary, "NSGetFactory") &&
|
||||
IsCompatibleExecutable(pluginTag->mFullPath))
|
||||
IsCompatibleExecutable(pluginTag->mFullPath.get()))
|
||||
{
|
||||
// Possibly a legacy XPCOM module. We'll need to create a calling
|
||||
// vtable/calling convention wrapper for it.
|
||||
@ -4795,16 +4830,10 @@ NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugi
|
||||
#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;
|
||||
// Now lets try to get the entry point from a 4.x plugin
|
||||
rv = Create4xPlugin(serviceManager, pluginTag, &plugin);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
pluginTag->mEntryPoint = plugin;
|
||||
pluginTag->Mark(NS_PLUGIN_FLAG_OLDSCHOOL);
|
||||
// no need to initialize, already done by CreatePlugin()
|
||||
}
|
||||
@ -4815,9 +4844,11 @@ NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugi
|
||||
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 (StringBeginsWith(pluginTag->mDescription,
|
||||
NS_LITERAL_CSTRING("Shockwave Flash 6.0"),
|
||||
nsCaseInsensitiveCStringComparator()) &&
|
||||
pluginTag->mDescription.Length() > 21) {
|
||||
int ver = atoi(pluginTag->mDescription.get() + 21);
|
||||
if (ver && ver <= 50) {
|
||||
::UseInputWindow(NULL, false);
|
||||
}
|
||||
@ -4834,7 +4865,8 @@ NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugi
|
||||
|
||||
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)")));
|
||||
aMimeType, rv, *aPlugin,
|
||||
(pluginTag ? pluginTag->mFileName.get() : "(not found)")));
|
||||
|
||||
return rv;
|
||||
}
|
||||
@ -4846,7 +4878,7 @@ NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugi
|
||||
// Acrobat, Flash, Quicktime and Shockwave
|
||||
static PRBool isUnwantedPlugin(nsPluginTag * tag)
|
||||
{
|
||||
if(tag->mFileName == nsnull)
|
||||
if(tag->mFileName.IsEmpty())
|
||||
return PR_TRUE;
|
||||
|
||||
for (PRInt32 i = 0; i < tag->mVariants; ++i) {
|
||||
@ -4862,7 +4894,7 @@ static PRBool isUnwantedPlugin(nsPluginTag * tag)
|
||||
|
||||
// On Windows, we also want to include the Quicktime plugin from the 4.x directory
|
||||
// But because it spans several DLL's, the best check for now is by filename
|
||||
if (PL_strcasestr(tag->mFileName,"npqtplugin") != nsnull)
|
||||
if (tag->mFileName.Find("npqtplugin", PR_TRUE, 0, -1) != kNotFound)
|
||||
return PR_FALSE;
|
||||
|
||||
return PR_TRUE;
|
||||
@ -4907,12 +4939,12 @@ PRBool nsPluginHostImpl::IsDuplicatePlugin(nsPluginTag * aPluginTag)
|
||||
// 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))
|
||||
if (!tag->mFileName.Equals(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))
|
||||
if (!tag->mFullPath.Equals(aPluginTag->mFullPath))
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
@ -5595,10 +5627,10 @@ nsPluginHostImpl::WritePluginInfo()
|
||||
// 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 : ""),
|
||||
(!tag->mFileName.IsEmpty() ? tag->mFileName.get() : ""),
|
||||
PLUGIN_REGISTRY_FIELD_DELIMITER,
|
||||
PLUGIN_REGISTRY_END_OF_LINE_MARKER,
|
||||
(tag->mFullPath ? tag->mFullPath : ""),
|
||||
(!tag->mFullPath.IsEmpty() ? tag->mFullPath.get() : ""),
|
||||
PLUGIN_REGISTRY_FIELD_DELIMITER,
|
||||
PLUGIN_REGISTRY_END_OF_LINE_MARKER);
|
||||
|
||||
@ -5614,10 +5646,10 @@ nsPluginHostImpl::WritePluginInfo()
|
||||
|
||||
//description, name & mtypecount are on separate line
|
||||
PR_fprintf(fd, "%s%c%c\n%s%c%c\n%d\n",
|
||||
(tag->mDescription ? tag->mDescription : ""),
|
||||
(!tag->mDescription.IsEmpty() ? tag->mDescription.get() : ""),
|
||||
PLUGIN_REGISTRY_FIELD_DELIMITER,
|
||||
PLUGIN_REGISTRY_END_OF_LINE_MARKER,
|
||||
(tag->mName ? tag->mName : ""),
|
||||
(!tag->mName.IsEmpty() ? tag->mName.get() : ""),
|
||||
PLUGIN_REGISTRY_FIELD_DELIMITER,
|
||||
PLUGIN_REGISTRY_END_OF_LINE_MARKER,
|
||||
tag->mVariants + (tag->mIsNPRuntimeEnabledJavaPlugin ? 1 : 0));
|
||||
@ -5628,7 +5660,7 @@ nsPluginHostImpl::WritePluginInfo()
|
||||
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] : ""),
|
||||
(!tag->mMimeDescriptionArray[i].IsEmpty() ? tag->mMimeDescriptionArray[i].get() : ""),
|
||||
PLUGIN_REGISTRY_FIELD_DELIMITER,
|
||||
(tag->mExtensionsArray && tag->mExtensionsArray[i] ? tag->mExtensionsArray[i] : ""),
|
||||
PLUGIN_REGISTRY_FIELD_DELIMITER,
|
||||
@ -5819,7 +5851,7 @@ nsPluginHostImpl::ReadPluginInfo()
|
||||
(const char* const*)mimetypes,
|
||||
(const char* const*)mimedescriptions,
|
||||
(const char* const*)extensions,
|
||||
mimetypecount, lastmod, canunload);
|
||||
mimetypecount, lastmod, canunload, PR_TRUE);
|
||||
if (heapalloced) {
|
||||
delete [] heapalloced;
|
||||
}
|
||||
@ -5856,8 +5888,7 @@ nsPluginHostImpl::RemoveCachedPluginsInfo(const char *filename, nsPluginTag **re
|
||||
// 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)))
|
||||
if (tag->mFileName.Equals(filename) || tag->mFullPath.Equals(filename))
|
||||
{
|
||||
// Found it. Remove it from our list
|
||||
if (prev)
|
||||
@ -6549,20 +6580,19 @@ nsPluginHostImpl::HandleBadPlugin(PRLibrary* aLibrary, nsIPluginInstance *aInsta
|
||||
return rv;
|
||||
|
||||
// add plugin name to the message
|
||||
char * pluginname = nsnull;
|
||||
nsCString pluginname;
|
||||
nsActivePlugin * p = mActivePluginList.find(aInstance);
|
||||
if (p) {
|
||||
nsPluginTag * tag = p->mPluginTag;
|
||||
if (tag) {
|
||||
if (tag->mName)
|
||||
if (!tag->mName.IsEmpty())
|
||||
pluginname = tag->mName;
|
||||
else
|
||||
pluginname = tag->mFileName;
|
||||
}
|
||||
}
|
||||
|
||||
nsAutoString msg;
|
||||
msg.AssignWithConversion(pluginname);
|
||||
NS_ConvertUTF8toUTF16 msg(pluginname);
|
||||
msg.AppendLiteral("\n\n");
|
||||
msg.Append(message);
|
||||
|
||||
|
@ -68,6 +68,7 @@
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
// XXX this file really doesn't think this is possible, but ...
|
||||
#include "nsIFactory.h"
|
||||
@ -108,7 +109,8 @@ public:
|
||||
const char* const* aExtensions,
|
||||
PRInt32 aVariants,
|
||||
PRInt64 aLastModifiedTime = 0,
|
||||
PRBool aCanUnload = PR_TRUE);
|
||||
PRBool aCanUnload = PR_TRUE,
|
||||
PRBool aArgsAreUTF8 = PR_FALSE);
|
||||
|
||||
~nsPluginTag();
|
||||
|
||||
@ -143,11 +145,11 @@ public:
|
||||
|
||||
nsRefPtr<nsPluginTag> mNext;
|
||||
nsPluginHostImpl *mPluginHost;
|
||||
char *mName;
|
||||
char *mDescription;
|
||||
nsCString mName; // UTF-8
|
||||
nsCString mDescription; // UTF-8
|
||||
PRInt32 mVariants;
|
||||
char **mMimeTypeArray;
|
||||
char **mMimeDescriptionArray;
|
||||
nsTArray<nsCString> mMimeDescriptionArray; // UTF-8
|
||||
char **mExtensionsArray;
|
||||
PRLibrary *mLibrary;
|
||||
nsIPlugin *mEntryPoint;
|
||||
@ -155,11 +157,13 @@ public:
|
||||
PRPackedBool mXPConnected;
|
||||
PRPackedBool mIsJavaPlugin;
|
||||
PRPackedBool mIsNPRuntimeEnabledJavaPlugin;
|
||||
char *mFileName;
|
||||
char *mFullPath;
|
||||
nsCString mFileName; // UTF-8
|
||||
nsCString mFullPath; // UTF-8
|
||||
PRInt64 mLastModifiedTime;
|
||||
private:
|
||||
PRUint32 mFlags;
|
||||
|
||||
nsresult EnsureMembersAreUTF8();
|
||||
};
|
||||
|
||||
struct nsActivePlugin
|
||||
|
Loading…
Reference in New Issue
Block a user