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;
8 import android.widget.Button;
10 import org.chromium.chrome.R;
13 * An infobar that presents the user with up to 2 buttons.
15 public abstract class TwoButtonInfoBar extends InfoBar {
16 public TwoButtonInfoBar(InfoBarListeners.Dismiss dismissListener, int backgroundType,
18 super(dismissListener, backgroundType, iconDrawableId);
22 * Creates controls for the current InfoBar.
23 * @param layout InfoBarLayout to find controls in.
26 public void createContent(InfoBarLayout layout) {
27 Context context = layout.getContext();
28 layout.addButtons(getPrimaryButtonText(context), getSecondaryButtonText(context));
32 public void setControlsEnabled(boolean state) {
33 super.setControlsEnabled(state);
35 // Handle the buttons.
36 ContentWrapperView wrapper = getContentWrapper(false);
37 if (wrapper != null) {
38 Button primary = (Button) wrapper.findViewById(R.id.button_primary);
39 Button secondary = (Button) wrapper.findViewById(R.id.button_secondary);
40 if (primary != null) primary.setEnabled(state);
41 if (secondary != null) secondary.setEnabled(state);