Bug 351303 - Register an URL protocol with the operating system
Summary: Register an URL protocol with the operating system
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Runtime (show other bugs)
Version: 4.1   Edit
Hardware: All All
: P3 enhancement with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: platform-runtime-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 525305 527579
  Show dependency tree
 
Reported: 2011-07-06 06:52 EDT by Robert Gruendler CLA
Modified: 2018-07-13 17:37 EDT (History)
17 users (show)

See Also:


Attachments
URL scheme patch for osx (9.57 KB, patch)
2013-04-12 16:49 EDT, Robert Gruendler CLA
no flags Details | Diff
Patch for Equinox 3.7 Cocoa to listen for open URL evetns (4.25 KB, patch)
2013-11-13 06:08 EST, Mads Tandrup CLA
no flags Details | Diff
Open URL event introduced to SWT 3.7 Cocoa (4.11 KB, patch)
2013-11-13 06:11 EST, Mads Tandrup CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Gruendler CLA 2011-07-06 06:52:11 EDT
Build Identifier: 

As the "open with" functionality has been already implemented (https://bugs.eclipse.org/bugs/show_bug.cgi?id=301030), it would be great if eclipse would register a URL protocol so links to local files can be opened by eclipse.

This is especially helpful for web development, where stacktraces are being displayed in the browser, and using a specific url protocol would open the file link in the app which registered the protocol: ie eclipse://open?file=/path/to/file.txt&line=60

For a plugin i've created a workaround for OSX, which simply uses an Applescript that registeres the eclipse:// protocol with Mac OSX and uses applescript to open the file link in eclipse:

https://github.com/pulse00/Symfony-2-Eclipse-Plugin/tree/master/org.eclipse.symfony.ui/launcher/osx/symfony2eclipse.app/Contents

I think it would be a useful feature if eclipse could handle this natively.

Reproducible: Always
Comment 2 Robert Gruendler CLA 2012-10-03 07:50:04 EDT
would you accept a patch for this?
Comment 3 Paul Webster CLA 2012-10-03 08:10:09 EDT
Where would be a good place to put this?  org.eclipse.ui.cocoa?

PW
Comment 4 Robert Gruendler CLA 2012-10-03 08:14:00 EDT
Right now i don't have an idea ;) 

i've been extending PDT mainly, but i could have a look into this.

If org.eclipse.ui.cocoa is the bundle creating Eclipse.app/Contents/Info.plist, then i'd say it's the right place.
Comment 5 Paul Webster CLA 2012-10-03 08:24:24 EDT
(In reply to comment #4)
> 
> If org.eclipse.ui.cocoa is the bundle creating
> Eclipse.app/Contents/Info.plist, then i'd say it's the right place.

Things like the Info.plist are created in the launcher fragments (AFAIK).  Is it something to do with the application itself that has to register the protocol with the OS (as opposed to a running eclipse instance)?

PW
Comment 6 Robert Gruendler CLA 2012-10-03 08:44:40 EDT
afaik all there needs to be done is to add CFBundleURLTypes to the already existing Info.plist.

Here's how it's done in my applescript Info.plist:

https://github.com/pulse00/Symfony-2-Eclipse-Plugin/blob/master/com.dubture.symfony.ui/launcher/osx/symfony2eclipse.app/Contents/Info.plist#L24
Comment 7 Brian de Alwis CLA 2012-10-04 11:03:00 EDT
So there is bug 339526 against p2 (and implicitly against PDE) to allow specifying platform-specific manifests.

Robert, do you know how other platforms handle providing URL definitions?
Comment 8 Robert Gruendler CLA 2012-10-04 11:18:54 EDT
(In reply to comment #7)
> So there is bug 339526 against p2 (and implicitly against PDE) to allow
> specifying platform-specific manifests.
> 
> Robert, do you know how other platforms handle providing URL definitions?

No, unfortunately not. On windows it seems to be handled via the registry:

http://msdn.microsoft.com/en-us/library/aa767914%28v=vs.85%29.aspx

But i'm not sure about linux.
Comment 9 Pascal Rapicault CLA 2012-11-08 10:30:38 EST
For now, let's focus on the platforms that Robert knows about and see how we can progress from there.
Comment 10 Brian de Alwis CLA 2012-11-09 09:07:02 EST
That would entail something like the patch in 339526 to provide a custom Info.plist.

On Linux, the freedesktop.org spec seems to entail installing a set of files into one of /usr/share/mime, /usr/local/share/mime, or ~/.local/share/mime and then triggering update-mime-database.  See the sections on Directory Layout and URI scheme handlers at:

   http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html

On Windows, the URI scheme is configured through the Windows registry:

   http://msdn.microsoft.com/en-us/library/aa767914(v=VS.85).aspx
Comment 11 Robert Gruendler CLA 2013-04-12 16:49:36 EDT
Created attachment 229686 [details]
URL scheme patch for osx
Comment 12 Robert Gruendler CLA 2013-04-12 16:51:23 EDT
To bring this ticket a little onward i've created a patch which adds the corresponging entries in the .plist files of the rt.equinox.framework project.
Comment 13 Mads Tandrup CLA 2013-10-31 05:21:49 EDT
I'm looking at creating a custom URL scheme for a Eclipse RCP application.

I'm not sure if missing something. But once you get the URL protocol registered with the OS. Shouldn't we react to the OS events when opening a URL?

I've noticed that for OS X Bug 178927 extends equinox to listen for kAEOpenDocuments events.

On OS X there is a similar event for URLs called kAEGetURL.

Bug 201154 also updates SWT PI to listen for kAEOpenDocuments.

I think Equinox and SWT PI should be extended to listen for kAEGetURL. But is this tracked in separate bug reports?
Comment 14 Mads Tandrup CLA 2013-11-13 06:08:40 EST
Created attachment 237420 [details]
Patch for Equinox 3.7 Cocoa to listen for open URL evetns

I've created a patch for Equinox 3.7 Cocoa that allows it to listen for open URL events from Mac OS X.

I've used bug 178927 as reference, since it implemented support for open file events.

The patch requires changes to SWT as well.
Comment 15 Mads Tandrup CLA 2013-11-13 06:11:15 EST
Created attachment 237421 [details]
Open URL event introduced to SWT 3.7 Cocoa

Introduce new SWT.OpenUrl event.
And add needed plumbing for Equinox to deliver its Open URL events on OS X Cocoa.
Comment 16 Thomas Watson CLA 2014-07-17 08:08:33 EDT
Note the launcher part has been submitted to Gerrit with:

https://git.eclipse.org/r/#/c/30030/
Comment 17 Lakshmi P Shanmugam CLA 2015-03-25 05:16:15 EDT
(In reply to Mads Tandrup from comment #15)
> Created attachment 237421 [details]
> Open URL event introduced to SWT 3.7 Cocoa
> 
> Introduce new SWT.OpenUrl event.
> And add needed plumbing for Equinox to deliver its Open URL events on OS X
> Cocoa.

Hi Mads,
We are already past API freeze for this (4.5) release. We cannot add any new APIs now. I'll review the SWT patch and evaluate it for Eclipse 4.6.
Comment 18 Mads Tandrup CLA 2015-03-25 05:57:41 EDT
Sounds great. Apart from the Equinox changes, there's also SWT changes tracked in review https://git.eclipse.org/r/#/c/30107/
Comment 19 Mads Tandrup CLA 2015-07-16 06:48:42 EDT
I've noticed that both of my Gerrit patches are still open:
https://git.eclipse.org/r/#/c/30030/
https://git.eclipse.org/r/#/c/30107/

What can I do to move it forward?

Best regards,
Mads
Comment 20 Lakshmi P Shanmugam CLA 2015-08-12 05:17:13 EDT
Setting target to 4.6M2.
Comment 22 Lakshmi P Shanmugam CLA 2015-10-15 07:44:07 EDT
(In reply to Mads Tandrup from comment #19)
> I've noticed that both of my Gerrit patches are still open:
> https://git.eclipse.org/r/#/c/30030/
> https://git.eclipse.org/r/#/c/30107/
> 
> What can I do to move it forward?
> 
> Best regards,
> Mads

Hi Mads,
Thanks for the patches. I looked at them and had a few points.
1. The equinox patch doesn't include the changes to Info.plist to register the URL scheme. The patch would not work without that change, right?

2. The patches provide the implementation only for Mac. It's good that we now have the support for one platform. But, the API will be incomplete if don't implement this for the other supported platforms- gtk and windows. Have you investigated the support on them? Do you plan to provide patches for gtk & windows too?

3. I think we should track and discuss the SWT changes in a separate bug. I'll clone this bug.

4. It would we useful for testing purposes if you can describe the exact use-case used for testing the patch. We could also come up with other use-cases to include in testing.
Comment 23 Lars Vogel CLA 2016-04-25 15:17:18 EDT
Mass move to 4.7.
Comment 24 Zhaoxi Zhang CLA 2016-07-26 18:30:42 EDT
Is there any way for an Eclipse plugin to get the URL parameter in the current most-used Eclipse versions 4.1-4.3? I manually registered a custom URL protocol from the info.plist file of Eclipse app in Mac, and I want to acquire the URL parameter when launching Eclipse from the URL. Thanks.
Comment 25 Leo Ufimtsev CLA 2017-07-04 10:30:18 EDT
There's an open patch in this bug, that's awaiting response from Madas.

@Madas, are you still working on the patch?
Comment 26 Christian Georgi CLA 2017-09-04 07:18:01 EDT
I have updated the SWT patch with an implementation for Windows: https://git.eclipse.org/r/#/c/30107/10
Please review.
Comment 27 Lakshmi P Shanmugam CLA 2017-09-28 05:17:12 EDT
(In reply to Lakshmi Shanmugam from comment #22)
> 
> 3. I think we should track and discuss the SWT changes in a separate bug.
> I'll clone this bug.
> 

Created Bug 525305 to track and discuss the SWT changes.

(In reply to Christian Georgi from comment #26)
> I have updated the SWT patch with an implementation for Windows:
> https://git.eclipse.org/r/#/c/30107/10
> Please review.

Thanks for the patch. I've updated the gerrit patch to point to the SWT bug.
Can you please provide steps on how to verify the patch on Windows?
Comment 28 Lakshmi P Shanmugam CLA 2017-12-07 07:50:00 EST
From comment#22:
Pending item: Changes to Info.plist to register the URL scheme.
Are any changes required on Windows/Linux?
Comment 29 Christian Georgi CLA 2017-12-07 08:55:26 EST
(In reply to Lakshmi Shanmugam from comment #28)
> From comment#22:
> Pending item: Changes to Info.plist to register the URL scheme.
> Are any changes required on Windows/Linux?

Yes, see comment #8 and comment #10.
Comment 30 Eclipse Genie CLA 2017-12-15 03:23:10 EST
New Gerrit change created: https://git.eclipse.org/r/113456
Comment 31 Lakshmi P Shanmugam CLA 2017-12-15 03:24:56 EST
(In reply to Eclipse Genie from comment #30)
> New Gerrit change created: https://git.eclipse.org/r/113456

Patch for Info.plist to register eclipse URL scheme.
Comment 32 Christian Georgi CLA 2017-12-15 04:35:53 EST
(In reply to Lakshmi Shanmugam from comment #31)
> Patch for Info.plist to register eclipse URL scheme.

What is the purpose of the 'eclipse' scheme?  Which logic would run if an eclipse:/ link is opened?
Comment 33 Lakshmi P Shanmugam CLA 2018-01-15 05:32:25 EST
(In reply to Christian Georgi from comment #32)
> (In reply to Lakshmi Shanmugam from comment #31)
> > Patch for Info.plist to register eclipse URL scheme.
> 
> What is the purpose of the 'eclipse' scheme?  Which logic would run if an
> eclipse:/ link is opened?

On Mac, a custom url has to be registered with the OS by specifying it in the Info.plist of the app.
For example: open -a /Applications/Eclipse.app eclipse://12345
eclipse://12345 will be treated as a url by Eclipse.app only if it is declared in the Info.plist and registered with the OS.

We need to decide if want to create a custom url for eclipse by default or expect users to create one if required.

Anyway created a gerrit as it is also required for testing.
Comment 34 Christian Georgi CLA 2018-01-15 06:26:44 EST
(In reply to Lakshmi Shanmugam from comment #33)
> We need to decide if want to create a custom url for eclipse by default or
> expect users to create one if required.

Good point here.  Initially I thought about only custom schemes like 'foo:', but we could make the same work with one generic scheme 'eclipse:' whose handler dispatches to more specific handlers, like for 'eclipse:foo:' to the handler contributed by a 'Foo' bundle.  This would relief bundles or the platform from providing the protocol registration dance for each OS.

There could even be default handlers, like 'eclipse:install:' where P2 would install Eclipse features.  This is what VS code does as well (see the links on https://marketplace.visualstudio.com/ like 'vscode:extension/eamodio.gitlens').
Comment 35 Matthias Becker CLA 2018-01-15 08:31:16 EST
(In reply to Christian Georgi from comment #34)
> (In reply to Lakshmi Shanmugam from comment #33)
> > We need to decide if want to create a custom url for eclipse by default or
> > expect users to create one if required.
> 
> Good point here.  Initially I thought about only custom schemes like 'foo:',
> but we could make the same work with one generic scheme 'eclipse:' whose
> handler dispatches to more specific handlers, like for 'eclipse:foo:' to the
> handler contributed by a 'Foo' bundle.  This would relief bundles or the
> platform from providing the protocol registration dance for each OS.
> 
> There could even be default handlers, like 'eclipse:install:' where P2 would
> install Eclipse features.  This is what VS code does as well (see the links
> on https://marketplace.visualstudio.com/ like
> 'vscode:extension/eamodio.gitlens').

According to https://tools.ietf.org/html/rfc3986#section-3.1
":" are not allowed in URL schemes. This rfc says that schemas should follow the following grammar:

 scheme      = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )

We should consider this when going for the generic "eclipse"-approach.
Comment 36 Thomas Watson CLA 2018-01-15 09:13:17 EST
(In reply to Matthias Becker from comment #35)
> 
> According to https://tools.ietf.org/html/rfc3986#section-3.1
> ":" are not allowed in URL schemes. This rfc says that schemas should follow
> the following grammar:
> 
>  scheme      = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
> 
> We should consider this when going for the generic "eclipse"-approach.

But also above that section there is this description:

   The following are two example URIs and their component parts:

         foo://example.com:8042/over/there?name=ferret#nose
         \_/   \______________/\_________/ \_________/ \__/
          |           |            |            |        |
       scheme     authority       path        query   fragment
          |   _____________________|__
         / \ /                        \
         urn:example:animal:ferret:nose

'eclipse' is the scheme.  That scheme would define what the remainder of the URI syntax.  If the 'eclipse' scheme simply allows another embedded URI then I think that is fine.  Similar to the 'jar' scheme in Java.
Comment 37 Matthias Becker CLA 2018-01-15 10:29:18 EST
(In reply to Christian Georgi from comment #34)
> (In reply to Lakshmi Shanmugam from comment #33)
> > We need to decide if want to create a custom url for eclipse by default or
> > expect users to create one if required.
> 
> Good point here.  Initially I thought about only custom schemes like 'foo:',
> but we could make the same work with one generic scheme 'eclipse:' whose
> handler dispatches to more specific handlers, like for 'eclipse:foo:' to the
> handler contributed by a 'Foo' bundle.  This would relief bundles or the
> platform from providing the protocol registration dance for each OS.
> 
> There could even be default handlers, like 'eclipse:install:' where P2 would
> install Eclipse features.  This is what VS code does as well (see the links
> on https://marketplace.visualstudio.com/ like
> 'vscode:extension/eamodio.gitlens').

The "eclipse" schema fits perfectly e.g. for the marketplace client to install new features. But for other stuff I don't think that this is a good idea.

You should never put parts of the technology into the URL. The URL for our plugins (that provide support for SAP programming language ABAP) is adt: (for ABAP Development Tools). What if SAP decides in the future to move away from Eclipse and to move to IntelliJ (like the Android tooling did). In such a case the eclipse:adt: URLs would brake. A adt: URL would not break (cool URIs don't change!). The ABAP tooling in IntelliJ would simply also provide a link handler for the adt: scheme. The user could then decide if the Eclipse based or the IntelliJ based tooling should be used.
Comment 38 Christian Georgi CLA 2018-01-16 03:22:14 EST
Right, that's the downside of IDE-specific URLs.  This means we should prepare the platform for individual bundles' contribution of URL schemes.
Comment 39 Lakshmi P Shanmugam CLA 2018-01-17 05:47:50 EST
(In reply to Christian Georgi from comment #38)
> Right, that's the downside of IDE-specific URLs.  This means we should
> prepare the platform for individual bundles' contribution of URL schemes.

I think there is a problem to be addressed on Mac -- the custom url has to be declared in the Info.plist for OS to recognize it as a custom url for eclipse. So, plugins that contribute a URL scheme will be have to update the Info.plist as well.
Comment 40 Christian Georgi CLA 2018-01-17 07:20:20 EST
(In reply to Lakshmi Shanmugam from comment #39)
> I think there is a problem to be addressed on Mac -- the custom url has to
> be declared in the Info.plist for OS to recognize it as a custom url for
> eclipse. So, plugins that contribute a URL scheme will be have to update the
> Info.plist as well.
That's indeed an issue to address:

1. Either let plugins mess with Info.plist all by custom code.
Probably worst solution.

2. Let P2 do it through a new advice at plugin installation time (see bug 339526).
Would work nicely on MacOS, but fails for the registry entries on Windows.  There, we need the absolute path to the installation in the registry, which P2 does not know in case of prebuilt packages (like the download packages on eclipse.org).

3. Or have code in the platform/workbench to register all known schemes.
Not sure though when the code should run (startup?  on request by the user?)
This would be the solution to cover all OSes, since the running platform has all the knowledge to properly register itself on Mac, Windows, and Linux.
Comment 42 Leo Ufimtsev CLA 2018-01-22 13:49:33 EST
Please note, the linux part was also implemented/merged:
525305 – [API]Provide SWT.OpenUrl event
https://bugs.eclipse.org/bugs/show_bug.cgi?id=525305

In Linux it works like:
eclipse http://url

E.g, in Firefox one can link protocols to open with eclipse like:
(not tested but in theory):
about:config
network.protocol-handler.external.git = true
network.protocol-handler.app.git  = eclipse %s
network.protocol-handler.expose-all = true

[1]  http://kb.mozillazine.org/Register_protocol