| 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..5395ad427b2c4eced398c7b43850ad0fbbb496bc 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
|
| @@ -52,11 +52,10 @@ public abstract class InfoBar implements InfoBarView {
|
| private boolean mExpireOnNavigation;
|
| private boolean mIsDismissed;
|
| private boolean mControlsEnabled;
|
| + private boolean mIsJavaOnlyInfoBar = true;
|
|
|
| - // 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;
|
|
|
| // Used by tests to reference infobars.
|
| private final int mId;
|
| @@ -82,23 +81,21 @@ 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;
|
| mNativeInfoBarPtr = nativeInfoBarPtr;
|
| + mIsJavaOnlyInfoBar = false;
|
| }
|
| }
|
|
|
| - /**
|
| - * Change the pointer to the native-side counterpart of this InfoBar. Native-side code is
|
| - * responsible for managing the cleanup of the pointer.
|
| - * @param newInfoBarPtr Pointer to the NativeInfoBar.
|
| - */
|
| - protected void replaceNativePointer(long newInfoBarPtr) {
|
| - mNativeInfoBarPtr = newInfoBarPtr;
|
| + @CalledByNative
|
| + protected void onNativeDestroyed() {
|
| + mNativeInfoBarPtr = 0;
|
| }
|
|
|
| /**
|
| @@ -109,7 +106,7 @@ public abstract class InfoBar implements InfoBarView {
|
| * It should really be removed once all infobars have a C++ counterpart.
|
| */
|
| public final boolean shouldExpire() {
|
| - return mExpireOnNavigation && mNativeInfoBarPtr == 0;
|
| + return mExpireOnNavigation && mIsJavaOnlyInfoBar;
|
| }
|
|
|
| // Sets whether the bar should be dismissed when a navigation occurs.
|
| @@ -118,20 +115,6 @@ public abstract class InfoBar implements InfoBarView {
|
| }
|
|
|
| /**
|
| - * @return true if this java infobar owns this {@code nativePointer}
|
| - */
|
| - boolean ownsNativeInfoBar(long nativePointer) {
|
| - return mNativeInfoBarPtr == nativePointer;
|
| - }
|
| -
|
| - /**
|
| - * @return whether or not the InfoBar has been dismissed.
|
| - */
|
| - protected boolean isDismissed() {
|
| - return mIsDismissed;
|
| - }
|
| -
|
| - /**
|
| * Sets the Context used when creating the InfoBar.
|
| */
|
| protected void setContext(Context context) {
|
| @@ -237,8 +220,25 @@ public abstract class InfoBar implements InfoBarView {
|
|
|
| @Override
|
| public void onLinkClicked() {
|
| - if (mNativeInfoBarPtr != 0) {
|
| - nativeOnLinkClicked(mNativeInfoBarPtr);
|
| + if (mNativeInfoBarPtr != 0) nativeOnLinkClicked(mNativeInfoBarPtr);
|
| + }
|
| +
|
| + /**
|
| + * Performs some action related to the button being clicked.
|
| + *
|
| + * @param action The type of action defined as ACTION_* in this class.
|
| + * @param actionValue An additional string associated with the action if any. "" if none.
|
| + */
|
| + protected void onButtonClicked(int action, String actionValue) {
|
| + if (mNativeInfoBarPtr != 0) nativeOnButtonClicked(mNativeInfoBarPtr, action, actionValue);
|
| + }
|
| +
|
| + @Override
|
| + public void onCloseButtonClicked() {
|
| + if (mIsJavaOnlyInfoBar) {
|
| + dismissJavaOnlyInfoBar();
|
| + } else {
|
| + if (mNativeInfoBarPtr != 0) nativeOnCloseButtonClicked(mNativeInfoBarPtr);
|
| }
|
| }
|
|
|
| @@ -263,8 +263,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);
|
| }
|
|
|