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

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

Issue 1152013007: Disable Reader mode in fullscreen mode or when infobars are shown (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed a space and an explicit observer unregistration. 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
« no previous file with comments | « no previous file | chrome/android/java_staging/src/org/chromium/chrome/browser/dom_distiller/ReaderModeManager.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java
index 45efdf3cbff8477bd598aa8931d91c826f8f1de2..3a7b977a417edbe3763e6eda44624946d6978689 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java
@@ -15,6 +15,7 @@ import android.widget.FrameLayout;
import android.widget.LinearLayout;
import org.chromium.base.CalledByNative;
+import org.chromium.base.ObserverList;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.Tab;
@@ -54,6 +55,27 @@ public class InfoBarContainer extends SwipableOverlayView {
void notifyAnimationFinished(int animationType);
}
+ /**
+ * An observer that is notified of changes to a {@link InfoBarContainer} object.
+ */
+ public interface InfoBarContainerObserver {
+ /**
+ * Called when an {@link InfoBar} is about to be added (before the animation).
+ * @param container The notifying {@link InfoBarContainer}
+ * @param infoBar An {@link InfoBar} being added
+ * @param isFirst Whether the infobar container was empty
+ */
+ void onAddInfoBar(InfoBarContainer container, InfoBar infoBar, boolean isFirst);
+
+ /**
+ * Called when an {@link InfoBar} is about to be removed (before the animation).
+ * @param container The notifying {@link InfoBarContainer}
+ * @param infoBar An {@link InfoBar} being removed
+ * @param isLast Whether the infobar container is going to be empty
+ */
+ void onRemoveInfoBar(InfoBarContainer container, InfoBar infoBar, boolean isLast);
+ }
+
private static class InfoBarTransitionInfo {
// InfoBar being animated.
public InfoBar target;
@@ -111,6 +133,9 @@ public class InfoBarContainer extends SwipableOverlayView {
private Paint mTopBorderPaint;
+ private final ObserverList<InfoBarContainerObserver> mObservers =
+ new ObserverList<InfoBarContainerObserver>();
+
public InfoBarContainer(Context context, int tabId, ViewGroup parentView, Tab tab) {
super(context, null);
tab.addObserver(getTabObserver());
@@ -147,6 +172,22 @@ public class InfoBarContainer extends SwipableOverlayView {
mNativeInfoBarContainer = nativeInit();
}
+ /**
+ * Adds an {@link InfoBarContainerObserver}.
+ * @param observer The {@link InfoBarContainerObserver} to add.
+ */
+ public void addObserver(InfoBarContainerObserver observer) {
+ mObservers.addObserver(observer);
+ }
+
+ /**
+ * Removes a {@link InfoBarContainerObserver}.
+ * @param observer The {@link InfoBarContainerObserver} to remove.
+ */
+ public void removeObserver(InfoBarContainerObserver observer) {
+ mObservers.removeObserver(observer);
+ }
+
@Override
public void setContentViewCore(ContentViewCore contentViewCore) {
super.setContentViewCore(contentViewCore);
@@ -254,6 +295,11 @@ public class InfoBarContainer extends SwipableOverlayView {
return;
}
+ // We notify observers immediately (before the animation starts).
+ for (InfoBarContainerObserver observer : mObservers) {
+ observer.onAddInfoBar(this, infoBar, mInfoBars.isEmpty());
+ }
+
// We add the infobar immediately to mInfoBars but we wait for the animation to end to
// notify it's been added, as tests rely on this notification but expects the infobar view
// to be available when they get the notification.
@@ -312,6 +358,11 @@ public class InfoBarContainer extends SwipableOverlayView {
return;
}
+ // Notify observers immediately, before the animation begins.
+ for (InfoBarContainerObserver observer : mObservers) {
+ observer.onRemoveInfoBar(this, infoBar, mInfoBars.isEmpty());
+ }
+
// If an InfoBar is told to hide itself before it has a chance to be shown, don't bother
// with animating any of it.
boolean collapseAnimations = false;
@@ -325,9 +376,7 @@ public class InfoBarContainer extends SwipableOverlayView {
assert !collapseAnimations;
collapseAnimations = true;
}
- if (collapseAnimations) {
- mInfoBarTransitions.remove(info);
- }
+ if (collapseAnimations) mInfoBarTransitions.remove(info);
}
}
« no previous file with comments | « no previous file | chrome/android/java_staging/src/org/chromium/chrome/browser/dom_distiller/ReaderModeManager.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698