Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "nsISupports.idl" |
michael@0 | 7 | |
michael@0 | 8 | interface nsIFile; |
michael@0 | 9 | interface nsIMIMEInfo; |
michael@0 | 10 | interface nsIURI; |
michael@0 | 11 | |
michael@0 | 12 | %{C++ |
michael@0 | 13 | #define NS_MIMESERVICE_CID \ |
michael@0 | 14 | { /* 03af31da-3109-11d3-8cd0-0060b0fc14a3 */ \ |
michael@0 | 15 | 0x03af31da, \ |
michael@0 | 16 | 0x3109, \ |
michael@0 | 17 | 0x11d3, \ |
michael@0 | 18 | {0x8c, 0xd0, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \ |
michael@0 | 19 | } |
michael@0 | 20 | %} |
michael@0 | 21 | |
michael@0 | 22 | /** |
michael@0 | 23 | * The MIME service is responsible for mapping file extensions to MIME-types |
michael@0 | 24 | * (see RFC 2045). It also provides access to nsIMIMEInfo interfaces and |
michael@0 | 25 | * acts as a general convenience wrapper of nsIMIMEInfo interfaces. |
michael@0 | 26 | * |
michael@0 | 27 | * The MIME service maintains a database with a <b>one</b> MIME type <b>to many</b> |
michael@0 | 28 | * file extensions rule. Adding the same file extension to multiple MIME types |
michael@0 | 29 | * is illegal and behavior is undefined. |
michael@0 | 30 | * |
michael@0 | 31 | * @see nsIMIMEInfo |
michael@0 | 32 | */ |
michael@0 | 33 | [scriptable, uuid(5b3675a1-02db-4f8f-a560-b34736635f47)] |
michael@0 | 34 | interface nsIMIMEService : nsISupports { |
michael@0 | 35 | /** |
michael@0 | 36 | * Retrieves an nsIMIMEInfo using both the extension |
michael@0 | 37 | * and the type of a file. The type is given preference |
michael@0 | 38 | * during the lookup. One of aMIMEType and aFileExt |
michael@0 | 39 | * can be an empty string. At least one of aMIMEType and aFileExt |
michael@0 | 40 | * must be nonempty. |
michael@0 | 41 | */ |
michael@0 | 42 | nsIMIMEInfo getFromTypeAndExtension(in ACString aMIMEType, in AUTF8String aFileExt); |
michael@0 | 43 | |
michael@0 | 44 | /** |
michael@0 | 45 | * Retrieves a ACString representation of the MIME type |
michael@0 | 46 | * associated with this file extension. |
michael@0 | 47 | * |
michael@0 | 48 | * @param A file extension (excluding the dot ('.')). |
michael@0 | 49 | * @return The MIME type, if any. |
michael@0 | 50 | */ |
michael@0 | 51 | ACString getTypeFromExtension(in AUTF8String aFileExt); |
michael@0 | 52 | |
michael@0 | 53 | /** |
michael@0 | 54 | * Retrieves a ACString representation of the MIME type |
michael@0 | 55 | * associated with this URI. The association is purely |
michael@0 | 56 | * file extension to MIME type based. No attempt to determine |
michael@0 | 57 | * the type via server headers or byte scanning is made. |
michael@0 | 58 | * |
michael@0 | 59 | * @param The URI the user wants MIME info on. |
michael@0 | 60 | * @return The MIME type, if any. |
michael@0 | 61 | */ |
michael@0 | 62 | ACString getTypeFromURI(in nsIURI aURI); |
michael@0 | 63 | |
michael@0 | 64 | // |
michael@0 | 65 | ACString getTypeFromFile(in nsIFile aFile); |
michael@0 | 66 | |
michael@0 | 67 | /** |
michael@0 | 68 | * Given a Type/Extension combination, returns the default extension |
michael@0 | 69 | * for this type. This may be identical to the passed-in extension. |
michael@0 | 70 | * |
michael@0 | 71 | * @param aMIMEType The Type to get information on. Must not be empty. |
michael@0 | 72 | * @param aFileExt File Extension. Can be empty. |
michael@0 | 73 | */ |
michael@0 | 74 | AUTF8String getPrimaryExtension(in ACString aMIMEType, in AUTF8String aFileExt); |
michael@0 | 75 | }; |