This source file includes following definitions.
- initializeAccount
- logIn
- cancelLogIn
- dismissAutoLogins
- nativeLoginSuccess
- nativeLoginFailed
- nativeLoginDismiss
package org.chromium.chrome.browser.infobar;
import android.app.Activity;
import android.util.Pair;
import org.chromium.base.CalledByNative;
public class AutoLoginDelegate {
private final Activity mActivity;
private final AutoLoginProcessor mAutoLoginProcessor;
private Pair<Long, AutoLoginAccountDelegate> mAccountHelper;
public AutoLoginDelegate(AutoLoginProcessor autoLoginProcessor, Activity activity) {
mActivity = activity;
mAutoLoginProcessor = autoLoginProcessor;
mAccountHelper = null;
}
@CalledByNative
String initializeAccount(long nativeInfoBar, String realm, String account, String args) {
AutoLoginAccountDelegate accountHelper =
new AutoLoginAccountDelegate(mActivity, mAutoLoginProcessor, realm, account, args);
if (!accountHelper.hasAccount()) {
return "";
}
mAccountHelper = new Pair<Long, AutoLoginAccountDelegate>(nativeInfoBar, accountHelper);
return accountHelper.getAccountName();
}
@CalledByNative
boolean logIn(long nativeInfoBar) {
AutoLoginAccountDelegate account =
mAccountHelper != null && mAccountHelper.first == nativeInfoBar ?
mAccountHelper.second : null;
if (account == null || !account.logIn()) {
nativeLoginFailed(nativeInfoBar);
return false;
}
return true;
}
@CalledByNative
boolean cancelLogIn(long nativeInfoBar) {
mAccountHelper = null;
return true;
}
public void dismissAutoLogins(String accountName, String authToken, boolean success,
String result) {
if (mAccountHelper != null) {
long infoBar = mAccountHelper.first;
AutoLoginAccountDelegate delegate = mAccountHelper.second;
if (!delegate.loginRequested()) {
nativeLoginDismiss(infoBar);
} else {
String accountAuthToken = delegate.getAuthToken();
if (accountAuthToken != null && accountAuthToken.equals(authToken)
&& delegate.loginRequested()) {
if (success) {
nativeLoginSuccess(infoBar, result);
} else {
nativeLoginFailed(infoBar);
}
}
}
mAccountHelper = null;
}
}
private native void nativeLoginSuccess(long nativeAutoLoginInfoBarDelegateAndroid,
String result);
private native void nativeLoginFailed(long nativeAutoLoginInfoBarDelegateAndroid);
private native void nativeLoginDismiss(long nativeAutoLoginInfoBarDelegateAndroid);
}