2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nsPluginArray.h"
|
2013-08-13 23:56:21 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
#include "mozilla/dom/PluginArrayBinding.h"
|
|
|
|
#include "mozilla/dom/PluginBinding.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsMimeTypeArray.h"
|
2011-11-02 06:44:16 -07:00
|
|
|
#include "Navigator.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIDocShell.h"
|
|
|
|
#include "nsIWebNavigation.h"
|
2011-05-21 06:28:54 -07:00
|
|
|
#include "nsPluginHost.h"
|
2013-07-09 06:58:21 -07:00
|
|
|
#include "nsPluginTags.h"
|
2013-04-10 13:59:45 -07:00
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "nsIWeakReference.h"
|
|
|
|
#include "mozilla/Services.h"
|
2013-07-09 06:58:21 -07:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-11-02 06:44:16 -07:00
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2013-08-28 13:55:29 -07:00
|
|
|
nsPluginArray::nsPluginArray(nsPIDOMWindow* aWindow)
|
2013-07-09 06:58:21 -07:00
|
|
|
: mWindow(aWindow)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-07-09 06:58:21 -07:00
|
|
|
SetIsDOMBinding();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-04-10 13:59:45 -07:00
|
|
|
void
|
|
|
|
nsPluginArray::Init()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIObserverService> obsService =
|
|
|
|
mozilla::services::GetObserverService();
|
|
|
|
if (obsService) {
|
|
|
|
obsService->AddObserver(this, "plugin-info-updated", true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsPluginArray::~nsPluginArray()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
nsPIDOMWindow*
|
|
|
|
nsPluginArray::GetParentObject() const
|
|
|
|
{
|
2013-08-28 13:55:29 -07:00
|
|
|
MOZ_ASSERT(mWindow);
|
|
|
|
return mWindow;
|
2013-07-09 06:58:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
JSObject*
|
|
|
|
nsPluginArray::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
|
|
|
{
|
|
|
|
return PluginArrayBinding::Wrap(aCx, aScope, this);
|
|
|
|
}
|
2010-01-12 05:08:43 -08:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsPluginArray)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsPluginArray)
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsPluginArray)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIObserver)
|
2013-04-10 13:59:45 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2013-08-28 13:55:29 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_2(nsPluginArray,
|
|
|
|
mWindow,
|
2013-07-09 06:58:21 -07:00
|
|
|
mPlugins)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
void
|
|
|
|
nsPluginArray::GetPlugins(nsTArray<nsRefPtr<nsPluginElement> >& aPlugins)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-07-09 06:58:21 -07:00
|
|
|
aPlugins.Clear();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
if (!AllowPlugins()) {
|
|
|
|
return;
|
|
|
|
}
|
2011-12-01 00:28:16 -08:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
if (mPlugins.IsEmpty()) {
|
|
|
|
EnsurePlugins();
|
2012-08-20 11:34:32 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
aPlugins = mPlugins;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
nsPluginElement*
|
|
|
|
nsPluginArray::Item(uint32_t aIndex)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-07-09 06:58:21 -07:00
|
|
|
bool unused;
|
|
|
|
return IndexedGetter(aIndex, unused);
|
2008-10-22 07:31:14 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
nsPluginElement*
|
|
|
|
nsPluginArray::NamedItem(const nsAString& aName)
|
2008-10-22 07:31:14 -07:00
|
|
|
{
|
2013-07-09 06:58:21 -07:00
|
|
|
bool unused;
|
|
|
|
return NamedGetter(aName, unused);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
void
|
|
|
|
nsPluginArray::Refresh(bool aReloadDocuments)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-07-09 06:58:21 -07:00
|
|
|
nsRefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
if(!AllowPlugins() || !pluginHost) {
|
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
// NS_ERROR_PLUGINS_PLUGINSNOTCHANGED on reloading plugins indicates
|
|
|
|
// that plugins did not change and was not reloaded
|
|
|
|
if (pluginHost->ReloadPlugins() ==
|
|
|
|
NS_ERROR_PLUGINS_PLUGINSNOTCHANGED) {
|
|
|
|
nsTArray<nsRefPtr<nsPluginTag> > newPluginTags;
|
|
|
|
pluginHost->GetPlugins(newPluginTags);
|
|
|
|
|
|
|
|
// Check if the number of plugins we know about are different from
|
|
|
|
// the number of plugin tags the plugin host knows about. If the
|
|
|
|
// lengths are different, we refresh. This is safe because we're
|
|
|
|
// notified for every plugin enabling/disabling event that
|
|
|
|
// happens, and therefore the lengths will be in sync only when
|
|
|
|
// the both arrays contain the same plugin tags (though as
|
|
|
|
// different types).
|
|
|
|
if (newPluginTags.Length() == mPlugins.Length()) {
|
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
mPlugins.Clear();
|
2008-10-31 14:40:35 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
nsCOMPtr<nsIDOMNavigator> navigator;
|
2013-08-28 13:55:29 -07:00
|
|
|
mWindow->GetNavigator(getter_AddRefs(navigator));
|
2008-10-31 14:40:35 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
if (!navigator) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static_cast<mozilla::dom::Navigator*>(navigator.get())->RefreshMIMEArray();
|
2008-10-31 14:40:35 -07:00
|
|
|
|
2013-08-28 13:55:29 -07:00
|
|
|
nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(mWindow);
|
2013-07-09 06:58:21 -07:00
|
|
|
if (aReloadDocuments && webNav) {
|
|
|
|
webNav->Reload(nsIWebNavigation::LOAD_FLAGS_NONE);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
nsPluginElement*
|
|
|
|
nsPluginArray::IndexedGetter(uint32_t aIndex, bool &aFound)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-07-09 06:58:21 -07:00
|
|
|
aFound = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
if (!AllowPlugins()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
if (mPlugins.IsEmpty()) {
|
|
|
|
EnsurePlugins();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
aFound = aIndex < mPlugins.Length();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
return aFound ? mPlugins[aIndex] : nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-08-12 21:05:05 -07:00
|
|
|
void
|
|
|
|
nsPluginArray::Invalidate()
|
|
|
|
{
|
2013-04-10 13:59:45 -07:00
|
|
|
nsCOMPtr<nsIObserverService> obsService =
|
|
|
|
mozilla::services::GetObserverService();
|
|
|
|
if (obsService) {
|
|
|
|
obsService->RemoveObserver(this, "plugin-info-updated");
|
|
|
|
}
|
2010-08-12 21:05:05 -07:00
|
|
|
}
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
nsPluginElement*
|
|
|
|
nsPluginArray::NamedGetter(const nsAString& aName, bool &aFound)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-07-09 06:58:21 -07:00
|
|
|
aFound = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
if (!AllowPlugins()) {
|
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
if (mPlugins.IsEmpty()) {
|
|
|
|
EnsurePlugins();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
for (uint32_t i = 0; i < mPlugins.Length(); ++i) {
|
|
|
|
nsAutoString pluginName;
|
|
|
|
nsPluginElement* plugin = mPlugins[i];
|
|
|
|
plugin->GetName(pluginName);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
if (pluginName.Equals(aName)) {
|
|
|
|
aFound = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
return plugin;
|
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
return nullptr;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
uint32_t
|
|
|
|
nsPluginArray::Length()
|
|
|
|
{
|
|
|
|
if (!AllowPlugins()) {
|
|
|
|
return 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
if (mPlugins.IsEmpty()) {
|
|
|
|
EnsurePlugins();
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
return mPlugins.Length();
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
void
|
|
|
|
nsPluginArray::GetSupportedNames(nsTArray< nsString >& aRetval)
|
|
|
|
{
|
|
|
|
aRetval.Clear();
|
|
|
|
|
|
|
|
if (!AllowPlugins()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < mPlugins.Length(); ++i) {
|
|
|
|
nsAutoString pluginName;
|
|
|
|
mPlugins[i]->GetName(pluginName);
|
|
|
|
|
|
|
|
aRetval.AppendElement(pluginName);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-10 13:59:45 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPluginArray::Observe(nsISupports *aSubject, const char *aTopic,
|
|
|
|
const PRUnichar *aData) {
|
|
|
|
if (!nsCRT::strcmp(aTopic, "plugin-info-updated")) {
|
|
|
|
Refresh(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
bool
|
|
|
|
nsPluginArray::AllowPlugins() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-08-28 13:55:29 -07:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(mWindow);
|
2013-07-09 06:58:21 -07:00
|
|
|
|
|
|
|
return docShell && docShell->PluginsAllowedInCurrentDoc();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
void
|
|
|
|
nsPluginArray::EnsurePlugins()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-07-09 06:58:21 -07:00
|
|
|
nsRefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
if (!mPlugins.IsEmpty() || !pluginHost) {
|
|
|
|
// We already have an array of plugin elements, or no plugin host
|
|
|
|
|
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
nsTArray<nsRefPtr<nsPluginTag> > pluginTags;
|
|
|
|
pluginHost->GetPlugins(pluginTags);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
// need to wrap each of these with a nsPluginElement, which is
|
|
|
|
// scriptable.
|
|
|
|
for (uint32_t i = 0; i < pluginTags.Length(); ++i) {
|
|
|
|
mPlugins.AppendElement(new nsPluginElement(mWindow, pluginTags[i]));
|
|
|
|
}
|
|
|
|
}
|
2010-01-12 05:08:43 -08:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
// nsPluginElement implementation.
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsPluginElement)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsPluginElement)
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsPluginElement)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2013-08-28 13:55:29 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_2(nsPluginElement, mWindow, mMimeTypes)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-08-28 13:55:29 -07:00
|
|
|
nsPluginElement::nsPluginElement(nsPIDOMWindow* aWindow,
|
2013-07-09 06:58:21 -07:00
|
|
|
nsPluginTag* aPluginTag)
|
|
|
|
: mWindow(aWindow),
|
|
|
|
mPluginTag(aPluginTag)
|
|
|
|
{
|
|
|
|
SetIsDOMBinding();
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
nsPIDOMWindow*
|
|
|
|
nsPluginElement::GetParentObject() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-08-28 13:55:29 -07:00
|
|
|
MOZ_ASSERT(mWindow);
|
|
|
|
return mWindow;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
JSObject*
|
|
|
|
nsPluginElement::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
2009-04-22 12:13:10 -07:00
|
|
|
{
|
2013-07-09 06:58:21 -07:00
|
|
|
return PluginBinding::Wrap(aCx, aScope, this);
|
2009-04-22 12:13:10 -07:00
|
|
|
}
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
void
|
|
|
|
nsPluginElement::GetDescription(nsString& retval) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-07-09 06:58:21 -07:00
|
|
|
CopyUTF8toUTF16(mPluginTag->mDescription, retval);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
void
|
|
|
|
nsPluginElement::GetFilename(nsString& retval) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-07-09 06:58:21 -07:00
|
|
|
CopyUTF8toUTF16(mPluginTag->mFileName, retval);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
void
|
|
|
|
nsPluginElement::GetVersion(nsString& retval) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-07-09 06:58:21 -07:00
|
|
|
CopyUTF8toUTF16(mPluginTag->mVersion, retval);
|
|
|
|
}
|
2008-10-22 07:31:14 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
void
|
|
|
|
nsPluginElement::GetName(nsString& retval) const
|
|
|
|
{
|
|
|
|
CopyUTF8toUTF16(mPluginTag->mName, retval);
|
|
|
|
}
|
2008-10-22 07:31:14 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
nsMimeType*
|
|
|
|
nsPluginElement::Item(uint32_t aIndex)
|
|
|
|
{
|
|
|
|
EnsureMimeTypes();
|
2008-10-22 07:31:14 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
return mMimeTypes.SafeElementAt(aIndex);
|
|
|
|
}
|
2008-10-22 07:31:14 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
nsMimeType*
|
|
|
|
nsPluginElement::NamedItem(const nsAString& aName)
|
|
|
|
{
|
|
|
|
bool unused;
|
|
|
|
return NamedGetter(aName, unused);
|
2008-10-22 07:31:14 -07:00
|
|
|
}
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
nsMimeType*
|
|
|
|
nsPluginElement::IndexedGetter(uint32_t aIndex, bool &aFound)
|
2008-10-22 07:31:14 -07:00
|
|
|
{
|
2013-07-09 06:58:21 -07:00
|
|
|
EnsureMimeTypes();
|
2008-10-22 07:31:14 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
aFound = aIndex < mMimeTypes.Length();
|
2008-10-22 07:31:14 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
return aFound ? mMimeTypes[aIndex] : nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
nsMimeType*
|
|
|
|
nsPluginElement::NamedGetter(const nsAString& aName, bool &aFound)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-07-09 06:58:21 -07:00
|
|
|
EnsureMimeTypes();
|
|
|
|
|
|
|
|
aFound = false;
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < mMimeTypes.Length(); ++i) {
|
|
|
|
if (mMimeTypes[i]->Type().Equals(aName)) {
|
|
|
|
aFound = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
return mMimeTypes[i];
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2008-10-31 14:40:35 -07:00
|
|
|
}
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
uint32_t
|
|
|
|
nsPluginElement::Length()
|
2008-10-31 14:40:35 -07:00
|
|
|
{
|
2013-07-09 06:58:21 -07:00
|
|
|
EnsureMimeTypes();
|
2008-10-31 14:40:35 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
return mMimeTypes.Length();
|
|
|
|
}
|
2008-10-31 14:40:35 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
void
|
|
|
|
nsPluginElement::GetSupportedNames(nsTArray< nsString >& retval)
|
|
|
|
{
|
|
|
|
EnsureMimeTypes();
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < mMimeTypes.Length(); ++i) {
|
|
|
|
retval.AppendElement(mMimeTypes[i]->Type());
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
nsTArray<nsRefPtr<nsMimeType> >&
|
|
|
|
nsPluginElement::MimeTypes()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-07-09 06:58:21 -07:00
|
|
|
EnsureMimeTypes();
|
|
|
|
|
|
|
|
return mMimeTypes;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsPluginElement::EnsureMimeTypes()
|
|
|
|
{
|
|
|
|
if (!mMimeTypes.IsEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < mPluginTag->mMimeTypes.Length(); ++i) {
|
|
|
|
NS_ConvertUTF8toUTF16 type(mPluginTag->mMimeTypes[i]);
|
|
|
|
mMimeTypes.AppendElement(new nsMimeType(mWindow, this, i, type));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|