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 nsIURI; |
michael@0 | 9 | interface nsIFile; |
michael@0 | 10 | interface nsIUTF8StringEnumerator; |
michael@0 | 11 | interface nsIHandlerApp; |
michael@0 | 12 | interface nsIArray; |
michael@0 | 13 | interface nsIMutableArray; |
michael@0 | 14 | interface nsIInterfaceRequestor; |
michael@0 | 15 | |
michael@0 | 16 | typedef long nsHandlerInfoAction; |
michael@0 | 17 | |
michael@0 | 18 | /** |
michael@0 | 19 | * nsIHandlerInfo gives access to the information about how a given protocol |
michael@0 | 20 | * scheme or MIME-type is handled. |
michael@0 | 21 | */ |
michael@0 | 22 | [scriptable, uuid(325e56a7-3762-4312-aec7-f1fcf84b4145)] |
michael@0 | 23 | interface nsIHandlerInfo : nsISupports { |
michael@0 | 24 | /** |
michael@0 | 25 | * The type of this handler info. For MIME handlers, this is the MIME type. |
michael@0 | 26 | * For protocol handlers, it's the scheme. |
michael@0 | 27 | * |
michael@0 | 28 | * @return String representing the type. |
michael@0 | 29 | */ |
michael@0 | 30 | readonly attribute ACString type; |
michael@0 | 31 | |
michael@0 | 32 | /** |
michael@0 | 33 | * A human readable description of the handler type |
michael@0 | 34 | */ |
michael@0 | 35 | attribute AString description; |
michael@0 | 36 | |
michael@0 | 37 | /** |
michael@0 | 38 | * The application the user has said they want associated with this content |
michael@0 | 39 | * type. This is not always guaranteed to be set!! |
michael@0 | 40 | */ |
michael@0 | 41 | attribute nsIHandlerApp preferredApplicationHandler; |
michael@0 | 42 | |
michael@0 | 43 | /** |
michael@0 | 44 | * Applications that can handle this content type. |
michael@0 | 45 | * |
michael@0 | 46 | * The list will include the preferred handler, if any. Elements of this |
michael@0 | 47 | * array are nsIHandlerApp objects, and this attribute will always reference |
michael@0 | 48 | * an array, whether or not there are any possible handlers. If there are |
michael@0 | 49 | * no possible handlers, the array will contain no elements, so just check |
michael@0 | 50 | * its length (nsIArray::length) to see if there are any possible handlers. |
michael@0 | 51 | */ |
michael@0 | 52 | readonly attribute nsIMutableArray possibleApplicationHandlers; |
michael@0 | 53 | |
michael@0 | 54 | /** |
michael@0 | 55 | * Indicates whether a default application handler exists, |
michael@0 | 56 | * i.e. whether launchWithFile with action = useSystemDefault is possible |
michael@0 | 57 | * and defaultDescription will contain usable information. |
michael@0 | 58 | */ |
michael@0 | 59 | readonly attribute boolean hasDefaultHandler; |
michael@0 | 60 | |
michael@0 | 61 | /** |
michael@0 | 62 | * A pretty name description of the associated default application. Only |
michael@0 | 63 | * usable if hasDefaultHandler is true. |
michael@0 | 64 | */ |
michael@0 | 65 | readonly attribute AString defaultDescription; |
michael@0 | 66 | |
michael@0 | 67 | /** |
michael@0 | 68 | * Launches the application with the specified URI, in a way that |
michael@0 | 69 | * depends on the value of preferredAction. preferredAction must be |
michael@0 | 70 | * useHelperApp or useSystemDefault. |
michael@0 | 71 | * |
michael@0 | 72 | * @note Only the URI scheme is used to determine how to launch. This is |
michael@0 | 73 | * essentially a pass-by-value operation. This means that in the case of |
michael@0 | 74 | * a file: URI, the handler that is registered for file: will be launched |
michael@0 | 75 | * and our code will not make any decision based on the content-type or |
michael@0 | 76 | * extension, though the invoked file: handler is free to do so. |
michael@0 | 77 | * |
michael@0 | 78 | * @param aURI |
michael@0 | 79 | * The URI to launch this application with |
michael@0 | 80 | * |
michael@0 | 81 | * @param aWindowContext |
michael@0 | 82 | * The window to parent the dialog against, and, if a web handler |
michael@0 | 83 | * is chosen, it is loaded in this window as well. See |
michael@0 | 84 | * nsIHandlerApp.launchWithURI for more details. |
michael@0 | 85 | * |
michael@0 | 86 | * @throw NS_ERROR_INVALID_ARG if preferredAction is not valid for this |
michael@0 | 87 | * call. Other exceptions may be thrown. |
michael@0 | 88 | */ |
michael@0 | 89 | void launchWithURI(in nsIURI aURI, |
michael@0 | 90 | [optional] in nsIInterfaceRequestor aWindowContext); |
michael@0 | 91 | |
michael@0 | 92 | /** |
michael@0 | 93 | * preferredAction is how the user specified they would like to handle |
michael@0 | 94 | * this content type: save to disk, use specified helper app, use OS |
michael@0 | 95 | * default handler or handle using navigator; possible value constants |
michael@0 | 96 | * listed below |
michael@0 | 97 | */ |
michael@0 | 98 | attribute nsHandlerInfoAction preferredAction; |
michael@0 | 99 | |
michael@0 | 100 | const long saveToDisk = 0; |
michael@0 | 101 | /** |
michael@0 | 102 | * Used to indicate that we know nothing about what to do with this. You |
michael@0 | 103 | * could consider this to be not initialized. |
michael@0 | 104 | */ |
michael@0 | 105 | const long alwaysAsk = 1; |
michael@0 | 106 | const long useHelperApp = 2; |
michael@0 | 107 | const long handleInternally = 3; |
michael@0 | 108 | const long useSystemDefault = 4; |
michael@0 | 109 | |
michael@0 | 110 | /** |
michael@0 | 111 | * alwaysAskBeforeHandling: if true, we should always give the user a |
michael@0 | 112 | * dialog asking how to dispose of this content. |
michael@0 | 113 | */ |
michael@0 | 114 | attribute boolean alwaysAskBeforeHandling; |
michael@0 | 115 | }; |
michael@0 | 116 | |
michael@0 | 117 | /** |
michael@0 | 118 | * nsIMIMEInfo extends nsIHandlerInfo with a bunch of information specific to |
michael@0 | 119 | * MIME content-types. There is a one-to-many relationship between MIME types |
michael@0 | 120 | * and file extensions. This means that a MIMEInfo object may have multiple |
michael@0 | 121 | * file extensions associated with it. However, the reverse is not true. |
michael@0 | 122 | * |
michael@0 | 123 | * MIMEInfo objects are generally retrieved from the MIME Service |
michael@0 | 124 | * @see nsIMIMEService |
michael@0 | 125 | */ |
michael@0 | 126 | [scriptable, uuid(1c21acef-c7a1-40c6-9d40-a20480ee53a1)] |
michael@0 | 127 | interface nsIMIMEInfo : nsIHandlerInfo { |
michael@0 | 128 | /** |
michael@0 | 129 | * Gives you an array of file types associated with this type. |
michael@0 | 130 | * |
michael@0 | 131 | * @return Number of elements in the array. |
michael@0 | 132 | * @return Array of extensions. |
michael@0 | 133 | */ |
michael@0 | 134 | nsIUTF8StringEnumerator getFileExtensions(); |
michael@0 | 135 | |
michael@0 | 136 | /** |
michael@0 | 137 | * Set File Extensions. Input is a comma delimited list of extensions. |
michael@0 | 138 | */ |
michael@0 | 139 | void setFileExtensions(in AUTF8String aExtensions); |
michael@0 | 140 | |
michael@0 | 141 | /** |
michael@0 | 142 | * Returns whether or not the given extension is |
michael@0 | 143 | * associated with this MIME info. |
michael@0 | 144 | * |
michael@0 | 145 | * @return TRUE if the association exists. |
michael@0 | 146 | */ |
michael@0 | 147 | boolean extensionExists(in AUTF8String aExtension); |
michael@0 | 148 | |
michael@0 | 149 | /** |
michael@0 | 150 | * Append a given extension to the set of extensions |
michael@0 | 151 | */ |
michael@0 | 152 | void appendExtension(in AUTF8String aExtension); |
michael@0 | 153 | |
michael@0 | 154 | /** |
michael@0 | 155 | * Returns the first extension association in |
michael@0 | 156 | * the internal set of extensions. |
michael@0 | 157 | * |
michael@0 | 158 | * @return The first extension. |
michael@0 | 159 | */ |
michael@0 | 160 | attribute AUTF8String primaryExtension; |
michael@0 | 161 | |
michael@0 | 162 | /** |
michael@0 | 163 | * The MIME type of this MIMEInfo. |
michael@0 | 164 | * |
michael@0 | 165 | * @return String representing the MIME type. |
michael@0 | 166 | * |
michael@0 | 167 | * @deprecated use nsIHandlerInfo::type instead. |
michael@0 | 168 | */ |
michael@0 | 169 | readonly attribute ACString MIMEType; |
michael@0 | 170 | |
michael@0 | 171 | /** |
michael@0 | 172 | * Returns whether or not these two nsIMIMEInfos are logically |
michael@0 | 173 | * equivalent. |
michael@0 | 174 | * |
michael@0 | 175 | * @returns PR_TRUE if the two are considered equal |
michael@0 | 176 | */ |
michael@0 | 177 | boolean equals(in nsIMIMEInfo aMIMEInfo); |
michael@0 | 178 | |
michael@0 | 179 | /** |
michael@0 | 180 | * Returns a list of nsILocalHandlerApp objects containing |
michael@0 | 181 | * handlers associated with this mimeinfo. Implemented per |
michael@0 | 182 | * platform using information in this object to generate the |
michael@0 | 183 | * best list. Typically used for an "open with" style user |
michael@0 | 184 | * option. |
michael@0 | 185 | * |
michael@0 | 186 | * @return nsIArray of nsILocalHandlerApp |
michael@0 | 187 | */ |
michael@0 | 188 | readonly attribute nsIArray possibleLocalHandlers; |
michael@0 | 189 | |
michael@0 | 190 | /** |
michael@0 | 191 | * Launches the application with the specified file, in a way that |
michael@0 | 192 | * depends on the value of preferredAction. preferredAction must be |
michael@0 | 193 | * useHelperApp or useSystemDefault. |
michael@0 | 194 | * |
michael@0 | 195 | * @param aFile The file to launch this application with. |
michael@0 | 196 | * |
michael@0 | 197 | * @throw NS_ERROR_INVALID_ARG if action is not valid for this function. |
michael@0 | 198 | * Other exceptions may be thrown. |
michael@0 | 199 | */ |
michael@0 | 200 | void launchWithFile(in nsIFile aFile); |
michael@0 | 201 | }; |
michael@0 | 202 | |
michael@0 | 203 | /** |
michael@0 | 204 | * nsIHandlerApp represents an external application that can handle content |
michael@0 | 205 | * of some sort (either a MIME type or a protocol). |
michael@0 | 206 | * |
michael@0 | 207 | * FIXME: now that we've made nsIWebHandlerApp inherit from nsIHandlerApp, |
michael@0 | 208 | * we should also try to make nsIWebContentHandlerInfo inherit from or possibly |
michael@0 | 209 | * be replaced by nsIWebHandlerApp (bug 394710). |
michael@0 | 210 | */ |
michael@0 | 211 | [scriptable, uuid(8BDF20A4-9170-4548-AF52-78311A44F920)] |
michael@0 | 212 | interface nsIHandlerApp : nsISupports { |
michael@0 | 213 | |
michael@0 | 214 | /** |
michael@0 | 215 | * Human readable name for the handler |
michael@0 | 216 | */ |
michael@0 | 217 | attribute AString name; |
michael@0 | 218 | |
michael@0 | 219 | /** |
michael@0 | 220 | * Detailed description for this handler. Suitable for |
michael@0 | 221 | * a tooltip or short informative sentence. |
michael@0 | 222 | */ |
michael@0 | 223 | attribute AString detailedDescription; |
michael@0 | 224 | |
michael@0 | 225 | /** |
michael@0 | 226 | * Whether or not the given handler app is logically equivalent to the |
michael@0 | 227 | * invokant (i.e. they represent the same app). |
michael@0 | 228 | * |
michael@0 | 229 | * Two apps are the same if they are both either local or web handlers |
michael@0 | 230 | * and their executables/URI templates and command line parameters are |
michael@0 | 231 | * the same. |
michael@0 | 232 | * |
michael@0 | 233 | * @param aHandlerApp the handler app to compare to the invokant |
michael@0 | 234 | * |
michael@0 | 235 | * @returns true if the two are logically equivalent, false otherwise |
michael@0 | 236 | */ |
michael@0 | 237 | boolean equals(in nsIHandlerApp aHandlerApp); |
michael@0 | 238 | |
michael@0 | 239 | /** |
michael@0 | 240 | * Launches the application with the specified URI. |
michael@0 | 241 | * |
michael@0 | 242 | * @param aURI |
michael@0 | 243 | * The URI to launch this application with |
michael@0 | 244 | * |
michael@0 | 245 | * @param aWindowContext |
michael@0 | 246 | * |
michael@0 | 247 | * Currently only relevant to web-handler apps. If given, this |
michael@0 | 248 | * represents the docshell to load the handler in and is passed |
michael@0 | 249 | * through to nsIURILoader.openURI. If this parameter is null or |
michael@0 | 250 | * not present, the web handler app implementation will attempt to |
michael@0 | 251 | * find/create a place to load the handler and do so. As of this |
michael@0 | 252 | * writing, it tries to load the web handler in a new window using |
michael@0 | 253 | * nsIBrowserDOMWindow.openURI. In the future, it may attempt to |
michael@0 | 254 | * have a more comprehensive strategy which could include handing |
michael@0 | 255 | * off to the system default browser (bug 394479). |
michael@0 | 256 | */ |
michael@0 | 257 | void launchWithURI(in nsIURI aURI, |
michael@0 | 258 | [optional] in nsIInterfaceRequestor aWindowContext); |
michael@0 | 259 | |
michael@0 | 260 | }; |
michael@0 | 261 | |
michael@0 | 262 | /** |
michael@0 | 263 | * nsILocalHandlerApp is a local OS-level executable |
michael@0 | 264 | */ |
michael@0 | 265 | [scriptable, uuid(D36B6329-52AE-4f45-80F4-B2536AE5F8B2)] |
michael@0 | 266 | interface nsILocalHandlerApp : nsIHandlerApp { |
michael@0 | 267 | |
michael@0 | 268 | /** |
michael@0 | 269 | * Pointer to the executable file used to handle content |
michael@0 | 270 | */ |
michael@0 | 271 | attribute nsIFile executable; |
michael@0 | 272 | |
michael@0 | 273 | /** |
michael@0 | 274 | * Returns the current number of command line parameters. |
michael@0 | 275 | */ |
michael@0 | 276 | readonly attribute unsigned long parameterCount; |
michael@0 | 277 | |
michael@0 | 278 | /** |
michael@0 | 279 | * Clears the current list of command line parameters. |
michael@0 | 280 | */ |
michael@0 | 281 | void clearParameters(); |
michael@0 | 282 | |
michael@0 | 283 | /** |
michael@0 | 284 | * Appends a command line parameter to the command line |
michael@0 | 285 | * parameter list. |
michael@0 | 286 | * |
michael@0 | 287 | * @param param the parameter to add. |
michael@0 | 288 | */ |
michael@0 | 289 | void appendParameter(in AString param); |
michael@0 | 290 | |
michael@0 | 291 | /** |
michael@0 | 292 | * Retrieves a specific command line parameter. |
michael@0 | 293 | * |
michael@0 | 294 | * @param param the index of the parameter to return. |
michael@0 | 295 | * |
michael@0 | 296 | * @return the parameter string. |
michael@0 | 297 | * |
michael@0 | 298 | * @throw NS_ERROR_INVALID_ARG if the index is out of range. |
michael@0 | 299 | */ |
michael@0 | 300 | AString getParameter(in unsigned long parameterIndex); |
michael@0 | 301 | |
michael@0 | 302 | /** |
michael@0 | 303 | * Checks to see if a parameter exists in the command line |
michael@0 | 304 | * parameter list. |
michael@0 | 305 | * |
michael@0 | 306 | * @param param the parameter to search for. |
michael@0 | 307 | * |
michael@0 | 308 | * @return TRUE if the parameter exists in the current list. |
michael@0 | 309 | */ |
michael@0 | 310 | boolean parameterExists(in AString param); |
michael@0 | 311 | }; |
michael@0 | 312 | |
michael@0 | 313 | /** |
michael@0 | 314 | * nsIWebHandlerApp is a web-based handler, as speced by the WhatWG HTML5 |
michael@0 | 315 | * draft. Currently, only GET-based handlers are supported. At some point, |
michael@0 | 316 | * we probably want to work with WhatWG to spec out and implement POST-based |
michael@0 | 317 | * handlers as well. |
michael@0 | 318 | */ |
michael@0 | 319 | [scriptable, uuid(7521a093-c498-45ce-b462-df7ba0d882f6)] |
michael@0 | 320 | interface nsIWebHandlerApp : nsIHandlerApp { |
michael@0 | 321 | |
michael@0 | 322 | /** |
michael@0 | 323 | * Template used to construct the URI to GET. Template is expected to have |
michael@0 | 324 | * a %s in it, and the escaped URI to be handled is inserted in place of |
michael@0 | 325 | * that %s, as per the HTML5 spec. |
michael@0 | 326 | */ |
michael@0 | 327 | attribute AUTF8String uriTemplate; |
michael@0 | 328 | }; |
michael@0 | 329 | |
michael@0 | 330 | /** |
michael@0 | 331 | * nsIDBusHandlerApp represents local applications launched by DBus a message |
michael@0 | 332 | * invoking a method taking a single string argument descibing a URI |
michael@0 | 333 | */ |
michael@0 | 334 | [scriptable, uuid(1ffc274b-4cbf-4bb5-a635-05ad2cbb6534)] |
michael@0 | 335 | interface nsIDBusHandlerApp : nsIHandlerApp { |
michael@0 | 336 | |
michael@0 | 337 | /** |
michael@0 | 338 | * Service defines the dbus service that should handle this protocol. |
michael@0 | 339 | * If its not set, NS_ERROR_FAILURE will be returned by LaunchWithURI |
michael@0 | 340 | */ |
michael@0 | 341 | attribute AUTF8String service; |
michael@0 | 342 | |
michael@0 | 343 | /** |
michael@0 | 344 | * Objpath defines the object path of the dbus service that should handle |
michael@0 | 345 | * this protocol. If its not set, NS_ERROR_FAILURE will be returned |
michael@0 | 346 | * by LaunchWithURI |
michael@0 | 347 | */ |
michael@0 | 348 | attribute AUTF8String objectPath; |
michael@0 | 349 | |
michael@0 | 350 | /** |
michael@0 | 351 | * DBusInterface defines the interface of the dbus service that should |
michael@0 | 352 | * handle this protocol. If its not set, NS_ERROR_FAILURE will be |
michael@0 | 353 | * returned by LaunchWithURI |
michael@0 | 354 | */ |
michael@0 | 355 | attribute AUTF8String dBusInterface; |
michael@0 | 356 | |
michael@0 | 357 | /** |
michael@0 | 358 | * Method defines the dbus method that should be invoked to handle this |
michael@0 | 359 | * protocol. If its not set, NS_ERROR_FAILURE will be returned by |
michael@0 | 360 | * LaunchWithURI |
michael@0 | 361 | */ |
michael@0 | 362 | attribute AUTF8String method; |
michael@0 | 363 | |
michael@0 | 364 | }; |
michael@0 | 365 |