Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1532)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/password_manager/AccountChooserDialog.java

Issue 2126353003: [CM API] Account Chooser with Sign in button for single account (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/password_manager/AccountChooserDialog.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/password_manager/AccountChooserDialog.java b/chrome/android/java/src/org/chromium/chrome/browser/password_manager/AccountChooserDialog.java
index e206d32d8be073522ad297e0655f866d723865b2..e12ed00719ae4c432c7d2a55599d32fa8fd3fa81 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/password_manager/AccountChooserDialog.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/password_manager/AccountChooserDialog.java
@@ -44,6 +44,7 @@ public class AccountChooserDialog
private final int mTitleLinkStart;
private final int mTitleLinkEnd;
private final String mOrigin;
+ private final String mSigninButtonText;
private ArrayAdapter<Credential> mAdapter;
private boolean mIsDestroyed;
private boolean mWasDismissedByNative;
@@ -54,10 +55,15 @@ public class AccountChooserDialog
private Credential mCredential;
private long mNativeAccountChooserDialog;
private AlertDialog mDialog;
+ /**
+ * True, if credentials were selected via "Sign In" button instead of clicking on the credential
+ * itself.
+ */
+ private boolean mSigninButtonClicked;
private AccountChooserDialog(Context context, long nativeAccountChooserDialog,
Credential[] credentials, String title, int titleLinkStart, int titleLinkEnd,
- String origin) {
+ String origin, String signinButtonText) {
mNativeAccountChooserDialog = nativeAccountChooserDialog;
mContext = context;
mCredentials = credentials.clone();
@@ -65,6 +71,8 @@ public class AccountChooserDialog
mTitleLinkStart = titleLinkStart;
mTitleLinkEnd = titleLinkEnd;
mOrigin = origin;
+ mSigninButtonText = signinButtonText;
+ mSigninButtonClicked = false;
}
/**
@@ -78,12 +86,12 @@ public class AccountChooserDialog
@CalledByNative
private static AccountChooserDialog createAndShowAccountChooser(WindowAndroid windowAndroid,
long nativeAccountChooserDialog, Credential[] credentials, String title,
- int titleLinkStart, int titleLinkEnd, String origin) {
+ int titleLinkStart, int titleLinkEnd, String origin, String signinButtonText) {
Activity activity = windowAndroid.getActivity().get();
if (activity == null) return null;
AccountChooserDialog chooser =
new AccountChooserDialog(activity, nativeAccountChooserDialog, credentials, title,
- titleLinkStart, titleLinkEnd, origin);
+ titleLinkStart, titleLinkEnd, origin, signinButtonText);
chooser.show();
return chooser;
}
@@ -164,6 +172,7 @@ public class AccountChooserDialog
mCredential = mCredentials[item];
}
});
+ if (!mSigninButtonText.isEmpty()) builder.setPositiveButton(mSigninButtonText, this);
gone 2016/07/07 21:30:42 Defensively use !TextUtils.isEmpty(mSigninButtonTe
melandory 2016/07/08 08:02:19 Done.
mDialog = builder.create();
mDialog.setOnDismissListener(this);
mDialog.show();
@@ -203,14 +212,19 @@ public class AccountChooserDialog
}
@Override
- public void onClick(DialogInterface dialog, int whichButton) {}
+ public void onClick(DialogInterface dialog, int whichButton) {
+ if (whichButton == DialogInterface.BUTTON_POSITIVE) {
+ mCredential = mCredentials[0];
+ mSigninButtonClicked = true;
+ }
+ }
@Override
public void onDismiss(DialogInterface dialog) {
if (!mWasDismissedByNative) {
if (mCredential != null) {
- nativeOnCredentialClicked(
- mNativeAccountChooserDialog, mCredential.getIndex(), mCredential.getType());
+ nativeOnCredentialClicked(mNativeAccountChooserDialog, mCredential.getIndex(),
+ mCredential.getType(), mSigninButtonClicked);
} else {
nativeCancelDialog(mNativeAccountChooserDialog);
}
@@ -218,8 +232,8 @@ public class AccountChooserDialog
destroy();
}
- private native void nativeOnCredentialClicked(
- long nativeAccountChooserDialogAndroid, int credentialId, int credentialType);
+ private native void nativeOnCredentialClicked(long nativeAccountChooserDialogAndroid,
+ int credentialId, int credentialType, boolean signinButtonClicked);
private native void nativeCancelDialog(long nativeAccountChooserDialogAndroid);
private native void nativeDestroy(long nativeAccountChooserDialogAndroid);
private native void nativeOnLinkClicked(long nativeAccountChooserDialogAndroid);

Powered by Google App Engine
This is Rietveld 408576698