1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
23 * Dan Mosedale <dmose@mozilla.org>
24 * Myk Melez <myk@mozilla.org>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #include
"nsISupports.idl"
44 interface nsIUTF8StringEnumerator
;
45 interface nsIHandlerApp
;
47 interface nsIMutableArray
;
48 interface nsIInterfaceRequestor
;
50 typedef long nsHandlerInfoAction
;
53 * nsIHandlerInfo gives access to the information about how a given protocol
54 * scheme or MIME-type is handled.
56 [scriptable
, uuid(325e56a7
-3762-4312-aec7
-f1fcf84b4145
)]
57 interface nsIHandlerInfo
: nsISupports
{
59 * The type of this handler info. For MIME handlers, this is the MIME type.
60 * For protocol handlers, it's the scheme.
62 * @return String representing the type.
64 readonly attribute ACString type
;
67 * A human readable description of the handler type
69 attribute AString description
;
72 * The application the user has said they want associated with this content
73 * type. This is not always guaranteed to be set!!
75 attribute nsIHandlerApp preferredApplicationHandler
;
78 * Applications that can handle this content type.
80 * The list will include the preferred handler, if any. Elements of this
81 * array are nsIHandlerApp objects, and this attribute will always reference
82 * an array, whether or not there are any possible handlers. If there are
83 * no possible handlers, the array will contain no elements, so just check
84 * its length (nsIArray::length) to see if there are any possible handlers.
86 readonly attribute nsIMutableArray possibleApplicationHandlers
;
89 * Indicates whether a default application handler exists,
90 * i.e. whether launchWithFile with action = useSystemDefault is possible
91 * and defaultDescription will contain usable information.
93 readonly attribute
boolean hasDefaultHandler
;
96 * A pretty name description of the associated default application. Only
97 * usable if hasDefaultHandler is true.
99 readonly attribute AString defaultDescription
;
102 * Launches the application with the specified URI, in a way that
103 * depends on the value of preferredAction. preferredAction must be
104 * useHelperApp or useSystemDefault.
106 * @note Only the URI scheme is used to determine how to launch. This is
107 * essentially a pass-by-value operation. This means that in the case of
108 * a file: URI, the handler that is registered for file: will be launched
109 * and our code will not make any decision based on the content-type or
110 * extension, though the invoked file: handler is free to do so.
113 * The URI to launch this application with
115 * @param aWindowContext
116 * The window to parent the dialog against, and, if a web handler
117 * is chosen, it is loaded in this window as well. See
118 * nsIHandlerApp.launchWithURI for more details.
120 * @throw NS_ERROR_INVALID_ARG if preferredAction is not valid for this
121 * call. Other exceptions may be thrown.
123 void launchWithURI
(in nsIURI aURI
,
124 [optional] in nsIInterfaceRequestor aWindowContext
);
127 * preferredAction is how the user specified they would like to handle
128 * this content type: save to disk, use specified helper app, use OS
129 * default handler or handle using navigator; possible value constants
132 attribute nsHandlerInfoAction preferredAction
;
134 const long saveToDisk
= 0;
136 * Used to indicate that we know nothing about what to do with this. You
137 * could consider this to be not initialized.
139 const long alwaysAsk
= 1;
140 const long useHelperApp
= 2;
141 const long handleInternally
= 3;
142 const long useSystemDefault
= 4;
145 * alwaysAskBeforeHandling: if true, we should always give the user a
146 * dialog asking how to dispose of this content.
148 attribute
boolean alwaysAskBeforeHandling
;
152 * nsIMIMEInfo extends nsIHandlerInfo with a bunch of information specific to
153 * MIME content-types. There is a one-to-many relationship between MIME types
154 * and file extensions. This means that a MIMEInfo object may have multiple
155 * file extensions associated with it. However, the reverse is not true.
157 * MIMEInfo objects are generally retrieved from the MIME Service
158 * @see nsIMIMEService
160 [scriptable
, uuid(cd7083f8
-5fe9
-4248-bb09
-0b0e2982fde8
)]
161 interface nsIMIMEInfo
: nsIHandlerInfo
{
163 * Gives you an array of file types associated with this type.
165 * @return Number of elements in the array.
166 * @return Array of extensions.
168 nsIUTF8StringEnumerator getFileExtensions
();
171 * Set File Extensions. Input is a comma delimited list of extensions.
173 void setFileExtensions
(in AUTF8String aExtensions
);
176 * Returns whether or not the given extension is
177 * associated with this MIME info.
179 * @return TRUE if the association exists.
181 boolean extensionExists
(in AUTF8String aExtension
);
184 * Append a given extension to the set of extensions
186 void appendExtension
(in AUTF8String aExtension
);
189 * Returns the first extension association in
190 * the internal set of extensions.
192 * @return The first extension.
194 attribute AUTF8String primaryExtension
;
197 * The MIME type of this MIMEInfo.
199 * @return String representing the MIME type.
201 * @deprecated use nsIHandlerInfo::type instead.
203 readonly attribute ACString MIMEType
;
206 * Mac Type and creator types
208 attribute PRUint32 macType
;
209 attribute PRUint32 macCreator
;
212 * Returns whether or not these two nsIMIMEInfos are logically
215 * @returns PR_TRUE if the two are considered equal
217 boolean equals
(in nsIMIMEInfo aMIMEInfo
);
220 * Returns a list of nsILocalHandlerApp objects containing
221 * handlers associated with this mimeinfo. Implemented per
222 * platform using information in this object to generate the
223 * best list. Typically used for an "open with" style user
226 * @return nsIArray of nsILocalHandlerApp
228 readonly attribute nsIArray possibleLocalHandlers
;
231 * Launches the application with the specified file, in a way that
232 * depends on the value of preferredAction. preferredAction must be
233 * useHelperApp or useSystemDefault.
235 * @param aFile The file to launch this application with.
237 * @throw NS_ERROR_INVALID_ARG if action is not valid for this function.
238 * Other exceptions may be thrown.
240 void launchWithFile
(in nsIFile aFile
);
244 * nsIHandlerApp represents an external application that can handle content
245 * of some sort (either a MIME type or a protocol).
247 * FIXME: now that we've made nsIWebHandlerApp inherit from nsIHandlerApp,
248 * we should also try to make nsIWebContentHandlerInfo inherit from or possibly
249 * be replaced by nsIWebHandlerApp (bug 394710).
251 [scriptable
, uuid(8d298761
-0963-4c90
-99e2
-6ea498825e82
)]
252 interface nsIHandlerApp
: nsISupports
{
255 * Human readable name for the handler
257 attribute AString name
;
260 * Whether or not the given handler app is logically equivalent to the
261 * invokant (i.e. they represent the same app).
263 * Two apps are the same if they are both either local or web handlers
264 * and their executables/URI templates are the same in a string comparison.
266 * @param aHandlerApp the handler app to compare to the invokant
268 * @returns true if the two are logically equivalent, false otherwise
270 boolean equals
(in nsIHandlerApp aHandlerApp
);
273 * Launches the application with the specified URI.
276 * The URI to launch this application with
278 * @param aWindowContext
280 * Currently only relevant to web-handler apps. If given, this
281 * represents the docshell to load the handler in and is passed
282 * through to nsIURILoader.openURI. If this parameter is null or
283 * not present, the web handler app implementation will attempt to
284 * find/create a place to load the handler and do so. As of this
285 * writing, it tries to load the web handler in a new window using
286 * nsIBrowserDOMWindow.openURI. In the future, it may attempt to
287 * have a more comprehensive strategy which could include handing
288 * off to the system default browser (bug 394479).
290 void launchWithURI
(in nsIURI aURI
,
291 [optional] in nsIInterfaceRequestor aWindowContext
);
296 * nsILocalHandlerApp is a local OS-level executable
298 [scriptable
, uuid(9812be73
-273c
-478c
-8170-c3e0db08ae7c
)]
299 interface nsILocalHandlerApp
: nsIHandlerApp
{
302 * Pointer to the executable file used to handle content
304 attribute nsIFile executable
;
308 * nsIWebHandlerApp is a web-based handler, as speced by the WhatWG HTML5
309 * draft. Currently, only GET-based handlers are supported. At some point,
310 * we probably want to work with WhatWG to spec out and implement POST-based
313 [scriptable
, uuid(7521a093
-c498
-45ce
-b462
-df7ba0d882f6
)]
314 interface nsIWebHandlerApp
: nsIHandlerApp
{
317 * Template used to construct the URI to GET. Template is expected to have
318 * a %s in it, and the escaped URI to be handled is inserted in place of
319 * that %s, as per the HTML5 spec.
321 attribute AUTF8String uriTemplate
;
325 * nsIDBusHandlerApp represents local applications launched by DBus a message
326 * invoking a method taking a single string argument descibing a URI
328 [scriptable
, uuid(1ffc274b
-4cbf
-4bb5
-a635
-05ad2cbb6534
)]
329 interface nsIDBusHandlerApp
: nsIHandlerApp
{
332 * Service defines the dbus service that should handle this protocol.
333 * If its not set, NS_ERROR_FAILURE will be returned by LaunchWithURI
335 attribute AUTF8String service
;
338 * Objpath defines the object path of the dbus service that should handle
339 * this protocol. If its not set, NS_ERROR_FAILURE will be returned
342 attribute AUTF8String objectPath
;
345 * DBusInterface defines the interface of the dbus service that should
346 * handle this protocol. If its not set, NS_ERROR_FAILURE will be
347 * returned by LaunchWithURI
349 attribute AUTF8String dBusInterface
;
352 * Method defines the dbus method that should be invoked to handle this
353 * protocol. If its not set, NS_ERROR_FAILURE will be returned by
356 attribute AUTF8String method
;