1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 sw=2 et tw=79: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsMimeTypeArray_h___
8 #define nsMimeTypeArray_h___
12 #include "nsWrapperCache.h"
13 #include "nsAutoPtr.h"
14 #include "nsPIDOMWindow.h"
17 class nsPluginElement
;
19 class nsMimeTypeArray MOZ_FINAL
: public nsISupports
,
23 explicit nsMimeTypeArray(nsPIDOMWindow
* aWindow
);
25 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
26 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsMimeTypeArray
)
28 nsPIDOMWindow
* GetParentObject() const;
29 virtual JSObject
* WrapObject(JSContext
* aCx
) MOZ_OVERRIDE
;
33 // MimeTypeArray WebIDL methods
34 nsMimeType
* Item(uint32_t index
);
35 nsMimeType
* NamedItem(const nsAString
& name
);
36 nsMimeType
* IndexedGetter(uint32_t index
, bool &found
);
37 nsMimeType
* NamedGetter(const nsAString
& name
, bool &found
);
38 bool NameIsEnumerable(const nsAString
& name
);
40 void GetSupportedNames(unsigned, nsTArray
< nsString
>& retval
);
43 virtual ~nsMimeTypeArray();
45 void EnsurePluginMimeTypes();
48 nsCOMPtr
<nsPIDOMWindow
> mWindow
;
50 // mMimeTypes contains MIME types handled by non-hidden plugins, those
51 // popular plugins that must be exposed in navigator.plugins enumeration to
52 // avoid breaking web content. Likewise, mMimeTypes are exposed in
53 // navigator.mimeTypes enumeration.
54 nsTArray
<nsRefPtr
<nsMimeType
> > mMimeTypes
;
56 // mHiddenMimeTypes contains MIME types handled by plugins hidden from
57 // navigator.plugins enumeration or by an OS PreferredApplicationHandler.
58 // mHiddenMimeTypes are hidden from navigator.mimeTypes enumeration.
59 nsTArray
<nsRefPtr
<nsMimeType
> > mHiddenMimeTypes
;
62 class nsMimeType MOZ_FINAL
: public nsWrapperCache
65 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsMimeType
)
66 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(nsMimeType
)
68 nsMimeType(nsPIDOMWindow
* aWindow
, nsPluginElement
* aPluginElement
,
69 uint32_t aPluginTagMimeIndex
, const nsAString
& aMimeType
);
70 nsMimeType(nsPIDOMWindow
* aWindow
, const nsAString
& aMimeType
);
71 nsPIDOMWindow
* GetParentObject() const;
72 virtual JSObject
* WrapObject(JSContext
* aCx
) MOZ_OVERRIDE
;
74 const nsString
& Type() const
79 // MimeType WebIDL methods
80 void GetDescription(nsString
& retval
) const;
81 nsPluginElement
*GetEnabledPlugin() const;
82 void GetSuffixes(nsString
& retval
) const;
83 void GetType(nsString
& retval
) const;
86 virtual ~nsMimeType();
88 nsCOMPtr
<nsPIDOMWindow
> mWindow
;
90 // Strong reference to the active plugin, if any. Note that this
91 // creates an explicit reference cycle through the plugin element's
92 // mimetype array. We rely on the cycle collector to break this
94 nsRefPtr
<nsPluginElement
> mPluginElement
;
95 uint32_t mPluginTagMimeIndex
;
99 #endif /* nsMimeTypeArray_h___ */