- add sources.
[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.view.View;
9 import android.widget.Button;
10 import android.widget.TextView;
11
12 import org.chromium.chrome.R;
13
14 /**
15  * An infobar that presents the user with up to 2 buttons.
16  */
17 public abstract class TwoButtonInfoBar extends InfoBar {
18     public TwoButtonInfoBar(InfoBarListeners.Dismiss dismissListener, int backgroundType,
19             int iconDrawableId) {
20         super(dismissListener, backgroundType, iconDrawableId);
21     }
22
23     /**
24      * Creates controls for the current InfoBar.
25      * @param layout InfoBarLayout to find controls in.
26      */
27     @Override
28     public void createContent(InfoBarLayout layout) {
29         Context context = layout.getContext();
30         layout.addButtons(getPrimaryButtonText(context), getSecondaryButtonText(context));
31     }
32
33     @Override
34     public void setControlsEnabled(boolean state) {
35         super.setControlsEnabled(state);
36
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);
44         }
45     }
46 }