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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/infobar/AccountChooserInfoBar.java

Issue 1150193004: Straighten up life cycle of native InfoBar pointers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed unrelated file Created 5 years, 6 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/infobar/AccountChooserInfoBar.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/AccountChooserInfoBar.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/AccountChooserInfoBar.java
index 66782203ce3710e221755674aae815d27f9a4b01..9455802e6e0a6e199985c30f9e9814dfb6ab0594 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/infobar/AccountChooserInfoBar.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/AccountChooserInfoBar.java
@@ -12,7 +12,6 @@ import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.FrameLayout;
import android.widget.ImageView;
-import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
@@ -28,43 +27,32 @@ import org.chromium.chrome.browser.signin.AccountManagementFragment;
* full name in case they are available.
*/
public class AccountChooserInfoBar extends InfoBar {
+ private long mNativePtr;
private final Credential[] mCredentials;
private final ImageView[] mAvatarViews;
/**
* Creates and shows the infobar wich allows user to choose credentials for login.
- * @param nativeInfoBar Pointer to the native infobar.
* @param enumeratedIconId Enum ID corresponding to the icon that the infobar will show.
* @param credentials Credentials to display in the infobar.
*/
@CalledByNative
- private static InfoBar show(
- long nativeInfoBar, int enumeratedIconId, Credential[] credentials) {
- return new AccountChooserInfoBar(
- nativeInfoBar, ResourceId.mapToDrawableId(enumeratedIconId), credentials);
+ private static InfoBar show(int enumeratedIconId, Credential[] credentials) {
+ return new AccountChooserInfoBar(ResourceId.mapToDrawableId(enumeratedIconId), credentials);
}
/**
* Creates and shows the infobar which allows user to choose credentials.
- * @param nativeInfoBar Pointer to the native infobar.
* @param iconDrawableId Drawable ID corresponding to the icon that the infobar will show.
* @param credentials Credentials to display in the infobar.
*/
- public AccountChooserInfoBar(long nativeInfoBar, int iconDrawableId, Credential[] credentials) {
+ public AccountChooserInfoBar(int iconDrawableId, Credential[] credentials) {
super(null /* Infobar Listener */, iconDrawableId, null /* bitmap*/,
null /* message to show */);
- setNativeInfoBar(nativeInfoBar);
mCredentials = credentials.clone();
mAvatarViews = new ImageView[mCredentials.length];
}
-
- @Override
- public void onCloseButtonClicked() {
- // Notifies the native infobar, which closes the infobar.
- nativeOnCloseButtonClicked(mNativeInfoBarPtr);
- }
-
@Override
public void onButtonClicked(boolean isPrimaryButton) {
onCloseButtonClicked();
@@ -97,8 +85,9 @@ public class AccountChooserInfoBar extends InfoBar {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
- convertView = (LinearLayout) LayoutInflater.from(getContext()).inflate(
- R.layout.account_chooser_infobar_item, parent, false);
+ convertView =
+ LayoutInflater.from(getContext())
+ .inflate(R.layout.account_chooser_infobar_item, parent, false);
} else {
int oldPosition = (int) convertView.getTag();
mAvatarViews[oldPosition] = null;
@@ -126,7 +115,7 @@ public class AccountChooserInfoBar extends InfoBar {
@Override
public void onClick(View view) {
nativeOnCredentialClicked(
- mNativeInfoBarPtr, currentCredentialIndex, credentialType);
+ mNativePtr, currentCredentialIndex, credentialType);
}
});
return convertView;
@@ -155,6 +144,17 @@ public class AccountChooserInfoBar extends InfoBar {
layout.setCustomViewInButtonRow(OverflowSelector.createOverflowSelector(getContext()));
}
+ @CalledByNative
+ private void setNativePtr(long nativePtr) {
+ mNativePtr = nativePtr;
+ }
+
+ @Override
+ protected void onNativeDestroyed() {
+ mNativePtr = 0;
+ super.onNativeDestroyed();
+ }
+
private native void nativeOnCredentialClicked(
long nativeAccountChooserInfoBar, int credentialId, int credentialType);
}

Powered by Google App Engine
This is Rietveld 408576698