mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-03 12:35:58 +00:00
Bug 855613. Stop exposing nsIDOMMimeType in nsIPluginTag. r=joshmoz@gmail.com
This commit is contained in:
parent
9aa8e82fee
commit
a577974812
@ -302,7 +302,7 @@ function initPluginsRow() {
|
||||
let mimeTypes = aTag.getMimeTypes();
|
||||
if (mimeTypes.length < 1)
|
||||
return false;
|
||||
let mimeType = mimeTypes[0].type;
|
||||
let mimeType = mimeTypes[0];
|
||||
return (!aTag.disabled && pluginHost.isPluginClickToPlayForType(mimeType));
|
||||
});
|
||||
|
||||
@ -314,7 +314,7 @@ function initPluginsRow() {
|
||||
|
||||
let permissionEntries = [];
|
||||
for (let plugin of tags) {
|
||||
let mimeType = plugin.getMimeTypes()[0].type;
|
||||
let mimeType = plugin.getMimeTypes()[0];
|
||||
let permString = pluginHost.getPermissionStringForType(mimeType);
|
||||
let pluginName = makeNicePluginName(plugin.name)
|
||||
let permEntry = fillInPluginPermissionTemplate(pluginName, permString);
|
||||
|
@ -4,9 +4,8 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
interface nsIDOMMimeType;
|
||||
|
||||
[scriptable, uuid(87b4fcfc-417b-47f6-9c79-dfeb5e5a4840)]
|
||||
[scriptable, uuid(00ea1f72-a57a-49bb-ac57-478902d9228b)]
|
||||
interface nsIPluginTag : nsISupports
|
||||
{
|
||||
// enabledState is stored as one of the following as an integer in prefs,
|
||||
@ -20,11 +19,17 @@ interface nsIPluginTag : nsISupports
|
||||
readonly attribute AUTF8String fullpath;
|
||||
readonly attribute AUTF8String version;
|
||||
readonly attribute AUTF8String name;
|
||||
attribute boolean blocklisted;
|
||||
readonly attribute boolean disabled;
|
||||
readonly attribute boolean clicktoplay;
|
||||
attribute boolean blocklisted;
|
||||
readonly attribute boolean disabled;
|
||||
readonly attribute boolean clicktoplay;
|
||||
attribute unsigned long enabledState;
|
||||
|
||||
void getMimeTypes([optional] out unsigned long aCount,
|
||||
[retval, array, size_is(aCount)] out nsIDOMMimeType aResults);
|
||||
[retval, array, size_is(aCount)] out wstring aResults);
|
||||
void getMimeDescriptions([optional] out unsigned long aCount,
|
||||
[retval, array, size_is(aCount)]
|
||||
out wstring aResults);
|
||||
void getExtensions([optional] out unsigned long aCount,
|
||||
[retval, array, size_is(aCount)]
|
||||
out wstring aResults);
|
||||
};
|
||||
|
@ -74,33 +74,33 @@ NS_IMPL_ISUPPORTS1(DOMMimeTypeImpl, nsIDOMMimeType)
|
||||
/* nsPluginTag */
|
||||
|
||||
nsPluginTag::nsPluginTag(nsPluginTag* aPluginTag)
|
||||
: mName(aPluginTag->mName),
|
||||
mDescription(aPluginTag->mDescription),
|
||||
mMimeTypes(aPluginTag->mMimeTypes),
|
||||
mMimeDescriptions(aPluginTag->mMimeDescriptions),
|
||||
mExtensions(aPluginTag->mExtensions),
|
||||
mLibrary(nullptr),
|
||||
mIsJavaPlugin(aPluginTag->mIsJavaPlugin),
|
||||
mIsFlashPlugin(aPluginTag->mIsFlashPlugin),
|
||||
mFileName(aPluginTag->mFileName),
|
||||
mFullPath(aPluginTag->mFullPath),
|
||||
mVersion(aPluginTag->mVersion),
|
||||
mLastModifiedTime(0),
|
||||
mNiceFileName()
|
||||
: mName(aPluginTag->mName),
|
||||
mDescription(aPluginTag->mDescription),
|
||||
mMimeTypes(aPluginTag->mMimeTypes),
|
||||
mMimeDescriptions(aPluginTag->mMimeDescriptions),
|
||||
mExtensions(aPluginTag->mExtensions),
|
||||
mLibrary(nullptr),
|
||||
mIsJavaPlugin(aPluginTag->mIsJavaPlugin),
|
||||
mIsFlashPlugin(aPluginTag->mIsFlashPlugin),
|
||||
mFileName(aPluginTag->mFileName),
|
||||
mFullPath(aPluginTag->mFullPath),
|
||||
mVersion(aPluginTag->mVersion),
|
||||
mLastModifiedTime(0),
|
||||
mNiceFileName()
|
||||
{
|
||||
}
|
||||
|
||||
nsPluginTag::nsPluginTag(nsPluginInfo* aPluginInfo)
|
||||
: mName(aPluginInfo->fName),
|
||||
mDescription(aPluginInfo->fDescription),
|
||||
mLibrary(nullptr),
|
||||
mIsJavaPlugin(false),
|
||||
mIsFlashPlugin(false),
|
||||
mFileName(aPluginInfo->fFileName),
|
||||
mFullPath(aPluginInfo->fFullPath),
|
||||
mVersion(aPluginInfo->fVersion),
|
||||
mLastModifiedTime(0),
|
||||
mNiceFileName()
|
||||
: mName(aPluginInfo->fName),
|
||||
mDescription(aPluginInfo->fDescription),
|
||||
mLibrary(nullptr),
|
||||
mIsJavaPlugin(false),
|
||||
mIsFlashPlugin(false),
|
||||
mFileName(aPluginInfo->fFileName),
|
||||
mFullPath(aPluginInfo->fFullPath),
|
||||
mVersion(aPluginInfo->fVersion),
|
||||
mLastModifiedTime(0),
|
||||
mNiceFileName()
|
||||
{
|
||||
InitMime(aPluginInfo->fMimeTypeArray,
|
||||
aPluginInfo->fMimeDescriptionArray,
|
||||
@ -120,18 +120,19 @@ nsPluginTag::nsPluginTag(const char* aName,
|
||||
int32_t aVariants,
|
||||
int64_t aLastModifiedTime,
|
||||
bool aArgsAreUTF8)
|
||||
: mName(aName),
|
||||
mDescription(aDescription),
|
||||
mLibrary(nullptr),
|
||||
mIsJavaPlugin(false),
|
||||
mIsFlashPlugin(false),
|
||||
mFileName(aFileName),
|
||||
mFullPath(aFullPath),
|
||||
mVersion(aVersion),
|
||||
mLastModifiedTime(aLastModifiedTime),
|
||||
mNiceFileName()
|
||||
: mName(aName),
|
||||
mDescription(aDescription),
|
||||
mLibrary(nullptr),
|
||||
mIsJavaPlugin(false),
|
||||
mIsFlashPlugin(false),
|
||||
mFileName(aFileName),
|
||||
mFullPath(aFullPath),
|
||||
mVersion(aVersion),
|
||||
mLastModifiedTime(aLastModifiedTime),
|
||||
mNiceFileName()
|
||||
{
|
||||
InitMime(aMimeTypes, aMimeDescriptions, aExtensions, static_cast<uint32_t>(aVariants));
|
||||
InitMime(aMimeTypes, aMimeDescriptions, aExtensions,
|
||||
static_cast<uint32_t>(aVariants));
|
||||
if (!aArgsAreUTF8)
|
||||
EnsureMembersAreUTF8();
|
||||
}
|
||||
@ -431,19 +432,51 @@ nsPluginTag::SetPluginState(PluginState state)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPluginTag::GetMimeTypes(uint32_t* aCount, nsIDOMMimeType*** aResults)
|
||||
nsPluginTag::GetMimeTypes(uint32_t* aCount, PRUnichar*** aResults)
|
||||
{
|
||||
uint32_t count = mMimeTypes.Length();
|
||||
*aResults = static_cast<nsIDOMMimeType**>
|
||||
*aResults = static_cast<PRUnichar**>
|
||||
(nsMemory::Alloc(count * sizeof(**aResults)));
|
||||
if (!*aResults)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aCount = count;
|
||||
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
nsIDOMMimeType* mimeType = new DOMMimeTypeImpl(this, i);
|
||||
(*aResults)[i] = mimeType;
|
||||
NS_ADDREF((*aResults)[i]);
|
||||
(*aResults)[i] = ToNewUnicode(mMimeTypes[i]);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPluginTag::GetMimeDescriptions(uint32_t* aCount, PRUnichar*** aResults)
|
||||
{
|
||||
uint32_t count = mMimeDescriptions.Length();
|
||||
*aResults = static_cast<PRUnichar**>
|
||||
(nsMemory::Alloc(count * sizeof(**aResults)));
|
||||
if (!*aResults)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aCount = count;
|
||||
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
(*aResults)[i] = ToNewUnicode(mMimeDescriptions[i]);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPluginTag::GetExtensions(uint32_t* aCount, PRUnichar*** aResults)
|
||||
{
|
||||
uint32_t count = mExtensions.Length();
|
||||
*aResults = static_cast<PRUnichar**>
|
||||
(nsMemory::Alloc(count * sizeof(**aResults)));
|
||||
if (!*aResults)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aCount = count;
|
||||
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
(*aResults)[i] = ToNewUnicode(mExtensions[i]);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -37,7 +37,7 @@
|
||||
ok(tagTestPlugin, "plugin tags should have Test Plug-in");
|
||||
var mimeType = tagTestPlugin.getMimeTypes()[0];
|
||||
ok(mimeType, "should have a MIME type for Test Plug-in");
|
||||
ok(navigator.mimeTypes[mimeType.type], "navigator.mimeTypes should have an entry for '" + mimeType.type + "'");
|
||||
ok(navigator.mimeTypes[mimeType], "navigator.mimeTypes should have an entry for '" + mimeType + "'");
|
||||
ok(!tagTestPlugin.disabled, "test plugin should not be disabled");
|
||||
|
||||
nextTest = testPart2;
|
||||
@ -46,7 +46,7 @@
|
||||
function testPart2() {
|
||||
var navTestPlugin = navigator.plugins.namedItem("Test Plug-in");
|
||||
ok(!navTestPlugin, "now navigator.plugins should not have Test Plug-in");
|
||||
ok(!navigator.mimeTypes[mimeType.type], "now navigator.mimeTypes should not have an entry for '" + mimeType.type + "'");
|
||||
ok(!navigator.mimeTypes[mimeType], "now navigator.mimeTypes should not have an entry for '" + mimeType + "'");
|
||||
|
||||
nextTest = testPart3;
|
||||
tagTestPlugin.enabledState = Components.interfaces.nsIPluginTag.STATE_ENABLED;
|
||||
@ -54,7 +54,7 @@
|
||||
|
||||
function testPart3() {
|
||||
ok(navTestPlugin, "now navigator.plugins should have Test Plug-in again");
|
||||
ok(navigator.mimeTypes[mimeType.type], "now navigator.mimeTypes should have an entry for '" + mimeType.type + "' again");
|
||||
ok(navigator.mimeTypes[mimeType], "now navigator.mimeTypes should have an entry for '" + mimeType + "' again");
|
||||
obsService.removeObserver(observer, "plugin-info-updated");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
@ -402,9 +402,19 @@ function PluginWrapper(aId, aName, aDescription, aTags) {
|
||||
|
||||
this.__defineGetter__("pluginMimeTypes", function() {
|
||||
let types = [];
|
||||
for (let tag of aTags)
|
||||
for (let type of tag.getMimeTypes({}))
|
||||
for (let tag of aTags) {
|
||||
let mimeTypes = tag.getMimeTypes({});
|
||||
let mimeDescriptions = tag.getMimeDescriptions({});
|
||||
let extensions = tag.getExtensions({});
|
||||
for (let i = 0; i < mimeTypes.length; i++) {
|
||||
let type = {};
|
||||
type.type = mimeTypes[i];
|
||||
type.description = mimeDescriptions[i];
|
||||
type.suffixes = extensions[i];
|
||||
|
||||
types.push(type);
|
||||
}
|
||||
}
|
||||
return types;
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user