External URI handling broken due to protocol handler registration changes

RESOLVED FIXED in mozilla6

Status

Core Graveyard
File Handling
RESOLVED FIXED
6 years ago
11 months ago

People

(Reporter: Chris Coulson, Assigned: Chris Coulson)

Tracking

Trunk
mozilla6
All
Linux

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 2 obsolete attachments)

(Assignee)

Description

6 years ago
Created attachment 517395 [details] [diff] [review]
Use GIO for finding the default handler

We're trying to get u1ms:// URI's to open in Banshee in Ubuntu, and have registered the handler in the proper way (it's desktop file defines x-scheme-handler/u1ms in its MimeType field). However, clicking u1ms links in Firefox results in a dialog with the following message being displayed:

"Firefox doesn't know how to open this address, because the protocol (u1ms) isn't associated with any program."

(Note, that we're building Firefox with --enable-gio in Ubuntu, as this doesn't work in gnomevfs at all anymore)

This is because nsGNOMERegistry::HandlerExists checks for the existence of a protocol handler by looking directly at the GConf keys in /desktop/gnome/url-handlers, which are deprecated in GNOME 3.0 (see also bug 611953). When built with --enable-gio, nsGNOMERegistry::HandlerExists should use the gio API directly.

Note, this bug applies to any URI which needs to be handled by an external application (eg, mailto:// links only work on my machine by virtue of having stale entries in /desktop/gnome/url-handlers, and those don't match my preferred mail client anyway).

I've attached a patch which fixes this. Unfortunately, it depends on the patches on bug 611953 too, as it uses the new nsIGIOService::GetAppForURIScheme
(Assignee)

Updated

6 years ago
(Assignee)

Updated

6 years ago
Assignee: nobody → chrisccoulson
(Assignee)

Updated

6 years ago
Attachment #517395 - Flags: review?(roc)
(Assignee)

Updated

6 years ago
Depends on: 611953
Attachment #517395 - Flags: review?(roc) → review?(karlt)
Comment on attachment 517395 [details] [diff] [review]
Use GIO for finding the default handler

nsGIOService::Init() always returns true, so IIUC the presence of NS_GIOSERVICE_CONTRACTID indicates the presence of GIO but not necessarily GVFS.
Would it be reasonable to fall back to GConf if nsIGIOService::GetAppForURIScheme failed?
(Assignee)

Comment 2

6 years ago
(In reply to comment #1)
> Comment on attachment 517395 [details] [diff] [review]
> Use GIO for finding the default handler
> 
> nsGIOService::Init() always returns true, so IIUC the presence of
> NS_GIOSERVICE_CONTRACTID indicates the presence of GIO but not necessarily
> GVFS.
> Would it be reasonable to fall back to GConf if
> nsIGIOService::GetAppForURIScheme failed?

I don't think we need to do that. With glib >= 2.28, nsIGIOService::GetAppForURIScheme will work regardless of whether gvfs is present (g_app_info_get_default_for_uri_scheme is implemented independently of the vfs backend).

On older glib versions this was delegated to a gvfs module (which just did the lookup in the legacy gconf settings). If gvfs is missing in this case, falling back to gconf to do the lookup won't help much. Launching will fail straight afterwards even if we do find the handler, as the launch is already done via GIO (with no fallback) and depends on gvfs being present (glib < 2.28)
Comment on attachment 517395 [details] [diff] [review]
Use GIO for finding the default handler

(In reply to comment #2)
> Launching will fail straight
> afterwards even if we do find the handler, as the launch is already done via
> GIO (with no fallback) and depends on gvfs being present (glib < 2.28)

OK.  There's nothing to lose then.

>+    if (NS_FAILED(giovfs->GetAppForURIScheme(nsDependentCString(aProtocolScheme),
>+        getter_AddRefs(app))))

Can you align the "getter_AddRefs(app))" argument with the first argument of the function call, please?
Attachment #517395 - Flags: review?(karlt) → review+
(Assignee)

Comment 4

6 years ago
Created attachment 525655 [details] [diff] [review]
Use GIO for finding the default handler (v2)

Thanks, I've fixed the indentation now
Attachment #517395 - Attachment is obsolete: true
Attachment #525655 - Flags: review+
(Assignee)

Updated

6 years ago
Attachment #525655 - Flags: review+ → review?
(Assignee)

Updated

6 years ago
Attachment #525655 - Flags: review?
Comment on attachment 525655 [details] [diff] [review]
Use GIO for finding the default handler (v2)

>+    if (NS_FAILED(giovfs->GetAppForURIScheme(nsDependentCString(aProtocolScheme),
>+                  getter_AddRefs(app))))

"getter_AddRefs(app)" is not a parameter to NS_FAILED() but to GetAppForURIScheme() so it should be aligned with "nsDependentCString(aProtocolScheme)".
(Assignee)

Comment 6

6 years ago
Created attachment 525691 [details] [diff] [review]
Use GIO for finding the default handler (v3)

Oops, yes you're right, sorry. Here we go again :)
Attachment #525655 - Attachment is obsolete: true
http://hg.mozilla.org/mozilla-central/rev/46a89f1c9263
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla6
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.