This was way too hard!
We really need to reimplement in-browser view source mode. But we have always supported external view source mode, using the default text/plain handler, via a hidden GSetting. So even once we restore in-browser view source, we will still want to keep this code around.
We have to use the portal D-Bus API manually because the only way to get it using GLib is to use g_app_info_launch_default_for_uri(), and that will always pick Epiphany itself as the default handler, because Epiphany supports opening HTML files. The portal is only accessible via a fallback path.
5d7e8272f flatpak: Implement view page source
lib/ephy-flatpak-utils.c | 236 +++++++++++++++++++++++++++++++++++++++++++++++
lib/ephy-flatpak-utils.h | 10 +-
src/window-commands.c | 84 +++++++++++++++--
3 files changed, 320 insertions(+), 10 deletions(-)