This source file includes following definitions.
- isPasswordAuthenticationEnabled
- requestAuthentication
- getPasswordProtectionString
- CalledByNative
- create
- onResult
- isPasswordAuthenticationEnabled
- requestAuthentication
- getPasswordProtectionString
- getDelegate
- setDelegate
- isPasswordAuthenticationEnabled
- requestAuthentication
- getPasswordProtectionString
- nativeOnResult
package org.chromium.chrome.browser.password_manager;
import org.chromium.base.CalledByNative;
import org.chromium.chrome.browser.Tab;
public class PasswordAuthenticationManager {
public interface PasswordAuthenticationDelegate {
boolean isPasswordAuthenticationEnabled();
void requestAuthentication(Tab tab, PasswordAuthenticationCallback callback);
String getPasswordProtectionString();
}
public static class PasswordAuthenticationCallback {
private long mNativePtr;
@CalledByNative("PasswordAuthenticationCallback")
private static PasswordAuthenticationCallback create(long nativePtr) {
return new PasswordAuthenticationCallback(nativePtr);
}
private PasswordAuthenticationCallback(long nativePtr) {
mNativePtr = nativePtr;
}
public final void onResult(boolean authenticated) {
if (mNativePtr == 0) {
assert false : "Can not call onResult more than once per callback.";
return;
}
nativeOnResult(mNativePtr, authenticated);
mNativePtr = 0;
}
}
private static class DefaultPasswordAuthenticationDelegate
implements PasswordAuthenticationDelegate {
@Override
public boolean isPasswordAuthenticationEnabled() {
return false;
}
@Override
public void requestAuthentication(Tab tab, PasswordAuthenticationCallback callback) {
callback.onResult(true);
}
@Override
public String getPasswordProtectionString() {
return "";
}
}
private static PasswordAuthenticationDelegate sDelegate;
private PasswordAuthenticationManager() {}
private static PasswordAuthenticationDelegate getDelegate() {
if (sDelegate == null) {
sDelegate = new DefaultPasswordAuthenticationDelegate();
}
return sDelegate;
}
public static void setDelegate(PasswordAuthenticationDelegate delegate) {
sDelegate = delegate;
}
public static boolean isPasswordAuthenticationEnabled() {
return getDelegate().isPasswordAuthenticationEnabled();
}
@CalledByNative
public static void requestAuthentication(
Tab tab, PasswordAuthenticationCallback callback) {
getDelegate().requestAuthentication(tab, callback);
}
public static String getPasswordProtectionString() {
return getDelegate().getPasswordProtectionString();
}
private static native void nativeOnResult(long callbackPtr, boolean authenticated);
}