blob: 700707571ae67944c4e491b6eceda252f28e551d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/android/password_authentication_manager.h"
#include "chrome/browser/android/tab_android.h"
#include "jni/PasswordAuthenticationManager_jni.h"
namespace {
class PasswordAuthenticationCallback {
public:
explicit PasswordAuthenticationCallback(
const base::Closure& success_callback) {
success_callback_ = success_callback;
}
void OnResult(bool result) {
if (result)
success_callback_.Run();
delete this;
}
private:
virtual ~PasswordAuthenticationCallback() {}
base::Closure success_callback_;
};
} // namespace
PasswordAuthenticationManager::PasswordAuthenticationManager() {
}
PasswordAuthenticationManager::~PasswordAuthenticationManager() {
}
bool PasswordAuthenticationManager::RegisterPasswordAuthenticationManager(
JNIEnv* env) {
return RegisterNativesImpl(env);
}
void PasswordAuthenticationManager::AuthenticatePasswordAutofill(
content::WebContents* web_contents,
const base::Closure& success_callback) {
TabAndroid* tab = TabAndroid::FromWebContents(web_contents);
if (!tab)
return;
JNIEnv* env = base::android::AttachCurrentThread();
PasswordAuthenticationCallback* auth_callback =
new PasswordAuthenticationCallback(success_callback);
Java_PasswordAuthenticationManager_requestAuthentication(
env,
tab->GetJavaObject().obj(),
Java_PasswordAuthenticationCallback_create(
env,
reinterpret_cast<intptr_t>(auth_callback)).obj());
}
// static
void OnResult(JNIEnv* env,
jclass jcaller,
jlong callback_ptr,
jboolean authenticated) {
PasswordAuthenticationCallback* callback =
reinterpret_cast<PasswordAuthenticationCallback*>(callback_ptr);
callback->OnResult(authenticated);
}
|