2001-09-26 02:43:09 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2010-08-13 08:05:05 +04:00
|
|
|
/* vim: set ts=2 sw=2 et tw=79: */
|
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___
|
|
|
|
|
|
|
|
#include "nsIDOMMimeTypeArray.h"
|
|
|
|
#include "nsIDOMMimeType.h"
|
2004-02-19 05:44:03 +03:00
|
|
|
#include "nsString.h"
|
2003-02-27 02:54:55 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2008-11-01 00:40:35 +03:00
|
|
|
#include "nsCOMArray.h"
|
1999-04-20 23:18:51 +04:00
|
|
|
|
|
|
|
class nsIDOMNavigator;
|
|
|
|
|
2010-08-13 08:05:05 +04:00
|
|
|
// NB: Due to weak references, nsNavigator has intimate knowledge of our
|
|
|
|
// members.
|
2004-12-10 22:48:22 +03:00
|
|
|
class nsMimeTypeArray : public nsIDOMMimeTypeArray
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
{
|
1999-04-20 23:18:51 +04:00
|
|
|
public:
|
2007-01-25 02:31:12 +03:00
|
|
|
nsMimeTypeArray(nsIDOMNavigator* navigator);
|
|
|
|
virtual ~nsMimeTypeArray();
|
1999-04-20 23:18:51 +04:00
|
|
|
|
2007-01-25 02:31:12 +03:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIDOMMIMETYPEARRAY
|
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
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
nsIDOMMimeType* GetItemAt(uint32_t aIndex, nsresult* aResult);
|
2008-11-01 00:40:35 +03:00
|
|
|
nsIDOMMimeType* GetNamedItem(const nsAString& aName, nsresult* aResult);
|
2008-10-22 18:31:14 +04:00
|
|
|
|
|
|
|
static nsMimeTypeArray* FromSupports(nsISupports* aSupports)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMMimeTypeArray> array_qi = do_QueryInterface(aSupports);
|
|
|
|
|
|
|
|
// If this assertion fires the QI implementation for the object in
|
|
|
|
// question doesn't use the nsIDOMMimeTypeArray pointer as the nsISupports
|
|
|
|
// pointer. That must be fixed, or we'll crash...
|
|
|
|
NS_ASSERTION(array_qi == static_cast<nsIDOMMimeTypeArray*>(aSupports),
|
|
|
|
"Uh, fix QI!");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return static_cast<nsMimeTypeArray*>(aSupports);
|
|
|
|
}
|
|
|
|
|
2010-08-13 08:05:05 +04:00
|
|
|
void Invalidate()
|
|
|
|
{
|
|
|
|
// NB: This will cause GetMimeTypes to fail from now on.
|
2012-07-30 18:20:58 +04:00
|
|
|
mNavigator = nullptr;
|
2010-08-13 08:05:05 +04:00
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
1999-04-20 23:18:51 +04:00
|
|
|
private:
|
2001-07-23 09:36:52 +04:00
|
|
|
nsresult GetMimeTypes();
|
|
|
|
void Clear();
|
1999-04-20 23:18:51 +04:00
|
|
|
|
|
|
|
protected:
|
2007-01-25 02:31:12 +03:00
|
|
|
nsIDOMNavigator* mNavigator;
|
2008-11-01 00:40:35 +03:00
|
|
|
// Number of mimetypes handled by plugins.
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mPluginMimeTypeCount;
|
2008-11-01 00:40:35 +03:00
|
|
|
// mMimeTypeArray contains all mimetypes handled by plugins
|
|
|
|
// (mPluginMimeTypeCount) and any mimetypes that we handle internally and
|
|
|
|
// have been looked up before. The number of items in mMimeTypeArray should
|
|
|
|
// thus always be equal to or higher than mPluginMimeTypeCount.
|
|
|
|
nsCOMArray<nsIDOMMimeType> mMimeTypeArray;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mInited;
|
1999-04-20 23:18:51 +04:00
|
|
|
};
|
|
|
|
|
2004-12-10 22:48:22 +03:00
|
|
|
class nsMimeType : public nsIDOMMimeType
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
{
|
1999-04-20 23:18:51 +04:00
|
|
|
public:
|
2007-01-25 02:31:12 +03:00
|
|
|
nsMimeType(nsIDOMPlugin* aPlugin, nsIDOMMimeType* aMimeType);
|
|
|
|
virtual ~nsMimeType();
|
1999-04-20 23:18:51 +04:00
|
|
|
|
2007-01-25 02:31:12 +03:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIDOMMIMETYPE
|
1999-04-20 23:18:51 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
void DetachPlugin() { mPlugin = nullptr; }
|
2010-02-11 14:03:47 +03:00
|
|
|
|
1999-04-20 23:18:51 +04:00
|
|
|
protected:
|
2007-01-25 02:31:12 +03:00
|
|
|
nsIDOMPlugin* mPlugin;
|
|
|
|
nsCOMPtr<nsIDOMMimeType> mMimeType;
|
2003-02-27 02:54:55 +03:00
|
|
|
};
|
|
|
|
|
2004-12-10 22:48:22 +03:00
|
|
|
class nsHelperMimeType : public nsIDOMMimeType
|
2003-02-27 02:54:55 +03:00
|
|
|
{
|
|
|
|
public:
|
2007-01-25 02:31:12 +03:00
|
|
|
nsHelperMimeType(const nsAString& aType)
|
|
|
|
: mType(aType)
|
|
|
|
{
|
2004-12-10 22:48:22 +03:00
|
|
|
}
|
2003-02-27 02:54:55 +03:00
|
|
|
|
2007-01-25 02:31:12 +03:00
|
|
|
virtual ~nsHelperMimeType()
|
2004-12-10 22:48:22 +03:00
|
|
|
{
|
|
|
|
}
|
2003-02-27 02:54:55 +03:00
|
|
|
|
2007-01-25 02:31:12 +03:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIDOMMIMETYPE
|
2003-02-27 02:54:55 +03:00
|
|
|
|
|
|
|
private:
|
2007-01-25 02:31:12 +03:00
|
|
|
nsString mType;
|
1999-04-20 23:18:51 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsMimeTypeArray_h___ */
|