-
Notifications
You must be signed in to change notification settings - Fork 15.8k
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
session: add setPermissionRequestHandler api #4223
Conversation
9d3802b
to
ffaf9a9
Compare
Will you be adding the other permission types? |
ffaf9a9
to
2a278ce
Compare
85b68aa
to
f7556de
Compare
@@ -133,6 +133,10 @@ class WebContents : public mate::TrackableObject<WebContents>, | |||
void SetAllowTransparency(bool allow); | |||
bool IsGuest() const; | |||
|
|||
// Handler for permission requests. | |||
void SetPermissionRequestHandler(v8::Local<v8::Value> val, |
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.
It should be a method of Session
since permission manager is session wide.
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.
if we are providing this method with session
module, can the permission-request
event be removed ? the event way currently breaks permission being granted by default. With the callback,
session.setPermissionRequestHandler((webContents, permission, callback) => {
// logic
callback(); // "granted/denied"
})
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.
Sounds good to me to remove permission-request
event if we have session.setPermissionRequestHandler
API.
31fcf4f
to
db26dca
Compare
@zcbenz have made the changes, thanks! |
@deepak1556 pointerLock and fullscreen would be great. |
* `callback` Function - Allow or deny the permission. | ||
|
||
Sets the handler which can be used to respond to permission requests for the `session`. | ||
Calling `callback('granted')` will allow the permission and `callback('denied')` will reject it. |
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.
Maybe use a boolean instead?
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.
Done.
Have added |
c088172
to
b575cd0
Compare
@@ -397,6 +399,18 @@ void Session::SetCertVerifyProc(v8::Local<v8::Value> val, | |||
browser_context_->cert_verifier()->SetVerifyProc(proc); | |||
} | |||
|
|||
void Session::SetPermissionRequestHandler(v8::Local<v8::Value> val, | |||
mate::Arguments* args) { |
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.
Unaligned indention.
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.
Fixed.
👍 |
session: add setPermissionRequestHandler api
Thanks! |
Fixes #4174
Depends on electron-archive/brightray#195