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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBar.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 setNativeInfoBarPtr calls from child classes Created 5 years, 7 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/InfoBar.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBar.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBar.java
index 26c1a291f8b4adb39918cb5f7f8e4857a4db16e1..11568152c4103068e9c51ab590c4c77fb4663ea6 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBar.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBar.java
@@ -53,10 +53,8 @@ public abstract class InfoBar implements InfoBarView {
private boolean mIsDismissed;
private boolean mControlsEnabled;
- // This cannot be private until the swap in place infrastructure is
- // improved since subclasses need to access a possibly replaced native
- // pointer.
- protected long mNativeInfoBarPtr;
+ // This points to the InfoBarAndroid class not any of its subclasses.
+ private long mNativeInfoBarPtr;
David Trainor- moved to gerrit 2015/06/02 17:51:55 Where do we ever clear this pointer? I don't see
Changwan Ryu 2015/06/03 04:55:41 I was addressing this in a separate CL but merged
// Used by tests to reference infobars.
private final int mId;
@@ -82,9 +80,10 @@ public abstract class InfoBar implements InfoBarView {
/**
* Stores a pointer to the native-side counterpart of this InfoBar.
- * @param nativeInfoBarPtr Pointer to the NativeInfoBar.
+ * @param nativeInfoBarPtr Pointer to the native InfoBarAndroid, not to its subclass.
*/
- protected void setNativeInfoBar(long nativeInfoBarPtr) {
+ @CalledByNative
+ private void setNativeInfoBar(long nativeInfoBarPtr) {
if (nativeInfoBarPtr != 0) {
// The native code takes care of expiring infobars on navigations.
mExpireOnNavigation = false;
@@ -237,8 +236,19 @@ public abstract class InfoBar implements InfoBarView {
@Override
public void onLinkClicked() {
+ if (mNativeInfoBarPtr != 0) nativeOnLinkClicked(mNativeInfoBarPtr);
+ }
+
+ protected void onButtonClicked(int action, String actionValue) {
+ if (mNativeInfoBarPtr != 0) nativeOnButtonClicked(mNativeInfoBarPtr, action, actionValue);
+ }
+
+ @Override
+ public void onCloseButtonClicked() {
if (mNativeInfoBarPtr != 0) {
- nativeOnLinkClicked(mNativeInfoBarPtr);
+ nativeOnCloseButtonClicked(mNativeInfoBarPtr);
+ } else {
+ dismissJavaOnlyInfoBar();
}
}
@@ -263,8 +273,8 @@ public abstract class InfoBar implements InfoBarView {
mListener = listener;
}
- protected native void nativeOnLinkClicked(long nativeInfoBarAndroid);
- protected native void nativeOnButtonClicked(
+ private native void nativeOnLinkClicked(long nativeInfoBarAndroid);
+ private native void nativeOnButtonClicked(
long nativeInfoBarAndroid, int action, String actionValue);
- protected native void nativeOnCloseButtonClicked(long nativeInfoBarAndroid);
+ private native void nativeOnCloseButtonClicked(long nativeInfoBarAndroid);
}

Powered by Google App Engine
This is Rietveld 408576698