-
-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
webextensions: add a portal for managing WebExtensions native messagi…
…ng servers. Rebase, fix and continue work on webextensions: add a portal for managing WebExtensions native messaging servers: #705 This commit builds on the work done in the original MR authored by @jhenstridge but resolves pending items and brings it closer to completion. This is intended to provide a way for a confined web browser to start native code helpers for their extensions. At present it can start the servers installed on the host system. But in future this could be extended to cover sandboxed native messaging servers too.
- Loading branch information
Showing
12 changed files
with
1,717 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
Copyright (C) 2022 Canonical Ltd | ||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 2 of the License, or (at your option) any later version. | ||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public | ||
License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
--> | ||
|
||
<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd"> | ||
<!-- | ||
org.freedesktop.portal.WebExtensions: | ||
@short_description: WebExtensions portal | ||
The WebExtensions portal allows sandboxed web browsers to start | ||
native messaging hosts installed on the host system. | ||
Accompanying documentation for Firefox's implementation is | ||
available: `Native messaging for a strictly-confined Firefox | ||
<https://firefox-source-docs.mozilla.org/toolkit/components/extensions/webextensions/native-messaging-portal-design.html>`_. | ||
This documentation describes version 1 of this interface. | ||
--> | ||
<interface name="org.freedesktop.portal.WebExtensions"> | ||
<!-- | ||
CreateSession: | ||
@options: Vardict with optional further information | ||
@session_handle: Object path for the #org.freedesktop.portal.Session created by this call. | ||
Create a web extensions session. A successfully created | ||
session can at any time be closed using | ||
org.freedesktop.portal.Session::Close, or may at any time be | ||
closed by the portal implementation, which will be signalled | ||
via org.freedesktop.portal.Session::Closed. | ||
To close a session, the browser should: | ||
1. close the process's stdin/stdout/stderr file descriptors | ||
obtained from the portal; | ||
2. wait for a D-Bus Closed signal from the portal on the | ||
org.freedesktop.portal.Session object (which will be | ||
triggered on SIGCHLD via the g_child_watch_add_full | ||
handler); and | ||
3. if the Closed signal from the portal doesn't come in time, | ||
call the Close method on the org.freedesktop.portal.Session | ||
object. | ||
Supported keys in the @options vardict include: | ||
<variablelist> | ||
<varlistentry> | ||
<term>mode s</term> | ||
<listitem><para> | ||
A string indicating which behaviour the portal should | ||
use when locating and starting native messaging | ||
hosts. Valid values are "mozilla" and "chromium". By | ||
default, mozilla behaviour is used. | ||
</para></listitem> | ||
</varlistentry> | ||
<varlistentry> | ||
<term>session_handle_token s</term> | ||
<listitem><para> | ||
A string that will be used as the last element of the session handle. Must be a valid | ||
object path element. See the #org.freedesktop.portal.Session documentation for | ||
more information about the session handle. | ||
</para></listitem> | ||
</varlistentry> | ||
</variablelist> | ||
--> | ||
<method name="CreateSession"> | ||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/> | ||
<arg type="a{sv}" name="options" direction="in"/> | ||
<arg type="o" name="session_handle" direction="out"/> | ||
</method> | ||
<!-- | ||
GetManifest: | ||
@session_handle: Object path for the #org.freedesktop.portal.Session object | ||
@name: name of the native messaging host | ||
@extension_or_origin: extension ID or origin URI identifying the extension | ||
@json_manifest: the JSON manifest for the native messaging host | ||
Return the JSON manifest of the native messaging host that | ||
Start would invoke. | ||
--> | ||
<method name="GetManifest"> | ||
<annotation name="org.qtproject.QtDBus.QtTypeName.In3" value="QVariantMap"/> | ||
<arg type="o" name="session_handle" direction="in"/> | ||
<arg type="s" name="name" direction="in"/> | ||
<arg type="s" name="extension_or_origin" direction="in"/> | ||
<annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="QVariantMap"/> | ||
<arg type="s" name="json_manifest" direction="out"/> | ||
</method> | ||
<!-- | ||
Start: | ||
@session_handle: Object path for the #org.freedesktop.portal.Session object | ||
@name: name of the native messaging host | ||
@extension_or_origin: extension ID or origin URI identifying the extension | ||
@options: Vardict with optional further information | ||
@handle: Object path for the #org.freedesktop.portal.Request object representing this call | ||
Start the named native messaging host. The caller must | ||
indicate the requesting web extension (either by extension ID | ||
for Firefox, or origin URI for Chrome), which will be matched | ||
against the host's access control list. | ||
If the host can't be started, or invalid data is provided, | ||
the session will be closed. | ||
Supported keys in the @options vardict include: | ||
<variablelist> | ||
<varlistentry> | ||
<term>handle_token s</term> | ||
<listitem><para> | ||
A string that will be used as the last element of the @handle. Must be a valid | ||
object path element. See the #org.freedesktop.portal.Request documentation for | ||
more information about the @handle. | ||
</para></listitem> | ||
</varlistentry> | ||
</variablelist> | ||
--> | ||
<method name="Start"> | ||
<arg type="o" name="session_handle" direction="in"/> | ||
<arg type="s" name="name" direction="in"/> | ||
<arg type="s" name="extension_or_origin" direction="in"/> | ||
<annotation name="org.qtproject.QtDBus.QtTypeName.In3" value="QVariantMap"/> | ||
<arg type="a{sv}" name="options" direction="in"/> | ||
<arg type="o" name="handle" direction="out"/> | ||
</method> | ||
<!-- | ||
GetPipes: | ||
@session_handle: Object path for the #org.freedesktop.portal.Session object | ||
@options: Vardict with optional further information | ||
@stdin: File descriptor representing the hosts's stdin. | ||
@stdout: File descriptor representing the host's stdout. | ||
@stderr: File descriptor representing the host's stderr. | ||
Retrieve file descriptors for the native messaging host | ||
identified by the session. This method should only be called | ||
after the Start request recveives a successful response. | ||
--> | ||
<method name="GetPipes"> | ||
<annotation name="org.gtk.GDBus.C.UnixFD" value="true"/> | ||
<arg type="o" name="session_handle" direction="in"/> | ||
<annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QVariantMap"/> | ||
<arg type="a{sv}" name="options" direction="in"/> | ||
<arg type="h" name="stdin" direction="out"/> | ||
<arg type="h" name="stdout" direction="out"/> | ||
<arg type="h" name="stderr" direction="out"/> | ||
</method> | ||
<property name="version" type="u" access="read"/> | ||
</interface> | ||
</node> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.