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

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

Issue 2767523002: ❄ Add InfoBarCompactLayout (Closed)
Patch Set: ❄ Experimental compact InfoBar layout Created 3 years, 9 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 71caf987c2794ae032a5efd5d4e6fcfd37d0ed17..e27ff5bf3b2e07c0de8954ebd0bfcc3831f94118 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
@@ -35,7 +35,9 @@ public abstract class InfoBar implements InfoBarView {
private long mNativeInfoBarPtr;
/**
+ * Constructor for regular infobars.
* @param iconDrawableId ID of the resource to use for the Icon. If 0, no icon will be shown.
+ * @param iconBitmap Icon to draw, in bitmap form. Used mainly for generated icons.
* @param message The message to show in the infobar.
*/
public InfoBar(int iconDrawableId, Bitmap iconBitmap, CharSequence message) {
@@ -80,14 +82,34 @@ public abstract class InfoBar implements InfoBarView {
protected final View createView() {
assert mContext != null;
- InfoBarLayout layout =
- new InfoBarLayout(mContext, this, mIconDrawableId, mIconBitmap, mMessage);
- createContent(layout);
- layout.onContentCreated();
- mView = layout;
+ if (usesCompactLayout()) {
+ InfoBarCompactLayout layout =
+ new InfoBarCompactLayout(mContext, this, mIconDrawableId, mIconBitmap);
+ createCompactLayoutContent(layout);
+ mView = layout;
+ } else {
+ InfoBarLayout layout =
+ new InfoBarLayout(mContext, this, mIconDrawableId, mIconBitmap, mMessage);
+ createContent(layout);
+ layout.onContentCreated();
+ mView = layout;
+ }
+
return mView;
}
+ /** If this returns true, the infobar contents will be replaced with a one-line layout. */
+ protected boolean usesCompactLayout() {
+ return false;
+ }
+
+ /**
+ * Prepares and inserts views into an {@link InfoBarCompactLayout}.
+ * {@link #usesCompactLayout} must return 'true' for this function to be called.
+ * @param layout Layout to plug views into.
+ */
+ protected void createCompactLayoutContent(InfoBarCompactLayout layout) {}
+
/**
* Replaces the View currently shown in the infobar with the given View. Triggers the swap
* animation via the InfoBarContainer.

Powered by Google App Engine
This is Rietveld 408576698