Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1892)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/infobar/TwoButtonInfoBar.java

Issue 24109002: [InfoBar] Upstram basic infobar flow for Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@upstream_infobar_full
Patch Set: Fix License header in two more files Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/infobar/TwoButtonInfoBar.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/TwoButtonInfoBar.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/TwoButtonInfoBar.java
new file mode 100644
index 0000000000000000000000000000000000000000..848d210ed81df6a4e2b1ebef05e34b71ebd6096d
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/TwoButtonInfoBar.java
@@ -0,0 +1,46 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.infobar;
+
+import android.content.Context;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+
+import org.chromium.chrome.R;
+
+/**
+ * An infobar that presents the user with up to 2 buttons.
+ */
+public abstract class TwoButtonInfoBar extends InfoBar {
+ public TwoButtonInfoBar(InfoBarListeners.Dismiss dismissListener, int backgroundType,
+ int iconDrawableId) {
+ super(dismissListener, backgroundType, iconDrawableId);
+ }
+
+ /**
+ * Creates controls for the current InfoBar.
+ * @param layout InfoBarLayout to find controls in.
+ */
+ @Override
+ public void createContent(InfoBarLayout layout) {
+ Context context = layout.getContext();
+ layout.addButtons(getPrimaryButtonText(context), getSecondaryButtonText(context));
+ }
+
+ @Override
+ public void setControlsEnabled(boolean state) {
+ super.setControlsEnabled(state);
+
+ // Handle the buttons.
+ ContentWrapperView wrapper = getContentWrapper(false);
+ if (wrapper != null) {
+ Button primary = (Button) wrapper.findViewById(R.id.button_primary);
+ Button secondary = (Button) wrapper.findViewById(R.id.button_secondary);
+ if (primary != null) primary.setEnabled(state);
+ if (secondary != null) secondary.setEnabled(state);
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698