-
Notifications
You must be signed in to change notification settings - Fork 28.3k
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
Move webview's use of setIgnoreMenuShortcuts to main process #98131
Move webview's use of setIgnoreMenuShortcuts to main process #98131
Conversation
src/vs/code/electron-main/app.ts
Outdated
ipc.on('vscode:webview.setIgnoreMenuShortcuts', (_event: IpcMainEvent, webContentsId: number, enabled: boolean) => { | ||
const contents = webContents.fromId(webContentsId); | ||
if (!contents) { | ||
throw new Error(`Invalid webContentsId: ${webContentsId}`); |
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.
Is this helpful? Should it not use the log service instead?
src/vs/code/electron-main/app.ts
Outdated
@@ -296,6 +296,16 @@ export class CodeApplication extends Disposable { | |||
|
|||
ipc.on('vscode:reloadWindow', (event: IpcMainEvent) => event.sender.reload()); | |||
|
|||
ipc.on('vscode:webview.setIgnoreMenuShortcuts', (_event: IpcMainEvent, webContentsId: number, enabled: boolean) => { |
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.
Instead of using raw IPC I would prefer to go through IElectronService
and friends if possible. We need to move off the direct IPC usage.
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.
Thanks for the suggestion. Just pushed an update that moves to use channels instead. I've never worked with these directly before so let me know I've I'm using them incorrectly
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.
@mjbvz thanks, any reason you decided to introduce a new service vs. just using the existing IElectronService
?
I typically prefer to call interfaces XY-Main-XY
only when they are only used in electron-main
. In your case I would rename it to IWebviewService
. But again, I think everything can reuse the existing electron service for this purpose.
@bpasero Webviews require a number of ipc calls:
I felt it would be better to have these all in a webview specific service rather than adding them to |
@mjbvz ok I wasn't aware there are more methods needed. I think it is fine to have your own service then as long as you set it up the way the electron service is setup, e.g. using the |
Part of microsoft#95955 Switches from calling `setIgnoreMenuShortcuts` on the renderer to calling it on the main thread
@bpasero Thanks. I've aligned the service more with ElectronMainService. I'm going to merge this PR and then move the existing webview protocol handling code from using ipc to use this service instead |
465a9ef
to
60a3a85
Compare
I suggest you look at |
Ah ok, I'll update it to use |
Part of #95955
Switches from calling
setIgnoreMenuShortcuts
in our renderers processes to instead call it in the main process