fix: implement 'login' event for WebContents (#20954)

This commit is contained in:
Jeremy Apthorp 2019-11-11 09:47:01 -08:00 committed by GitHub
parent 049bd09150
commit 034f4d5734
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 239 additions and 247 deletions

View file

@ -495,15 +495,6 @@ void OnClientCertificateSelected(
}
}
void PassLoginInformation(scoped_refptr<LoginHandler> login_handler,
gin_helper::Arguments* args) {
base::string16 username, password;
if (args->GetNext(&username) && args->GetNext(&password))
login_handler->Login(username, password);
else
login_handler->CancelAuth();
}
#if defined(USE_NSS_CERTS)
int ImportIntoCertStore(CertificateManagerModel* model,
const base::DictionaryValue& options) {
@ -667,25 +658,6 @@ void App::OnNewWindowForTab() {
}
#endif
void App::OnLogin(scoped_refptr<LoginHandler> login_handler,
const base::DictionaryValue& request_details) {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
bool prevent_default = false;
content::WebContents* web_contents = login_handler->GetWebContents();
if (web_contents) {
prevent_default =
Emit("login", WebContents::FromOrCreate(isolate(), web_contents),
request_details, *login_handler->auth_info(),
base::BindOnce(&PassLoginInformation,
base::RetainedRef(login_handler)));
}
// Default behavior is to always cancel the auth.
if (!prevent_default)
login_handler->CancelAuth();
}
bool App::CanCreateWindow(
content::RenderFrameHost* opener,
const GURL& opener_url,