Bug 1550519 - Show a translucent parent highlight when a subgrid is highlighted....
[gecko.git] / dom / base / nsMimeTypeArray.h
bloba6e9078e99a18e5b82f53517ca1246ffca0b46f1
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
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___
10 #include "nsString.h"
11 #include "nsTArray.h"
12 #include "nsWrapperCache.h"
13 #include "nsPIDOMWindow.h"
14 #include "mozilla/dom/BindingDeclarations.h"
16 class nsMimeType;
17 class nsPluginElement;
19 class nsMimeTypeArray final : public nsISupports, public nsWrapperCache {
20 public:
21 explicit nsMimeTypeArray(nsPIDOMWindowInner* aWindow);
23 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
24 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsMimeTypeArray)
26 nsPIDOMWindowInner* GetParentObject() const;
27 virtual JSObject* WrapObject(JSContext* aCx,
28 JS::Handle<JSObject*> aGivenProto) override;
30 void Refresh();
32 // MimeTypeArray WebIDL methods
33 nsMimeType* Item(uint32_t index, mozilla::dom::CallerType aCallerType);
34 nsMimeType* NamedItem(const nsAString& name,
35 mozilla::dom::CallerType aCallerType);
36 nsMimeType* IndexedGetter(uint32_t index, bool& found,
37 mozilla::dom::CallerType aCallerType);
38 nsMimeType* NamedGetter(const nsAString& name, bool& found,
39 mozilla::dom::CallerType aCallerType);
40 uint32_t Length(mozilla::dom::CallerType aCallerType);
41 void GetSupportedNames(nsTArray<nsString>& retval,
42 mozilla::dom::CallerType aCallerType);
44 protected:
45 virtual ~nsMimeTypeArray();
47 void EnsurePluginMimeTypes();
48 void Clear();
50 nsCOMPtr<nsPIDOMWindowInner> mWindow;
52 // mMimeTypes contains MIME types handled by plugins or by an OS
53 // PreferredApplicationHandler.
54 nsTArray<RefPtr<nsMimeType> > mMimeTypes;
55 nsTArray<RefPtr<nsMimeType> > mCTPMimeTypes;
58 class nsMimeType final : public nsWrapperCache {
59 public:
60 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsMimeType)
61 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(nsMimeType)
63 nsMimeType(nsPIDOMWindowInner* aWindow, nsPluginElement* aPluginElement,
64 const nsAString& aType, const nsAString& aDescription,
65 const nsAString& aExtension);
66 nsPIDOMWindowInner* GetParentObject() const;
67 virtual JSObject* WrapObject(JSContext* aCx,
68 JS::Handle<JSObject*> aGivenProto) override;
70 const nsString& Type() const { return mType; }
72 // MimeType WebIDL methods
73 void GetDescription(nsString& retval) const;
74 nsPluginElement* GetEnabledPlugin() const;
75 void GetSuffixes(nsString& retval) const;
76 void GetType(nsString& retval) const;
78 protected:
79 virtual ~nsMimeType();
81 nsCOMPtr<nsPIDOMWindowInner> mWindow;
83 // Strong reference to the active plugin. Note that this creates an explicit
84 // reference cycle through the plugin element's mimetype array. We rely on the
85 // cycle collector to break this cycle.
86 RefPtr<nsPluginElement> mPluginElement;
87 nsString mType;
88 nsString mDescription;
89 nsString mExtension;
92 #endif /* nsMimeTypeArray_h___ */