1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
14 * The Original Code is the Mozilla browser.
16 * The Initial Developer of the Original Code is Mozilla.
17 * Portions created by the Initial Developer are Copyright (C) 2007
18 * the Initial Developer. All Rights Reserved.
21 * Myk Melez <myk@mozilla.org>
23 * Alternatively, the contents of this file may be used under the terms of
24 * either the GNU General Public License Version 2 or later (the "GPL"), or
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 * in which case the provisions of the GPL or the LGPL are applicable instead
27 * of those above. If you wish to allow use of your version of this file only
28 * under the terms of either the GPL or the LGPL, and not to allow others to
29 * use your version of this file under the terms of the MPL, indicate your
30 * decision by deleting the provisions above and replace them with the notice
31 * and other provisions required by the GPL or the LGPL. If you do not delete
32 * the provisions above, a recipient may use your version of this file under
33 * the terms of any one of the MPL, the GPL or the LGPL.
35 * ***** END LICENSE BLOCK ***** */
37 #include
"nsISupports.idl"
39 interface nsIHandlerInfo
;
40 interface nsISimpleEnumerator
;
42 [scriptable
, uuid(53f0ad17
-ec62
-46a1
-adbc
-efccc06babcd
)]
43 interface nsIHandlerService
: nsISupports
46 * Retrieve a list of all handlers in the datastore. This list is not
47 * guaranteed to be in any particular order, and callers should not assume
48 * it will remain in the same order in the future.
50 * @returns a list of all handlers in the datastore
52 nsISimpleEnumerator enumerate
();
55 * Fill a handler info object with information from the datastore.
57 * Note: because of the way the external helper app service currently mixes
58 * OS and user handler info in the same handler info object, this method
59 * takes an existing handler info object (probably retrieved from the OS)
60 * and "fills it in" with information from the datastore, overriding any
61 * existing properties on the object with properties from the datastore.
63 * Ultimately, however, we're going to separate OS and user handler info
64 * into separate objects, at which point this method should be renamed to
65 * something like "get" or "retrieve", take a class and type (or perhaps
66 * a type whose class can be determined by querying the type, for example
67 * an nsIContentType which is also an nsIMIMEType or an nsIProtocolScheme),
68 * and return a handler info object representing only the user info.
70 * Note: if you specify an override type, then the service will fill in
71 * the handler info object with information about that type instead of
72 * the type specified by the object's nsIHandlerInfo::type attribute.
74 * This is useful when you are trying to retrieve information about a MIME
75 * type that doesn't exist in the datastore, but you have a file extension
76 * for that type, and nsIHandlerService::getTypeFromExtension returns another
77 * MIME type that does exist in the datastore and can handle that extension.
79 * For example, the user clicks on a link, and the content has a MIME type
80 * that isn't in the datastore, but the link has a file extension, and that
81 * extension is associated with another MIME type in the datastore (perhaps
82 * an unofficial MIME type preceded an official one, like with image/x-png
85 * In that situation, you can call this method to fill in the handler info
86 * object with information about that other type by passing the other type
87 * as the aOverrideType parameter.
89 * @param aHandlerInfo the handler info object
90 * @param aOverrideType a type to use instead of aHandlerInfo::type
92 * Note: if there is no information in the datastore about this type,
93 * this method throws NS_ERROR_NOT_AVAILABLE. Callers are encouraged to
94 * check exists() before calling fillHandlerInfo(), to prevent spamming the
95 * console with XPCOM exception errors.
97 void fillHandlerInfo
(in nsIHandlerInfo aHandlerInfo
,
98 in ACString aOverrideType
);
101 * Save the preferred action, preferred handler, possible handlers, and
102 * always ask properties of the given handler info object to the datastore.
103 * Updates an existing record or creates a new one if necessary.
105 * Note: if preferred action is undefined or invalid, then we assume
106 * the default value nsIHandlerInfo::useHelperApp.
108 * @param aHandlerInfo the handler info object
110 void store
(in nsIHandlerInfo aHandlerInfo
);
113 * Whether or not a record for the given handler info object exists
114 * in the datastore. If the datastore is corrupt (or some other error
115 * is caught in the implementation), false will be returned.
117 * @param aHandlerInfo a handler info object
119 * @returns whether or not a record exists
121 boolean exists
(in nsIHandlerInfo aHandlerInfo
);
124 * Remove the given handler info object from the datastore. Deletes all
125 * records associated with the object, including the preferred handler, info,
126 * and type records plus the entry in the list of types, if they exist.
127 * Otherwise, it does nothing and does not return an error.
129 * @param aHandlerInfo the handler info object
131 void remove
(in nsIHandlerInfo aHandlerInfo
);
134 * Get the MIME type mapped to the given file extension in the datastore.
136 * XXX If we ever support extension -> protocol scheme mappings, then this
137 * method should work for those as well.
139 * Note: in general, you should use nsIMIMEService::getTypeFromExtension
140 * to get a MIME type from a file extension, as that method checks a variety
141 * of other sources besides just the datastore. Use this only when you want
142 * to specifically get only the mapping available in the datastore.
144 * @param aFileExtension the file extension
146 * @returns the MIME type, if any; otherwise returns an empty string ("").
148 ACString getTypeFromExtension
(in ACString aFileExtension
);