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;
8 * An infobar that presents the user with several buttons.
10 * TODO(newt): merge this into InfoBar.java.
12 public class ConfirmInfoBar extends InfoBar {
13 /** Text shown on the primary button, e.g. "OK". */
14 private final String mPrimaryButtonText;
16 /** Text shown on the secondary button, e.g. "Cancel".*/
17 private final String mSecondaryButtonText;
19 /** Text shown on the extra button, e.g. "More info". */
20 private final String mTertiaryButtonText;
22 /** Notified when one of the buttons is clicked. */
23 private final InfoBarListeners.Confirm mConfirmListener;
25 public ConfirmInfoBar(long nativeInfoBar, InfoBarListeners.Confirm confirmListener,
26 int iconDrawableId, String message, String linkText, String primaryButtonText,
27 String secondaryButtonText) {
28 super(confirmListener, iconDrawableId, message);
29 mPrimaryButtonText = primaryButtonText;
30 mSecondaryButtonText = secondaryButtonText;
31 mTertiaryButtonText = linkText;
32 mConfirmListener = confirmListener;
33 setNativeInfoBar(nativeInfoBar);
37 public void createContent(InfoBarLayout layout) {
38 layout.setButtons(mPrimaryButtonText, mSecondaryButtonText, mTertiaryButtonText);
42 public void onButtonClicked(boolean isPrimaryButton) {
43 if (mConfirmListener != null) {
44 mConfirmListener.onConfirmInfoBarButtonClicked(this, isPrimaryButton);
47 if (mNativeInfoBarPtr != 0) {
48 int action = isPrimaryButton ? InfoBar.ACTION_TYPE_OK : InfoBar.ACTION_TYPE_CANCEL;
49 nativeOnButtonClicked(mNativeInfoBarPtr, action, "");
54 public void onCloseButtonClicked() {
55 if (mNativeInfoBarPtr != 0) {
56 nativeOnCloseButtonClicked(mNativeInfoBarPtr);
58 super.dismissJavaOnlyInfoBar();