uriloader/exthandler/nsIHandlerService.idl

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:14b86cad1e0d
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/. */
4
5 #include "nsISupports.idl"
6
7 interface nsIHandlerInfo;
8 interface nsISimpleEnumerator;
9
10 [scriptable, uuid(53f0ad17-ec62-46a1-adbc-efccc06babcd)]
11 interface nsIHandlerService : nsISupports
12 {
13 /**
14 * Retrieve a list of all handlers in the datastore. This list is not
15 * guaranteed to be in any particular order, and callers should not assume
16 * it will remain in the same order in the future.
17 *
18 * @returns a list of all handlers in the datastore
19 */
20 nsISimpleEnumerator enumerate();
21
22 /**
23 * Fill a handler info object with information from the datastore.
24 *
25 * Note: because of the way the external helper app service currently mixes
26 * OS and user handler info in the same handler info object, this method
27 * takes an existing handler info object (probably retrieved from the OS)
28 * and "fills it in" with information from the datastore, overriding any
29 * existing properties on the object with properties from the datastore.
30 *
31 * Ultimately, however, we're going to separate OS and user handler info
32 * into separate objects, at which point this method should be renamed to
33 * something like "get" or "retrieve", take a class and type (or perhaps
34 * a type whose class can be determined by querying the type, for example
35 * an nsIContentType which is also an nsIMIMEType or an nsIProtocolScheme),
36 * and return a handler info object representing only the user info.
37 *
38 * Note: if you specify an override type, then the service will fill in
39 * the handler info object with information about that type instead of
40 * the type specified by the object's nsIHandlerInfo::type attribute.
41 *
42 * This is useful when you are trying to retrieve information about a MIME
43 * type that doesn't exist in the datastore, but you have a file extension
44 * for that type, and nsIHandlerService::getTypeFromExtension returns another
45 * MIME type that does exist in the datastore and can handle that extension.
46 *
47 * For example, the user clicks on a link, and the content has a MIME type
48 * that isn't in the datastore, but the link has a file extension, and that
49 * extension is associated with another MIME type in the datastore (perhaps
50 * an unofficial MIME type preceded an official one, like with image/x-png
51 * and image/png).
52 *
53 * In that situation, you can call this method to fill in the handler info
54 * object with information about that other type by passing the other type
55 * as the aOverrideType parameter.
56 *
57 * @param aHandlerInfo the handler info object
58 * @param aOverrideType a type to use instead of aHandlerInfo::type
59 *
60 * Note: if there is no information in the datastore about this type,
61 * this method throws NS_ERROR_NOT_AVAILABLE. Callers are encouraged to
62 * check exists() before calling fillHandlerInfo(), to prevent spamming the
63 * console with XPCOM exception errors.
64 */
65 void fillHandlerInfo(in nsIHandlerInfo aHandlerInfo,
66 in ACString aOverrideType);
67
68 /**
69 * Save the preferred action, preferred handler, possible handlers, and
70 * always ask properties of the given handler info object to the datastore.
71 * Updates an existing record or creates a new one if necessary.
72 *
73 * Note: if preferred action is undefined or invalid, then we assume
74 * the default value nsIHandlerInfo::useHelperApp.
75 *
76 * @param aHandlerInfo the handler info object
77 */
78 void store(in nsIHandlerInfo aHandlerInfo);
79
80 /**
81 * Whether or not a record for the given handler info object exists
82 * in the datastore. If the datastore is corrupt (or some other error
83 * is caught in the implementation), false will be returned.
84 *
85 * @param aHandlerInfo a handler info object
86 *
87 * @returns whether or not a record exists
88 */
89 boolean exists(in nsIHandlerInfo aHandlerInfo);
90
91 /**
92 * Remove the given handler info object from the datastore. Deletes all
93 * records associated with the object, including the preferred handler, info,
94 * and type records plus the entry in the list of types, if they exist.
95 * Otherwise, it does nothing and does not return an error.
96 *
97 * @param aHandlerInfo the handler info object
98 */
99 void remove(in nsIHandlerInfo aHandlerInfo);
100
101 /**
102 * Get the MIME type mapped to the given file extension in the datastore.
103 *
104 * XXX If we ever support extension -> protocol scheme mappings, then this
105 * method should work for those as well.
106 *
107 * Note: in general, you should use nsIMIMEService::getTypeFromExtension
108 * to get a MIME type from a file extension, as that method checks a variety
109 * of other sources besides just the datastore. Use this only when you want
110 * to specifically get only the mapping available in the datastore.
111 *
112 * @param aFileExtension the file extension
113 *
114 * @returns the MIME type, if any; otherwise returns an empty string ("").
115 */
116 ACString getTypeFromExtension(in ACString aFileExtension);
117 };

mercurial