Upstream version 9.37.193.0
[platform/framework/web/crosswalk.git] / src / chrome / android / java / src / org / chromium / chrome / browser / infobar / TwoButtonInfoBar.java
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.
4
5 package org.chromium.chrome.browser.infobar;
6
7 import android.content.Context;
8 import android.widget.Button;
9
10 import org.chromium.chrome.R;
11
12 /**
13  * An infobar that presents the user with up to 2 buttons.
14  */
15 public abstract class TwoButtonInfoBar extends InfoBar {
16     public TwoButtonInfoBar(InfoBarListeners.Dismiss dismissListener, int backgroundType,
17             int iconDrawableId) {
18         super(dismissListener, backgroundType, iconDrawableId);
19     }
20
21     /**
22      * Creates controls for the current InfoBar.
23      * @param layout InfoBarLayout to find controls in.
24      */
25     @Override
26     public void createContent(InfoBarLayout layout) {
27         Context context = layout.getContext();
28         layout.addButtons(getPrimaryButtonText(context), getSecondaryButtonText(context));
29     }
30
31     @Override
32     public void setControlsEnabled(boolean state) {
33         super.setControlsEnabled(state);
34
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);
42         }
43     }
44 }