Bug 1890277: part 1) Add CSP parser tests for `require-trusted-types-for`. r=tschuster
[gecko.git] / uriloader / exthandler / nsIExternalProtocolService.idl
blob5c544a967d2a0b07a5a804afa16f5fe36a4d4e8d
1 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "nsISupports.idl"
9 interface nsIURI;
10 interface nsIFile;
11 interface nsIPrincipal;
12 interface nsIInterfaceRequestor;
13 interface nsIHandlerInfo;
15 webidl BrowsingContext;
17 /**
18 * The external protocol service is used for finding and launching
19 * web handlers (a la registerProtocolHandler in the HTML5 draft) or
20 * platform-specific applications for handling particular protocols.
22 * You can ask the external protocol service if it has an external
23 * handler for a given protocol scheme. And you can ask it to load
24 * the url using the default handler.
26 [scriptable, uuid(70f93b7a-3ec6-4bcb-b093-92d9984c9f83)]
27 interface nsIExternalProtocolService : nsISupports
29 /**
30 * Check whether a handler for a specific protocol exists. Specifically,
31 * this looks to see whether there are any known possible application handlers
32 * in either the nsIHandlerService datastore or registered with the OS.
34 * @param aProtocolScheme The scheme from a url: http, ftp, mailto, etc.
36 * @return true if we have a handler and false otherwise.
38 * XXX shouldn't aProtocolScheme be an ACString like nsIURI::scheme?
40 boolean externalProtocolHandlerExists(in string aProtocolScheme);
42 /**
43 * Check whether a handler for a specific protocol is "exposed" as a visible
44 * feature of the current application.
46 * An exposed protocol handler is one that can be used in all contexts. A
47 * non-exposed protocol handler is one that can only be used internally by the
48 * application. For example, a non-exposed protocol would not be loaded by the
49 * application in response to a link click or a X-remote openURL command.
50 * Instead, it would be deferred to the system's external protocol handler.
51 * XXX shouldn't aProtocolScheme be an ACString like nsIURI::scheme?
53 boolean isExposedProtocol(in string aProtocolScheme);
55 /**
56 * Retrieve the handler for the given protocol. If neither the application
57 * nor the OS knows about a handler for the protocol, the object this method
58 * returns will represent a default handler for unknown content.
60 * @param aProtocolScheme the scheme from a URL: http, ftp, mailto, etc.
62 * Note: aProtocolScheme should not include a trailing colon, which is part
63 * of the URI syntax, not part of the scheme itself (i.e. pass "mailto" not
64 * "mailto:").
66 * @return the handler, if any; otherwise a default handler
68 nsIHandlerInfo getProtocolHandlerInfo(in ACString aProtocolScheme);
70 /**
71 * Given a scheme, looks up the protocol info from the OS. This should be
72 * overridden by each OS's implementation.
74 * @param aScheme The protocol scheme we are looking for.
75 * @param aFound Was an OS default handler for this scheme found?
76 * @return An nsIHanderInfo for the protocol.
78 nsIHandlerInfo getProtocolHandlerInfoFromOS(in ACString aProtocolScheme,
79 out boolean aFound);
81 /**
82 * Set some sane defaults for a protocol handler object.
84 * @param aHandlerInfo nsIHandlerInfo object, as returned by
85 * getProtocolHandlerInfoFromOS
86 * @param aOSHandlerExists was the object above created for an extant
87 * OS default handler? This is generally the
88 * value of the aFound out param from
89 * getProtocolHandlerInfoFromOS.
91 void setProtocolHandlerDefaults(in nsIHandlerInfo aHandlerInfo,
92 in boolean aOSHandlerExists);
94 /**
95 * Used to load a URI via an external application. Might prompt the user for
96 * permission to load the external application.
98 * @param aURI
99 * The URI to load
101 * @param aTriggeringPrincipal
102 * The principal triggering this load.
104 * @param aRedirectPrincipal
105 * The last post-redirect principal triggering this load.
106 * Used for display and permission purposes. If null, we'll
107 * use the triggering principal.
109 * @param aBrowsingContext
110 * The context to parent the dialog against, and, if a web handler
111 * is chosen, it is loaded in this window as well. This parameter
112 * may be ultimately passed nsIURILoader.openURI in the case of a
113 * web handler, and aWindowContext is null or not present, web
114 * handlers will fail. We need to do better than that; bug 394483
115 * filed in order to track.
117 * @param aWasTriggeredExternally
118 * If true, indicates the load was initiated by an external app.
120 * @param aHasValidUserGestureActivation
121 * Whether the document that triggered the load had user activation.
122 * Used for sandbox checks.
124 * @note Embedders that do not expose the http protocol should not currently
125 * use web-based protocol handlers, as handoff won't work correctly
126 * (bug 394479).
128 void loadURI(in nsIURI aURI,
129 [optional] in nsIPrincipal aTriggeringPrincipal,
130 [optional] in nsIPrincipal aRedirectPrincipal,
131 [optional] in BrowsingContext aBrowsingContext,
132 [optional] in boolean aWasTriggeredExternally,
133 [optional] in boolean aHasValidUserGestureActivation);
136 * Gets a human-readable description for the application responsible for
137 * handling a specific protocol.
139 * @param aScheme The scheme to look up. For example, "mms".
141 * @throw NS_ERROR_NOT_IMPLEMENTED
142 * If getting descriptions for protocol helpers is not supported
143 * @throw NS_ERROR_NOT_AVAILABLE
144 * If no protocol helper exists for this scheme, or if it is not
145 * possible to get a description for it.
147 AString getApplicationDescription(in AUTF8String aScheme);
150 * Check if this app is registered as the OS default for a given scheme.
152 * @param aScheme The scheme to look up. For example, "mms".
154 boolean isCurrentAppOSDefaultForProtocol(in AUTF8String aScheme);