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.view.View;
9 import android.widget.Button;
10 import android.widget.TextView;
12 import org.chromium.chrome.R;
15 * An infobar that presents the user with up to 2 buttons.
17 public abstract class TwoButtonInfoBar extends InfoBar {
18 public TwoButtonInfoBar(InfoBarListeners.Dismiss dismissListener, int backgroundType,
20 super(dismissListener, backgroundType, iconDrawableId);
24 * Creates controls for the current InfoBar.
25 * @param layout InfoBarLayout to find controls in.
28 public void createContent(InfoBarLayout layout) {
29 Context context = layout.getContext();
30 layout.addButtons(getPrimaryButtonText(context), getSecondaryButtonText(context));
34 public void setControlsEnabled(boolean state) {
35 super.setControlsEnabled(state);
37 // Handle the buttons.
38 ContentWrapperView wrapper = getContentWrapper(false);
39 if (wrapper != null) {
40 Button primary = (Button) wrapper.findViewById(R.id.button_primary);
41 Button secondary = (Button) wrapper.findViewById(R.id.button_secondary);
42 if (primary != null) primary.setEnabled(state);
43 if (secondary != null) secondary.setEnabled(state);