Also emit "login" on WebContents
This commit is contained in:
parent
f40a3f72d7
commit
569e87035a
1 changed files with 18 additions and 4 deletions
|
@ -242,12 +242,26 @@ void App::OnSelectCertificate(
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::OnLogin(LoginHandler* login_handler) {
|
void App::OnLogin(LoginHandler* login_handler) {
|
||||||
bool prevent_default = Emit(
|
// Convert the args explicitly since they will be passed for twice.
|
||||||
"login", login_handler->request(), login_handler->auth_info(),
|
v8::Locker locker(isolate());
|
||||||
api::WebContents::CreateFrom(isolate(), login_handler->GetWebContents()),
|
v8::HandleScope handle_scope(isolate());
|
||||||
|
auto web_contents =
|
||||||
|
WebContents::CreateFrom(isolate(), login_handler->GetWebContents());
|
||||||
|
auto request = mate::ConvertToV8(isolate(), login_handler->request());
|
||||||
|
auto auth_info = mate::ConvertToV8(isolate(), login_handler->auth_info());
|
||||||
|
auto callback = mate::ConvertToV8(
|
||||||
|
isolate(),
|
||||||
base::Bind(&PassLoginInformation, make_scoped_refptr(login_handler)));
|
base::Bind(&PassLoginInformation, make_scoped_refptr(login_handler)));
|
||||||
|
|
||||||
// Default behavior is to alwasy cancel the auth.
|
bool prevent_default =
|
||||||
|
Emit("login", web_contents, request, auth_info, callback);
|
||||||
|
|
||||||
|
// Also pass it to WebContents.
|
||||||
|
if (!prevent_default)
|
||||||
|
prevent_default =
|
||||||
|
web_contents->Emit("login", request, auth_info, callback);
|
||||||
|
|
||||||
|
// Default behavior is to always cancel the auth.
|
||||||
if (!prevent_default)
|
if (!prevent_default)
|
||||||
login_handler->CancelAuth();
|
login_handler->CancelAuth();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue