Last Comment Bug 639467 - External URI handling broken due to protocol handler registration changes
: External URI handling broken due to protocol handler registration changes
Status: RESOLVED FIXED
:
Product: Core Graveyard
Classification: Graveyard
Component: File Handling (show other bugs)
: Trunk
: All Linux
: -- normal (vote)
: mozilla6
Assigned To: Chris Coulson
:
Mentors:
Depends on: 611953
Blocks:
  Show dependency treegraph
 
Reported: 2011-03-07 05:28 PST by Chris Coulson
Modified: 2016-06-22 12:16 PDT (History)
1 user (show)
See Also:
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
Use GIO for finding the default handler (3.50 KB, patch)
2011-03-07 05:28 PST, Chris Coulson
karlt: review+
Details | Diff | Splinter Review
Use GIO for finding the default handler (v2) (3.51 KB, patch)
2011-04-13 04:03 PDT, Chris Coulson
no flags Details | Diff | Splinter Review
Use GIO for finding the default handler (v3) (3.54 KB, patch)
2011-04-13 09:19 PDT, Chris Coulson
no flags Details | Diff | Splinter Review

Description Chris Coulson 2011-03-07 05:28:46 PST
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
Comment 1 Karl Tomlinson (:karlt) 2011-04-11 18:12:33 PDT
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?
Comment 2 Chris Coulson 2011-04-12 17:40:23 PDT
(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 3 Karl Tomlinson (:karlt) 2011-04-12 17:49:39 PDT
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?
Comment 4 Chris Coulson 2011-04-13 04:03:55 PDT
Created attachment 525655 [details] [diff] [review]
Use GIO for finding the default handler (v2)

Thanks, I've fixed the indentation now
Comment 5 Karl Tomlinson (:karlt) 2011-04-13 09:12:29 PDT
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)".
Comment 6 Chris Coulson 2011-04-13 09:19:11 PDT
Created attachment 525691 [details] [diff] [review]
Use GIO for finding the default handler (v3)

Oops, yes you're right, sorry. Here we go again :)
Comment 7 Karl Tomlinson (:karlt) 2011-05-08 17:14:20 PDT
http://hg.mozilla.org/mozilla-central/rev/46a89f1c9263

Note You need to log in before you can comment on or make changes to this bug.