Comment 4 for bug 562580

Revision history for this message
Marc Tardif (cr3) wrote :

When looking at this problem more closely, I found a couple problems which actually provide a solution:

The first problem is that, even for known browsers like firefox and epiphany, the following code does not necessarily get called:

                    gct = subprocess.Popen(sudo_prefix + ["gconftool", "--get",
                        "/desktop/gnome/url-handlers/http/command"],
                        stdout=subprocess.PIPE, stderr=subprocess.PIPE)
                    if gct.returncode == 0:

The reason is that returncode will be set to None until the process has completed. Instead, the above conditionnal statement should be changed to the following code in order to consider the output from gconftool:

                    if gct.wait() == 0:

The second problem, which depends on the above problem being fixed, is that only firefox and epiphany are being treated specifically. The reason is to make sure that another browser window gets opened instead of a new tab being opened in a browser window in the background. So, this code should remain the same but the http command should be leveraged to open the corresponding browser:

                        subprocess.call(sudo_prefix + [preferred_browser % url], shell=True)
                        sys.exit(0)

Once both problems are solved, then the expected browser should be called regardless of the extension or mime type of the given url.