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
|
|
|
|
|
|
|
#ifndef nsPluginArray_h___
|
|
|
|
#define nsPluginArray_h___
|
|
|
|
|
2011-05-21 06:28:54 -07:00
|
|
|
#include "nsCOMPtr.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIDOMPluginArray.h"
|
|
|
|
#include "nsIDOMPlugin.h"
|
|
|
|
#include "nsIPluginHost.h"
|
|
|
|
#include "nsIURL.h"
|
2011-12-01 00:28:16 -08:00
|
|
|
#include "nsWeakReference.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-11-02 06:44:16 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class Navigator;
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsIDocShell;
|
|
|
|
|
2011-11-02 06:44:16 -07:00
|
|
|
// NB: Due to weak references, Navigator has intimate knowledge of our
|
2010-08-12 21:05:05 -07:00
|
|
|
// internals.
|
2008-09-05 14:54:53 -07:00
|
|
|
class nsPluginArray : public nsIDOMPluginArray
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2011-11-02 06:44:16 -07:00
|
|
|
nsPluginArray(mozilla::dom::Navigator* navigator, nsIDocShell *aDocShell);
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual ~nsPluginArray();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
// nsIDOMPluginArray
|
|
|
|
NS_DECL_NSIDOMPLUGINARRAY
|
|
|
|
|
|
|
|
nsresult GetPluginHost(nsIPluginHost** aPluginHost);
|
|
|
|
|
2008-10-22 07:31:14 -07:00
|
|
|
nsIDOMPlugin* GetItemAt(PRUint32 aIndex, nsresult* aResult);
|
2008-10-31 14:40:35 -07:00
|
|
|
nsIDOMPlugin* GetNamedItem(const nsAString& aName, nsresult* aResult);
|
2008-10-22 07:31:14 -07:00
|
|
|
|
|
|
|
static nsPluginArray* FromSupports(nsISupports* aSupports)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMPluginArray> array_qi = do_QueryInterface(aSupports);
|
|
|
|
|
|
|
|
// If this assertion fires the QI implementation for the object in
|
|
|
|
// question doesn't use the nsIDOMPluginArray pointer as the nsISupports
|
|
|
|
// pointer. That must be fixed, or we'll crash...
|
|
|
|
NS_ASSERTION(array_qi == static_cast<nsIDOMPluginArray*>(aSupports),
|
|
|
|
"Uh, fix QI!");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return static_cast<nsPluginArray*>(aSupports);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
|
|
|
nsresult GetPlugins();
|
2011-09-28 23:19:26 -07:00
|
|
|
bool AllowPlugins();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
public:
|
2010-08-12 21:05:05 -07:00
|
|
|
void Invalidate();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
protected:
|
2011-11-02 06:44:16 -07:00
|
|
|
mozilla::dom::Navigator* mNavigator;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIPluginHost> mPluginHost;
|
|
|
|
PRUint32 mPluginCount;
|
|
|
|
nsIDOMPlugin** mPluginArray;
|
2011-12-01 00:28:16 -08:00
|
|
|
nsWeakPtr mDocShell;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class nsPluginElement : public nsIDOMPlugin
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsPluginElement(nsIDOMPlugin* plugin);
|
|
|
|
virtual ~nsPluginElement();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIDOMPLUGIN
|
|
|
|
|
2008-10-22 07:31:14 -07:00
|
|
|
nsIDOMMimeType* GetItemAt(PRUint32 aIndex, nsresult* aResult);
|
2008-10-31 14:40:35 -07:00
|
|
|
nsIDOMMimeType* GetNamedItem(const nsAString& aName, nsresult* aResult);
|
2008-10-22 07:31:14 -07:00
|
|
|
|
|
|
|
static nsPluginElement* FromSupports(nsISupports* aSupports)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMPlugin> plugin_qi = do_QueryInterface(aSupports);
|
|
|
|
|
|
|
|
// If this assertion fires the QI implementation for the object in
|
|
|
|
// question doesn't use the nsIDOMPlugin pointer as the nsISupports
|
|
|
|
// pointer. That must be fixed, or we'll crash...
|
|
|
|
NS_ASSERTION(plugin_qi == static_cast<nsIDOMPlugin*>(aSupports),
|
|
|
|
"Uh, fix QI!");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return static_cast<nsPluginElement*>(aSupports);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
|
|
|
nsresult GetMimeTypes();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
nsIDOMPlugin* mPlugin;
|
|
|
|
PRUint32 mMimeTypeCount;
|
|
|
|
nsIDOMMimeType** mMimeTypeArray;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsPluginArray_h___ */
|