1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/base/nsMimeTypeArray.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,98 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=2 sw=2 et tw=79: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef nsMimeTypeArray_h___ 1.11 +#define nsMimeTypeArray_h___ 1.12 + 1.13 +#include "nsString.h" 1.14 +#include "nsTArray.h" 1.15 +#include "nsWrapperCache.h" 1.16 +#include "nsAutoPtr.h" 1.17 +#include "nsPIDOMWindow.h" 1.18 + 1.19 +class nsMimeType; 1.20 +class nsPluginElement; 1.21 + 1.22 +class nsMimeTypeArray MOZ_FINAL : public nsISupports, 1.23 + public nsWrapperCache 1.24 +{ 1.25 +public: 1.26 + nsMimeTypeArray(nsPIDOMWindow* aWindow); 1.27 + virtual ~nsMimeTypeArray(); 1.28 + 1.29 + NS_DECL_CYCLE_COLLECTING_ISUPPORTS 1.30 + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsMimeTypeArray) 1.31 + 1.32 + nsPIDOMWindow* GetParentObject() const; 1.33 + virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; 1.34 + 1.35 + void Refresh(); 1.36 + 1.37 + // MimeTypeArray WebIDL methods 1.38 + nsMimeType* Item(uint32_t index); 1.39 + nsMimeType* NamedItem(const nsAString& name); 1.40 + nsMimeType* IndexedGetter(uint32_t index, bool &found); 1.41 + nsMimeType* NamedGetter(const nsAString& name, bool &found); 1.42 + bool NameIsEnumerable(const nsAString& name); 1.43 + uint32_t Length(); 1.44 + void GetSupportedNames(unsigned, nsTArray< nsString >& retval); 1.45 + 1.46 +protected: 1.47 + void EnsurePluginMimeTypes(); 1.48 + void Clear(); 1.49 + 1.50 + nsCOMPtr<nsPIDOMWindow> mWindow; 1.51 + 1.52 + // mMimeTypes contains MIME types handled by non-hidden plugins, those 1.53 + // popular plugins that must be exposed in navigator.plugins enumeration to 1.54 + // avoid breaking web content. Likewise, mMimeTypes are exposed in 1.55 + // navigator.mimeTypes enumeration. 1.56 + nsTArray<nsRefPtr<nsMimeType> > mMimeTypes; 1.57 + 1.58 + // mHiddenMimeTypes contains MIME types handled by plugins hidden from 1.59 + // navigator.plugins enumeration or by an OS PreferredApplicationHandler. 1.60 + // mHiddenMimeTypes are hidden from navigator.mimeTypes enumeration. 1.61 + nsTArray<nsRefPtr<nsMimeType> > mHiddenMimeTypes; 1.62 +}; 1.63 + 1.64 +class nsMimeType MOZ_FINAL : public nsWrapperCache 1.65 +{ 1.66 +public: 1.67 + NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsMimeType) 1.68 + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(nsMimeType) 1.69 + 1.70 + nsMimeType(nsPIDOMWindow* aWindow, nsPluginElement* aPluginElement, 1.71 + uint32_t aPluginTagMimeIndex, const nsAString& aMimeType); 1.72 + nsMimeType(nsPIDOMWindow* aWindow, const nsAString& aMimeType); 1.73 + virtual ~nsMimeType(); 1.74 + 1.75 + nsPIDOMWindow* GetParentObject() const; 1.76 + virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; 1.77 + 1.78 + const nsString& Type() const 1.79 + { 1.80 + return mType; 1.81 + } 1.82 + 1.83 + // MimeType WebIDL methods 1.84 + void GetDescription(nsString& retval) const; 1.85 + nsPluginElement *GetEnabledPlugin() const; 1.86 + void GetSuffixes(nsString& retval) const; 1.87 + void GetType(nsString& retval) const; 1.88 + 1.89 +protected: 1.90 + nsCOMPtr<nsPIDOMWindow> mWindow; 1.91 + 1.92 + // Strong reference to the active plugin, if any. Note that this 1.93 + // creates an explicit reference cycle through the plugin element's 1.94 + // mimetype array. We rely on the cycle collector to break this 1.95 + // cycle. 1.96 + nsRefPtr<nsPluginElement> mPluginElement; 1.97 + uint32_t mPluginTagMimeIndex; 1.98 + nsString mType; 1.99 +}; 1.100 + 1.101 +#endif /* nsMimeTypeArray_h___ */