1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 package org.chromium.chrome.browser.infobar;
7 import android.content.Context;
9 import org.chromium.chrome.R;
12 * A simple infobar that contains a message and a close icon on the right side.
13 * This is used only in the context of Java code and is not associated with any native
16 public class MessageInfoBar extends InfoBar {
17 private final CharSequence mTitle;
20 * Creates and returns an infobar with a white background and a close button on the right.
21 * @param title the text displayed in the infobar
22 * @return the infobar.
24 public static MessageInfoBar createInfoBar(CharSequence title) {
25 return new MessageInfoBar(null, 0, title, BACKGROUND_TYPE_INFO);
29 * Creates and returns an infobar with a white background and a close button on the right.
30 * @param iconResourceId the icon shown on the right
31 * @param title the text displayed in the infobar
32 * @return the infobar.
34 public static MessageInfoBar createInfoBar(int iconResourceId, CharSequence title) {
35 return new MessageInfoBar(null, iconResourceId, title, BACKGROUND_TYPE_INFO);
39 * Creates a warning infobar, with a yellow background and a warning icon on the right.
40 * @param title the text displayed in the infobar
41 * @return the infobar.
43 public static MessageInfoBar createWarningInfoBar(CharSequence title) {
44 return createWarningInfoBar(null, title);
48 * Creates a warning infobar, with a yellow background and a warning icon on the right.
49 * @param listener an infobar dismissed listener
50 * @param title the text displayed in the infobar
51 * @return the infobar.
53 public static MessageInfoBar createWarningInfoBar(InfoBarListeners.Dismiss listener,
55 return new MessageInfoBar(listener, R.drawable.warning, title, BACKGROUND_TYPE_WARNING);
58 protected MessageInfoBar(InfoBarListeners.Dismiss listener, int iconResourceId,
59 CharSequence title, int backgroundType) {
60 super(listener, backgroundType, iconResourceId);
65 public CharSequence getMessageText(Context context) {
70 public void onCloseButtonClicked() {
71 super.dismissJavaOnlyInfoBar();