-
Notifications
You must be signed in to change notification settings - Fork 15k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: emit devtools-open-url
event for DevTools link selection
#36774
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chrome directs this through Browser::OpenURL
: https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/devtools/devtools_ui_bindings.cc;l=196-201;drc=fd7b4c1844e6431a5ba4475eb515257a3a238a31
We have an open-url
event on app
already, but it seems to be only used on macOS, for when a user opens an app-registered URL. Oh well.
Let's call this devtools-open-url
instead of devtools-open-in-new-tab
.
Can we not just open the platform specific application to handle the URL electron/shell/common/platform_util.h Lines 33 to 37 in 20cff64
|
devtools-open-in-new-tab
event for DevTools link selectiondevtools-open-url
event for DevTools link selection
@deepak1556 i considered that, but i think that allowing developers to decide for themselves is comparatively little effort and allows them to make a wider range of choices. I think it's reasonable for example to assume that a developer might want to open a URL in a new BrowserWindow within their own app, instead of shelling out to their external browser. |
96981a4
to
5a8cdc0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API LGTM
Release Notes Persisted
|
…ctron#36774) * feat: emit event for DevTools link selection * chore: devtools-open-in-new-tab -> devtools-open-url
…ctron#36774) * feat: emit event for DevTools link selection * chore: devtools-open-in-new-tab -> devtools-open-url
Description of Change
Closes #36715.
This PR adds a new event
devtools-open-url
corresponding to a link in DevTools being either clicked or selected for opening in a new tab via context menu. There is precedent for event emission corresponding toDevToolsEmbedderMessageDispatcher::Delegate
methods - this was previously a no-op and so the primary change here is adding an implementation to surface the action to developers.Alternatively, we could potentially have implemented the new window behavior ourselves, but this is (imo) a large security hole and as such I believe we should ibstead give developers more fine-grained control over handling and optionally opening new links there.
Tested by adding:
to the
createWindow
method in a default Fiddle and confirming thaturl
is correctly logged.Checklist
npm test
passesRelease Notes
Notes: Added a new
devtools-open-url
event towebContents
to allow developers to open new windows with them.