gecko-dev/uriloader/exthandler/nsIExternalProtocolService.idl

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

161 строка
6.4 KiB
Plaintext
Исходник Постоянная ссылка Обычный вид История

/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
2012-05-21 15:12:37 +04:00
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
interface nsIURI;
interface nsIFile;
interface nsIPrincipal;
interface nsIInterfaceRequestor;
interface nsIHandlerInfo;
webidl BrowsingContext;
/**
* The external protocol service is used for finding and launching
* web handlers (a la registerProtocolHandler in the HTML5 draft) or
* platform-specific applications for handling particular protocols.
*
* You can ask the external protocol service if it has an external
* handler for a given protocol scheme. And you can ask it to load
* the url using the default handler.
*/
[scriptable, uuid(70f93b7a-3ec6-4bcb-b093-92d9984c9f83)]
interface nsIExternalProtocolService : nsISupports
{
/**
* Check whether a handler for a specific protocol exists. Specifically,
* this looks to see whether there are any known possible application handlers
* in either the nsIHandlerService datastore or registered with the OS.
*
* @param aProtocolScheme The scheme from a url: http, ftp, mailto, etc.
*
* @return true if we have a handler and false otherwise.
*
* XXX shouldn't aProtocolScheme be an ACString like nsIURI::scheme?
*/
boolean externalProtocolHandlerExists(in string aProtocolScheme);
/**
* Check whether a handler for a specific protocol is "exposed" as a visible
* feature of the current application.
*
* An exposed protocol handler is one that can be used in all contexts. A
* non-exposed protocol handler is one that can only be used internally by the
* application. For example, a non-exposed protocol would not be loaded by the
* application in response to a link click or a X-remote openURL command.
* Instead, it would be deferred to the system's external protocol handler.
* XXX shouldn't aProtocolScheme be an ACString like nsIURI::scheme?
*/
boolean isExposedProtocol(in string aProtocolScheme);
/**
* Retrieve the handler for the given protocol. If neither the application
* nor the OS knows about a handler for the protocol, the object this method
* returns will represent a default handler for unknown content.
*
* @param aProtocolScheme the scheme from a URL: http, ftp, mailto, etc.
*
* Note: aProtocolScheme should not include a trailing colon, which is part
* of the URI syntax, not part of the scheme itself (i.e. pass "mailto" not
* "mailto:").
*
* @return the handler, if any; otherwise a default handler
*/
nsIHandlerInfo getProtocolHandlerInfo(in ACString aProtocolScheme);
/**
* Given a scheme, looks up the protocol info from the OS. This should be
* overridden by each OS's implementation.
*
* @param aScheme The protocol scheme we are looking for.
* @param aFound Was an OS default handler for this scheme found?
* @return An nsIHanderInfo for the protocol.
*/
nsIHandlerInfo getProtocolHandlerInfoFromOS(in ACString aProtocolScheme,
out boolean aFound);
/**
* Set some sane defaults for a protocol handler object.
*
* @param aHandlerInfo nsIHandlerInfo object, as returned by
* getProtocolHandlerInfoFromOS
* @param aOSHandlerExists was the object above created for an extant
* OS default handler? This is generally the
* value of the aFound out param from
* getProtocolHandlerInfoFromOS.
*/
void setProtocolHandlerDefaults(in nsIHandlerInfo aHandlerInfo,
in boolean aOSHandlerExists);
/**
* Used to load a URI via an external application. Might prompt the user for
* permission to load the external application.
*
* @param aURI
* The URI to load
*
* @param aTriggeringPrincipal
* The principal triggering this load.
*
* @param aRedirectPrincipal
* The last post-redirect principal triggering this load.
* Used for display and permission purposes. If null, we'll
* use the triggering principal.
*
* @param aBrowsingContext
* The context to parent the dialog against, and, if a web handler
* is chosen, it is loaded in this window as well. This parameter
* may be ultimately passed nsIURILoader.openURI in the case of a
* web handler, and aWindowContext is null or not present, web
* handlers will fail. We need to do better than that; bug 394483
* filed in order to track.
*
* @param aWasTriggeredExternally
* If true, indicates the load was initiated by an external app.
*
* @param aHasValidUserGestureActivation
* Whether the document that triggered the load had user activation.
* Used for sandbox checks.
*
* @param aNewWindowTarget
* Whether the load is the first load being triggered in a new window
* (e.g. due to a call to window.open or a target=_blank link click).
*
* @note Embedders that do not expose the http protocol should not currently
* use web-based protocol handlers, as handoff won't work correctly
* (bug 394479).
*/
void loadURI(in nsIURI aURI,
[optional] in nsIPrincipal aTriggeringPrincipal,
[optional] in nsIPrincipal aRedirectPrincipal,
[optional] in BrowsingContext aBrowsingContext,
[optional] in boolean aWasTriggeredExternally,
[optional] in boolean aHasValidUserGestureActivation,
[optional] in boolean aNewWindowTarget);
/**
* Gets a human-readable description for the application responsible for
* handling a specific protocol.
*
* @param aScheme The scheme to look up. For example, "mms".
*
* @throw NS_ERROR_NOT_IMPLEMENTED
* If getting descriptions for protocol helpers is not supported
* @throw NS_ERROR_NOT_AVAILABLE
* If no protocol helper exists for this scheme, or if it is not
* possible to get a description for it.
*/
AString getApplicationDescription(in AUTF8String aScheme);
Bug 1496380 - stop recursion via the external protocol handler if Firefox is either the default OS handler or a configured external handler, r=mossop This is an initial implementation of this idea that works on mac. I've added a Windows implementation in another commit in this stack. I'll look at a Linux one in a follow-up bug. I do not think we need them in the child process implementation or on Android. Effectively, this makes nsIHandlerInfo::LaunchWithURI() fall back to asking if the handler info points to the OS default and that's us, or if it points to a helper app and that's us. The latter is fairly easy to check, but the former, more common case, is actually annoying - there don't seem to be APIs on the external helper app service or the handler service that provide any information about the app that's currently the default. So despite my belief that these interfaces have too many methods that all do very similar things, and what we need is fewer interfaces with fewer methods, I added another one... For this mac implementation, I'm comparing bundle URLs and added newer API usage for 10.10 and later to avoid deprecation warnings. I've not changed the mac shell service as it uses bundle identifiers to check if we're the default. Another way of fixing these issues would be to complain about things when we receive these URIs from external parties and our own config says that we will just hand them to someone else. I decided not to do so because we end up with at least one of the following problems: - if we implement in BrowserContentHandler, that won't help for PWAs/Thunderbird - if we try to implement in the external protocol handler, we'd need to start passing load flag information through to lots of checks. - it wouldn't stop the recursion until we've already done one round of it for links that are in webpages, which seems suboptimal (ie, if you clicked a mailto: link on a webpage it'd go to the OS with that mailto link and only realize something's awry when we've gone back through the OS to us, rather than straightaway). If we wanted to, we could add a fix like that in belt-and-suspenders fashion. Differential Revision: https://phabricator.services.mozilla.com/D48742 --HG-- extra : moz-landing-system : lando
2019-11-26 21:51:04 +03:00
/**
* Check if this app is registered as the OS default for a given scheme.
*
* @param aScheme The scheme to look up. For example, "mms".
*/
boolean isCurrentAppOSDefaultForProtocol(in AUTF8String aScheme);
};