Bug 578733 - IWorkbenchBrowserSupport.AS_EDITOR ignored
Summary: IWorkbenchBrowserSupport.AS_EDITOR ignored
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.22   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2022-02-14 08:51 EST by Thomas Mauch CLA
Modified: 2022-04-02 13:33 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Mauch CLA 2022-02-14 08:51:09 EST
My plugin opens an internal browser using IWorkbenchBrowserSupport.AS_EDITOR by

IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
IWebBrowser browser = browserSupport.createBrowser(IWorkbenchBrowserSupport.AS_EDITOR | IWorkbenchBrowserSupport.LOCATION_BAR | IWorkbenchBrowserSupport.NAVIGATION_BAR, ...)

However this does not seem to work anymore since 4.22. I found the following note:

https://www.eclipse.org/eclipse/news/4.22/

External browser used by default
By default the Eclipse IDE will open the default system browser instead of the internal browser. You can change this setting via Windows -> Preferences -> General -> Web Browser

If I change the settings back to internal browser, it works again.
However it is quite unfortunate if my plugin forces the user to change some global settings to work (my plugin needs an internal browser to work properly).

I would expect that IWorkbenchBrowserSupport.AS_EDITOR overrides the global settings and I can open an internal browser if needed with this flag.
Is there a reason why the flag is ignored?
Is there another way to force opening an internal browser?
Comment 1 Andrey Loskutov CLA 2022-02-14 08:55:31 EST
@Lars, could you please check, the regression is coming from bug 577081.
Comment 2 Thomas Mauch CLA 2022-04-01 19:06:15 EDT
Any news on this issue?
It seeem to be a regression, so some timely feedback would be appreciated.
Thanks
Comment 3 Thomas Wolf CLA 2022-04-02 13:33:01 EDT
Not really a regression. If I look at the code [1] of DefaultBrowserSupport.createBrowser(int, String, String, String), it seems to me that this never worked if a user changed the preference manually to EXTERNAL unless the browserId was the HELP_BROWSER_ID.

Looks like there was never a way to force the use of the internal browser regardless of the preference (provided an internal browser is available at all).

See also bug 244047 for some history.

Note the Javadoc of IWorkbenchBrowserSupport.createBrowser(...):

  "If the user has chosen not to use the internal browser or it is not available
   on the current platform, an external browser will be used and all style
   parameters will be ignored."

Now the preference default has been changed. A strict reading of this javadoc would mean that as long as the user doesn't touch that preference at all (and an internal browser is available), the style flags _should_ have an effect. But if he sets the preference to internal and then back to external, the style flags would be ignored. Which doesn't make much sense.

Also, please note that AS_EDITOR is only a _hint_ according to its javadoc.

Simply treating AS_EDITOR as an indication to use an internal browser even if the preference says EXTERNAL may re-introduce bug 244047.

[1] https://git.eclipse.org/r/plugins/gitiles/platform/eclipse.platform.ui/+/aa2435ea3f8745bf499e4e6cda6521d72292a476/bundles/org.eclipse.ui.browser/src/org/eclipse/ui/internal/browser/DefaultBrowserSupport.java#94