Bug 1728955: part 8) Refactor `DisplayErrCode` in Windows' `nsClipboard`. r=masayuki
[gecko.git] / uriloader / exthandler / nsIHandlerService.idl
blob34519f57cd95a2c9a4c8faac0cbee4b203f795a7
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "nsISupports.idl"
7 interface nsIHandlerInfo;
8 interface nsISimpleEnumerator;
10 [scriptable, uuid(53f0ad17-ec62-46a1-adbc-efccc06babcd)]
11 interface nsIHandlerService : nsISupports
13 /**
14 * Asynchronously performs any IO that the nsIHandlerService needs to do
15 * before it can be of use.
17 void asyncInit();
19 /**
20 * Retrieve a list of all handlers in the datastore. This list is not
21 * guaranteed to be in any particular order, and callers should not assume
22 * it will remain in the same order in the future.
24 * @returns a list of all handlers in the datastore
26 nsISimpleEnumerator enumerate();
28 /**
29 * Fill a handler info object with information from the datastore.
31 * Note: because of the way the external helper app service currently mixes
32 * OS and user handler info in the same handler info object, this method
33 * takes an existing handler info object (probably retrieved from the OS)
34 * and "fills it in" with information from the datastore, overriding any
35 * existing properties on the object with properties from the datastore.
37 * Ultimately, however, we're going to separate OS and user handler info
38 * into separate objects, at which point this method should be renamed to
39 * something like "get" or "retrieve", take a class and type (or perhaps
40 * a type whose class can be determined by querying the type, for example
41 * an nsIContentType which is also an nsIMIMEType or an nsIProtocolScheme),
42 * and return a handler info object representing only the user info.
44 * Note: if you specify an override type, then the service will fill in
45 * the handler info object with information about that type instead of
46 * the type specified by the object's nsIHandlerInfo::type attribute.
48 * This is useful when you are trying to retrieve information about a MIME
49 * type that doesn't exist in the datastore, but you have a file extension
50 * for that type, and nsIHandlerService::getTypeFromExtension returns another
51 * MIME type that does exist in the datastore and can handle that extension.
53 * For example, the user clicks on a link, and the content has a MIME type
54 * that isn't in the datastore, but the link has a file extension, and that
55 * extension is associated with another MIME type in the datastore (perhaps
56 * an unofficial MIME type preceded an official one, like with image/x-png
57 * and image/png).
59 * In that situation, you can call this method to fill in the handler info
60 * object with information about that other type by passing the other type
61 * as the aOverrideType parameter.
63 * @param aHandlerInfo the handler info object
64 * @param aOverrideType a type to use instead of aHandlerInfo::type
66 * Note: if there is no information in the datastore about this type,
67 * this method throws NS_ERROR_NOT_AVAILABLE. Callers are encouraged to
68 * check exists() before calling fillHandlerInfo(), to prevent spamming the
69 * console with XPCOM exception errors.
71 void fillHandlerInfo(in nsIHandlerInfo aHandlerInfo,
72 in ACString aOverrideType);
74 /**
75 * Save the preferred action, preferred handler, possible handlers, and
76 * always ask properties of the given handler info object to the datastore.
77 * Updates an existing record or creates a new one if necessary.
79 * Note: if preferred action is undefined or invalid, then we assume
80 * the default value nsIHandlerInfo::useHelperApp.
82 * @param aHandlerInfo the handler info object
84 void store(in nsIHandlerInfo aHandlerInfo);
86 /**
87 * Whether or not a record for the given handler info object exists
88 * in the datastore. If the datastore is corrupt (or some other error
89 * is caught in the implementation), false will be returned.
91 * @param aHandlerInfo a handler info object
93 * @returns whether or not a record exists
95 boolean exists(in nsIHandlerInfo aHandlerInfo);
97 /**
98 * Remove the given handler info object from the datastore. Deletes all
99 * records associated with the object, including the preferred handler, info,
100 * and type records plus the entry in the list of types, if they exist.
101 * Otherwise, it does nothing and does not return an error.
103 * @param aHandlerInfo the handler info object
105 void remove(in nsIHandlerInfo aHandlerInfo);
108 * Get the MIME type mapped to the given file extension in the datastore.
110 * XXX If we ever support extension -> protocol scheme mappings, then this
111 * method should work for those as well.
113 * Note: in general, you should use nsIMIMEService::getTypeFromExtension
114 * to get a MIME type from a file extension, as that method checks a variety
115 * of other sources besides just the datastore. Use this only when you want
116 * to specifically get only the mapping available in the datastore.
118 * @param aFileExtension the file extension
120 * @returns the MIME type, if any; otherwise returns an empty string ("").
122 ACString getTypeFromExtension(in ACString aFileExtension);
125 * Whether or not there is a handler known to the OS for the
126 * specified protocol type.
128 * @param aProtocolScheme scheme to check for support
130 * @returns whether or not a handler exists
132 boolean existsForProtocolOS(in ACString aProtocolScheme);
135 * Whether or not there is a handler in the datastore or OS for
136 * the specified protocol type. If there is no handler in the datastore,
137 * falls back to a check for an OS handler.
139 * @param aProtocolScheme scheme to check for support
141 * @returns whether or not a handler exists
143 boolean existsForProtocol(in ACString aProtocolScheme);
146 * Fill in a handler info object using information from the OS, taking into
147 * account the MIME type and file extension. When the OS handler
148 * for the MIME type and extension match, |aFound| is returned as true. If
149 * either the MIME type or extension is the empty string and a handler is
150 * found, |aFound| is returned as true.
152 void getMIMEInfoFromOS(in nsIHandlerInfo aHandlerInfo,
153 in ACString aMIMEType,
154 in ACString aExtension,
155 out bool aFound);
158 * Get a description for the application responsible for handling
159 * the provided protocol.
161 AString getApplicationDescription(in ACString aProtocolScheme);