1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include
"nsISupports.idl"
13 #define NS_MIMESERVICE_CID \
14 { /* 03af31da-3109-11d3-8cd0-0060b0fc14a3 */ \
18 {0x8c, 0xd0, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
23 * The MIME service is responsible for mapping file extensions to MIME-types
24 * (see RFC 2045). It also provides access to nsIMIMEInfo interfaces and
25 * acts as a general convenience wrapper of nsIMIMEInfo interfaces.
27 * The MIME service maintains a database with a <b>one</b> MIME type <b>to many</b>
28 * file extensions rule. Adding the same file extension to multiple MIME types
29 * is illegal and behavior is undefined.
33 [scriptable
, uuid(5b3675a1
-02db
-4f8f
-a560
-b34736635f47
)]
34 interface nsIMIMEService
: nsISupports
{
36 * Retrieves an nsIMIMEInfo using both the extension
37 * and the type of a file. The type is given preference
38 * during the lookup. One of aMIMEType and aFileExt
39 * can be an empty string. At least one of aMIMEType and aFileExt
42 nsIMIMEInfo getFromTypeAndExtension
(in ACString aMIMEType
, in AUTF8String aFileExt
);
45 * Retrieves a ACString representation of the MIME type
46 * associated with this file extension.
48 * @param A file extension (excluding the dot ('.')).
49 * @return The MIME type, if any.
51 ACString getTypeFromExtension
(in AUTF8String aFileExt
);
54 * Retrieves a ACString representation of the MIME type
55 * associated with this URI. The association is purely
56 * file extension to MIME type based. No attempt to determine
57 * the type via server headers or byte scanning is made.
59 * @param The URI the user wants MIME info on.
60 * @return The MIME type, if any.
62 ACString getTypeFromURI
(in nsIURI aURI
);
65 ACString getTypeFromFile
(in nsIFile aFile
);
68 * Given a Type/Extension combination, returns the default extension
69 * for this type. This may be identical to the passed-in extension.
71 * @param aMIMEType The Type to get information on. Must not be empty.
72 * @param aFileExt File Extension. Can be empty.
74 AUTF8String getPrimaryExtension
(in ACString aMIMEType
, in AUTF8String aFileExt
);