-
-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
webextensions: add a portal for managing WebExtensions native messaging servers #705
base: main
Are you sure you want to change the base?
Changes from all commits
dbc110c
c9e02e9
4949408
d8885ee
b495e5d
d5a5260
e84d0fa
66edca5
da96923
ec70a7b
e101338
28df915
640d4fc
78ab279
d2375d5
e48d9eb
bec4a1b
7b14ac4
5026bd9
bcef3c7
20cd02f
916ae2a
f2cdd8e
838cadc
21e3a9a
f2d0e70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,158 @@ | ||||||
<?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. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also add a link to https://firefox-source-docs.mozilla.org/toolkit/components/extensions/webextensions/native-messaging-portal-design.html That link is currently 404, but it will be populated once the patch lands, following the documentation changes + review requested after https://phabricator.services.mozilla.com/D140803#5413606 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Link added. |
||||||
--> | ||||||
<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. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Elsewhere in this review (and earlier, at #705 (comment)) I described the expected behavior when a session is closed. Let's explicitly document what one can expect to happen when the Close is received, and what cause when Closed is signaled. See my comment elsewhere in this review round to get an idea of what you could document. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Explanatory comment added. |
||||||
|
||||||
To close a session, the browser should: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The steps below assume the presence of a process + pipes. That is only if Start + GetPipes have already returned. If it is before, then we should just close the session, right? Here is a tweak to clarify when the following sequence should be followed:
Suggested change
|
||||||
|
||||||
1. close the process's stdin/stdout/stderr file descriptors | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Firefox doesn't close stdout/stderr, only stdin. It is possible for the native application to continue writing to stderr which could help with debugging if desired. Here is a suggestion that is more accurate.
Suggested change
|
||||||
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"/> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this need annotations for Qt. See #1531 |
||||||
<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"> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the reason There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The https://phabricator.services.mozilla.com/D140803#inline-868567 We had the Mozilla side patches working without this method before hand, but they wanted to validate the manifest themselves (even though the browser won't be able to directly launch the native messaging server). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't they validate after starting? The end result here, with this method, is that any application can without any interference or feedback to the user probe the system for installed native messaging hosts. I realize it's not as bad as arbitrary access to |
||||||
<arg type="o" name="session_handle" direction="in"/> | ||||||
<arg type="s" name="name" direction="in"/> | ||||||
<arg type="s" name="extension_or_origin" direction="in"/> | ||||||
<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"/> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. annotation here too. |
||||||
<arg type="o" name="handle" direction="out"/> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this have a |
||||||
</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"/> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and annotation here. |
||||||
<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> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ src/screenshot.c | |
src/settings.c | ||
src/usb.c | ||
src/wallpaper.c | ||
src/web-extensions.c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This link leads to a 404.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't read the next comment https://github.com/flatpak/xdg-desktop-portal/pull/705/files#r1066436897