Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "nsISupports.idl" |
michael@0 | 8 | |
michael@0 | 9 | interface nsIURI; |
michael@0 | 10 | interface nsIFile; |
michael@0 | 11 | interface nsIInterfaceRequestor; |
michael@0 | 12 | interface nsIHandlerInfo; |
michael@0 | 13 | |
michael@0 | 14 | /** |
michael@0 | 15 | * The external protocol service is used for finding and launching |
michael@0 | 16 | * web handlers (a la registerProtocolHandler in the HTML5 draft) or |
michael@0 | 17 | * platform-specific applications for handling particular protocols. |
michael@0 | 18 | * |
michael@0 | 19 | * You can ask the external protocol service if it has an external |
michael@0 | 20 | * handler for a given protocol scheme. And you can ask it to load |
michael@0 | 21 | * the url using the default handler. |
michael@0 | 22 | */ |
michael@0 | 23 | [scriptable, uuid(70f93b7a-3ec6-4bcb-b093-92d9984c9f83)] |
michael@0 | 24 | interface nsIExternalProtocolService : nsISupports |
michael@0 | 25 | { |
michael@0 | 26 | /** |
michael@0 | 27 | * Check whether a handler for a specific protocol exists. Specifically, |
michael@0 | 28 | * this looks to see whether there are any known possible application handlers |
michael@0 | 29 | * in either the nsIHandlerService datastore or registered with the OS. |
michael@0 | 30 | * |
michael@0 | 31 | * @param aProtocolScheme The scheme from a url: http, ftp, mailto, etc. |
michael@0 | 32 | * |
michael@0 | 33 | * @return true if we have a handler and false otherwise. |
michael@0 | 34 | * |
michael@0 | 35 | * XXX shouldn't aProtocolScheme be an ACString like nsIURI::scheme? |
michael@0 | 36 | */ |
michael@0 | 37 | boolean externalProtocolHandlerExists(in string aProtocolScheme); |
michael@0 | 38 | |
michael@0 | 39 | /** |
michael@0 | 40 | * Check whether a handler for a specific protocol is "exposed" as a visible |
michael@0 | 41 | * feature of the current application. |
michael@0 | 42 | * |
michael@0 | 43 | * An exposed protocol handler is one that can be used in all contexts. A |
michael@0 | 44 | * non-exposed protocol handler is one that can only be used internally by the |
michael@0 | 45 | * application. For example, a non-exposed protocol would not be loaded by the |
michael@0 | 46 | * application in response to a link click or a X-remote openURL command. |
michael@0 | 47 | * Instead, it would be deferred to the system's external protocol handler. |
michael@0 | 48 | * XXX shouldn't aProtocolScheme be an ACString like nsIURI::scheme? |
michael@0 | 49 | */ |
michael@0 | 50 | boolean isExposedProtocol(in string aProtocolScheme); |
michael@0 | 51 | |
michael@0 | 52 | /** |
michael@0 | 53 | * Retrieve the handler for the given protocol. If neither the application |
michael@0 | 54 | * nor the OS knows about a handler for the protocol, the object this method |
michael@0 | 55 | * returns will represent a default handler for unknown content. |
michael@0 | 56 | * |
michael@0 | 57 | * @param aProtocolScheme the scheme from a URL: http, ftp, mailto, etc. |
michael@0 | 58 | * |
michael@0 | 59 | * Note: aProtocolScheme should not include a trailing colon, which is part |
michael@0 | 60 | * of the URI syntax, not part of the scheme itself (i.e. pass "mailto" not |
michael@0 | 61 | * "mailto:"). |
michael@0 | 62 | * |
michael@0 | 63 | * @return the handler, if any; otherwise a default handler |
michael@0 | 64 | */ |
michael@0 | 65 | nsIHandlerInfo getProtocolHandlerInfo(in ACString aProtocolScheme); |
michael@0 | 66 | |
michael@0 | 67 | /** |
michael@0 | 68 | * Given a scheme, looks up the protocol info from the OS. This should be |
michael@0 | 69 | * overridden by each OS's implementation. |
michael@0 | 70 | * |
michael@0 | 71 | * @param aScheme The protocol scheme we are looking for. |
michael@0 | 72 | * @param aFound Was an OS default handler for this scheme found? |
michael@0 | 73 | * @return An nsIHanderInfo for the protocol. |
michael@0 | 74 | */ |
michael@0 | 75 | nsIHandlerInfo getProtocolHandlerInfoFromOS(in ACString aProtocolScheme, |
michael@0 | 76 | out boolean aFound); |
michael@0 | 77 | |
michael@0 | 78 | /** |
michael@0 | 79 | * Set some sane defaults for a protocol handler object. |
michael@0 | 80 | * |
michael@0 | 81 | * @param aHandlerInfo nsIHandlerInfo object, as returned by |
michael@0 | 82 | * getProtocolHandlerInfoFromOS |
michael@0 | 83 | * @param aOSHandlerExists was the object above created for an extant |
michael@0 | 84 | * OS default handler? This is generally the |
michael@0 | 85 | * value of the aFound out param from |
michael@0 | 86 | * getProtocolHandlerInfoFromOS. |
michael@0 | 87 | */ |
michael@0 | 88 | void setProtocolHandlerDefaults(in nsIHandlerInfo aHandlerInfo, |
michael@0 | 89 | in boolean aOSHandlerExists); |
michael@0 | 90 | |
michael@0 | 91 | /** |
michael@0 | 92 | * Used to load a url via an external protocol handler (if one exists) |
michael@0 | 93 | * |
michael@0 | 94 | * @param aURL The url to load |
michael@0 | 95 | * |
michael@0 | 96 | * @deprecated Use LoadURI instead (See Bug 389565 for removal) |
michael@0 | 97 | */ |
michael@0 | 98 | [deprecated] void loadUrl(in nsIURI aURL); |
michael@0 | 99 | |
michael@0 | 100 | /** |
michael@0 | 101 | * Used to load a URI via an external application. Might prompt the user for |
michael@0 | 102 | * permission to load the external application. |
michael@0 | 103 | * |
michael@0 | 104 | * @param aURI |
michael@0 | 105 | * The URI to load |
michael@0 | 106 | * |
michael@0 | 107 | * @param aWindowContext |
michael@0 | 108 | * The window to parent the dialog against, and, if a web handler |
michael@0 | 109 | * is chosen, it is loaded in this window as well. This parameter |
michael@0 | 110 | * may be ultimately passed nsIURILoader.openURI in the case of a |
michael@0 | 111 | * web handler, and aWindowContext is null or not present, web |
michael@0 | 112 | * handlers will fail. We need to do better than that; bug 394483 |
michael@0 | 113 | * filed in order to track. |
michael@0 | 114 | * |
michael@0 | 115 | * @note Embedders that do not expose the http protocol should not currently |
michael@0 | 116 | * use web-based protocol handlers, as handoff won't work correctly |
michael@0 | 117 | * (bug 394479). |
michael@0 | 118 | */ |
michael@0 | 119 | void loadURI(in nsIURI aURI, |
michael@0 | 120 | [optional] in nsIInterfaceRequestor aWindowContext); |
michael@0 | 121 | |
michael@0 | 122 | /** |
michael@0 | 123 | * Gets a human-readable description for the application responsible for |
michael@0 | 124 | * handling a specific protocol. |
michael@0 | 125 | * |
michael@0 | 126 | * @param aScheme The scheme to look up. For example, "mms". |
michael@0 | 127 | * |
michael@0 | 128 | * @throw NS_ERROR_NOT_IMPLEMENTED |
michael@0 | 129 | * If getting descriptions for protocol helpers is not supported |
michael@0 | 130 | * @throw NS_ERROR_NOT_AVAILABLE |
michael@0 | 131 | * If no protocol helper exists for this scheme, or if it is not |
michael@0 | 132 | * possible to get a description for it. |
michael@0 | 133 | */ |
michael@0 | 134 | AString getApplicationDescription(in AUTF8String aScheme); |
michael@0 | 135 | }; |