After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 720245 - Search provider should spawn the default browser instead of ephy
Search provider should spawn the default browser instead of ephy
Status: RESOLVED WONTFIX
Product: epiphany
Classification: Core
Component: General
git master
Other Mac OS
: Normal normal
: ---
Assigned To: Epiphany Maintainers
Epiphany Maintainers
: 753774 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-12-11 11:26 UTC by Carlos Garcia Campos
Modified: 2015-08-30 13:54 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
search-provider: use default web browser (1.65 KB, patch)
2014-09-11 03:45 UTC, Michael Catanzaro
reviewed Details | Review
search-provider: launch results in default browser (1.46 KB, patch)
2014-09-11 14:47 UTC, Michael Catanzaro
none Details | Review
search-provider: launch results in default browser (1.41 KB, patch)
2014-09-11 14:49 UTC, Michael Catanzaro
reviewed Details | Review
search provider: open result in default browser (1.56 KB, patch)
2014-09-11 21:05 UTC, Michael Catanzaro
committed Details | Review
Revert "search provider: open result in default browser" (1.63 KB, patch)
2014-09-22 13:24 UTC, Michael Catanzaro
committed Details | Review

Description Carlos Garcia Campos 2013-12-11 11:26:58 UTC
We are currently spawning an ephy process unconditionally from the search provider. We should use gvfs open to launch the default browser instead.
Comment 1 Michael Catanzaro 2014-09-11 03:45:23 UTC
Created attachment 285879 [details] [review]
search-provider: use default web browser

The search provider should be useful even if the user's default web
browser isn't epiphany. This allows distros that are hesitant to ship
epiphany to package the search provider separately from the desktop
file. Use gvfs-open to open the URI in the default browser, and fall
back to epiphany if it's not installed.

I haven't figured out how to test this. If I edit /usr/share/dbus-1/services
and replace the Exec line with the path to the search provider in my jhbuild
install prefix, it doesn't work at all....
Comment 2 Carlos Garcia Campos 2014-09-11 07:32:45 UTC
Review of attachment 285879 [details] [review]:

::: src/ephy-search-provider.c
@@ +271,3 @@
+
+  /* Attempt to display results in the user's default browser. */
+  str = g_strdup_printf ("gvfs-open %s", uri);

Instead of spawning gvfs-open, we can use GAppInfo API, and we don't depend on gvfs. We can get the default application to handle HTML and supporing URIs (it should be something like g_app_info_get_default_for_type ("text/html", TRUE)) and then create GdkAppLaunchContext (that would also fix the TODO: Handle the timestamp if you pass the timestamp to the launch context). And finally you only need to call g_app_info_launch_uris(). That will spawn the process for you, or will 'activate' the application via DBus if supported.
Comment 3 Michael Catanzaro 2014-09-11 14:47:48 UTC
Created attachment 285918 [details] [review]
search-provider: launch results in default browser

This way, the search provider will be semi-useful even if the Epiphany
desktop file is not installed.

I haven't figured out how to test this. If I edit /usr/share/dbus-1/services
and replace the Exec line with the path to the search provider in my jhbuild
install prefix, it doesn't work at all....
Comment 4 Michael Catanzaro 2014-09-11 14:49:14 UTC
Created attachment 285919 [details] [review]
search-provider: launch results in default browser

Fix bogus bug reference
Comment 5 Carlos Garcia Campos 2014-09-11 15:05:40 UTC
Review of attachment 285919 [details] [review]:

::: src/ephy-search-provider.c
@@ +269,3 @@
+  GdkDisplay *display;
+  GdkAppLaunchContext *context;
+  GError *error;

This should be initialized to NULL.

@@ +278,3 @@
+  gdk_app_launch_context_set_timestamp (context, timestamp);
+
+  if (!g_app_info_launch_default_for_uri (uri, G_APP_LAUNCH_CONTEXT (context), &error)) {

I think launch_default_for_uri() also depends on gvfs, we don't need to guess the content type based on the uri, we already know we want th the default application to show HTML and that can handle URIs. That's why I proposed to use g_app_info_get_default_for_type() + g_app_info_launch_uris(), otherwise gtk_show_uri() would be even simpler
Comment 6 Michael Catanzaro 2014-09-11 21:05:41 UTC
Created attachment 285952 [details] [review]
search provider: open result in default browser
Comment 7 Carlos Garcia Campos 2014-09-12 06:16:59 UTC
Comment on attachment 285952 [details] [review]
search provider: open result in default browser

Thanks.
Comment 8 Michael Catanzaro 2014-09-12 13:57:15 UTC
Attachment 285952 [details] pushed as faaa23c - search provider: open result in default browser
Comment 9 Michael Catanzaro 2014-09-21 19:06:17 UTC
(In reply to comment #3)
> I haven't figured out how to test this. If I edit /usr/share/dbus-1/services
> and replace the Exec line with the path to the search provider in my jhbuild
> install prefix, it doesn't work at all....

Any hints on how to test search provider changes? I'm getting reports on IRC that launching results is broken, and I assume this commit is to blame.
Comment 10 Michael Catanzaro 2014-09-22 13:24:34 UTC
Created attachment 286810 [details] [review]
Revert "search provider: open result in default browser"

This reverts commit faaa23cb8956336fcd16258fd74ab9f69c01e438.
Comment 11 Michael Catanzaro 2014-09-22 13:25:28 UTC
Comment on attachment 286810 [details] [review]
Revert "search provider: open result in default browser"

Attachment 286810 [details] pushed as 1a058ad - Revert "search provider: open result in default browser"
Comment 12 Giovanni Campagna 2014-09-22 16:40:31 UTC
(In reply to comment #9)
> (In reply to comment #3)
> > I haven't figured out how to test this. If I edit /usr/share/dbus-1/services
> > and replace the Exec line with the path to the search provider in my jhbuild
> > install prefix, it doesn't work at all....
> 
> Any hints on how to test search provider changes? I'm getting reports on IRC
> that launching results is broken, and I assume this commit is to blame.

The problem is, the search provider is a GApplication, not a GtkApplication, so GDK is not initialized and gdk_display_get_default() returns NULL.
Comment 13 Michael Catanzaro 2014-09-22 17:16:15 UTC
OK, that makes sense. Thanks for debugging, Giovanni.

In other news, I finally figured out how to test changes to the search provider. In /usr/share/dbus-1/services/org.gnome.Epiphany.service, I have to change the Name line, not just the Exec line, since that changed in 3.12:

[D-BUS Service]
#Name=org.gnome.Epiphany
#Exec=/usr/bin/epiphany --headless-mode
Name=org.gnome.EpiphanySearchProvider
Exec=/home/mcatanzaro/jhbuild/install/libexec/epiphany-search-provider

All of which seems obvious in retrospect. Alas.

Anyway, Matthias requested that search providers not launch different applications. Maybe this makes sense, especially since Epiphany's is primarily useful for searching Epiphany's history and bookmarks, and the only way to change the search engine is Epiphany's preferences dialog. I don't really care either way; launching another browser seems harmless to me.
Comment 14 Florian Müllner 2015-08-19 10:43:06 UTC
*** Bug 753774 has been marked as a duplicate of this bug. ***
Comment 15 Michael Catanzaro 2015-08-30 13:54:10 UTC
I think the verdict on this (which never made it onto Bugzilla) was that search providers should not launch unrelated applications.