2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04: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/. */
|
1999-04-20 23:18:51 +04:00
|
|
|
|
|
|
|
#ifndef nsMimeTypeArray_h___
|
|
|
|
#define nsMimeTypeArray_h___
|
|
|
|
|
2004-02-19 05:44:03 +03:00
|
|
|
#include "nsString.h"
|
2013-07-09 17:58:21 +04:00
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsWrapperCache.h"
|
2013-08-23 09:17:11 +04:00
|
|
|
#include "nsPIDOMWindow.h"
|
2016-12-17 08:25:52 +03:00
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
1999-04-20 23:18:51 +04:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
class nsMimeType;
|
2013-08-15 22:17:48 +04:00
|
|
|
class nsPluginElement;
|
1999-04-20 23:18:51 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsMimeTypeArray final : public nsISupports, public nsWrapperCache {
|
1999-04-20 23:18:51 +04:00
|
|
|
public:
|
2016-01-30 20:05:36 +03:00
|
|
|
explicit nsMimeTypeArray(nsPIDOMWindowInner* aWindow);
|
1999-04-20 23:18:51 +04:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsMimeTypeArray)
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPIDOMWindowInner* GetParentObject() const;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
1999-04-20 23:18:51 +04:00
|
|
|
|
2011-12-01 12:28:16 +04:00
|
|
|
void Refresh();
|
1999-04-20 23:18:51 +04:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
// MimeTypeArray WebIDL methods
|
2016-12-17 08:25:52 +03:00
|
|
|
nsMimeType* Item(uint32_t index, mozilla::dom::CallerType aCallerType);
|
|
|
|
nsMimeType* NamedItem(const nsAString& name,
|
|
|
|
mozilla::dom::CallerType aCallerType);
|
|
|
|
nsMimeType* IndexedGetter(uint32_t index, bool& found,
|
|
|
|
mozilla::dom::CallerType aCallerType);
|
|
|
|
nsMimeType* NamedGetter(const nsAString& name, bool& found,
|
|
|
|
mozilla::dom::CallerType aCallerType);
|
|
|
|
uint32_t Length(mozilla::dom::CallerType aCallerType);
|
2016-12-17 08:25:52 +03:00
|
|
|
void GetSupportedNames(nsTArray<nsString>& retval,
|
|
|
|
mozilla::dom::CallerType aCallerType);
|
2008-10-22 18:31:14 +04:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
protected:
|
2014-06-23 23:56:07 +04:00
|
|
|
virtual ~nsMimeTypeArray();
|
|
|
|
|
2013-10-20 11:05:05 +04:00
|
|
|
void EnsurePluginMimeTypes();
|
2013-07-09 17:58:21 +04:00
|
|
|
void Clear();
|
2008-10-22 18:31:14 +04:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowInner> mWindow;
|
2010-08-13 08:05:05 +04:00
|
|
|
|
2015-05-30 08:42:23 +03:00
|
|
|
// mMimeTypes contains MIME types handled by plugins or by an OS
|
|
|
|
// PreferredApplicationHandler.
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<nsMimeType> > mMimeTypes;
|
2016-07-28 00:45:48 +03:00
|
|
|
nsTArray<RefPtr<nsMimeType> > mCTPMimeTypes;
|
1999-04-20 23:18:51 +04:00
|
|
|
};
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsMimeType final : public nsWrapperCache {
|
1999-04-20 23:18:51 +04:00
|
|
|
public:
|
2013-07-09 17:58:21 +04:00
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsMimeType)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(nsMimeType)
|
1999-04-20 23:18:51 +04:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsMimeType(nsPIDOMWindowInner* aWindow, nsPluginElement* aPluginElement,
|
2015-05-20 16:30:05 +03:00
|
|
|
const nsAString& aType, const nsAString& aDescription,
|
|
|
|
const nsAString& aExtension);
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPIDOMWindowInner* GetParentObject() const;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
2003-02-27 02:54:55 +03:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
const nsString& Type() const { return mType; }
|
2003-02-27 02:54:55 +03:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
// MimeType WebIDL methods
|
|
|
|
void GetDescription(nsString& retval) const;
|
|
|
|
nsPluginElement* GetEnabledPlugin() const;
|
|
|
|
void GetSuffixes(nsString& retval) const;
|
|
|
|
void GetType(nsString& retval) const;
|
|
|
|
|
|
|
|
protected:
|
2014-06-23 23:56:07 +04:00
|
|
|
virtual ~nsMimeType();
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowInner> mWindow;
|
2013-07-09 17:58:21 +04:00
|
|
|
|
2016-03-21 18:01:49 +03:00
|
|
|
// Strong reference to the active plugin. Note that this creates an explicit
|
|
|
|
// reference cycle through the plugin element's mimetype array. We rely on the
|
|
|
|
// cycle collector to break this cycle.
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsPluginElement> mPluginElement;
|
2007-01-25 02:31:12 +03:00
|
|
|
nsString mType;
|
2015-05-20 16:30:05 +03:00
|
|
|
nsString mDescription;
|
|
|
|
nsString mExtension;
|
1999-04-20 23:18:51 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsMimeTypeArray_h___ */
|